|
55 | 55 | ref="multipleTableRef" |
56 | 56 | class="mt-16" |
57 | 57 | :data="filteredData" |
58 | | - @selection-change="handleSelectionChange" |
| 58 | + @select="select" |
59 | 59 | :maxTableHeight="260" |
60 | 60 | :row-key="(row: any) => row.id" |
61 | 61 | style="min-width: 600px" |
@@ -147,6 +147,7 @@ import { hasPermission } from '@/utils/permission/index' |
147 | 147 | import { ComplexPermission } from '@/utils/permission/type' |
148 | 148 | import { getPermissionOptions } from '@/views/system/resource-authorization/constant' |
149 | 149 | import useStore from '@/stores' |
| 150 | +import { TreeToFlatten } from '@/utils/array' |
150 | 151 |
|
151 | 152 | const { model, user } = useStore() |
152 | 153 | const route = useRoute() |
@@ -310,11 +311,33 @@ const filteredData = computed(() => { |
310 | 311 | }) |
311 | 312 |
|
312 | 313 | const multipleSelection = ref<any[]>([]) |
| 314 | +const selectObj: any = {} |
| 315 | +const select = (val: any[], active: any) => { |
| 316 | + if (active.resource_type === 'folder') { |
| 317 | + if (!val.some((item) => item.id == active.id)) { |
| 318 | + if (selectObj[active.id] === undefined) { |
| 319 | + selectObj[active.id] = 0 |
| 320 | + } |
| 321 | + if (selectObj[active.id] % 2 == 0) { |
| 322 | + console.log(TreeToFlatten([active])) |
| 323 | + TreeToFlatten([active]) |
| 324 | + .filter((item: any) => item.id != active.id) |
| 325 | + .forEach((item: any) => { |
| 326 | + multipleTableRef.value?.toggleRowSelection(item, true) |
| 327 | + }) |
313 | 328 |
|
314 | | -const handleSelectionChange = (val: any[]) => { |
315 | | - multipleSelection.value = val |
| 329 | + multipleSelection.value = multipleTableRef.value.getSelectionRows() |
| 330 | + } else { |
| 331 | + multipleSelection.value = val |
| 332 | + } |
| 333 | + selectObj[active.id] = selectObj[active.id] + 1 |
| 334 | + } else { |
| 335 | + multipleSelection.value = val |
| 336 | + } |
| 337 | + } else { |
| 338 | + multipleSelection.value = val |
| 339 | + } |
316 | 340 | } |
317 | | -
|
318 | 341 | const dialogVisible = ref(false) |
319 | 342 | const radioPermission = ref('') |
320 | 343 | function openMulConfigureDialog() { |
|
0 commit comments