Browse Source

重建user

lizhen_gitee 10 months ago
parent
commit
ac70268fa4

+ 34 - 1
application/admin/controller/user/User.php

@@ -3,7 +3,6 @@
 namespace app\admin\controller\user;
 
 use app\common\controller\Backend;
-use app\common\library\Auth;
 
 /**
  * 会员管理
@@ -40,4 +39,38 @@ class User extends Backend
      */
 
 
+    /**
+     * 查看
+     */
+    public function index()
+    {
+        //当前是否为关联查询
+        $this->relationSearch = true;
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax()) {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField')) {
+                return $this->selectpage();
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+
+            $list = $this->model
+                    ->with(['wallet'])
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->paginate($limit);
+
+            foreach ($list as $row) {
+                
+                $row->getRelation('wallet')->visible(['money']);
+            }
+
+            $result = array("total" => $list->total(), "rows" => $list->items());
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+
 }

+ 2 - 1
application/admin/lang/zh-cn/user/user.php

@@ -34,5 +34,6 @@ return [
     'Idcard_status 0'  => '待审核',
     'Idcard_status 1'  => '审核通过',
     'Idcard_status 2'  => '审核驳回',
-    'Wechat_openid'    => '微信openid'
+    'Wechat_openid'    => '微信openid',
+    'Wallet.money'     => '余额'
 ];

+ 4 - 0
application/admin/model/User.php

@@ -111,4 +111,8 @@ class User extends Model
     }
 
 
+    public function wallet()
+    {
+        return $this->belongsTo('Userwallet', 'id', 'user_id', [], 'LEFT')->setEagerlyType(0);
+    }
 }

+ 7 - 6
public/assets/js/backend/user/user.js

@@ -5,12 +5,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             // 初始化表格参数配置
             Table.api.init({
                 extend: {
-                    index_url: 'user.user/index' + location.search,
-                    add_url: 'user.user/add',
-                    edit_url: 'user.user/edit',
-//                    del_url: 'user.user/del',
-                    multi_url: 'user.user/multi',
-                    import_url: 'user.user/import',
+                    index_url: 'user/user/index' + location.search,
+                    add_url: 'user/user/add',
+                    edit_url: 'user/user/edit',
+//                    del_url: 'user/user/del',
+                    multi_url: 'user/user/multi',
+                    import_url: 'user/user/import',
                     table: 'user',
                 }
             });
@@ -49,6 +49,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0'),"-1":__('Status -1')}, formatter: Table.api.formatter.status},
                         {field: 'idcard_status', title: __('Idcard_status'), searchList: {"-1":__('Idcard_status -1'),"0":__('Idcard_status 0'),"1":__('Idcard_status 1'),"2":__('Idcard_status 2')}, formatter: Table.api.formatter.status},
 //                        {field: 'wechat_openid', title: __('Wechat_openid'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                        {field: 'wallet.money', title: __('Wallet.money'), operate:'BETWEEN'},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]