mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
fix: 修复问题
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
<script setup lang="tsx">
|
||||
import { onMounted, ref, useAttrs } from 'vue';
|
||||
import { onMounted, ref, useAttrs, watch } from 'vue';
|
||||
import type { TreeSelectInst, TreeSelectProps } from 'naive-ui';
|
||||
import { useBoolean } from '@sa/hooks';
|
||||
import { fetchGetDeptTree } from '@/service/api/system/user';
|
||||
@ -48,6 +48,16 @@ onMounted(() => {
|
||||
}
|
||||
});
|
||||
|
||||
watch([expandAll, options], ([newVal]) => {
|
||||
if (newVal) {
|
||||
// 展开所有节点
|
||||
expandedKeys.value = getAllDeptIds(options.value);
|
||||
} else {
|
||||
// 折叠到只显示根节点
|
||||
expandedKeys.value = [100];
|
||||
}
|
||||
});
|
||||
|
||||
function getAllDeptIds(depts: any[]) {
|
||||
const deptIds: CommonType.IdType[] = [];
|
||||
depts.forEach(item => {
|
||||
@ -114,7 +124,6 @@ defineExpose({
|
||||
:loading="loading"
|
||||
virtual-scroll
|
||||
:check-strategy="cascade ? 'child' : 'all'"
|
||||
:default-expand-all="expandAll"
|
||||
v-bind="attrs"
|
||||
/>
|
||||
</NSpin>
|
||||
|
@ -51,19 +51,14 @@ onMounted(() => {
|
||||
});
|
||||
|
||||
// 添加 watch 监听 expandAll 的变化,options有值后,计算expandedKeys
|
||||
watch(
|
||||
[expandAll, options],
|
||||
([newVal]) => {
|
||||
if (newVal) {
|
||||
// 展开所有节点
|
||||
expandedKeys.value = getAllMenuIds(options.value);
|
||||
} else {
|
||||
// 折叠到只显示根节点
|
||||
expandedKeys.value = [0];
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
watch([expandAll, options], ([newVal]) => {
|
||||
if (newVal) {
|
||||
// 展开所有节点
|
||||
expandedKeys.value = getAllMenuIds(options.value);
|
||||
} else {
|
||||
expandedKeys.value = [0];
|
||||
}
|
||||
});
|
||||
|
||||
function renderPrefix({ option }: { option: TreeOption }) {
|
||||
const renderLocalIcon = String(option.icon).startsWith('icon-');
|
||||
|
Reference in New Issue
Block a user