diff --git a/src/views/system/role/DataPermissionForm.vue b/src/views/system/role/DataPermissionForm.vue
new file mode 100644
index 00000000..bccc5f46
--- /dev/null
+++ b/src/views/system/role/DataPermissionForm.vue
@@ -0,0 +1,174 @@
+
+
+
+
+
diff --git a/src/views/system/role/MenuPermissionForm.vue b/src/views/system/role/MenuPermissionForm.vue
index 70971781..a7995fec 100644
--- a/src/views/system/role/MenuPermissionForm.vue
+++ b/src/views/system/role/MenuPermissionForm.vue
@@ -13,28 +13,10 @@
{{ dataScopeForm.code }}
-
-
-
-
-
-
-
+
父子联动(选中父节点,自动选择子节点):
@@ -94,10 +76,8 @@ import * as RoleApi from '@/api/system/role'
import type { ElTree } from 'element-plus'
import type { FormExpose } from '@/components/Form'
import { handleTree, defaultProps } from '@/utils/tree'
-import { SystemDataScopeEnum } from '@/utils/constants'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import * as MenuApi from '@/api/system/menu'
-import * as DeptApi from '@/api/system/dept'
import * as PermissionApi from '@/api/system/permission'
// ========== CRUD 相关 ==========
const actionLoading = ref(false) // 遮罩层
@@ -130,50 +110,27 @@ const openModal = async (type: string, row: RoleApi.RoleVO) => {
dataScopeForm.code = row.code
actionScopeType.value = type
dialogScopeVisible.value = true
- if (type === 'menu') {
- const menuRes = await MenuApi.getSimpleMenusList()
- treeOptions.value = handleTree(menuRes)
- const role = await PermissionApi.listRoleMenusApi(row.id)
- if (role) {
- role?.forEach((item: any) => {
- unref(treeRef)?.setChecked(item, true, false)
- })
- }
- } else if (type === 'data') {
- const deptRes = await DeptApi.getSimpleDeptList()
- treeOptions.value = handleTree(deptRes)
- const role = await RoleApi.getRole(row.id)
- dataScopeForm.dataScope = role.dataScope
- if (role.dataScopeDeptIds) {
- role.dataScopeDeptIds?.forEach((item: any) => {
- unref(treeRef)?.setChecked(item, true, false)
- })
- }
+ const menuRes = await MenuApi.getSimpleMenusList()
+ treeOptions.value = handleTree(menuRes)
+ const role = await PermissionApi.listRoleMenusApi(row.id)
+ if (role) {
+ role?.forEach((item: any) => {
+ unref(treeRef)?.setChecked(item, true, false)
+ })
}
}
// 保存权限
const submitScope = async () => {
- if ('data' === actionScopeType.value) {
- const data = ref({
- roleId: dataScopeForm.id,
- dataScope: dataScopeForm.dataScope,
- dataScopeDeptIds:
- dataScopeForm.dataScope !== SystemDataScopeEnum.DEPT_CUSTOM
- ? []
- : (treeRef.value!.getCheckedKeys(false) as unknown as Array)
- })
- await PermissionApi.assignRoleDataScopeApi(data.value)
- } else if ('menu' === actionScopeType.value) {
- const data = ref({
- roleId: dataScopeForm.id,
- menuIds: [
- ...(treeRef.value!.getCheckedKeys(false) as unknown as Array),
- ...(treeRef.value!.getHalfCheckedKeys() as unknown as Array)
- ]
- })
- await PermissionApi.assignRoleMenuApi(data.value)
- }
+ const data = ref({
+ roleId: dataScopeForm.id,
+ menuIds: [
+ ...(treeRef.value!.getCheckedKeys(false) as unknown as Array),
+ ...(treeRef.value!.getHalfCheckedKeys() as unknown as Array)
+ ]
+ })
+ await PermissionApi.assignRoleMenuApi(data.value)
+
message.success(t('common.updateSuccess'))
dialogScopeVisible.value = false
}
@@ -193,10 +150,3 @@ onMounted(() => {
init()
})
-
diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue
index af8e0d3a..4be8e48c 100644
--- a/src/views/system/role/index.vue
+++ b/src/views/system/role/index.vue
@@ -146,11 +146,14 @@
+
+