From 3fc26a50252e285bde9dbe5895bf7e2e1495f19e Mon Sep 17 00:00:00 2001 From: BoBoooooo <17746714@qq.com> Date: Thu, 18 Mar 2021 09:53:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AD=90=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E8=A1=8C=E6=95=B0=E6=8D=AE=E5=8F=96=E6=B6=88=E5=90=8E?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=BF=98=E5=8E=9F=E5=8E=9F=E5=A7=8B=E6=95=B0?= =?UTF-8?q?=E6=8D=AEbug=20@0.9.1-8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- .../src/components/SubForm/GenerateSubForm.vue | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b29cede..621e598 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "element-pro-crud", - "version": "0.9.1-7", + "version": "0.9.1-8", "author": "BoBo", "main": "lib/ProCrud.umd.min.js", "files": [ diff --git a/src/component/form-designer/src/components/SubForm/GenerateSubForm.vue b/src/component/form-designer/src/components/SubForm/GenerateSubForm.vue index affe05a..58ae32c 100644 --- a/src/component/form-designer/src/components/SubForm/GenerateSubForm.vue +++ b/src/component/form-designer/src/components/SubForm/GenerateSubForm.vue @@ -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; } // 编辑当前行数据 @@ -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) => { @@ -255,6 +258,7 @@ export default class GenerateSubForm extends Vue { message: msg, }); formValue._mode = 'DETAIL'; + row._mode = 'DETAIL'; this.mode = 'DETAIL'; this.fetchList(); })