Commit 26a96a24 by 宁成龙

完善用户列表

parent 46abd3ee
......@@ -3,6 +3,7 @@
namespace App\Admin\Controllers;
use App\Admin\Repositories\User;
use App\Admin\Service\UserService;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
......@@ -18,30 +19,13 @@ class UserController extends AdminController
protected function grid()
{
return Grid::make(new User(), function (Grid $grid) {
$grid->column('id')->sortable();
$grid->column('user_sn');
$grid->column('name');
$grid->column('email');
$grid->column('email_verified_at');
$grid->column('password');
$grid->column('phone');
$grid->column('remember_token');
$grid->column('account_properties');
$grid->column('status');
$grid->column('company_name');
$grid->column('first_name');
$grid->column('sale_id');
$grid->column('sale_name');
$grid->column('last_name');
$grid->column('created_time');
$grid->column('update_time');
$grid->column('created_at');
$grid->column('updated_at')->sortable();
$grid->filter(function (Grid\Filter $filter) {
$filter->equal('id');
});
$grid->showFilter();
$grid->disableActions();
$grid->disableFilterButton();
$grid->disableRefreshButton();
$grid->disableCreateButton();
UserService::userListFilter($grid);
UserService::userListListField($grid);
});
}
......
<?php
namespace App\Admin\Service;
use App\Models\Cms\CmsUser;
use Dcat\Admin\Grid;
class UserService
{
public static function userListFilter(Grid $grid){
$grid->filter(function ($filter) {
$filter->expand(true);
$filter->whereBetween('create_time', function ($q) {
$start = strtotime($this->input['start'] ?? null);
$end = strtotime($this->input['end'] ?? null);
$q->whereBetween('create_time', [$start, $end]);
})->datetime()->width(3);
$filter->startWith('company_name')->width(2);
$filter->startWith('user_sn')->width(2);
$filter->startWith('name')->width(2);
$filter->equal('status')->select(admin_trans('user.options.status'))->width(2);
$filter->equal('sales_id',trans('inquiry.fields.sales_name'))->select(CmsUser::pluck('name', 'userId')->toArray())->width(3);
$filter->equal('status')->select(admin_trans('user.options.status'))->width(2);
});
}
public static function userListListField(Grid $grid){
$grid->column('company_name');
$grid->column('user_sn');
$grid->column('name');
$grid->column('phone');
$grid->column('email');
$grid->column('sale_name');
$grid->column('status')->using(admin_trans('user.options.status'));
$grid->column('created_time')->display(function ($time) {
return $time ? date('Y-m-d H:i:s', $time) : '';
})->sortable();;
$grid->column('update_time')->display(function ($time) {
return $time ? date('Y-m-d H:i:s', $time) : '';
})->sortable();;
}
}
......@@ -17,5 +17,5 @@ Route::group([
$router->resource('inquiry', 'InquiryController');
$router->resource('order', 'OrderController');
$router->resource('test', 'TestController');
$router->resource('users', 'UserController');
});
......@@ -12,8 +12,8 @@ return [
'password' => '密码',
'phone' => '手机号码',
'remember_token' => '记住登陆token',
'account_properties' => '账号属性,1是个人,2是企业',
'status' => '状态,1是正常,-1是禁用',
'account_properties' => '账号属性',
'status' => '状态',
'company_name' => '公司名称',
'first_name' => '名字',
'sale_id' => '业务员',
......@@ -23,5 +23,9 @@ return [
'update_time' => '更新时间',
],
'options' => [
"status"=>[
"1"=>"正常",
"-1"=>"禁用"
]
],
];
<?php
return [
'labels' => [
'User' => 'User',
'user' => 'User',
],
'fields' => [
'user_sn' => '客户编码',
'name' => '用户名',
'email' => '邮箱',
'email_verified_at' => '邮箱校验时间',
'password' => '密码',
'phone' => '手机号码',
'remember_token' => '记住登陆token',
'account_properties' => '账号属性',
'status' => '状态',
'company_name' => '公司名称',
'first_name' => '名字',
'sale_id' => '业务员',
'sale_name' => '业务员名字',
'last_name' => '姓氏',
'created_time' => '创建时间',
'update_time' => '更新时间',
],
'options' => [
"status"=>[
"1"=>"正常",
"-1"=>"禁用"
]
],
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment