1
李喆(开发组)
2025-07-10 c8df3f7110ecb3d26078c8499cd8364b4419cd06
1
已修改1个文件
50 ■■■■■ 文件已修改
src/views/wel/index.vue 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/wel/index.vue
@@ -13,9 +13,6 @@
      @refresh-change="refreshChange"
      @on-load="onLoad"
      @tree-load="treeLoad"
      @row-del="rowDel"
      @row-save="rowSave"
      @row-update="rowUpdate"
      @row-click="rowClick"
    >
      <template #menu-left>
@@ -455,15 +452,6 @@
        }
      );
    },
    rowDel(row, index, done) {
      done(row);
    },
    rowSave (row, done) {
      done(row);
    },
    rowUpdate (row, index, done) {
      done(row);
    },
    showEdit(row,done) {
      this.modalTitle = "修改";
      this.modalBox = true;
@@ -484,7 +472,9 @@
        }).then(
          res => {
            this.loading = false;
            this.$refs.crud.rowDel(row);
            var nodeArr = this.$refs.crud.$refs.table.store.states.lazyTreeNodeMap.value[row.parentId];
            var arr = nodeArr.filter(item => item.id !== row.id);
            this.$refs.crud.$refs.table.store.states.lazyTreeNodeMap.value[row.parentId] = arr;
          }
        );
      })
@@ -552,42 +542,10 @@
      }).then(
        res => {
          var children = res.data.data || [];
          this.updateParentNodeChildren(parentId, children);
          this.$refs.crud.$refs.table.store.states.lazyTreeNodeMap.value[parentId] = [...children];
          this.loading = false;
        }
      );
    },
    updateParentNodeChildren(parentId, newChildren) {  //新增的方法
      const updateTree = (nodes) => {
        for (let i = 0; i < nodes.length; i++) {
          if (nodes[i].id === parentId) {
            // 更新节点数据
            nodes[i].children = [...newChildren];
            this.data = [...this.data]; // 替换顶层引用
            return true;
          }
          if (Array.isArray(nodes[i].children) && nodes[i].children.length > 0) {
            if (updateTree(nodes[i].children)) {
              return true;
            }
          }
        }
        return false;
      };
      updateTree(this.data);
      // this.upData = JSON.parse(JSON.stringify(this.data));
      // this.data = [];
      // 强制刷新
      this.$nextTick(() => {
        this.$refs.crud?.refreshTable();
        // this.data = this.upData;
        // this.option.defaultExpandAll = true;
      });
      // setTimeout(()=> {
      //   this.data = this.upData;
      //   this.option.defaultExpandAll = true;
      //   console.log(this.data,222)
      // },3000)
    },
    updateLocalTreeNode(nodeData) {   //修改的方法
      const updateNode = (nodes) => {