|
@@ -182,24 +182,23 @@ export default {
|
|
|
this.modalTitle = '详情'
|
|
|
const that = this
|
|
|
selectSpareInfoListByModelId({ id: record.id }).then(res => {
|
|
|
- getSpareStore({
|
|
|
- spareVOS: res.data.map(item => {
|
|
|
- return {
|
|
|
- oldOrNew: item.oldOrNew,
|
|
|
- beiJianCode: item.no
|
|
|
- }
|
|
|
- }),
|
|
|
- sbId: record.id
|
|
|
- }).then(response => {
|
|
|
- console.log(response)
|
|
|
- that.data = res.data.map(item => {
|
|
|
- console.log(item)
|
|
|
-
|
|
|
- item.inventory = response.data.find(spare => spare.no === item.no) ? response.data.find(spare => spare.no === item.no).num : null
|
|
|
- console.log(item)
|
|
|
- return item
|
|
|
- })
|
|
|
- })
|
|
|
+ // getSpareStore({
|
|
|
+ // spareVOS: res.data.map(item => {
|
|
|
+ // return {
|
|
|
+ // oldOrNew: item.oldOrNew,
|
|
|
+ // beiJianCode: item.no
|
|
|
+ // }
|
|
|
+ // }),
|
|
|
+ // sbId: record.id
|
|
|
+ // }).then(response => {
|
|
|
+ // console.log(response)
|
|
|
+ that.data = res.data
|
|
|
+ // .map(item => {
|
|
|
+ // item.inventory = response.data.find(spare => spare.no === item.no) ? response.data.find(spare => spare.no === item.no).num : null
|
|
|
+ // console.log(item)
|
|
|
+ // return item
|
|
|
+ // })
|
|
|
+ // })
|
|
|
})
|
|
|
},
|
|
|
handleOk () {
|
|
@@ -215,12 +214,8 @@ export default {
|
|
|
}),
|
|
|
sbId: this.model.id
|
|
|
}).then(response => {
|
|
|
- console.log(response)
|
|
|
that.data = res.data.map(item => {
|
|
|
- console.log(item)
|
|
|
-
|
|
|
item.inventory = response.data.find(spare => spare.no === item.no) ? response.data.find(spare => spare.no === item.no).num : null
|
|
|
- console.log(item)
|
|
|
return item
|
|
|
})
|
|
|
})
|
|
@@ -233,25 +228,23 @@ export default {
|
|
|
handleSpareSelect () {
|
|
|
this.$refs.spareSelectModal.base({}, { yt: 1 })
|
|
|
},
|
|
|
- handleSpareSelected (record, keys, rows) {
|
|
|
+ handleSpareSelected (record, keys, rows, oldOrNew) {
|
|
|
const addData = []
|
|
|
console.log(record, keys, rows)
|
|
|
const that = this
|
|
|
|
|
|
getSpareStore({
|
|
|
- spareVOS: rows.data.map(item => {
|
|
|
+ spareVOS: rows.map(item => {
|
|
|
return {
|
|
|
- oldOrNew: item.oldOrNew,
|
|
|
+ oldOrNew,
|
|
|
beiJianCode: item.no
|
|
|
}
|
|
|
}),
|
|
|
sbId: that.model.id
|
|
|
}).then(response => {
|
|
|
- console.log(response)
|
|
|
for (let i = 0; i < rows.length; i++) {
|
|
|
addData.push({ sbId: that.model.id, modelId: that.model.id, spareId: rows[i].id, spareName: rows[i].name, num: 1, period: 500, periodType: 6, inventory: response.data.find(spare => spare.no === rows[i].no) ? response.data.find(spare => spare.no === rows[i].no).num : null })
|
|
|
}
|
|
|
- console.log(addData)
|
|
|
addSbModelBomBatch(addData)
|
|
|
.then((response) => {
|
|
|
that.$message.info('批量添加成功')
|
|
@@ -264,19 +257,31 @@ export default {
|
|
|
handleSpareStoreSelect () {
|
|
|
this.$refs.spareStoreSelectModal.base()
|
|
|
},
|
|
|
- handleSpareStoreSelected (record, keys, rows) {
|
|
|
+ handleSpareStoreSelected (record, keys, rows, oldOrNew) {
|
|
|
const addData = []
|
|
|
- console.log(record, keys, rows)
|
|
|
- for (let i = 0; i < rows.length; i++) {
|
|
|
- addData.push({ spareId: rows[i].spareId, sbId: this.model.id, modelId: this.model.id, no: rows[i].no, spareName: rows[i].spareName, num: 1, ggxh: rows[i].ggxh })
|
|
|
- }
|
|
|
- addSbModelBomBatch(addData)
|
|
|
- .then((response) => {
|
|
|
- this.$message.info('批量添加成功')
|
|
|
- this.handleOk()
|
|
|
- }).catch(() => {
|
|
|
- this.confirmLoading = false
|
|
|
- })
|
|
|
+ const that = this
|
|
|
+
|
|
|
+ getSpareStore({
|
|
|
+ spareVOS: rows.map(item => {
|
|
|
+ return {
|
|
|
+ oldOrNew,
|
|
|
+ beiJianCode: item.no
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ sbId: that.model.id
|
|
|
+ }).then(response => {
|
|
|
+ console.log(oldOrNew)
|
|
|
+ for (let i = 0; i < rows.length; i++) {
|
|
|
+ addData.push({ spareId: rows[i].spareId, oldOrNew, sbId: this.model.id, modelId: this.model.id, no: rows[i].no, spareName: rows[i].spareName, num: 1, ggxh: rows[i].ggxh, inventory: response.data.find(spare => spare.no === rows[i].no) ? response.data.find(spare => spare.no === rows[i].no).num : null })
|
|
|
+ }
|
|
|
+ addSbModelBomBatch(addData)
|
|
|
+ .then((response) => {
|
|
|
+ this.$message.info('批量添加成功')
|
|
|
+ this.handleOk()
|
|
|
+ }).catch(() => {
|
|
|
+ this.confirmLoading = false
|
|
|
+ })
|
|
|
+ })
|
|
|
|
|
|
/* const { data } = this
|
|
|
for (let i = 0; i < rows.length; i++) {
|