Эх сурвалжийг харах

Fix the bug of the advanced form editing

ShenXD 5 жил өмнө
parent
commit
9d7c9b5ba1

+ 3 - 1
src/views/form/advancedForm/AdvancedForm.vue

@@ -206,6 +206,7 @@ export default {
     },
     },
     toggle (key) {
     toggle (key) {
       const target = this.data.find(item => item.key === key)
       const target = this.data.find(item => item.key === key)
+      target._originalData = { ...target }
       target.editable = !target.editable
       target.editable = !target.editable
     },
     },
     getRowByKey (key, newData) {
     getRowByKey (key, newData) {
@@ -214,7 +215,8 @@ export default {
     },
     },
     cancel (key) {
     cancel (key) {
       const target = this.data.find(item => item.key === key)
       const target = this.data.find(item => item.key === key)
-      target.editable = false
+      Object.keys(target).forEach(key => { target[key] = target._originalData[key] })
+      target._originalData = undefined
     },
     },
     handleChange (value, key, column) {
     handleChange (value, key, column) {
       const newData = [...this.data]
       const newData = [...this.data]