Skip to content

Commit

Permalink
fix: 修复子表单行数据取消后无法还原原始数据bug @0.9.1-8
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Mar 18, 2021
1 parent d1c38a7 commit 3fc26a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "element-pro-crud",
"version": "0.9.1-7",
"version": "0.9.1-8",
"author": "BoBo<[email protected]>",
"main": "lib/ProCrud.umd.min.js",
"files": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,13 @@ export default class GenerateSubForm extends Vue {
if (row._mode === 'ADD') {
this.subTableForm.tableData.splice(index, 1);
}
// 取消后需要还原编辑前的数据
Object.keys(this.initialData).forEach((k) => {
row[k] = this.initialData[k];
});
row._mode = 'DETAIL';
this.mode = 'DETAIL';
// 取消后需要还原编辑前的数据
this.inlineFormData = this.initialData;
this.inlineFormData = row;
}

// 编辑当前行数据
Expand All @@ -205,11 +208,11 @@ export default class GenerateSubForm extends Vue {
row._mode = 'EDIT';
this.mode = 'EDIT';
this.inlineFormData = row;
this.initialData = row;
this.initialData = JSON.parse(JSON.stringify(row));
}

// 保存按钮点击
handleSaveOnClick() {
handleSaveOnClick(row) {
this.btnSaveIsLoading = true;
// 调用此方法验证表单数据和获取表单数据
this.$refs.tableForm.validate((valid) => {
Expand Down Expand Up @@ -255,6 +258,7 @@ export default class GenerateSubForm extends Vue {
message: msg,
});
formValue._mode = 'DETAIL';
row._mode = 'DETAIL';
this.mode = 'DETAIL';
this.fetchList();
})
Expand Down

0 comments on commit 3fc26a5

Please sign in to comment.