diff --git a/src/views/product/components/bindCons.vue b/src/views/product/components/bindCons.vue index 0df6bfb..aca9035 100644 --- a/src/views/product/components/bindCons.vue +++ b/src/views/product/components/bindCons.vue @@ -16,7 +16,8 @@
商品名:{{ goodsDetail.name }}
- + + @@ -54,6 +55,91 @@ + + + + + + + + + + + + + + + + + + + + 取 消 确 定 @@ -98,8 +184,33 @@ export default { // this.$message.error('请完善信息') // return // } + + let res = null this.formLoading = true - const res = await tbProskuConV2(this.tableData) + if (this.type == 1) { + res = await tbProskuConV2(this.tableData) + } else if (this.type == 2) { + let data = { ...this.tableData } + + let arr = [] + + data.cons.map(item => { + item.consList.map(val => { + if (val.name) { + let obj = { ...item } + obj.id = val.id + obj.name = val.name + obj.productSkuId = item.productSkuId + obj.conInfoId = val.conInfoId + obj.surplusStock = val.surplusStock + arr.push(obj) + } + }) + }) + + data.cons = arr + res = await tbProskuConV2(data) + } this.formLoading = false this.$message.success('编辑成功') this.dialogVisible = false @@ -109,12 +220,18 @@ export default { this.formLoading = false } }, - // 选择耗材 + // 商品选择耗材 selectionChange(e, row) { let item = this.options.find(item => item.consId == e) row.name = item.conName row.conUnit = item.conUnit }, + // 规格选择耗材 + skuSelectionChange(e, row) { + let item = this.options.find(item => item.consId == e) + row.name = item.conName + row.conUnit = item.conUnit + }, // 远程搜索耗材 remoteMethod(query) { if (query !== '') { @@ -202,9 +319,6 @@ export default { } } else { // 添加至规格 - if (this.goodsDetail.conInfos.length) { - this.tableData.cons = [...this.goodsDetail.conInfos] - } this.goodsDetail.skuList.map(val => { let item = {} @@ -219,8 +333,35 @@ export default { item.status = 1 item.specSnap = val.name + item.consList = [ + { + surplusStock: 0, + conInfoId: '', + name: '', + conUnit: '' + } + ] + this.tableData.cons.push(item) }) + + + + if (this.goodsDetail.conInfos.length) { + this.tableData.cons.map(val => { + this.goodsDetail.conInfos.map(item => { + if (item.productSkuId == val.productSkuId) { + val.consList.unshift({ + id: item.id, + surplusStock: item.surplusStock, + conInfoId: item.conInfoId, + name: item.conName, + conUnit: item.conUnit + }) + } + }) + }) + } } }, // 生成新关系项 @@ -253,10 +394,27 @@ export default { item.surplusStock = 0 item.status = 1 item.specSnap = val.specSnap + item.consList = [ + { + conInfoId: '', + name: '', + conUnit: '', + surplusStock: 0 + } + ] this.tableData.cons.push(item) } }, + // 规格生成新关系项 + skuCreateItem($index) { + this.tableData.cons[$index].consList.push({ + conInfoId: '', + name: '', + conUnit: '', + surplusStock: 0 + }) + }, reset() { this.goodsDetail = '' this.tableData.productId = '' @@ -321,4 +479,29 @@ export default { } } } + +.cons_list_wrap { + .row { + display: flex; + padding: 10px 0; + align-items: center; + gap: 10px; + + .item { + flex: 1; + display: flex; + align-items: center; + } + } +} + +.sku_table_item { + padding: 10px 0; + + .t { + height: 32px; + display: flex; + align-items: center; + } +} \ No newline at end of file