From c24b09d95ae2e813dfdcea61151ca44a95d9d618 Mon Sep 17 00:00:00 2001 From: rouchen <3133657697@qq.com> Date: Sat, 23 Mar 2024 08:33:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=A7=84=E6=A0=BC=E5=9B=9E?= =?UTF-8?q?=E6=98=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/product/info/index.vue | 79 +++++++++++++++++++++++++++----- 1 file changed, 67 insertions(+), 12 deletions(-) diff --git a/src/views/product/info/index.vue b/src/views/product/info/index.vue index 4ece47c..fcc91d8 100644 --- a/src/views/product/info/index.vue +++ b/src/views/product/info/index.vue @@ -335,14 +335,15 @@ @@ -410,7 +411,14 @@ export default { brandId: null, }, // 表单参数 - form: {}, + form: { + mianType: '', + parentType: '', + type:'', + image: '', + price: '', + stock: '' + }, // 表单校验 rules: { name: [ @@ -495,7 +503,6 @@ export default { }, "form.type": { handler(value) { - console.log(value) if (value != null){ getTemplateAttribute(value).then(response => { const {data} = response; @@ -515,6 +522,7 @@ export default { methods: { oneSetting(){ this.skuList.forEach(skuInfo => { + console.log(skuInfo) skuInfo.image = this.oneSettingForm.image; skuInfo.stock = this.oneSettingForm.stock; skuInfo.price = this.oneSettingForm.price; @@ -523,7 +531,11 @@ export default { changeRule(ruleId){ this.titleList = [] let ruleInfo = this.ruleList.find(ruleInfo => ruleInfo.id === ruleId); + const {ruleAttrList} = ruleInfo; + + console.log(ruleInfo) + console.log(ruleAttrList) let skuTotal = 1; for (let ruleAttrListKey in ruleAttrList) { let ruleAttrInfo = ruleAttrList[ruleAttrListKey]; @@ -534,7 +546,6 @@ export default { skuTotal = skuTotal * ruleAttrInfo.valueList.length; } this.titleList.push(...this.templateTitleList) ; - console.log(this.titleList); this.skuList = []; for (let i = 0; i < skuTotal; i++) { this.skuList.push( @@ -573,9 +584,9 @@ export default { if (response.code === 200){ // 添加逻辑 let attributeId = response.data, - code = this.customAttributeForm.code, - name = this.customAttributeForm.name, - value = this.customAttributeForm.value; + code = this.customAttributeForm.code, + name = this.customAttributeForm.name, + value = this.customAttributeForm.value; // categoryCommonElement / attributeIdCheckedList / attributeCheckedList this.categoryCommonElement.attributeList.push({ "id": attributeId, @@ -626,7 +637,6 @@ export default { listCategory().then(response => { this.categoryOptions = []; this.categoryOptions = this.handleTree(response.data, "id", "parentId"); - console.log(this.categoryOptions) }); }, remoteSearchBrandList(queryValue){ @@ -640,7 +650,7 @@ export default { next() { let isValidate = true; this.$refs["form"].validateField(this.rulesTemplateMap[this.stepNumber],(valid) => { - console.log(valid) + if (valid) { isValidate = false; } @@ -713,24 +723,69 @@ export default { handleUpdate(row) { this.reset(); const id = row.id || this.ids + getInfo(id).then(response => { + + console.log(response) this.form = response.data; + + this.initCategoryTree() + this.form.mianType=parseInt(response.data.mianType) + this.form.type=parseInt(response.data.type) + + this.oneSettingForm = response.data.productSkuModel + this.changeRule(response.data.ruleId) + this.oneSetting() this.open = true; this.title = "修改商品信息"; + }); }, /** 提交按钮 */ submitForm() { this.$refs["form"].validate(valid => { if (valid) { + let attrValueList = []; + for (const templateAttributeGroup of this.categoryCommonElement.templateAttributeGroupList) { + templateAttributeGroup.attributeList.map(attribute => attrValueList.push({id: attribute.id, value: attribute.value})) + } + + this.categoryCommonElement.templateAttributeList.map(attribute => attrValueList.push({id: attribute.id, value: attribute.value})) + this.attributeCheckedList.map(attribute => attrValueList.push({id: attribute.id, value: attribute.value})) + let ruleInfo = this.ruleList.find(ruleInfo => ruleInfo.id === this.form.ruleId); + const {ruleAttrList} = ruleInfo; + let ruleAttrSize = ruleAttrList.length; + let productSkuList = this.skuList.map(skuInfo => { + let sku = ""; + for (let index = 0; ; index++) { + sku += skuInfo["prop"+index]; + if (index+1 >= ruleAttrSize){ + break; + }else { + sku += "-"; + } + } + return { + sku: sku, + image: skuInfo.image, + stock: skuInfo.stock, + price: skuInfo.price + } + }) + let productAddReq = { + projectAddModel: this.form, + attrValueList: attrValueList, + productSkuList: productSkuList + }; + console.log(productAddReq) if (this.form.id != null) { - updateInfo(this.form).then(response => { + updateInfo(productAddReq).then(response => { this.$modal.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { - addInfo(this.form).then(response => { + addInfo(productAddReq).then(response => { this.$modal.msgSuccess("新增成功"); this.open = false; this.getList();