浏览代码

更新表格插件用法

邹景立 3 年之前
父节点
当前提交
6781a7fe7d

+ 5 - 6
app/admin/controller/Auth.php

@@ -18,6 +18,7 @@ namespace app\admin\controller;
 
 use app\admin\model\SystemAuth;
 use think\admin\Controller;
+use think\admin\helper\QueryHelper;
 use think\admin\service\AdminService;
 
 /**
@@ -44,13 +45,11 @@ class Auth extends Controller
      */
     public function index()
     {
-        if ($this->request->isGet() && input('get.output') !== 'layui.table') {
+        $this->_query(SystemAuth::class)->layTable(function () {
             $this->title = '系统权限管理';
-            $this->fetch();
-        } else {
-            $query = $this->_query(SystemAuth::class)->dateBetween('create_at');
-            $query->like('title,desc')->equal('status,utype')->layTable();
-        }
+        }, function (QueryHelper $query) {
+            $query->dateBetween('create_at')->like('title,desc')->equal('status,utype');
+        });
     }
 
     /**

+ 7 - 4
app/admin/controller/Base.php

@@ -18,6 +18,7 @@ namespace app\admin\controller;
 
 use app\admin\model\SystemBase;
 use think\admin\Controller;
+use think\admin\helper\QueryHelper;
 
 /**
  * 数据字典管理
@@ -42,10 +43,12 @@ class Base extends Controller
      */
     public function index()
     {
-        $this->applyTypes();
-        $this->title = '数据字典管理';
-        $query = $this->_query(SystemBase::class)->where(['deleted' => 0]);
-        $query->equal('type')->like('code,name,status')->dateBetween('create_at')->layTable();
+        $this->_query(SystemBase::class)->layTable(function () {
+            $this->applyTypes();
+            $this->title = '数据字典管理';
+        }, function (QueryHelper $query) {
+            $query->where(['deleted' => 0])->equal('type')->like('code,name,status')->dateBetween('create_at');
+        });
     }
 
     /**

+ 11 - 8
app/admin/controller/Oplog.php

@@ -18,6 +18,7 @@ namespace app\admin\controller;
 
 use Exception;
 use think\admin\Controller;
+use think\admin\helper\QueryHelper;
 use think\admin\service\AdminService;
 use think\exception\HttpResponseException;
 
@@ -45,14 +46,16 @@ class Oplog extends Controller
      */
     public function index()
     {
-        $this->title = '系统日志管理';
-        $this->isSupper = AdminService::instance()->isSuper();
-        // 读取数据类型
-        $this->users = $this->app->db->name($this->table)->distinct(true)->column('username');
-        $this->actions = $this->app->db->name($this->table)->distinct(true)->column('action');
-        // 数据列表处理
-        $query = $this->_query($this->table)->dateBetween('create_at');
-        $query->equal('username,action')->like('content,geoip,node')->layTable();
+        $this->_query($this->table)->layTable(function () {
+            $this->title = '系统日志管理';
+            $this->isSupper = AdminService::instance()->isSuper();
+            // 读取数据类型
+            $this->users = $this->app->db->name($this->table)->distinct(true)->column('username');
+            $this->actions = $this->app->db->name($this->table)->distinct(true)->column('action');
+        }, function (QueryHelper $query) {
+            // 数据列表处理
+            $query->dateBetween('create_at')->equal('username,action')->like('content,geoip,node');
+        });
     }
 
     /**

+ 16 - 8
app/admin/controller/User.php

@@ -19,6 +19,7 @@ namespace app\admin\controller;
 use app\admin\model\SystemBase;
 use app\admin\model\SystemUser;
 use think\admin\Controller;
+use think\admin\helper\QueryHelper;
 use think\admin\service\AdminService;
 
 /**
@@ -61,22 +62,29 @@ class User extends Controller
     public function index()
     {
         $this->type = input('type', 'index');
-        if ($this->request->isGet() && input('get.output') !== 'layui.table') {
-            $this->bases = (new SystemBase)->items('身份权限');
+        $this->_query(SystemUser::class)->layTable(function () {
             $this->title = '系统用户管理';
-            $this->fetch();
-        } else {
-            $query = $this->_query(SystemUser::class);
+            $this->bases = (new SystemBase)->items('身份权限');
+        }, function (QueryHelper $query) {
             // 加载对应数据列表
             if ($this->type === 'index') {
                 $query->where(['is_deleted' => 0, 'status' => 1]);
             } elseif ($this->type = 'recycle') {
                 $query->where(['is_deleted' => 0, 'status' => 0]);
             }
-            // 列表排序并显示
+            // 数据列表搜索过滤
             $query->equal('status,usertype')->dateBetween('login_at,create_at');
-            $query->like('username,nickname,contact_phone#phone,contact_mail#mail')->layTable();
-        }
+            $query->like('username,nickname,contact_phone#phone,contact_mail#mail');
+        });
+    }
+
+    /**
+     * 数据列表处理
+     * @param array $data
+     */
+    protected function _page_filter(array &$data)
+    {
+        (new SystemBase)->items('身份权限', $data, 'usertype', 'userinfo');
     }
 
     /**

+ 7 - 2
app/admin/view/user/index.html

@@ -43,10 +43,15 @@
                 {field: 'sort', title: '排序权重', width: 100, align: 'center', sort: true, templet: '#SortInputTpl'},
                 {field: 'nickname', title: '用户名称', minWidth: 100, align: 'center', sort: false, templet: '<div>{{d.nickname||"-"}}</div>'},
                 {field: 'username', title: '登录账号', minWidth: 100, align: 'center', sort: true, templet: '<div>{{d.username||"-"}}</div>'},
-                {field: 'usertype', title: '角色身份', minWidth: 100, align: 'center', sort: true, templet: '<div>{{d.usertype||"-"}}</div>'},
+                {
+                    field: 'usertype', title: '角色身份', minWidth: 120, align: 'center', sort: true, templet: function (d) {
+                        d.userinfo = d.userinfo || {};
+                        return d.userinfo.code ? (d.userinfo.name + ' ( ' + d.userinfo.code + ' ) ') : '';
+                    }
+                },
                 {field: 'contact_mail', title: '联系邮箱', align: 'center', sort: false, templet: '<div>{{d.contact_mail||"-"}}</div>'},
                 {field: 'contact_phone', title: '联系电话', align: 'center', sort: false, templet: '<div>{{d.contact_phone||"-"}}</div>'},
-                {field: 'login_num', title: '登录次数', align: 'center', sort: false},
+                {field: 'login_num', title: '登录次数', align: 'center', minWidth: 80, sort: false},
                 {field: 'login_at', title: '最后登录', sort: true, align: 'center', minWidth: 170},
                 {field: 'create_at', title: '创建时间', align: 'center', minWidth: 170, sort: true},
                 {field: 'status', title: '权限状态', align: 'center', minWidth: 110, fixed: 'right', templet: '#StatusSwitchTpl'},

文件差异内容过多而无法显示
+ 0 - 1894
public/static/theme/css/console.css


文件差异内容过多而无法显示
+ 0 - 0
public/static/theme/css/console.css.map


部分文件因为文件数量过多而无法显示