|
99 | 99 | </el-select>
|
100 | 100 | </el-form-item>
|
101 | 101 | <!-- 分配角色的菜单权限对话框 -->
|
102 |
| - <el-form-item |
103 |
| - label="权限范围" |
104 |
| - v-if=" |
105 |
| - actionScopeType === 'menu' || dataScopeForm.dataScope === SystemDataScopeEnum.DEPT_CUSTOM |
106 |
| - " |
107 |
| - > |
108 |
| - <el-card shadow="never"> |
109 |
| - <template #header> |
110 |
| - 父子联动(选中父节点,自动选择子节点): |
111 |
| - <el-switch v-model="checkStrictly" inline-prompt active-text="是" inactive-text="否" /> |
112 |
| - 全选/全不选: |
113 |
| - <el-switch |
114 |
| - v-model="treeNodeAll" |
115 |
| - inline-prompt |
116 |
| - active-text="是" |
117 |
| - inactive-text="否" |
118 |
| - @change="handleCheckedTreeNodeAll()" |
119 |
| - /> |
120 |
| - </template> |
121 |
| - <el-tree |
122 |
| - ref="treeRef" |
123 |
| - node-key="id" |
124 |
| - show-checkbox |
125 |
| - :default-checked-keys="defaultCheckedKeys" |
126 |
| - :check-strictly="!checkStrictly" |
127 |
| - :props="defaultProps" |
128 |
| - :data="treeOptions" |
129 |
| - empty-text="加载中,请稍后" |
130 |
| - /> |
131 |
| - </el-card> |
132 |
| - </el-form-item> |
| 102 | + <el-row> |
| 103 | + <el-col :span="24"> |
| 104 | + <el-form-item |
| 105 | + label="权限范围" |
| 106 | + v-if=" |
| 107 | + actionScopeType === 'menu' || |
| 108 | + dataScopeForm.dataScope === SystemDataScopeEnum.DEPT_CUSTOM |
| 109 | + " |
| 110 | + style="display: flex" |
| 111 | + > |
| 112 | + <el-card class="card" shadow="never"> |
| 113 | + <template #header> |
| 114 | + <!--父子联动(选中父节点,自动选择子节点):--> |
| 115 | + <!--<el-switch v-model="checkStrictly" inline-prompt active-text="是" inactive-text="否" />--> |
| 116 | + <!--全选/全不选:--> |
| 117 | + <!--<el-switch--> |
| 118 | + <!-- v-model="treeNodeAll"--> |
| 119 | + <!-- inline-prompt--> |
| 120 | + <!-- active-text="是"--> |
| 121 | + <!-- inactive-text="否"--> |
| 122 | + <!-- @change="handleCheckedTreeNodeAll()"--> |
| 123 | + <!--/>--> |
| 124 | + </template> |
| 125 | + <el-tree |
| 126 | + ref="treeRef" |
| 127 | + node-key="id" |
| 128 | + show-checkbox |
| 129 | + :check-strictly="!checkStrictly" |
| 130 | + :props="defaultProps" |
| 131 | + :data="treeOptions" |
| 132 | + empty-text="加载中,请稍后" |
| 133 | + /> |
| 134 | + </el-card> |
| 135 | + </el-form-item> </el-col |
| 136 | + ></el-row> |
133 | 137 | </el-form>
|
134 | 138 | <!-- 操作按钮 -->
|
135 | 139 | <template #footer>
|
@@ -245,39 +249,40 @@ const dialogScopeVisible = ref(false)
|
245 | 249 | const dialogScopeTitle = ref('数据权限')
|
246 | 250 | const actionScopeType = ref('')
|
247 | 251 | const dataScopeDictDatas = ref()
|
248 |
| -const defaultCheckedKeys = ref() |
249 | 252 | // 选项
|
250 |
| -const checkStrictly = ref(true) |
251 |
| -const treeNodeAll = ref(false) |
| 253 | +const checkStrictly = ref(false) |
| 254 | +// const treeNodeAll = ref(false) |
252 | 255 | // 全选/全不选
|
253 |
| -const handleCheckedTreeNodeAll = () => { |
254 |
| - treeRef.value!.setCheckedNodes(treeNodeAll.value ? treeOptions.value : []) |
255 |
| -} |
| 256 | +// const handleCheckedTreeNodeAll = () => { |
| 257 | +// treeRef.value!.setCheckedNodes(treeNodeAll.value ? treeOptions.value : []) |
| 258 | +// } |
256 | 259 | // 权限操作
|
257 | 260 | const handleScope = async (type: string, row: RoleApi.RoleVO) => {
|
258 | 261 | dataScopeForm.id = row.id
|
259 | 262 | dataScopeForm.name = row.name
|
260 | 263 | dataScopeForm.code = row.code
|
| 264 | + actionScopeType.value = type |
| 265 | + dialogScopeVisible.value = true |
261 | 266 | if (type === 'menu') {
|
262 | 267 | const menuRes = await listSimpleMenusApi()
|
263 | 268 | treeOptions.value = handleTree(menuRes)
|
264 | 269 | const role = await PermissionApi.listRoleMenusApi(row.id)
|
265 | 270 | if (role) {
|
266 |
| - // treeRef.value!.setCheckedKeys(role as unknown as Array<number>) |
267 |
| - defaultCheckedKeys.value = role |
| 271 | + role?.forEach((item: any) => { |
| 272 | + unref(treeRef)?.setChecked(item, true, false) |
| 273 | + }) |
268 | 274 | }
|
269 | 275 | } else if (type === 'data') {
|
270 | 276 | const deptRes = await listSimpleDeptApi()
|
271 | 277 | treeOptions.value = handleTree(deptRes)
|
272 | 278 | const role = await RoleApi.getRoleApi(row.id)
|
273 | 279 | dataScopeForm.dataScope = role.dataScope
|
274 | 280 | if (role.dataScopeDeptIds) {
|
275 |
| - // treeRef.value!.setCheckedKeys(role.dataScopeDeptIds as unknown as Array<number>, false) |
276 |
| - defaultCheckedKeys.value = role.dataScopeDeptIds |
| 281 | + role.dataScopeDeptIds?.forEach((item: any) => { |
| 282 | + unref(treeRef)?.setChecked(item, true, false) |
| 283 | + }) |
277 | 284 | }
|
278 | 285 | }
|
279 |
| - actionScopeType.value = type |
280 |
| - dialogScopeVisible.value = true |
281 | 286 | }
|
282 | 287 | // 保存权限
|
283 | 288 | const submitScope = async () => {
|
@@ -312,3 +317,10 @@ onMounted(() => {
|
312 | 317 | init()
|
313 | 318 | })
|
314 | 319 | </script>
|
| 320 | +<style scoped> |
| 321 | +.card { |
| 322 | + width: 100%; |
| 323 | + max-height: 400px; |
| 324 | + overflow-y: scroll; |
| 325 | +} |
| 326 | +</style> |
0 commit comments