This commit is contained in:
Pan 2019-03-12 13:20:46 +08:00
parent 056dd3687e
commit 312814d261
2 changed files with 13 additions and 21 deletions

View File

@ -147,16 +147,18 @@ export default {
}) })
} }
}, },
updateTreeArray(index, item) { updateTreeNode(item) {
const { _id } = item return new Promise(resolve => {
const data = this.data const { _id, _parent } = item
const index = _id.split('-').slice(-1)[0] // get last index
for (let i = 0; i < data.length; i++) { if (_parent) {
if (data[i]._id === _id) { _parent.children.splice(index, 1, item)
data.splice(i, 1, Object.assign({}, item)) resolve(this.data)
break } else {
this.data.splice(index, 1, item)
resolve(this.data)
} }
} })
} }
} }
} }

View File

@ -127,18 +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))
this.$refs.TreeTable.updateTreeArray(i, this.tempItem)
break
}
}
this.dialogFormVisible = false this.dialogFormVisible = false
}, },
addMenuItem(row, type) { addMenuItem(row, type) {