WIN-2308041133\Administrator 1 month ago
parent
commit
d820a837a1
1 changed files with 23 additions and 2 deletions
  1. 23 2
      app/admin/controller/setting/SystemAdmin.php

+ 23 - 2
app/admin/controller/setting/SystemAdmin.php

@@ -4,7 +4,7 @@ namespace app\admin\controller\setting;
 
 use app\admin\controller\AuthController;
 use crmeb\services\{FormBuilder as Form, JsonService as Json, UtilService as Util};
-use app\admin\model\system\{SystemRole, SystemAdmin as AdminModel};
+use app\admin\model\system\{SystemRole, SystemAdmin as AdminModel, SystemStore};
 use think\facade\Route as Url;
 
 /**
@@ -54,6 +54,14 @@ class SystemAdmin extends AuthController
             }
             return $options;
         })->multiple(1);
+        $f[] = Form::select('mer_id', '门店')->setOptions(function () use ($admin) {
+            $list = SystemStore::getStoreList(['type'=>1]);
+            $options = [];
+            foreach ($list as $id => $roleName) {
+                $options[] = ['label' => $roleName['name'], 'value' => $roleName['id']];
+            }
+            return $options;
+        });
         $f[] = Form::radio('status', '状态', 1)->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
         $form = Form::make_post_form('添加管理员', $f, Url::buildUrl('save'));
         $this->assign(compact('form'));
@@ -74,11 +82,13 @@ class SystemAdmin extends AuthController
             'pwd',
             'real_name',
             ['roles', []],
-            ['status', 0]
+            ['status', 0],
+            ['mer_id',0]
         ]);
         if (!$data['account']) return Json::fail('请输入管理员账号');
         if (!$data['roles']) return Json::fail('请选择至少一个管理员身份');
         if (!$data['pwd']) return Json::fail('请输入管理员登陆密码');
+        if (!$data['mer_id']) return Json::fail('请选择门店');
         if ($data['pwd'] != $data['conf_pwd']) return Json::fail('两次输入密码不想同');
         if (AdminModel::be($data['account'], 'account')) return Json::fail('管理员账号已存在');
         $salt = substr(md5(rand(1, 999999)), 0, 6);
@@ -116,6 +126,14 @@ class SystemAdmin extends AuthController
             }
             return $options;
         })->multiple(1);
+        $f[] = Form::select('mer_id', '门店')->setOptions(function () use ($admin) {
+            $list = SystemStore::getStoreList(['type'=>1]);
+            $options = [];
+            foreach ($list as $id => $roleName) {
+                $options[] = ['label' => $roleName['name'], 'value' => $roleName['id']];
+            }
+            return $options;
+        });
         $f[] = Form::radio('status', '状态', 1)->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
         $form = Form::make_post_form('编辑管理员', $f, Url::buildUrl('update', compact('id')));
         $this->assign(compact('form'));
@@ -137,10 +155,12 @@ class SystemAdmin extends AuthController
             'pwd',
             'real_name',
             ['roles', []],
+            ['mer_id', 0],
             ['status', 0]
         ]);
         if (!$data['account']) return Json::fail('请输入管理员账号');
         if (!$data['roles']) return Json::fail('请选择至少一个管理员身份');
+        if (!$data['mer_id']) return Json::fail('请选择门店');
         if (!$data['pwd'])
             unset($data['pwd']);
         else {
@@ -193,6 +213,7 @@ class SystemAdmin extends AuthController
                 ['new_pwd', ''],
                 ['new_pwd_ok', ''],
                 ['pwd', ''],
+//                ['mer_id', ''],
                 'real_name',
             ]);
             if ($data['pwd'] != '') {