From 088beed4e94e50030c50124b31b935da877ea3aa Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Wed, 22 Nov 2023 18:59:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF,=20=E4=BF=9D=E5=AD=98=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/product/addGood/specGood.vue | 83 ++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 9 deletions(-) diff --git a/pages/product/addGood/specGood.vue b/pages/product/addGood/specGood.vue index 06ded00..a5a355f 100644 --- a/pages/product/addGood/specGood.vue +++ b/pages/product/addGood/specGood.vue @@ -9,7 +9,7 @@ - 添加模板 + 添加模板 点击设置规格 @@ -38,17 +38,22 @@ 添加新规格 - 保存模板 + 保存模板 - {{addAttrType==1?'添加规格值': '添加新规格'}} + + 添加规格值 + 添加新规格 + 添加模板 + - - + + + 确认 @@ -110,7 +115,8 @@ import { Toast } from "../../../libs/uniApi"; import { specificationUpdate, - attrList + attrList, + specificationAdd } from "@/api/product.js" export default { components: { @@ -140,9 +146,10 @@ deleteIndex: '', //删除图片下标 showDelete: false, userInfo: {}, - addAttrType: 1, // 规格类型, 1为添加规格值, 2为添加新规格 + addAttrType: 1, // 规格类型, 1为添加规格值, 2为添加新规格, 3为添加新模板, 4为保存模板 attrName: '', // 规格名称 attrDetail: '', // 规格值 + attrMode: '', //新增模板名称 changeAttr: 0, // 选中的规格 } }, @@ -294,7 +301,7 @@ this.addAttrValueCard(); }) } - } else { // 1级 + } else if (this.addAttrType == 2) { // 1级 if (this.attr.find(item => item.value == this.attrName)) { this.closeAddAttr(); this.$nextTick(() => { @@ -323,11 +330,69 @@ } this.closeAddAttr(); } + } else if (this.addAttrType == 3 || this.addAttrType == 4){ + this.addNewAttrMode(); } }, // 保存模板 saveAttrMode() { - + if(this.attr.length<=0)return Toast('不可保存空模板'); + if(this.attr_template_id){ + this.addAttrType = 4; + let template = this.attr_mode_list.find(e=>e.attr_template_id==this.attr_template_id); + specificationUpdate(this.userInfo.service.mer_id, this.attr_template_id, { + attr_template_id: template.attr_template_id, + mer_id: template.attr_template_id, + template_name: template.template_name, + template_value: this.attr + }).then((res)=>{ + this.$refs.modeRef.close(); + this.$nextTick(()=>{ + Toast('保存成功'); + }) + }).catch(err=>{ + Toast(err) + }) + }else { + this.preAddMode(4) + } + }, + // 添加新模板 + addNewAttrMode(){ + this.attrMode = this.attrMode.trim(' '); + if(this.attrMode==''||this.attrMode===undefined||this.attrMode===null){ + return Toast('模板名称不可为空') + } + let attr = []; + if(this.addAttrType==3){ + attr[0] = {}; + attr[0].value = this.attrName; + attr[0].detail = []; + attr[0].detail[0] = this.attrDetail; + }else attr = this.attr; + specificationAdd(this.userInfo.service.mer_id, { + template_name: this.attrMode, + template_value: attr + }).then((res)=>{ + this.initAttrModeList(); + this.closeAddAttr(); + this.$nextTick(()=>{ + this.$refs.modeRef.close(); + this.$nextTick(()=>{ + Toast('保存成功'); + }) + }) + }).catch(err=>{ + Toast(err) + }) + }, + // 预添加模板 + preAddMode(type=3){ + this.attrName = ''; + this.attrDetail = ''; + this.attrMode = ''; + this.addAttrType = type; + this.$refs.inputModeRef.open(); }, // 提交数据 submitAttr() {