diff --git a/src/views/product/info/index.vue b/src/views/product/info/index.vue index ab3d04f..a864c42 100644 --- a/src/views/product/info/index.vue +++ b/src/views/product/info/index.vue @@ -96,8 +96,6 @@ 加载失败 - - @@ -117,7 +115,6 @@ - @@ -323,6 +320,8 @@ import ImageUpload from "@/components/ImageUpload" import {listBrand} from "@/api/product/brand" import { listRule } from "@/api/product/rule" import {listAll7 } from "@/api/product/type" +import data from "@/views/system/dict/data.vue"; +import item from "@/layout/components/Sidebar/Item.vue"; export default { @@ -486,6 +485,17 @@ export default { cartesian(ruleAttrJson, 0, {}); + this.tableBodyTemplate.forEach(item=>{ + let sku = []; + for (let itemKey in item) { + if(itemKey.indexOf("xxx") > -1){ + sku.push(item[itemKey]) + } + } + sku = sku.join(','); + item['sku'] = sku; + }) + this.tableColumnHeaderTemplate.push( {prop:'stock',label:'商品库存'}, {prop:'price',label:'商品价格'}, @@ -628,7 +638,30 @@ export default { this.reset(); const id = row.id || this.ids getInfo(id).then(response => { - this.form = response.data; + let typeList = []; + let data = response.data; + this.active = Number(data.step); + let ruleId = data.ruleId; + this.changeRuleInfoListByRuleId(ruleId); + if(data.skuInfoList !=null && data.skuInfoList.size > 0){ + data.skuInfoList.forEach(item => { + if (item.sku !== null) { + let skuArray = item.sku.split(','); + for (let i = 0; i < skuArray.length; i++) { + item[`xxx${i}`] = skuArray[i]; + } + } + }); + } + + this.tableBodyTemplate=data.skuInfoList; + + this.form = data; + let typeAttr = data.typeIds.split(",") + typeAttr.forEach(item => { + typeList.push(item * 1) + }); + this.form.type = typeList this.open = true; this.title = "修改商品信息"; }); @@ -637,6 +670,12 @@ export default { submitForm() { this.$refs["form"].validate(valid => { if (valid) { + let typeIds = this.form.type.join(','); + let type = this.form.type[this.form.type - 1]; + this.form.typeIds = typeIds; + this.form.type = type; + + this.form["skuInfoList"] = this.tableBodyTemplate; if (this.form.id != null) { this.updateInfoById(this.form) } else {