wyh преди 1 година
родител
ревизия
4e6502f5f0
променени са 1 файла, в които са добавени 15 реда и са изтрити 5 реда
  1. 15 5
      src/views/module_base/energyRate/modules/EnergyRateForm.vue

+ 15 - 5
src/views/module_base/energyRate/modules/EnergyRateForm.vue

@@ -101,7 +101,7 @@
         </template>
         <template slot="operation" slot-scope="text, record">
           <span>
-            <a-popconfirm title="是否要删除此行?" @confirm="remove(record.key)">
+            <a-popconfirm title="是否要删除此行?" @confirm="remove(record)">
                 <a>删除</a>
             </a-popconfirm>
           </span>
@@ -567,10 +567,20 @@
           console.log(this.model.data)
         }
       },
-      remove(key) {
-        console.log(key)
-        const newData = this.model.data.filter(item => item.key !== key)
-        this.model.data = newData
+      remove(record) {
+        if (record.id) {
+          const key = record.id
+          const newData = this.model.data.filter(item => item.id !== key)
+          this.model.data = newData
+          console.log(this.model.data)
+        } else {
+          const key = record.key
+          const newData = this.model.data.filter(item => item.key !== key)
+          this.model.data = newData
+        }
+        // console.log(key)
+        // const newData = this.model.data.filter(item => item.key !== key)
+        // this.model.data = newData
       },
       submitForm () {
         const that = this;