Browse Source

fix(系统模块): 菜单保存优化

shizhongming 2 years ago
parent
commit
28813c0fc4
2 changed files with 11 additions and 1 deletions
  1. 10 1
      src/components/Tree/src/BasicTree.vue
  2. 1 0
      src/components/Tree/src/types/tree.ts

+ 10 - 1
src/components/Tree/src/BasicTree.vue

@@ -43,6 +43,9 @@
     setup(props, { attrs, slots, emit, expose }) {
       const [bem] = createBEM('tree');
 
+      const antInstanceRef = ref();
+      const getAntInstance = () => unref(antInstanceRef);
+
       const state = reactive<TreeState>({
         checkStrictly: props.checkStrictly,
         expandedKeys: props.expandedKeys || [],
@@ -337,6 +340,7 @@
         updateNodeByKey,
         getSelectedNode,
         checkAll,
+        getAntInstance,
         expandAll,
         filterByLevel: (level: number) => {
           state.expandedKeys = filterByLevel(level);
@@ -459,7 +463,12 @@
               tip="加载中..."
             >
               <ScrollContainer style={scrollStyle} v-show={!unref(getNotFound)}>
-                <Tree {...unref(getBindValues)} showIcon={false} treeData={treeData.value}>
+                <Tree
+                  {...unref(getBindValues)}
+                  showIcon={false}
+                  ref={antInstanceRef}
+                  treeData={treeData.value}
+                >
                   {extendSlots(slots, ['title'])}
                 </Tree>
               </ScrollContainer>

+ 1 - 0
src/components/Tree/src/types/tree.ts

@@ -192,4 +192,5 @@ export interface TreeActionType {
     treeList?: TreeItem[],
     selectNode?: TreeItem | null,
   ) => TreeItem | null;
+  getAntInstance: () => any;
 }