diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemRole.php b/crmeb/app/adminapi/controller/v1/setting/SystemRole.php index 3869f730f..fcb94d806 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemRole.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemRole.php @@ -77,6 +77,10 @@ class SystemRole extends AuthController if (!$data['role_name']) return app('json')->fail(400220); if (!is_array($data['rules']) || !count($data['rules'])) return app('json')->fail(400221); + + $res = app()->make(SystemMenusServices::class)->getColumn([['pid', 'in', $data['rules']]], 'id'); + $data['rules'] = array_merge($data['rules'], $res); + $data['rules'] = implode(',', $data['rules']); if ($id) { if (!$this->services->update($id, $data)) return app('json')->fail(100007); diff --git a/crmeb/app/model/system/SystemMenus.php b/crmeb/app/model/system/SystemMenus.php index 0a73b5d00..4278d9921 100644 --- a/crmeb/app/model/system/SystemMenus.php +++ b/crmeb/app/model/system/SystemMenus.php @@ -232,7 +232,11 @@ class SystemMenus extends BaseModel public function searchAuthTypeAttr($query, $value) { if ($value !== '') { - $query->where('auth_type', $value); + if ($value == 3) { + $query->whereIn('auth_type', [1, 3]); + } else { + $query->where('auth_type', $value); + } } } } diff --git a/crmeb/app/services/system/SystemMenusServices.php b/crmeb/app/services/system/SystemMenusServices.php index 0b4029eff..fea86739b 100644 --- a/crmeb/app/services/system/SystemMenusServices.php +++ b/crmeb/app/services/system/SystemMenusServices.php @@ -120,9 +120,13 @@ class SystemMenusServices extends BaseServices * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - protected function getFormCascaderMenus(int $value = 0) + protected function getFormCascaderMenus(int $value = 0, $auth_type = 0) { - $menuList = $this->dao->getMenusRoule(['is_del' => 0], ['id as value', 'pid', 'menu_name as label']); + $where = ['is_del' => 0]; + if ($auth_type == 3) { + $where = ['is_del' => 0, 'auth_type' => 3]; + } + $menuList = $this->dao->getMenusRoule($where, ['id as value', 'pid', 'menu_name as label']); $menuList = $this->getMenusData($menuList); if ($value) { $data = get_tree_value($menuList, $value); @@ -151,7 +155,7 @@ class SystemMenusServices extends BaseServices $field[] = Form::radio('auth_type', '类型', $formData['auth_type'] ?? 1)->options([['value' => 1, 'label' => '菜单'], ['value' => 3, 'label' => '按钮']]); $field[] = Form::radio('is_show', '权限状态', $formData['is_show'] ?? 1)->options([['value' => 1, 'label' => '开启'], ['value' => 0, 'label' => '关闭']]); $field[] = Form::radio('is_show_path', '是否显示', $formData['is_show_path'] ?? 0)->options([['value' => 1, 'label' => '显示'], ['value' => 0, 'label' => '隐藏']]); - [$menuList, $data] = $this->getFormCascaderMenus((int)($formData['pid'] ?? 0)); + [$menuList, $data] = $this->getFormCascaderMenus((int)($formData['pid'] ?? 0), 3); $field[] = Form::cascader('menu_list', '父级id', $data)->data($menuList)->filterable(true); return $field; } @@ -245,7 +249,7 @@ class SystemMenusServices extends BaseServices public function getMenus($roles): array { $field = ['menu_name', 'pid', 'id']; - $where = ['is_del' => 0]; + $where = ['is_del' => 0, 'auth_type' => 3]; if (!$roles) { $menus = $this->dao->getMenusRoule($where, $field); } else { diff --git a/template/admin/src/pages/setting/systemMenus/index.vue b/template/admin/src/pages/setting/systemMenus/index.vue index 5aeea2f52..72961230b 100644 --- a/template/admin/src/pages/setting/systemMenus/index.vue +++ b/template/admin/src/pages/setting/systemMenus/index.vue @@ -177,7 +177,7 @@ export default { roleData: { is_show: 1, keyword: '', - // auth_type: 1, + auth_type: 3, }, defaultProps: { children: 'children', diff --git a/template/admin/src/pages/system/systemMenus/components/menusFrom.vue b/template/admin/src/pages/system/systemMenus/components/menusFrom.vue index 62e078162..6376573fd 100644 --- a/template/admin/src/pages/system/systemMenus/components/menusFrom.vue +++ b/template/admin/src/pages/system/systemMenus/components/menusFrom.vue @@ -14,11 +14,10 @@