Browse Source

产品分类-编辑后刷新问题

jingbb 3 tháng trước cách đây
mục cha
commit
024fe806a7

+ 0 - 5
src/views/BasicData/productCassification1.vue

@@ -162,13 +162,8 @@
    * 成功回调
    */
   async function handleSuccess({ isUpdate, values }) {
-    if (isUpdate) {
-      await updateTableDataRecord(values.id, values);
-      emit('success')
-    } else {
       await reload();
       emit('success')
-    }
   }
   /**
    * 批量删除事件

+ 5 - 16
src/views/BasicData/productCassificationTree.vue

@@ -35,7 +35,7 @@
   // 部门树列表数据
   let treeData = ref<any[]>([]);
   // 当前展开的项
-  let expandedKeys = ref<any[]>([]);
+  let expandedKeys = ref([]);
   // 当前选中的项
   let selectedKeys = ref<any[]>([]);
   // 是否自动展开父级
@@ -50,14 +50,12 @@
   // 加载信息
   async function loadDepartTreeData() {
     loading.value = true;
-    treeData.value = [];
-    listTree({pageSize:-1})
+    await listTree({pageSize:-1})
       .then((res) => {
           if (Array.isArray(res)) {
             treeData.value[0] = {id:'0',name:'基本分类(Basic Classification)',children:[]};
             treeData.value[0].children = res;
-            expandedKeys.value=['0']
-            // autoExpandParentNode();
+            autoExpandParentNode();
           }
       })
       .finally(() => (loading.value = false));
@@ -67,17 +65,8 @@
 
   // 自动展开父节点,只展开一级
   function autoExpandParentNode() {
-    expandedKeys.value=['0']
-    // let keys: Array<any> = [];
-    // treeData.value.forEach((item, index) => {
-    //   if (item.children && item.children.length > 0) {
-    //     keys.push(item.id);
-    //   }
-    // });
-    // if (keys.length > 0) {
-    //   reloadTree();
-    //   expandedKeys.value = keys;
-    // }
+      reloadTree();
+      expandedKeys.value = ['0']
   }
 
   // 重新加载树组件,防止无法默认展开数据