|
|
|
|
@ -1,14 +1,16 @@
|
|
|
|
|
<script setup lang="tsx">
|
|
|
|
|
import type { RadioChangeEvent } from 'ant-design-vue';
|
|
|
|
|
|
|
|
|
|
import type { MenuPermissionOption } from './data';
|
|
|
|
|
|
|
|
|
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
|
|
|
|
import type { MenuOption } from '#/api/system/menu/model';
|
|
|
|
|
|
|
|
|
|
import { nextTick, onMounted, ref, watch } from 'vue';
|
|
|
|
|
import { nextTick, onMounted, ref, shallowRef, watch } from 'vue';
|
|
|
|
|
|
|
|
|
|
import { cloneDeep, findGroupParentIds } from '@vben/utils';
|
|
|
|
|
|
|
|
|
|
import { Alert, Checkbox, RadioGroup, Space } from 'ant-design-vue';
|
|
|
|
|
import { Alert, Checkbox, message, RadioGroup, Space } from 'ant-design-vue';
|
|
|
|
|
import { uniq } from 'lodash-es';
|
|
|
|
|
|
|
|
|
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
|
|
|
@ -18,6 +20,7 @@ import {
|
|
|
|
|
menusWithPermissions,
|
|
|
|
|
rowAndChildrenChecked,
|
|
|
|
|
setPermissionsChecked,
|
|
|
|
|
setTableChecked,
|
|
|
|
|
} from './helper';
|
|
|
|
|
import { useFullScreenGuide } from './hook';
|
|
|
|
|
|
|
|
|
|
@ -227,10 +230,13 @@ onMounted(() => {
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 缓存上次(切换节点关系前)选中的keys
|
|
|
|
|
const lastCheckedKeys = shallowRef<(number | string)[]>([]);
|
|
|
|
|
/**
|
|
|
|
|
* 节点关联变动 事件
|
|
|
|
|
*/
|
|
|
|
|
async function handleAssociationChange() {
|
|
|
|
|
async function handleAssociationChange(e: RadioChangeEvent) {
|
|
|
|
|
lastCheckedKeys.value = getCheckedKeys();
|
|
|
|
|
// 清空全部permissions选中
|
|
|
|
|
const records = tableApi.grid.getData();
|
|
|
|
|
records.forEach((item) => {
|
|
|
|
|
@ -238,9 +244,19 @@ async function handleAssociationChange() {
|
|
|
|
|
});
|
|
|
|
|
// 需要清空全部勾选
|
|
|
|
|
await tableApi.grid.clearCheckboxRow();
|
|
|
|
|
updateCheckedNumber();
|
|
|
|
|
// 滚动到顶部
|
|
|
|
|
await tableApi.grid.scrollTo(0, 0);
|
|
|
|
|
|
|
|
|
|
// 从节点关联切换到节点独立
|
|
|
|
|
// 由于节点独立兼容节点关联 设置选中
|
|
|
|
|
// if (e.target.value) {
|
|
|
|
|
// setTableChecked(lastCheckedKeys.value, records, tableApi, false);
|
|
|
|
|
// } else {
|
|
|
|
|
// setTableChecked(lastCheckedKeys.value, records, tableApi, true);
|
|
|
|
|
// }
|
|
|
|
|
setTableChecked(lastCheckedKeys.value, records, tableApi, !e.target.value);
|
|
|
|
|
|
|
|
|
|
updateCheckedNumber();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -337,6 +353,11 @@ function getCheckedKeys() {
|
|
|
|
|
defineExpose({
|
|
|
|
|
getCheckedKeys,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
|
const keys = getCheckedKeys();
|
|
|
|
|
message.success(`keys:${keys.length}`);
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
@ -364,6 +385,7 @@ defineExpose({
|
|
|
|
|
</template>
|
|
|
|
|
<template #toolbar-tools>
|
|
|
|
|
<Space>
|
|
|
|
|
<a-button @click="test"> 测试 </a-button>
|
|
|
|
|
<a-button @click="setExpandOrCollapse(false)">
|
|
|
|
|
{{ $t('pages.common.collapse') }}
|
|
|
|
|
</a-button>
|
|
|
|
|
|