|
|
@@ -6,7 +6,7 @@ namespace app\admin\controller;
|
|
|
|
|
|
use app\admin\service\AuthService;
|
|
|
use app\BaseController;
|
|
|
-use app\common\model\StoreModel;
|
|
|
+use app\common\model\DepartmentModel;
|
|
|
use think\App;
|
|
|
use think\facade\View;
|
|
|
|
|
|
@@ -14,7 +14,7 @@ use think\facade\View;
|
|
|
class AuthGroup extends BaseController
|
|
|
{
|
|
|
private $authService;
|
|
|
- private $storeModel;
|
|
|
+ private $departmentModel;
|
|
|
|
|
|
public $reception_rules = [
|
|
|
["id" => 10001, "zh" => "客户资料", "en" => "Customer information", "icon" => ""],
|
|
|
@@ -33,7 +33,7 @@ class AuthGroup extends BaseController
|
|
|
{
|
|
|
parent::__construct($app);
|
|
|
$this->authService = new AuthService();
|
|
|
- $this->storeModel = new StoreModel();
|
|
|
+ $this->departmentModel = new DepartmentModel();
|
|
|
}
|
|
|
|
|
|
public function index() {
|
|
|
@@ -47,7 +47,7 @@ class AuthGroup extends BaseController
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
public function add() {
|
|
|
- $all_groups = $this->authService->authGroupModel->fetchAllGroups();
|
|
|
+ $all_department = $this->departmentModel->findAllDepartment();
|
|
|
|
|
|
if ($this->request->isAjax()) {
|
|
|
$params = $this->request->param();
|
|
|
@@ -56,13 +56,15 @@ class AuthGroup extends BaseController
|
|
|
'name' => format_string($params['name'] ?? null),
|
|
|
'rules' => format_string($params['rule_ids'] ?? null),
|
|
|
"reception_rules" => isset($params["reception_rules"]) ? join(',', $params['reception_rules']) : null,
|
|
|
+ "data_rules" => isset($params["data_rules"]) ? join(',', $params['data_rules']) : null,
|
|
|
+ "department_id" => format_string($params['department_id'] ?? null),
|
|
|
'describe' => format_string($params['describe'] ?? null),
|
|
|
]);
|
|
|
return $this->ok($res);
|
|
|
}
|
|
|
View::assign([
|
|
|
"reception_rules" => $this->reception_rules,
|
|
|
- "all_groups" => recursion($all_groups, 0)
|
|
|
+ "all_department" => recursion($all_department, 0)
|
|
|
]);
|
|
|
return view();
|
|
|
}
|
|
|
@@ -76,25 +78,32 @@ class AuthGroup extends BaseController
|
|
|
public function edit() {
|
|
|
$params = $this->request->param();
|
|
|
$id = $params['id'];
|
|
|
- $all_groups = $this->authService->authGroupModel->fetchAllGroups();
|
|
|
$group = $this->authService->authGroupModel->findById($id);
|
|
|
+ $all_department = $this->departmentModel->findAllDepartment();
|
|
|
if ($this->request->isAjax()) {
|
|
|
$res = $this->authService->authGroupModel->where('id', $params['id'])->save([
|
|
|
'pid' => 0,
|
|
|
'name' => $params['name'] ?? $group->name,
|
|
|
'rules' => !isset($params['rule_ids']) ? null : $params['rule_ids'],
|
|
|
"reception_rules" => isset($params["reception_rules"]) ? join(',', $params['reception_rules']) : null,
|
|
|
+ "data_rules" => isset($params["data_rules"]) ? join(',', $params['data_rules']) : null,
|
|
|
+ "department_id" => format_string($params['department_id'] ?? null),
|
|
|
'describe' => $params['describe'] ?? $group->describe,
|
|
|
'update_time' => time()
|
|
|
]);
|
|
|
return $this->ok($res);
|
|
|
}
|
|
|
- $reception_rules = $group->reception_rules ? explode(',',$group->reception_rules) : [];
|
|
|
- foreach ($this->reception_rules as &$item) $item['isChecked'] = in_array($item['id'], $reception_rules);
|
|
|
+ $reception_rule_ids = $group->reception_rules ? explode(',',$group->reception_rules) : [];
|
|
|
+ $reception_rules = array_merge([],$this->reception_rules);
|
|
|
+ foreach ($reception_rules as &$item) $item['isChecked'] = in_array($item['id'], $reception_rule_ids);
|
|
|
+ $data_rule_ids = $group->data_rules ? explode(',', $group->data_rules) : [];
|
|
|
+ $data_rules = array_merge([], $this->reception_rules);
|
|
|
+ foreach ($data_rules as &$item) $item['isChecked'] = in_array($item['id'], $data_rule_ids);
|
|
|
View::assign([
|
|
|
'group' => $group,
|
|
|
- "all_groups" => recursion($all_groups, 0),
|
|
|
- "reception_rules" => $this->reception_rules,
|
|
|
+ "reception_rules" => $reception_rules,
|
|
|
+ "data_rules" => $data_rules,
|
|
|
+ "all_department" => recursion($all_department, 0)
|
|
|
]);
|
|
|
return view();
|
|
|
}
|