Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tree-table): 更新数据未触发 computed tableData 更新问题 #1692

Merged
merged 2 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/components/TreeTable/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ export default {
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)
}
})
}
}
}
Expand Down
13 changes: 2 additions & 11 deletions src/views/tree-table/custom/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,8 @@ export default {
this.tempItem = Object.assign({}, row)
this.dialogFormVisible = true
},
updateItem() {
const data = this.$refs.TreeTable.getData()
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
}
}

async updateItem() {
await this.$refs.TreeTable.updateTreeNode(this.tempItem)
this.dialogFormVisible = false
},
addMenuItem(row, type) {
Expand Down