Browse Source

bugfix:模板管理-新增

chrislee 1 year ago
parent
commit
44288ecfe9
1 changed files with 10 additions and 9 deletions
  1. 10 9
      src/views/modules/warehouse/template-add.vue

+ 10 - 9
src/views/modules/warehouse/template-add.vue

@@ -172,19 +172,18 @@
       // 添加物品
       // 添加物品
       addMaterial (item) {
       addMaterial (item) {
         if (item) {
         if (item) {
-          this.dataList.push({
+          // 判断列表中是否存在,存在则删除
+          this.removeItem(item.materialId)
+          // 添加记录
+          this.dataList.push({...item,
             count: 0,
             count: 0,
-            materialId: item.materialId,
-            materialName: item.materialName,
-            notes: item.notes,
-            orgId: this.$store.state.user.orgId,
-            unitName: item.unitName,
-            specifications: item.specifications
+            orgId: this.$store.state.user.orgId
           })
           })
         }
         }
       },
       },
       addItems (items) {
       addItems (items) {
-        this.dataList = []
+        // this.dataList = []
+        // console.log(JSON.stringify(items))
         items.forEach((item) => {
         items.forEach((item) => {
           this.addMaterial(item)
           this.addMaterial(item)
         })
         })
@@ -192,7 +191,9 @@
       // 删除物品
       // 删除物品
       removeItem (id) {
       removeItem (id) {
         let index = this.dataList.findIndex((item) => { return item.materialId === id })
         let index = this.dataList.findIndex((item) => { return item.materialId === id })
-        this.dataList.splice(index, 1)
+        if (index >= 0) {
+          this.dataList.splice(index, 1)
+        }
       }
       }
     }
     }
   }
   }