From 948f7242451bc6cbc1506b031b701556eefb96c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E5=90=8C=E5=AD=A6?= <2495967527@qq.com> Date: Fri, 16 Aug 2024 18:00:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/product/popup/add-attribute.vue | 31 ++++++-- .../modules/product/popup/add-discount.vue | 2 +- .../modules/product/popup/add-or-update.vue | 77 ++++++++++++++++--- .../product/popup/add-specifications.vue | 54 +++++++++---- 4 files changed, 131 insertions(+), 33 deletions(-) diff --git a/src/views/modules/product/popup/add-attribute.vue b/src/views/modules/product/popup/add-attribute.vue index 837752a..712ed8a 100644 --- a/src/views/modules/product/popup/add-attribute.vue +++ b/src/views/modules/product/popup/add-attribute.vue @@ -111,15 +111,34 @@ export default { this.init(cloneDeep(e.row)); } return { - add: () => { + add: (data) => { this.modalConfig.title = "添加属性"; - this.$nextTick(() => { - this.modalData = {}; - this.$refs.ruleForm.resetFields(); - }); + if (data.length == 0) { + this.ruleForm = { + name: "", + value: [], + }; + } else { + this.ruleForm = { + name: data[0].name, + value: data[0].value.split(","), + }; + } this.isAdd = true; }, - update: () => { + update: (data) => { + console.log(data); + if (data.length == 0) { + this.ruleForm = { + name: "", + value: [], + }; + } else { + this.ruleForm = { + name: data[0].name, + value: data[0].value.split(","), + }; + } this.isAdd = false; }, }; diff --git a/src/views/modules/product/popup/add-discount.vue b/src/views/modules/product/popup/add-discount.vue index e270d20..50836bd 100644 --- a/src/views/modules/product/popup/add-discount.vue +++ b/src/views/modules/product/popup/add-discount.vue @@ -204,7 +204,7 @@ export default { .catch(() => { this.$message({ type: "info", - message: "已取消删除", + message: "已取消", }); }); }, diff --git a/src/views/modules/product/popup/add-or-update.vue b/src/views/modules/product/popup/add-or-update.vue index 4722c58..a79fb6b 100644 --- a/src/views/modules/product/popup/add-or-update.vue +++ b/src/views/modules/product/popup/add-or-update.vue @@ -64,7 +64,7 @@ export default { //单库存 singleStock: "", //其他属性 - otherAttribute: '[{"name":"颜色","value":"黄色;屎黄色"}]', + otherAttribute: [], //[{"name":"颜色","value":"黄色;屎黄色"}] //折扣情况 discountActivity: { // "endTime": "2024-08-31 00:00:00", @@ -146,6 +146,8 @@ export default { fullscreen: true, }, fileList: [], //回显图片 + fileListOne: [], //介绍图 + fileListTwo: [], //视频 place: "", //场地 passCheck: [], //通行证 }; @@ -178,7 +180,7 @@ export default { description: "", merchantId: "", name: "", - otherAttribute: "", + otherAttribute: [], productAttributeList: [], productCategoryId: "", productIntroducePhoto: "", @@ -220,20 +222,67 @@ export default { url: item.url, }; }); + if (row.productIntroducePhoto) { + this.fileListOne = [ + { + name: "", + url: row.productIntroducePhoto, + }, + ]; + } else { + this.fileListOne = []; + } + if (row.productVideo) { + this.fileListTwo = [ + { + name: "", + url: row.productVideo, + }, + ]; + } else { + this.fileListTwo = []; + } this.place = row.productPlace.split("-"); this.modalData = row; + this.$set(this.modalData, "singleStock", row.stockNum); + if (row.minSalePrice == row.maxSalePrice) { + this.$set(this.modalData, "singlePrice", row.maxSalePrice); + } else { + this.$set( + this.modalData, + "singlePrice", + row.minSalePrice + "~" + row.maxSalePrice + ); + } + if (!row.productAttributeList) { + this.$set(this.modalData, "productAttributeList", []); + } + if (row.otherAttribute) { + this.modalData.otherAttribute = JSON.parse(row.otherAttribute); + } else { + this.modalData.otherAttribute = []; + } }, addSpecs() { console.log("123"); if (this.isAdd) { - this.$refs.addSpecifications.toggle().add(); - } else { this.$refs.addSpecifications .toggle() - .update( + .add( this.modalData.productAttributeList, this.modalData.productSpecificationList ); + } else { + if (this.modalData.productAttributeList.length == 0) { + this.$refs.addSpecifications.toggle().update([], []); + } else { + this.$refs.addSpecifications + .toggle() + .update( + this.modalData.productAttributeList, + this.modalData.productSpecificationList + ); + } } }, //获取属性 @@ -250,7 +299,11 @@ export default { this.$set(this.modalData, "singleStock", stockNum); }, addAttribute() { - this.$refs.addAttribute.toggle().add(); + if (this.isAdd) { + this.$refs.addAttribute.toggle().add(this.modalData.otherAttribute); + } else { + this.$refs.addAttribute.toggle().update(this.modalData.otherAttribute); + } }, getAttribute(data) { console.log(data); @@ -488,9 +541,7 @@ export default { render: () => { return ( 0 - } + readonly={this.modalData.productAttributeList.length > 0} placeholder="请输入价格" v-model={this.modalData.singlePrice} > @@ -504,9 +555,7 @@ export default { render: () => { return ( 0 - } + readonly={this.modalData.productAttributeList.length > 0} placeholder="请输入库存" v-model={this.modalData.singleStock} > @@ -603,6 +652,8 @@ export default { drag action={this.$api.mer_admin.uploadFile()} limit={1} + file-list={this.fileListOne} + list-type="picture" {...{ props: { "on-change": handleChange, @@ -652,6 +703,8 @@ export default { drag action={this.$api.mer_admin.uploadFile()} limit={1} + file-list={this.fileListTwo} + list-type="picture" {...{ props: { "on-change": handleChange, diff --git a/src/views/modules/product/popup/add-specifications.vue b/src/views/modules/product/popup/add-specifications.vue index 7e7df04..c0dda21 100644 --- a/src/views/modules/product/popup/add-specifications.vue +++ b/src/views/modules/product/popup/add-specifications.vue @@ -133,24 +133,50 @@ export default { this.init(cloneDeep(e.row)); } return { - add: () => { - this.modalConfig.title = "属性"; - this.$nextTick(() => { - // this.$refs.modal.resetFields(); - this.modalData = {}; - }); + add: (productAttributeList, productSpecificationList) => { + this.modalConfig.title = "添加属性"; + if (productAttributeList.length == 0) { + this.AttributeData = [ + { + attributeName: "", + attributeValue: [], + inputVisible: false, + }, + ]; + } else { + this.AttributeData = productAttributeList.map((item) => { + return { + attributeName: item.attributeName, + attributeValue: item.attributeValue.split(","), + id: item.id, + inputVisible: false, + }; + }); + } + this.tableData = productSpecificationList; this.isAdd = true; }, update: (productAttributeList, productSpecificationList) => { + this.modalConfig.title = "编辑属性"; console.log(productAttributeList, productSpecificationList); - this.AttributeData = productAttributeList.map((item) => { - return { - attributeName: item.attributeName, - attributeValue: item.attributeValue.split(","), - id: item.id, - inputVisible: false, - }; - }); + if (productAttributeList.length == 0) { + this.AttributeData = [ + { + attributeName: "", + attributeValue: [], + inputVisible: false, + }, + ]; + } else { + this.AttributeData = productAttributeList.map((item) => { + return { + attributeName: item.attributeName, + attributeValue: item.attributeValue.split(","), + id: item.id, + inputVisible: false, + }; + }); + } this.tableData = productSpecificationList; this.isAdd = false; },