Browse Source

能源费率删除问题

yuhan 1 year ago
parent
commit
a33748273e
1 changed files with 14 additions and 13 deletions
  1. 14 13
      src/views/module_base/energyRate/modules/EnergyRateForm.vue

+ 14 - 13
src/views/module_base/energyRate/modules/EnergyRateForm.vue

@@ -99,9 +99,9 @@
               <a-input v-model="record.endamount" placeholder="请输入结束量" ></a-input>
             </a-form-model-item>
         </template>
-        <template slot="operation" slot-scope="text, record">
+        <template slot="operation" slot-scope="text, record, index">
           <span>
-            <a-popconfirm title="是否要删除此行?" @confirm="remove(record)">
+            <a-popconfirm title="是否要删除此行?" @confirm="remove(record, index)">
                 <a>删除</a>
             </a-popconfirm>
           </span>
@@ -567,17 +567,18 @@
           console.log(this.model.data)
         }
       },
-      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
-        }
+      remove(record, index) {
+        this.model.data.splice(index, 1)
+        // 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