Browse Source

后台,重建用户

lizhen_gitee 5 months ago
parent
commit
53405374ca

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

@@ -35,4 +35,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(['jigou'])
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->paginate($limit);
+
+            foreach ($list as $row) {
+                
+                $row->getRelation('jigou')->visible(['title']);
+            }
+
+            $result = array("total" => $list->total(), "rows" => $list->items());
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+
 }

+ 26 - 23
application/admin/lang/zh-cn/user/user.php

@@ -1,27 +1,30 @@
 <?php
 
 return [
-    'Id'         => 'ID',
-    'Username'   => '用户名',
-    'Nickname'   => '昵称',
-    'Mobile'     => '手机号',
-    'Avatar'     => '头像',
-    'Gender'     => '性别',
-    'Gender 1'   => '男',
-    'Gender 0'   => '女',
-    'Prevtime'   => '上次登录时间',
-    'Logintime'  => '登录时间',
-    'Loginip'    => '登录IP',
-    'Joinip'     => '加入IP',
-    'Jointime'   => '加入时间',
-    'Createtime' => '创建时间',
-    'Updatetime' => '更新时间',
-    'Token'      => 'Token',
-    'Status'     => '状态',
-    'Status 1'   => '正常',
-    'Set status to 1'=> '设为正常',
-    'Status 0'   => '禁用',
-    'Set status to 0'=> '设为禁用',
-    'Status -1'  => '注销',
-    'Set status to -1'=> '设为注销'
+    'Id'               => 'ID',
+    'Username'         => '用户名',
+    'Nickname'         => '昵称',
+    'Mobile'           => '手机号',
+    'Avatar'           => '头像',
+    'Gender'           => '性别',
+    'Gender 1'         => '男',
+    'Gender 0'         => '女',
+    'Prevtime'         => '上次登录时间',
+    'Logintime'        => '登录时间',
+    'Loginip'          => '登录IP',
+    'Joinip'           => '加入IP',
+    'Jointime'         => '加入时间',
+    'Createtime'       => '创建时间',
+    'Updatetime'       => '更新时间',
+    'Token'            => 'Token',
+    'Status'           => '状态',
+    'Status 1'         => '正常',
+    'Set status to 1'  => '设为正常',
+    'Status 0'         => '禁用',
+    'Set status to 0'  => '设为禁用',
+    'Status -1'        => '注销',
+    'Set status to -1' => '设为注销',
+    'Bind_jigou_id'    => '绑定机构id',
+    'Bind_jigou_times' => '换绑机构次数',
+    'Jigou.title'      => '机构名称'
 ];

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

@@ -97,4 +97,8 @@ class User extends Model
     }
 
 
+    public function jigou()
+    {
+        return $this->belongsTo('Votejigou', 'bind_jigou_id', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
 }

+ 12 - 0
application/admin/view/user/user/add.html

@@ -92,6 +92,18 @@
 
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Bind_jigou_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-bind_jigou_id" data-rule="required" data-source="votejigou/index" data-field="title" class="form-control selectpage" name="row[bind_jigou_id]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Bind_jigou_times')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-bind_jigou_times" class="form-control" name="row[bind_jigou_times]" type="number" value="0">
+        </div>
+    </div>
     <div class="form-group layer-footer">
         <label class="control-label col-xs-12 col-sm-2"></label>
         <div class="col-xs-12 col-sm-8">

+ 12 - 0
application/admin/view/user/user/edit.html

@@ -92,6 +92,18 @@
 
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Bind_jigou_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-bind_jigou_id" data-rule="required" data-source="votejigou/index" data-field="title" class="form-control selectpage" name="row[bind_jigou_id]" type="text" value="{$row.bind_jigou_id|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Bind_jigou_times')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-bind_jigou_times" class="form-control" name="row[bind_jigou_times]" type="number" value="{$row.bind_jigou_times|htmlentities}">
+        </div>
+    </div>
     <div class="form-group layer-footer">
         <label class="control-label col-xs-12 col-sm-2"></label>
         <div class="col-xs-12 col-sm-8">

+ 8 - 5
public/assets/js/backend/user/user.js

@@ -28,20 +28,23 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     [
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
-//                        {field: 'username', title: __('Username'), operate: 'LIKE'},
-                        {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
+//                        {field: 'username', title: __('Username'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                        {field: 'nickname', title: __('Nickname'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                         {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
                         {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
 //                        {field: 'gender', title: __('Gender'), searchList: {"1":__('Gender 1'),"0":__('Gender 0')}, formatter: Table.api.formatter.normal},
 //                        {field: 'prevtime', title: __('Prevtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'logintime', title: __('Logintime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
-                        {field: 'loginip', title: __('Loginip'), operate: 'LIKE'},
-                        {field: 'joinip', title: __('Joinip'), operate: 'LIKE'},
+                        {field: 'loginip', title: __('Loginip'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                        {field: 'joinip', title: __('Joinip'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                         {field: 'jointime', title: __('Jointime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
 //                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
 //                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
-//                        {field: 'token', title: __('Token'), operate: 'LIKE'},
+//                        {field: 'token', title: __('Token'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                         {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0'),"-1":__('Status -1')}, formatter: Table.api.formatter.status},
+                        {field: 'bind_jigou_id', title: __('Bind_jigou_id')},
+                        {field: 'jigou.title', title: __('Jigou.title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                        {field: 'bind_jigou_times', title: __('Bind_jigou_times')},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]