...
|
...
|
@@ -10,10 +10,10 @@ |
10
|
10
|
<BasicForm @register="registerForm">
|
11
|
11
|
<template #menu>
|
12
|
12
|
<BasicTree
|
|
13
|
+ v-if="treeData.length"
|
13
|
14
|
checkable
|
14
|
15
|
toolbar
|
15
|
|
- defaultExpandAll
|
16
|
|
- v-if="treeData.length"
|
|
16
|
+ autoExpandParent
|
17
|
17
|
ref="treeRef"
|
18
|
18
|
:treeData="treeData"
|
19
|
19
|
:replaceFields="{ title: 'menuName' }"
|
...
|
...
|
@@ -69,8 +69,16 @@ |
69
|
69
|
}
|
70
|
70
|
});
|
71
|
71
|
}
|
|
72
|
+ // function lookForAllId(data = [], arr = []) {
|
|
73
|
+ // for (const item of data) {
|
|
74
|
+ // arr.push(item.parentId);
|
|
75
|
+ // if (item.children && item.children.length > 0) lookForAllId(item.children, arr);
|
|
76
|
+ // }
|
|
77
|
+ // return arr;
|
|
78
|
+ // }
|
72
|
79
|
const originMenus = ref();
|
73
|
80
|
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
|
81
|
+ allCheckedKeys.value = [];
|
74
|
82
|
resetFields();
|
75
|
83
|
roleId.value = '';
|
76
|
84
|
// 在打开弹窗时清除所有选择的菜单
|
...
|
...
|
@@ -85,6 +93,7 @@ |
85
|
93
|
}
|
86
|
94
|
// 更新
|
87
|
95
|
if (unref(isUpdate)) {
|
|
96
|
+ allCheckedKeys.value = [];
|
88
|
97
|
checked.value = [];
|
89
|
98
|
//通过角色id去获取角色对应的菜单的ids
|
90
|
99
|
roleMenus.value = await getMenusIdsByRoleId(data.record.id);
|
...
|
...
|
@@ -107,6 +116,8 @@ |
107
|
116
|
}
|
108
|
117
|
nextTick(() => {
|
109
|
118
|
treeRef.value.setCheckedKeys(checked.value);
|
|
119
|
+ // const expandTreeIds = lookForAllId(treeData.value);
|
|
120
|
+ // treeRef.value.setExpandedKeys(expandTreeIds);
|
110
|
121
|
});
|
111
|
122
|
roleId.value = data.record.id;
|
112
|
123
|
setFieldsValue(data.record);
|
...
|
...
|
@@ -127,6 +138,9 @@ |
127
|
138
|
status: values.status,
|
128
|
139
|
menu: allCheckedKeys.value.length ? allCheckedKeys.value : originMenus.value,
|
129
|
140
|
};
|
|
141
|
+ console.log(allCheckedKeys.value);
|
|
142
|
+ if (allCheckedKeys.value.length == 0) return createMessage.error('请勾选权限菜单');
|
|
143
|
+ if (req.menu == undefined) return createMessage.error('请勾选权限菜单');
|
130
|
144
|
saveOrUpdateRoleInfoWithMenu(req).then(() => {
|
131
|
145
|
closeDrawer();
|
132
|
146
|
emit('success');
|
...
|
...
|
|