|
@@ -172,19 +172,18 @@
|
|
|
// 添加物品
|
|
|
addMaterial (item) {
|
|
|
if (item) {
|
|
|
- this.dataList.push({
|
|
|
+ // 判断列表中是否存在,存在则删除
|
|
|
+ this.removeItem(item.materialId)
|
|
|
+ // 添加记录
|
|
|
+ this.dataList.push({...item,
|
|
|
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) {
|
|
|
- this.dataList = []
|
|
|
+ // this.dataList = []
|
|
|
+ // console.log(JSON.stringify(items))
|
|
|
items.forEach((item) => {
|
|
|
this.addMaterial(item)
|
|
|
})
|
|
@@ -192,7 +191,9 @@
|
|
|
// 删除物品
|
|
|
removeItem (id) {
|
|
|
let index = this.dataList.findIndex((item) => { return item.materialId === id })
|
|
|
- this.dataList.splice(index, 1)
|
|
|
+ if (index >= 0) {
|
|
|
+ this.dataList.splice(index, 1)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|