From 1172883260f5c7d04cdf6372a2071c1a0f285592 Mon Sep 17 00:00:00 2001 From: duan <1004387497@qq.com> Date: Wed, 10 Jul 2024 16:18:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BB=91=E5=AE=9A=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=A4=9A=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../invoicing/consumable/specifications.vue | 171 ++++++------------ 1 file changed, 56 insertions(+), 115 deletions(-) diff --git a/src/views/invoicing/consumable/specifications.vue b/src/views/invoicing/consumable/specifications.vue index bc0a78d..22c00ce 100644 --- a/src/views/invoicing/consumable/specifications.vue +++ b/src/views/invoicing/consumable/specifications.vue @@ -38,7 +38,6 @@
- @@ -84,53 +83,26 @@ - {{ addSelect.length ? addSelect[0].name : '' }} +
- + 取 消 @@ -261,33 +233,15 @@ export default { loading: false, total: 0 }, - ruleForm: { - conInfoId: "", - conInfoIdname: "", - productSkuId: "", - productSkuIdname: "", - shopId: localStorage.getItem('shopId'), - surplusStock: '', - status: false - }, rules: { - conNameS: [ - { required: true, message: '请输入耗材信息', trigger: 'blur' } - ], - name: [ - { required: true, message: '请选择商品规格', trigger: 'blur' } - ], - surplusStock: [ - { required: true, message: '请输入单位耗材值', trigger: 'blur' } - ], - status: [ - { required: true, message: '选择状态', trigger: 'blur' } - ] + }, - // 动态新增选择框 + // 动态新增选择框-所有数据 addSelect: [], + // 筛选集合 + commodityArr: [], // 选择耗材的index - ALLisDistribute: null + ALLisDistribute: null, } }, mounted() { @@ -311,14 +265,31 @@ export default { .match(/^\d*(\.?\d{0,2})/g)[0] || '' }, selectShop(res) { - // console.log(res, '调试1') + this.commodityArr = [] this.addSelect = res - res[0]['specSnap'] = res[0].name + console.log(res, 'tiaosjo') + res.forEach((ele, i) => { + // isDistribute1为共享库存-商品,0不共享是多规格 + // 判断是否共享拆分数据到商品和规格集合里 + if (ele.isDistribute == 1) { + ele.specSnap = ele.name + ele.conName = ele.conName + this.commodityArr.push(ele) + } else { + // 规格数据处理 + ele.skuList.forEach(element => { + element.conInfoId = element.id + element.conName = element.conName + this.commodityArr.push(element) + }) + } + }) this.clickdialogframe('add') + }, // 选择耗材 - selecthaocai(i) { - this.ALLisDistribute = i + selecthaocai(item) { + this.ALLisDistribute = item this.informationdialogshow = true }, //表格拖拽 @@ -420,27 +391,15 @@ export default { }, // 耗材信息的信息 tableDatainformationtable(item) { - - this.addSelect.forEach((ele, i) => { - ele.consInfoId = item.id - ele.conName = item.conName - if (this.ALLisDistribute != null) { - // this.addSelect.forEach((ele, i) => { - ele.skuList[this.ALLisDistribute].conInfoId = item.id - ele.skuList[this.ALLisDistribute].conName = item.conName - // }) - console.log(ele.skuList[this.ALLisDistribute], "打印"); + this.commodityArr.forEach(ele => { + if (ele.id == this.ALLisDistribute.id) { + ele.consInfoId = this.ALLisDistribute.id + ele.conName = item.conName + ele.skuId = ele.id } }) - // this.ruleForm.skuInfos = item - // this.ruleForm.conInfoId = item.id - // this.ruleForm.conInfoIdname = item.conName this.informationdialogshow = false }, - // tableDatatablesku(item) {///规格 - // this.ruleForm = item - // this.tableDataskudialogshow = false - // }, // 获取商品规格 async getTableDatasku() { this.tableDatasku.loading = true @@ -492,41 +451,23 @@ export default { }); this.informationdialogshowedit = false } else { - let { id, consInfoId, surplusStock, isDistribute } = this.addSelect[0] // isDistribute1为共享库存-商品,0不共享是多规格 - // 如果isDistribute为0 是多规格的时候 - if (isDistribute != 1) { - surplusStock = this.addSelect[0].skuList[0].surplusStock - } - let obj = { - productId: id, - consInfoId: consInfoId, - skuInfos: null, - surplusStock: surplusStock - } let isgongx = false - this.addSelect[0].skuList.forEach(ele => { - console.log(ele, "jiancha"); - ele.skuId = ele.id - // ele.surplusStock = surplusStock - if (isDistribute == 1) { - ele.surplusStock = surplusStock - ele.conInfoId = consInfoId - } + this.commodityArr.forEach(ele => { if (!ele.skuId || !ele.surplusStock) { isgongx = true - } else { - isgongx = false } }) if (isgongx) { this.$message.error('请选择耗材信息与输入耗材值') + isgongx = false return } - - obj.skuInfos = this.addSelect[0].skuList - - await posttbProskuCons(obj) + this.addSelect.forEach(ele => { + ele.skuInfos = ele.skuList + ele.productId = ele.id //商品id + }) + await posttbProskuCons(this.addSelect) this.$message({ message: '新增成功', type: 'success'