|
@@ -18,7 +18,7 @@
|
|
|
import TreeHeader from './TreeHeader.vue';
|
|
|
import { ScrollContainer } from '/@/components/Container';
|
|
|
|
|
|
- import { omit, get } from 'lodash-es';
|
|
|
+ import { omit, get, cloneDeep, concat, uniq } from 'lodash-es';
|
|
|
import { isBoolean, isFunction } from '/@/utils/is';
|
|
|
import { extendSlots, getSlot } from '/@/utils/helper/tsxHelper';
|
|
|
import { filter } from '/@/utils/helper/treeHelper';
|
|
@@ -56,6 +56,25 @@
|
|
|
searchData: [] as TreeItem[],
|
|
|
});
|
|
|
|
|
|
+ const copyState = {
|
|
|
+ checkedKeys: [],
|
|
|
+ };
|
|
|
+
|
|
|
+ watch(
|
|
|
+ () => searchState.startSearch,
|
|
|
+ (newVal, oldVal) => {
|
|
|
+ if (newVal && !oldVal) {
|
|
|
+ // before search, save current checkedKeys
|
|
|
+ copyState.checkedKeys = cloneDeep(state.checkedKeys);
|
|
|
+ } else if (!newVal && oldVal) {
|
|
|
+ // after search, restore checkedKeys
|
|
|
+ state.checkedKeys = uniq(concat(state.checkedKeys, copyState.checkedKeys));
|
|
|
+ copyState.checkedKeys = [];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ { immediate: true }
|
|
|
+ );
|
|
|
+
|
|
|
const treeDataRef = ref<TreeItem[]>([]);
|
|
|
|
|
|
const [createContextMenu] = useContextMenu();
|