| | |
| | | @refresh-change="refreshChange" |
| | | @on-load="onLoad" |
| | | @tree-load="treeLoad" |
| | | @row-del="rowDel" |
| | | @row-save="rowSave" |
| | | @row-update="rowUpdate" |
| | | @row-click="rowClick" |
| | | > |
| | | <template #menu-left> |
| | |
| | | } |
| | | ); |
| | | }, |
| | | 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; |
| | |
| | | }).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; |
| | | } |
| | | ); |
| | | }) |
| | |
| | | }).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) => { |