fix[Tree-Table]: fixed update item data bug (#1692)
This commit is contained in:
parent
8edf209498
commit
9574643e92
|
@ -146,6 +146,19 @@ export default {
|
||||||
this.selcetRecursion(child, select, children)
|
this.selcetRecursion(child, select, children)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
updateTreeNode(item) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
const { _id, _parent } = item
|
||||||
|
const index = _id.split('-').slice(-1)[0] // get last index
|
||||||
|
if (_parent) {
|
||||||
|
_parent.children.splice(index, 1, item)
|
||||||
|
resolve(this.data)
|
||||||
|
} else {
|
||||||
|
this.data.splice(index, 1, item)
|
||||||
|
resolve(this.data)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,17 +127,8 @@ export default {
|
||||||
this.tempItem = Object.assign({}, row)
|
this.tempItem = Object.assign({}, row)
|
||||||
this.dialogFormVisible = true
|
this.dialogFormVisible = true
|
||||||
},
|
},
|
||||||
updateItem() {
|
async updateItem() {
|
||||||
const data = this.$refs.TreeTable.getData()
|
await this.$refs.TreeTable.updateTreeNode(this.tempItem)
|
||||||
const { _id } = this.tempItem
|
|
||||||
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
|
||||||
if (data[i]._id === _id) {
|
|
||||||
data.splice(i, 1, Object.assign({}, this.tempItem))
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.dialogFormVisible = false
|
this.dialogFormVisible = false
|
||||||
},
|
},
|
||||||
addMenuItem(row, type) {
|
addMenuItem(row, type) {
|
||||||
|
|
Loading…
Reference in New Issue