1557492053 3 år sedan
förälder
incheckning
9776a8e65c

+ 4 - 4
.env

@@ -5,10 +5,10 @@ DEFAULT_TIMEZONE = Asia/Shanghai
 
 [DATABASE]
 TYPE = mysql
-HOSTNAME = 8.219.191.124
-DATABASE = yuanzhongxiu
-USERNAME = yuanzhongxiu
-PASSWORD = WPDrmPREz36y6mMb
+HOSTNAME = 49.4.53.36
+DATABASE = erp_yzx
+USERNAME = root
+PASSWORD = Aa@@1144271187
 HOSTPORT = 3306
 CHARSET = utf8
 DEBUG = true

+ 68 - 7
app/admin/controller/Admin.php

@@ -8,6 +8,7 @@ use app\BaseController;
 use app\common\model\AdminModel;
 use app\common\model\AuthGroupAccessModel;
 use app\common\model\AuthGroupModel;
+use app\common\model\StoreModel;
 use think\App;
 use think\facade\View;
 use think\Request;
@@ -17,12 +18,34 @@ class Admin extends BaseController
     private $model;
     private $authGroupModel;
     private $authGroupAccessModel;
+    private $storeModel;
+
+    public $rules = [
+        ["id" => 1, "name" => "后台管理员", "pid" => 0],
+        ["id" => 2, "name" => "门店", "pid" => 0],
+        ["id" => 3, "name" => "门店主管", "pid" => 2],
+        ["id" => 4, "name" => "门店老师", "pid" => 2],
+        ["id" => 5, "name" => "门店顾问", "pid" => 2],
+        ["id" => 6, "name" => "门店促销员", "pid" => 2],
+        ["id" => 7, "name" => "佛堂", "pid" => 0],
+        ["id" => 8, "name" => "佛堂负责人", "pid" => 7],
+        ["id" => 9, "name" => "佛堂前台", "pid" => 7],
+        ["id" => 10, "name" => "佛堂道士", "pid" => 7],
+        ["id" => 11, "name" => "佛堂和尚", "pid" => 7],
+        ["id" => 12, "name" => "物流部", "pid" => 0],
+        ["id" => 13, "name" => "物流负责人", "pid" => 12],
+        ["id" => 14, "name" => "物流助理", "pid" => 12],
+        ["id" => 15, "name" => "财务", "pid" => 0],
+        ["id" => 16, "name" => "财务负责人", "pid" => 15],
+        ["id" => 17, "name" => "门店经销商", "pid" => 2],
+    ];
 
     public function __construct(App $app)
     {
         $this->model = new AdminModel();
         $this->authGroupModel = new AuthGroupModel();
         $this->authGroupAccessModel = new AuthGroupAccessModel();
+        $this->storeModel = new StoreModel();
         parent::__construct($app);
     }
 
@@ -33,9 +56,17 @@ class Admin extends BaseController
      */
     public function index(Request $request)
     {
+        $params = $request->param();
         $list = $this->model->findByPaginate();
+        $all_groups = $this->authGroupModel->fetchAllGroups();
+        $format_params = [
+            'group_id' => format_string($params['group_id'] ?? null),
+        ];
         View::assign([
+            'rules' => $this->rules,
             'list' => $list,
+            'all_groups' => recursion($all_groups, 0),
+            'params' => $format_params
         ]);
         return view();
     }
@@ -56,7 +87,11 @@ class Admin extends BaseController
             $res = $this->model->create([
                 'account' => $params['account'],
                 'nickname' => $params['nickname'],
+                'mobile'    => $params['mobile'],
                 'password' => md5($params['password']),
+                'store_id' => isset($params['store_id']) && $params['store_id'] > 0 ? $params : null,
+                'is_login_backstage' => $params['is_login_backstage'],
+                'rule'  =>  $params['rule']
             ]);
             $this->authGroupAccessModel->save([
                 'admin_id'  =>  $res->id,
@@ -64,9 +99,11 @@ class Admin extends BaseController
             ]);
             return $this->ok(true);
         }
-        $groups = $this->authGroupModel->fetchAllGroups();
+        $all_groups = $this->authGroupModel->fetchAllGroups();
         View::assign([
-            'groups' => $groups
+            'stores'    =>  $this->storeModel->findAllStore(),
+            'rules' =>  recursion($this->rules,0),
+            'all_groups' => recursion($all_groups, 0)
         ]);
         return view();
     }
@@ -88,7 +125,11 @@ class Admin extends BaseController
             $this->model->where('id',$params['id'])->update([
                 'account' => $params['account'],
                 'nickname' => $params['nickname'],
-                'password' => $params['password'] == $admin->password ? $admin->password : md5($params['password']),
+                'mobile'    => $params['mobile'],
+                'password' => isset($params['password']) && $params['password'] != $admin->password ? md5($params['password']) : $admin['password'],
+                'store_id' => isset($params['store_id']) && $params['store_id'] > 0 ? $params['store_id'] : null,
+                'is_login_backstage' => $params['is_login_backstage'],
+                'rule'  =>  $params['rule'] > 0 ? $params['rule'] : null,
                 'update_time' => time()
             ]);
             $relation = $this->authGroupAccessModel->findByAdminId($admin->id);
@@ -99,9 +140,10 @@ class Admin extends BaseController
             }
             return $this->ok(true);
         }
-        $groups = $this->authGroupModel->fetchAllGroups();
         View::assign([
-            'groups' => $groups,
+            'stores'    =>  $this->storeModel->findAllStore(),
+            'all_groups' => recursion($this->authGroupModel->fetchAllGroups(), 0),
+            'rules' =>  recursion($this->rules,0),
             'admin' => $this->model->findById($params['id']),
         ]);
         return view();
@@ -117,8 +159,18 @@ class Admin extends BaseController
         return $this->ok(true);
     }
 
-    public function  test() {
-        echo "test";
+
+    public function total_data() {
+        $params = $this->request->param();
+        if(!isset($params['id']))
+            return $this->fail(lang('ID not exist'));
+        View::assign([
+            'stores'    =>  $this->storeModel->findAllStore(),
+            'all_groups' => recursion($this->authGroupModel->fetchAllGroups(), 0),
+            'rules' =>  recursion($this->rules,0),
+            'admin' => $this->model->findById($params['id']),
+        ]);
+        return view();
     }
 
 }
@@ -148,3 +200,12 @@ class Admin extends BaseController
 
 
 
+
+
+
+
+
+
+
+
+

+ 42 - 37
app/admin/controller/Auth.php

@@ -12,6 +12,7 @@ use app\BaseController;
 use think\facade\View;
 
 
+// 部门管理
 class Auth extends BaseController
 {
 
@@ -31,38 +32,45 @@ class Auth extends BaseController
         return view();
     }
 
-    public function add() {
-        if ($this->request->isAjax()) {
-            $params = $this->request->param();
-            $res = $this->service->authGroupModel->save([
-                'name' => format_string($params['name'] ?? null),
-                'rules' => format_string($params['rule_ids'] ?? null),
-                'describe' => format_string($params['describe'] ?? null),
-            ]);
-            return $this->ok($res);
-        }
-        return view();
-    }
-
-    public function edit() {
-        $params = $this->request->param();
-        $id = $params['id'];
-        $group = $this->service->authGroupModel->findById($id);
-        if ($this->request->isAjax()) {
-            $res = $this->service->authGroupModel->where('id', $params['id'])->save([
-                'name' => format_string($params['name'] ?? null),
-                'rules' => format_string($params['rule_ids'] ?? null),
-                'describe' => format_string($params['describe'] ?? null),
-                'update_time'   =>  time()
-            ]);
-            return $this->ok($res);
-        }
-        View::assign([
-            'group' => $group,
-        ]);
-        return view();
-    }
+//    public function add() {
+//        if ($this->request->isAjax()) {
+//            $params = $this->request->param();
+//            $res = $this->service->authGroupModel->save([
+//                'name' => format_string($params['name'] ?? null),
+//                'rules' => format_string($params['rule_ids'] ?? null),
+//                'describe' => format_string($params['describe'] ?? null),
+//            ]);
+//            return $this->ok($res);
+//        }
+//        return view();
+//    }
+//
+//    public function edit() {
+//        $params = $this->request->param();
+//        $id = $params['id'];
+//        $group = $this->service->authGroupModel->findById($id);
+//        if ($this->request->isAjax()) {
+//            $res = $this->service->authGroupModel->where('id', $params['id'])->save([
+//                'name' => format_string($params['name'] ?? null),
+//                'rules' => format_string($params['rule_ids'] ?? null),
+//                'describe' => format_string($params['describe'] ?? null),
+//                'update_time'   =>  time()
+//            ]);
+//            return $this->ok($res);
+//        }
+//        View::assign([
+//            'group' => $group,
+//        ]);
+//        return view();
+//    }
 
+    /**
+     * @param null $admin_id
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
     public function findAuthRuleByAdminId($admin_id = null) {
         $all_rules = $this->service->authRuleModel->findByIds(["*"]);
         $format_rules = array_map(function ($data) {
@@ -71,7 +79,7 @@ class Auth extends BaseController
                 'title'     =>  $data['name'],
                 'pid'       =>  $data['pid'],
                 'field'     =>  $data['name'],
-                'spread'    =>  false,
+                'spread'    =>  true,
                 'checked'   =>  false
             ];
         }, $all_rules);
@@ -93,17 +101,16 @@ class Auth extends BaseController
      * @throws \think\db\exception\ModelNotFoundException
      */
     public function findAuthRuleByGroupId($group_id = null) {
-        $all_rules = $this->service->authRuleModel->findByIds(["*"]);
         $format_rules = array_map(function ($data) {
             return [
                 'id'        =>  $data['id'],
                 'title'     =>  $data['name'],
                 'pid'       =>  $data['pid'],
                 'field'     =>  $data['name'],
-                'spread'    =>  false,
+                'spread'    =>  true,
                 'checked'   =>  false
             ];
-        }, $all_rules);
+        }, $this->service->authRuleModel->findByIds(["*"]));
         if(!isset($group_id))
             return $this->ok(recursion($format_rules));
         $rules = $this->service->loadRuleByGroupId($group_id);
@@ -114,8 +121,6 @@ class Auth extends BaseController
         return $this->ok(recursion($format_rules));
     }
 
-
-
 }
 
 

+ 123 - 0
app/admin/controller/AuthGroup.php

@@ -0,0 +1,123 @@
+<?php
+
+
+namespace app\admin\controller;
+
+
+use app\admin\service\AuthService;
+use app\BaseController;
+use app\common\model\StoreModel;
+use think\App;
+use think\facade\View;
+
+
+class AuthGroup extends BaseController
+{
+    private $authService;
+    private $storeModel;
+
+    public function __construct(App $app)
+    {
+        parent::__construct($app);
+        $this->authService = new AuthService();
+        $this->storeModel = new StoreModel();
+    }
+
+    public function index() {
+        return view();
+    }
+
+    /**
+     * @return \think\response\Json|\think\response\View
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function add() {
+        $all_groups = $this->authService->authGroupModel->fetchAllGroups();
+        if ($this->request->isAjax()) {
+            $params = $this->request->param();
+            $res = $this->authService->authGroupModel->save([
+                'pid'   =>  $params['pid'] ?? 1,
+                'name' => format_string($params['name'] ?? null),
+                'rules' => format_string($params['rule_ids'] ?? null),
+                "store_ids" =>  isset($params["store_ids"]) ? join(',', $params['store_ids']) : null,
+                'describe' => format_string($params['describe'] ?? null),
+            ]);
+            return $this->ok($res);
+        }
+        $stores = $this->storeModel->findAllStore();
+        View::assign([
+            "stores"    =>  $stores,
+            "all_groups"    =>  recursion($all_groups, 0)
+        ]);
+        return view();
+    }
+
+    /**
+     * @return \think\response\Json|\think\response\View
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function edit() {
+        $params = $this->request->param();
+        $id = $params['id'];
+        $all_groups = $this->authService->authGroupModel->fetchAllGroups();
+        $group = $this->authService->authGroupModel->findById($id);
+        if ($this->request->isAjax()) {
+            $res = $this->authService->authGroupModel->where('id', $params['id'])->save([
+                'pid' => $params['pid'] ?? $group->pid,
+                'name' => $params['name'] ?? $group->name,
+                'rules' => !isset($params['rule_ids']) ? null : $params['rule_ids'],
+                "store_ids" =>  isset($params["store_ids"]) ? join(',', $params['store_ids']) : null,
+                'describe' => $params['describe'] ?? $group->describe,
+                'update_time' => time()
+            ]);
+            return $this->ok($res);
+        }
+        $stores = $this->storeModel->findAllStore();
+        $store_ids = $group->store_ids ? explode(",",$group->store_ids) : [];
+        foreach ($stores as &$item) $item->isChecked = in_array($item->id, $store_ids);
+        View::assign([
+            'group' => $group,
+            "stores" => $stores,
+            "all_groups" => recursion($all_groups, 0)
+        ]);
+        return view();
+    }
+
+    public function delete(\think\Request $request) {
+        $params = $request->param();
+        if(!isset($params['ids']))
+            return $this->fail(lang("Please select the data you want to delete"));
+        $this->authService->authGroupModel->deleteByIds(explode(',', $params['ids']));
+        return $this->ok(true);
+    }
+
+
+    public function findAllAuthGroups() {
+        $groups = $this->authService->authGroupModel->fetchAllGroups()->toArray();
+        $format_groups = array_map(function ($data) {
+            return [
+                'id'        =>  $data['id'],
+                'title'     =>  $data['name'],
+                'pid'       =>  $data['pid'],
+                'field'     =>  $data['name'],
+                'spread'    =>  true,
+                'checked'   =>  false,
+                'disabled'  =>  $data['id'] == 1
+            ];
+        }, $groups);
+        return $this->ok(recursion($format_groups));
+    }
+
+
+
+}
+
+
+
+
+
+

+ 0 - 23
app/admin/controller/Department.php

@@ -1,23 +0,0 @@
-<?php
-
-
-namespace app\admin\controller;
-
-
-use app\BaseController;
-
-class Department extends BaseController
-{
-
-    public function index() {
-        return "部门管理";
-    }
-
-
-}
-
-
-
-
-
-

+ 6 - 0
app/admin/lang/zh-cn.php

@@ -129,6 +129,12 @@ return [
     "Account"   =>  '账号',
     "Group"     =>  "组",
     "The account already exists."   => "账号已经存在!",
+    "Superior department"   =>  "上级部门",
+    "Permission"   =>  "权限",
+    "Department"    =>  "部门",
+    "Is login backstage" => "是否允许登录后台",
+    "Not available" =>  "暂无",
+
 
 
 ];

+ 14 - 0
app/admin/service/AuthService.php

@@ -22,6 +22,13 @@ class AuthService
         $this->authRuleModel = new AuthRuleModel();
     }
 
+    /**
+     * @param int $group_id
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
     public function loadRuleByGroupId(int $group_id) {
         $group = $this->authGroupModel->findById($group_id);
         if ($group) {
@@ -31,6 +38,13 @@ class AuthService
         return [];
     }
 
+    /**
+     * @param int $adminId
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
     public function loadRuleByAdminId(int $adminId) {
         $access = $this->authGroupAccessModel->findByAdminId($adminId);
         if ($access && $access->group_id > 0) {

+ 85 - 44
app/admin/view/admin/add.html

@@ -10,72 +10,113 @@
             <div class="card">
               <div class="card-body">
                 <form class="layui-form">
-
-                  <div class="layui-form-item">
-                    <label class="layui-form-label">{:lang("Account")}</label>
-                    <div class="layui-input-block">
-                      <input type="text" name="account" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">{:lang("Account")}</label>
+                        <div class="layui-input-block">
+                          <input type="text" name="account" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
+                        </div>
                     </div>
-                  </div>
 
-                  <div class="layui-form-item">
-                    <label class="layui-form-label">{:lang("name")}</label>
-                    <div class="layui-input-block">
-                      <input type="text" name="nickname" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">{:lang("Name")}</label>
+                        <div class="layui-input-block">
+                          <input type="text" name="nickname" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
+                        </div>
                     </div>
-                  </div>
 
-                  <div class="layui-form-item">
-                    <label class="layui-form-label">{:lang('Group')}</label>
-                    <div class="layui-input-block">
-                      <select name="group_id" lay-filter="required">
-                        {volist name="groups" id="item"}
-                        <option value="{$item.id}">{$item.name}</option>
-                        {/volist}
-                      </select>
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">{:lang("Mobile")}</label>
+                        <div class="layui-input-block">
+                          <input type="text" name="mobile" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
+                        </div>
                     </div>
-                  </div>
-
-                  <div class="layui-form-item">
-                    <label class="layui-form-label">{:lang("Password")}</label>
-                    <div class="layui-input-block">
-                      <input type="password" name="password" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">{:lang("Password")}</label>
+                        <div class="layui-input-block">
+                            <input type="password" name="password" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
+                        </div>
                     </div>
-                  </div>
-
-
-                  <div class="layui-form-item">
-                    <div class="layui-input-block">
-                      <button type="button" class="layui-btn" lay-submit="" lay-filter="caviar_submit_btn">{:lang('Submit')}</button>
-                      <button type="reset" class="layui-btn layui-btn-primary">{:lang("Reset")}</button>
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">{:lang("Is login backstage")}</label>
+                        <div class="layui-input-block">
+                            <input type="radio" name="is_login_backstage" value="0" title="{:lang('No')}">
+                            <input type="radio" name="is_login_backstage" value="1" title="{:lang('Yes')}" checked>
+                        </div>
+                    </div>
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">{:lang('Department')}</label>
+                        <div class="layui-input-block">
+                          <select name="group_id" lay-filter="required">
+                              {volist name="all_groups" id="item"}
+                              <option value="{$item.id}"  >{$item.name}</option>
+                              {volist name='$item.children' id='first'}
+                              <option value="{$first.id}">&nbsp;&nbsp;| --&nbsp;{$first.name}</option>
+                              {volist name='$first.children' id='second'}
+                              <option value="{$second.id}">&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;{$second.name}</option>
+                              {volist name='$second.children' id='thirdly'}
+                              <option value="{$thirdly.id}">&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;{$thirdly.name}</option>
+                              {volist name='$thirdly.children' id='fourthly'}
+                              <option value="{$fourthly.id}">&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;{$fourthly.name}</option>
+                              {/volist}
+                              {/volist}
+                              {/volist}
+                              {/volist}
+                              {/volist}
+                          </select>
+                        </div>
+                    </div>
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">{:lang("Store")}</label>
+                        <div class="layui-input-block">
+                            <select name="store_id">
+                                <option value="">{:lang('Unknown')}</option>
+                                {volist name="stores" id="item"}
+                                <option value="{$item.id}">{$item.name}</option>
+                                {/volist}
+                            </select>
+                        </div>
+                    </div>
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">{:lang("Rule")}</label>
+                        <div class="layui-input-block">
+                            <select name="rule">
+                                {volist name="rules" id="item"}
+                                <option value="{$item.id}">{$item.name}</option>
+                                {volist name="item.children" id="el"}
+                                <option value="{$el.id}">&nbsp;&nbsp;| --&nbsp;{$el.name}</option>
+                                {/volist}
+                                {/volist}
+                            </select>
+                        </div>
+                    </div>
+                    <div class="layui-form-item">
+                        <div class="layui-input-block">
+                          <button type="button" class="layui-btn" lay-submit="" lay-filter="caviar_submit_btn">{:lang('Submit')}</button>
+                          <button type="reset" class="layui-btn layui-btn-primary">{:lang("Reset")}</button>
+                        </div>
                     </div>
-                  </div>
                 </form>
-
               </div>
             </div>
           </div>
-
         </div>
-
       </div>
     </main>
-    <!--End 页面主要内容-->
   </div>
 </div>
 <script>
   layui.use(['laydate','form','upload'], () => {
     const form = layui.form;
 
-    form.on('submit(caviar_submit_btn)', (data) =>{
-      const response = request('{:url("admin/admin/add")}',data.field)
-      response.then((res) => {
+    form.on('submit(caviar_submit_btn)', (data) => {
+        const response = request('{:url("admin/admin/add")}', data.field)
+        response.then((res) => {
         console.log(res);
-        res.code === 200 ? layer.msg("{:lang('Succeed')}", {icon: 1,time:500},() => {
+        res.code === 200 ? layer.msg("{:lang('Succeed')}", { icon: 1, time:500 },() => {
           parent.location.reload();
-        }) : layer.msg(res.message,{icon: 5})
-      })
-      return false;
+        }) : layer.msg(res.message,{ icon: 5 })
+        });
+        return false;
     });
   });
 </script>

+ 71 - 20
app/admin/view/admin/edit.html

@@ -1,5 +1,4 @@
 {include file='common/_js_css'}
-
 <div class="lyear-layout-web">
     <div class="lyear-layout-container">
         <!--页面主要内容-->
@@ -8,42 +7,97 @@
                 <div class="row">
                     <div class="col-lg-12">
                         <div class="card">
+                            <ul class="nav nav-tabs page-tabs">
+                                <li class="active"> <a href="{:url('admin/admin/edit')}?id={$admin.id}">{:lang("Base")}</a> </li>
+                                <li> <a href="{:url('admin/admin/total_data')}?id={$admin.id}">{:lang("Total Data")}</a> </li>
+                            </ul>
                             <div class="card-body">
                                 <form class="layui-form">
-                                    <input name="id" value="{$admin.id}" hidden>
                                     <div class="layui-form-item">
                                         <label class="layui-form-label">{:lang("Account")}</label>
                                         <div class="layui-input-block">
-                                            <input type="text" name="account" value="{$admin.account}"lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
+                                            <input name="id" value="{$admin.id}" hidden>
+                                            <input type="text" value="{$admin.account}" name="account" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
                                         </div>
                                     </div>
 
                                     <div class="layui-form-item">
                                         <label class="layui-form-label">{:lang("Name")}</label>
                                         <div class="layui-input-block">
-                                            <input type="text" name="nickname" value="{$admin.nickname}" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
+                                            <input type="text" value="{$admin.nickname}" name="nickname" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
                                         </div>
                                     </div>
 
                                     <div class="layui-form-item">
-                                        <label class="layui-form-label">{:lang('Group')}</label>
+                                        <label class="layui-form-label">{:lang("Mobile")}</label>
+                                        <div class="layui-input-block">
+                                            <input type="text" value="{$admin.mobile}" name="mobile" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
+                                        </div>
+                                    </div>
+                                    <div class="layui-form-item">
+                                        <label class="layui-form-label">{:lang("Password")}</label>
+                                        <div class="layui-input-block">
+                                            <input type="password" value="{$admin.password}" name="password" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
+                                        </div>
+                                    </div>
+                                    <div class="layui-form-item">
+                                        <label class="layui-form-label">{:lang("Is login backstage")}</label>
+                                        <div class="layui-input-block">
+                                            {if $admin.is_login_backstage == 0}
+                                            <input type="radio" name="is_login_backstage" value="0" title="{:lang('No')}" checked>
+                                            <input type="radio" name="is_login_backstage" value="1" title="{:lang('Yes')}" >
+                                            {else /}
+                                            <input type="radio" name="is_login_backstage" value="0" title="{:lang('No')}" >
+                                            <input type="radio" name="is_login_backstage" value="1" title="{:lang('Yes')}" checked>
+                                            {/if}
+                                        </div>
+                                    </div>
+                                    <div class="layui-form-item">
+                                        <label class="layui-form-label">{:lang('Department')}</label>
                                         <div class="layui-input-block">
                                             <select name="group_id" lay-filter="required">
-                                                {volist name="groups" id="item"}
-                                                <option value="{$item.id}" {if $item.id == $admin.access.group_id} selected {/if} >{$item.name}</option>
+                                                {volist name="all_groups" id="item"}
+                                                <option value="{$item.id}"  {if $admin.access.group.id == $item.id} selected {/if} >{$item.name}</option>
+                                                {volist name='$item.children' id='first'}
+                                                <option value="{$first.id}"  {if $admin.access.group.id == $first.id} selected {/if}>&nbsp;&nbsp;| --&nbsp;{$first.name}</option>
+                                                {volist name='$first.children' id='second'}
+                                                <option value="{$second.id}"  {if $admin.access.group.id == $second.id} selected {/if}>&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;{$second.name}</option>
+                                                {volist name='$second.children' id='thirdly'}
+                                                <option value="{$thirdly.id}"  {if $admin.access.group.id == $thirdly.id} selected {/if}>&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;{$thirdly.name}</option>
+                                                {volist name='$thirdly.children' id='fourthly'}
+                                                <option value="{$fourthly.id}"  {if $admin.access.group.id == $fourthly.id} selected {/if}>&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;{$fourthly.name}</option>
+                                                {/volist}
+                                                {/volist}
+                                                {/volist}
+                                                {/volist}
                                                 {/volist}
                                             </select>
                                         </div>
                                     </div>
-
                                     <div class="layui-form-item">
-                                        <label class="layui-form-label">{:lang("Password")}</label>
+                                        <label class="layui-form-label">{:lang("Store")}</label>
                                         <div class="layui-input-block">
-                                            <input type="password" name="password" value="{$admin.password}" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
+                                            <select name="store_id">
+                                                <option value="">{:lang('Unknown')}</option>
+                                                {volist name="stores" id="item"}
+                                                <option value="{$item.id}"  {if $admin.store_id == $item.id} selected {/if} >{$item.name}</option>
+                                                {/volist}
+                                            </select>
+                                        </div>
+                                    </div>
+                                    <div class="layui-form-item">
+                                        <label class="layui-form-label">{:lang("Rule")}</label>
+                                        <div class="layui-input-block">
+                                            <select name="rule">
+                                                {volist name="rules" id="item"}
+                                                <option value="{$item.id}" {if $admin.rule == $item.id} selected {/if} >{$item.name}</option>
+                                                {volist name="item.children" id="el"}
+                                                <option value="{$el.id}" {if $admin.rule == $el.id} selected {/if} >&nbsp;&nbsp;| --&nbsp;{$el.name}</option>
+                                                {/volist}
+                                                {/volist}
+                                            </select>
                                         </div>
                                     </div>
-
-
                                     <div class="layui-form-item">
                                         <div class="layui-input-block">
                                             <button type="button" class="layui-btn" lay-submit="" lay-filter="caviar_submit_btn">{:lang('Submit')}</button>
@@ -51,13 +105,10 @@
                                         </div>
                                     </div>
                                 </form>
-
                             </div>
                         </div>
                     </div>
-
                 </div>
-
             </div>
         </main>
         <!--End 页面主要内容-->
@@ -67,14 +118,14 @@
     layui.use(['laydate','form','upload'], () => {
         const form = layui.form;
 
-        form.on('submit(caviar_submit_btn)', (data) =>{
-            const response = request('{:url("admin/admin/edit")}',data.field)
+        form.on('submit(caviar_submit_btn)', (data) => {
+            const response = request('{:url("admin/admin/edit")}', data.field)
             response.then((res) => {
                 console.log(res);
-                res.code === 200 ? layer.msg("{:lang('Succeed')}", {icon: 1,time:500},() => {
+                res.code === 200 ? layer.msg("{:lang('Succeed')}", { icon: 1, time:500 },() => {
                     parent.location.reload();
-                }) : layer.msg(res.message,{icon: 5})
-            })
+                }) : layer.msg(res.message,{ icon: 5 })
+            });
             return false;
         });
     });

+ 51 - 12
app/admin/view/admin/index.html

@@ -3,9 +3,52 @@
 <div class="container-fluid">
     <div class="row">
         <div class="col-lg-12">
+            <div class="card" id="select_card_caviar"  style="display: none">
+                <div class="card-header">{:lang("condition")}</div>
+                <div class="card-body">
+                    <form action="{:url('admin/admin/index')}" method="post" class="form-horizontal form-search">
+                        <div class="row">
+                            <div class="col-md-4">
+                                <div class="form-group">
+                                    <label class="w-120 pull-left control-label">{:lang("Department")}</label>
+                                    <div class="pull-left w-120-calc">
+                                        <select class="form-control pull-left" name="group_id">
+                                            {volist name="all_groups" id="item"}
+                                            <option value="{$item.id}" {if $params.group_id == $item.id} selected {/if} >{$item.name}</option>
+                                            {volist name='$item.children' id='first'}
+                                            <option value="{$first.id}" {if $params.group_id == $first.id} selected {/if} >&nbsp;&nbsp;| --&nbsp;{$first.name}</option>
+                                            {volist name='$first.children' id='second'}
+                                            <option value="{$second.id}" {if $params.group_id == $second.id} selected {/if}>&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;{$second.name}</option>
+                                            {volist name='$second.children' id='thirdly'}
+                                            <option value="{$thirdly.id}" {if $params.group_id == $thirdly.id} selected {/if}>&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;{$thirdly.name}</option>
+                                            {volist name='$thirdly.children' id='fourthly'}
+                                            <option value="{$fourthly.id}" {if $params.group_id == $fourthly.id} selected {/if}>&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;{$fourthly.name}</option>
+                                            {/volist}
+                                            {/volist}
+                                            {/volist}
+                                            {/volist}
+                                            {/volist}
+                                        </select>
+                                    </div>
+                                </div>
+                            </div>
+                            <div class="col-md-4">
+                                <div class="form-group">
+                                    <label class="w-120 pull-left control-label"></label>
+                                    <div class="pull-left w-120-calc">
+                                        <button class="btn btn-success m-r-5" id="caviar_send_btn" type="submit" href="#">{:lang('search')}</button>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+
+                    </form>
+                </div>
+            </div>
             <div class="card">
                 <div class="card-toolbar clearfix">
                     <div class="toolbar-btn-action">
+                        <a class="btn btn-success m-r-5" id="caviar_search_btn" href="#!" onclick="select_card_switch()">{$Think.lang.unfold_search}</a>
                         <a class="btn btn-primary m-r-5" href="#!" onclick="add('{:url(\'admin/admin/add\')}')"><i class="mdi mdi-plus"></i> {:lang('add')}</a>
                     </div>
                 </div>
@@ -14,15 +57,13 @@
                         <table class="table table-bordered">
                             <thead>
                             <tr>
-                                <th>
-                                    <label class="lyear-checkbox checkbox-primary">
-                                        <input type="checkbox" id="check-all" onclick="checkbox()"><span></span>
-                                    </label>
-                                </th>
                                 <th>{:lang("ID")}</th>
                                 <th>{:lang('Account')}</th>
-                                <th>{:lang('Name')}</th>
-                                <th>{:lang('Group')}</th>
+                                <th>{:lang("Name")}</th>
+                                <th>{:lang("Mobile")}</th>
+                                <th>{:lang("Department")}</th>
+                                <th>{:lang("Is login backstage")}</th>
+                                <th>{:lang("rule")}</th>
                                 <th>{:lang('update_time')}</th>
                                 <th>{:lang('operation')}</th>
                             </tr>
@@ -30,15 +71,13 @@
                             <tbody>
                             {volist name="list" id="item"}
                             <tr>
-                                <td>
-                                    <label class="lyear-checkbox checkbox-primary">
-                                        <input class="checkbox_caviar" type="checkbox" name="ids[]" value="{$item.id}"><span></span>
-                                    </label>
-                                </td>
                                 <td>{$item.id}</td>
                                 <td>{$item.account}</td>
                                 <td>{$item.nickname}</td>
+                                <td>{$item.mobile}</td>
                                 <td>{$item.access.group.name}</td>
+                                <td>{if $item.is_login_backstage == 1}{:lang("Yes")}{else /}{:lang("No")}{/if}</td>
+                                <td>{$rules[$item.rule - 1]['name']}</td>
                                 <td>{$item.update_time}</td>
                                 <td>
                                     <div class="btn-group">

+ 0 - 4
app/admin/view/auth/index.html

@@ -58,10 +58,6 @@
     </div>
 </div>
 
-<style>
-
-</style>
-
 <script type="text/javascript">
     if(check_params(["{params.store_id}"]))
         $('#select_card_caviar').css('display','block');

+ 114 - 0
app/admin/view/auth_group/add.html

@@ -0,0 +1,114 @@
+{include file='common/_js_css'}
+
+<div class="lyear-layout-web">
+    <div class="lyear-layout-container">
+        <!--页面主要内容-->
+        <main>
+            <div class="container-fluid">
+                <div class="row">
+                    <div class="col-lg-12">
+                        <div class="card">
+                            <div class="card-body">
+                                <form class="layui-form">
+                                    <div class="layui-form-item">
+                                        <label class="layui-form-label">{:lang("Name")}</label>
+                                        <div class="layui-input-block">
+                                            <input type="text" name="name" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
+                                        </div>
+                                    </div>
+                                    <div class="layui-form-item">
+                                        <label class="layui-form-label">{:lang("Describe")}</label>
+                                        <div class="layui-input-block">
+                                            <input type="text" name="describe" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
+                                        </div>
+                                    </div>
+
+                                    <div class="layui-form-item">
+                                        <label class="layui-form-label">{:lang("Store")}</label>
+                                        <div class="layui-input-block">
+                                            {volist name="stores" id="item"}
+                                            <input type="checkbox" name="store_ids[]" value="{$item.id}" title={$item.name}>
+                                            {/volist}
+                                        </div>
+                                    </div>
+                                    <div class="layui-form-item">
+                                        <label class="layui-form-label">{:lang('Superior department')}</label>
+                                        <div class="layui-input-block">
+                                            <select name="pid" lay-filter="required">
+                                                <option value="0" selected>{:lang("Unknown")}</option>
+                                                {volist name="all_groups" id="item"}
+                                                <option value="{$item.id}"  >{$item.name}</option>
+                                                {volist name='$item.children' id='first'}
+                                                <option value="{$first.id}">&nbsp;&nbsp;| --&nbsp;{$first.name}</option>
+                                                {volist name='$first.children' id='second'}
+                                                <option value="{$second.id}">&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;{$second.name}</option>
+                                                {volist name='$second.children' id='thirdly'}
+                                                <option value="{$thirdly.id}">&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;{$thirdly.name}</option>
+                                                {volist name='$thirdly.children' id='fourthly'}
+                                                <option value="{$fourthly.id}">&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;{$fourthly.name}</option>
+                                                {/volist}
+                                                {/volist}
+                                                {/volist}
+                                                {/volist}
+                                                {/volist}
+                                            </select>
+                                        </div>
+                                    </div>
+                                    <div class="layui-form-item">
+                                        <label class="layui-form-label">{:lang("Permission")}</label>
+                                        <div class="layui-input-block">
+                                            <div id="auth_caviar" class="demo-tree-more"></div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-form-item">
+                                        <div class="layui-input-block">
+                                            <button type="button" class="layui-btn" lay-submit="" lay-filter="caviar_submit_btn" lay-checked="getChecked">{:lang('Submit')}</button>
+                                            <button type="reset" class="layui-btn layui-btn-primary">{:lang("Reset")}</button>
+                                        </div>
+                                    </div>
+                                </form>
+                            </div>
+                        </div>
+                    </div>
+
+                </div>
+
+            </div>
+        </main>
+        <!--End 页面主要内容-->
+    </div>
+</div>
+<script>
+
+    layui.use(['tree', 'util'], async function(){
+        const tree = layui.tree
+            ,layer = layui.layer
+            ,form = layui.form;
+
+        const response = await request('{:url("admin/auth/findAuthRuleByAdminId")}');
+        let data = []
+        if(response.code === 200) data = response.data;
+
+        tree.render({
+            elem: '#auth_caviar'
+            ,data: data
+            ,showCheckbox: true  //是否显示复选框
+            ,id: "auth_input"
+        });
+
+        form.on('submit(caviar_submit_btn)', (data) => {
+            const checkedData = deepTraversal(tree.getChecked('auth_input')); //获取选中节点的数据
+            request('{:url("admin/auth_group/add")}',{
+                ...data.field,
+                rule_ids: checkedData.map(v => v.id).join(",")
+            }).then((res) => {
+                res.code === 200 ? layer.msg("{:lang('Succeed')}", { icon: 1, time:500 }, () => {
+                    parent.location.reload();
+                }) : layer.msg(res.message, { icon: 5 })
+            })
+            return false;
+        });
+
+    });
+
+</script>

+ 139 - 0
app/admin/view/auth_group/edit.html

@@ -0,0 +1,139 @@
+{include file='common/_js_css'}
+
+<div class="lyear-layout-web">
+    <div class="lyear-layout-container">
+        <!--页面主要内容-->
+        <main>
+            <div class="container-fluid">
+                <div class="row">
+                    <div class="col-lg-12">
+                        <div class="card">
+                            <div class="card-body">
+                                <form class="layui-form">
+                                    <div class="layui-form-item">
+                                        <label class="layui-form-label">{:lang("Name")}</label>
+                                        <div class="layui-input-block">
+                                            <input name="id" value="{$group.id}" hidden>
+                                            <input type="text" name="name" value="{$group.name}" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
+                                        </div>
+                                    </div>
+                                    <div class="layui-form-item">
+                                        <label class="layui-form-label">{:lang("Describe")}</label>
+                                        <div class="layui-input-block">
+                                            <input type="text" name="describe" value="{$group.describe}" lay-verify="required" lay-reqtext="{:lang('Please fill in')}" autocomplete="off" class="layui-input">
+                                        </div>
+                                    </div>
+                                    <div class="layui-form-item">
+                                        <label class="layui-form-label">{:lang("Store")}</label>
+                                        <div class="layui-input-block">
+                                            {volist name="stores" id="item"}
+                                            <input type="checkbox" name="store_ids[]" value="{$item.id}" title={$item.name} {if $item.isChecked} checked {/if}>
+                                            {/volist}
+                                        </div>
+                                    </div>
+                                    <div class="layui-form-item">
+                                        <label class="layui-form-label">{:lang('Superior department')}</label>
+                                        <div class="layui-input-block">
+                                            <select name="pid" lay-filter="required">
+                                                <option value="0" selected>{:lang("Unknown")}</option>
+                                                {volist name="all_groups" id="item"}
+                                                <option value="{$item.id}"  {if $group.pid == $item.id} selected {/if} >{$item.name}</option>
+                                                {volist name='$item.children' id='first'}
+                                                <option value="{$first.id}"  {if $group.pid == $first.id} selected {/if}>&nbsp;&nbsp;| --&nbsp;{$first.name}</option>
+                                                {volist name='$first.children' id='second'}
+                                                <option value="{$second.id}"  {if $group.pid == $second.id} selected {/if}>&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;{$second.name}</option>
+                                                {volist name='$second.children' id='thirdly'}
+                                                <option value="{$thirdly.id}"  {if $group.pid == $thirdly.id} selected {/if}>&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;{$thirdly.name}</option>
+                                                {volist name='$thirdly.children' id='fourthly'}
+                                                <option value="{$fourthly.id}"  {if $group.pid == $fourthly.id} selected {/if}>&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;{$fourthly.name}</option>
+                                                {/volist}
+                                                {/volist}
+                                                {/volist}
+                                                {/volist}
+                                                {/volist}
+                                            </select>
+                                        </div>
+                                    </div>
+                                    <div class="layui-form-item">
+                                        <label class="layui-form-label">{:lang("Permission")}</label>
+                                        <div class="layui-input-block">
+                                            <div id="auth_caviar" class="demo-tree-more"></div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-form-item">
+                                        <div class="layui-input-block">
+                                            <button type="button" class="layui-btn" lay-submit="" lay-filter="caviar_submit_btn" lay-checked="getChecked">{:lang('Submit')}</button>
+                                            <button type="button" class="btn btn-danger" onclick='
+                                           deletingASingle_("{:url(\"admin/auth_group/delete\")}","{$group.id}",["{:lang(\"Succeed\")}"],"{:lang(\"Warn\")}","{:lang(\"Are you sure you want to delete the selected data\")}",["{:lang(\"Confirm\")}"])'
+                                            >{:lang('Delete')}</button>
+                                            <button type="reset" class="layui-btn layui-btn-primary">{:lang("Reset")}</button>
+                                        </div>
+                                    </div>
+                                </form>
+
+                            </div>
+                        </div>
+                    </div>
+
+                </div>
+
+            </div>
+        </main>
+        <!--End 页面主要内容-->
+    </div>
+</div>
+<script>
+    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
+
+    layui.use(['tree', 'util'], async function(){
+        var tree = layui.tree
+            ,layer = layui.layer
+            ,form = layui.form;
+
+        const response = await request('{:url("admin/auth/findAuthRuleByGroupId")}?group_id={$group.id}');
+        let data = []
+        if(response.code === 200) data = response.data;
+
+        tree.render({
+            elem: '#auth_caviar'
+            ,data: data
+            ,showCheckbox: true  //是否显示复选框
+            ,id: "auth_input"
+        });
+
+        form.on('submit(caviar_submit_btn)', (data) => {
+            const checkedData = deepTraversal(tree.getChecked('auth_input')); //获取选中节点的数据
+            request('{:url("admin/auth_group/edit")}',{
+                ...data.field,
+                rule_ids: checkedData.length === 0 ? undefined : checkedData.map(v => v.id).join(",")
+            }).then((res) => {
+                res.code === 200 ? layer.msg("{:lang('Succeed')}", {icon: 1,time:500},() => {
+                    parent.location.reload();
+                }) : layer.msg(res.message,{icon: 5})
+            })
+            return false;
+        });
+
+    });
+    function deletingASingle_(url,
+                             id,
+                             hints = ['Succeed'],
+                             title= 'Warn',
+                             content= 'Are you sure you want to delete the selected data?',
+                             btn = ['Confirm']) {
+        layer.open({
+            title: title,
+            content: content,
+            btn: btn,
+            yes: async (index, layero) => {
+                const response = await request(url, { ids: id.toString()} );
+                response.code === 200 ? layer.msg(hints[0], {icon: 1,time:200},() => {
+                    parent.layer.close(index);
+                    location.replace("{:url('admin/auth_group/index')}")
+                }) : layer.msg(res.message,{icon: 5})
+                layer.close(index);
+            }
+
+        });
+    }
+</script>

+ 41 - 0
app/admin/view/auth_group/index.html

@@ -0,0 +1,41 @@
+{include file='common/_js_css'}
+
+
+<div class="container-fluid">
+    <div class="row">
+        <div class="col-lg-12">
+            <div class="card">
+                <div class="card-toolbar clearfix">
+                    <div class="toolbar-btn-action">
+                        <a class="btn btn-primary m-r-5" href="#!" onclick="add('{:url(\'admin/auth_group/add\')}')"><i class="mdi mdi-plus"></i> {:lang('add')}</a>
+                    </div>
+                </div>
+                <div class="card-body">
+                    <div id="auth_group_tree" class="demo-tree-more"></div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script>
+    layui.use(['tree', 'util'], async() => {
+        const tree = layui.tree
+        let data = [];
+        const response = await request('{:url("admin/auth_group/findAllAuthGroups")}');
+        if(response.code === 200) data = response.data;
+
+        //基本演示
+        tree.render({
+            elem: '#auth_group_tree'
+            ,data: data
+            ,showCheckbox: true  //是否显示复选框
+            ,isJump: true //是否允许点击节点时弹出新窗口跳转
+            ,click: function(obj){
+                const data = obj.data;  //获取当前点击的节点数据
+                view("{:url('admin/auth_group/edit')}?id=" + data.id.toString(), "{:lang('Update')}")
+            }
+        });
+
+
+    });
+</script>

+ 5 - 2
app/common/model/AuthRuleModel.php

@@ -24,8 +24,11 @@ class AuthRuleModel extends BaseModel
         if(count($ids) == 0)
             return [];
         if($ids[0] == '*')
-            return $this->select()->order("weigh","desc")->toArray();
-        return $this->where('id','in', $ids)->order("weigh","desc")->select()->toArray();
+            return $this->where('is_delete',0)->order("weigh","desc")->select()->toArray();
+        return $this->where([
+            ['is_delete','=',0],
+            ['id','in', $ids]
+        ])->order("weigh","desc")->select()->toArray();
     }