From 250886c8409599b19967eec294fcd6b032aa376e Mon Sep 17 00:00:00 2001 From: fanfan Date: Mon, 9 Sep 2024 18:11:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E9=80=89=E6=8B=A9=20=20?= =?UTF-8?q?=E5=8E=BB=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/model/goods/MultiSpec.js | 2 +- .../Modal/GoodsModal/GoodsModal.vue | 12 +- src/views/dataCenter/goods/Index.vue | 69 +++++---- .../dataCenter/goods/modules/MultiSpec.vue | 140 +++++++++++------- 4 files changed, 140 insertions(+), 83 deletions(-) diff --git a/src/common/model/goods/MultiSpec.js b/src/common/model/goods/MultiSpec.js index 753ca64..237234a 100644 --- a/src/common/model/goods/MultiSpec.js +++ b/src/common/model/goods/MultiSpec.js @@ -230,7 +230,7 @@ export default class MultiSpec { oldSkuItem = oldSkuList.find( (item) => newSkuList[index].tempId === - (item.goods_props && item.goods_props.length > 0) ? item.goods_props.map((v) => v.value.name).join('_') : item.tempId + ((item.goods_props && item.goods_props.length > 0) ? item.goods_props.map((v) => v.value.name).join('_') : item.tempId) ) // } diff --git a/src/components/Modal/GoodsModal/GoodsModal.vue b/src/components/Modal/GoodsModal/GoodsModal.vue index 9841ed7..356ca33 100644 --- a/src/components/Modal/GoodsModal/GoodsModal.vue +++ b/src/components/Modal/GoodsModal/GoodsModal.vue @@ -52,6 +52,11 @@ :subTitleColor="true" /> + +

+ {{ text == 10 ? '单规格' : '多规格' }} +

+
{{ text }} @@ -82,10 +87,9 @@ const columns = [ scopedSlots: { customRender: 'item' }, }, { - title: '规格值', - dataIndex: 'specific_value', - width: '100px', - scopedSlots: { customRender: 'specific_value' }, + title: '规格类型', + dataIndex: 'spec_type', + scopedSlots: { customRender: 'spec_type' }, }, { title: '商品价格', diff --git a/src/views/dataCenter/goods/Index.vue b/src/views/dataCenter/goods/Index.vue index 20077e0..3b453d5 100644 --- a/src/views/dataCenter/goods/Index.vue +++ b/src/views/dataCenter/goods/Index.vue @@ -113,12 +113,12 @@ - - - {{ item.name }} - - - + + + {{ item.name }} + + +
-
+
加价利润率: - +
分类加价 批量加价 @@ -339,6 +345,11 @@

{{ text > 0 ? Number(text) + '%' : 0 }}

+ +

+ {{ text == 10 ? '单规格' : '多规格' }} +

+

- -

- {{ text == 1 ? '是' : '否' }} -

-
+ +

+ {{ text == 1 ? '是' : '否' }} +

+
{{ @@ -404,6 +415,12 @@ const columns = [ width: '300px', scopedSlots: { customRender: 'goods_name' }, }, + { + title: '规格类型', + width: '90px', + dataIndex: 'spec_type', + scopedSlots: { customRender: 'spec_type' }, + }, { title: '行情价', width: '100px', @@ -466,11 +483,11 @@ const columns = [ scopedSlots: { customRender: 'is_pool' }, }, { - title: '比同款下架', - width: '100px', - dataIndex: 'is_jd_remove', - scopedSlots: { customRender: 'is_jd_remove' }, - }, + title: '比同款下架', + width: '100px', + dataIndex: 'is_jd_remove', + scopedSlots: { customRender: 'is_jd_remove' }, + }, { title: '状态', width: '50px', @@ -524,7 +541,7 @@ export default { end_time: '', is_has_banner: '', is_has_detail: '', - is_jd_remove:'' + is_jd_remove: '', }, // 正在加载 isLoading: false, @@ -560,7 +577,7 @@ export default { saleVisible: false, priceVisible: false, jingPinVisible: false, - batchPrice:false, + batchPrice: false, specsType: [ { name: '全部', val: '' }, { name: '单规格', val: 10 }, @@ -595,7 +612,7 @@ export default { categoryIds: [], categoryPriceIds: [], rate: '', - batchRate:'', + batchRate: '', pickerOptions: { disabledDate(time) { return time.getTime() > Date.now() @@ -856,8 +873,8 @@ export default { }) }, getGoodsJingDong(val) { - this.queryParam.is_jd_remove = val - }, + this.queryParam.is_jd_remove = val + }, getChannel(val) { this.queryParam.channel = val }, @@ -1072,7 +1089,7 @@ export default { '&is_self=' + this.queryParam.is_self + '&is_jd_remove=' + - (this.queryParam.is_jd_remove || '') + + (this.queryParam.is_jd_remove || '') + '&goodsIds=' + goodsIds + '&Access-Token=' + diff --git a/src/views/dataCenter/goods/modules/MultiSpec.vue b/src/views/dataCenter/goods/modules/MultiSpec.vue index b20b16c..7bcea40 100644 --- a/src/views/dataCenter/goods/modules/MultiSpec.vue +++ b/src/views/dataCenter/goods/modules/MultiSpec.vue @@ -14,12 +14,8 @@ placeholder="请输入规格名称" @change="onChangeSpecGroupIpt" /> - 删除规格组删除规格组
@@ -50,7 +46,7 @@ class="spec-group-add-btn" icon="plus" @click="handleAddSpecGroup" - >添加规格组添加规格组 @@ -95,13 +91,26 @@ bordered > + + - - - @@ -124,12 +133,14 @@ {{ item.goods_sku_no }} - @@ -142,11 +153,12 @@ import MultiSpecModel from '@/common/model/goods/MultiSpec' import { SelectImage } from '@/components' import SelectGoods from '@/components/SelectGoods/SelectGoods.vue' import * as GoodsApi from '@/api/goods' - +import { GoodsItem } from '@/components/Table/table' export default { components: { SelectImage, - SelectGoods + SelectGoods, + GoodsItem }, props: { // 默认的规格列表 @@ -156,10 +168,10 @@ export default { // 商品规格是否锁定(锁定状态下不允许编辑规格) isSpecLocked: PropTypes.bool.def(false), checkList: PropTypes.array.def([]), - channel:PropTypes.any, + channel: PropTypes.any, source: PropTypes.any.def(0), }, - data () { + data() { return { // 标签布局属性 labelCol: { span: 3 }, @@ -172,93 +184,114 @@ export default { // 规格列表 specList: [], // SKU列表 - skuList: [] + skuList: [], }, - visible: false + visible: false, } }, watch: { - defaultSpecList (val) { + defaultSpecList(val) { if (val.length && this.MultiSpecModel.isEmpty()) { this.getData() } - } + }, }, // 初始化数据 - created () { + created() { // 获取规格及SKU信息 this.getData() }, methods: { + handleEdit(item) { + const routeData = this.$router.resolve({ + path: '/goods/update', + query: { + goodsId: item.goods_id, + }, + }) + window.open(routeData.href, '_blank') + }, + handleCancel(index) { + this.multiSpecData.skuList[index].cost_price = '' + this.multiSpecData.skuList[index].goods_id = '' + this.multiSpecData.skuList[index].goods_image = '' + this.multiSpecData.skuList[index].goods_name = '' + this.multiSpecData.skuList[index].goods_price = '' + this.multiSpecData.skuList[index].goods_price_min = '' + this.multiSpecData.skuList[index].goods_sku_no = '' + this.multiSpecData.skuList[index].goods_weight = '' + this.multiSpecData.skuList[index].line_price = '' + this.multiSpecData.skuList[index].stock_num = '' + }, // 获取规格及SKU信息(展示) - getData () { + getData() { const { defaultSpecList, defaultSkuList } = this this.multiSpecData = this.MultiSpecModel.getData(defaultSpecList, defaultSkuList) }, // 获取规格及SKU信息(表单提交) - getFromSpecData () { + getFromSpecData() { return this.MultiSpecModel.getFromSpecData() }, // 添加规格组 - handleAddSpecGroup () { + handleAddSpecGroup() { if (this.checkSkuMaxNum()) { this.MultiSpecModel.handleAddSpecGroup() } }, // 删除规格组 - handleDeleteSpecGroup (groupIndex) { + handleDeleteSpecGroup(groupIndex) { const app = this const modal = this.$confirm({ title: '您确定要删除该规格组吗?', content: '删除后不可恢复', - onOk () { + onOk() { // 删除元素 app.MultiSpecModel.handleDeleteSpecGroup(groupIndex) // 关闭对话框 modal.destroy() - } + }, }) }, // 新增规格值 - handleAddSpecValue (groupIndex) { + handleAddSpecValue(groupIndex) { if (this.checkSkuMaxNum()) { this.MultiSpecModel.handleAddSpecValue(groupIndex) } }, // 删除规格值 - handleDeleteSpecValue (groupIndex, valueIndex) { + handleDeleteSpecValue(groupIndex, valueIndex) { const app = this const modal = this.$confirm({ title: '您确定要删除该规格值吗?', content: '删除后不可恢复', - onOk () { + onOk() { // 删除元素 app.MultiSpecModel.handleDeleteSpecValue(groupIndex, valueIndex) // 关闭对话框 modal.destroy() - } + }, }) }, // 规格组输入框change事件 - onChangeSpecGroupIpt () { + onChangeSpecGroupIpt() { // 更新skuList this.MultiSpecModel.onUpdate(true) }, // 规格值输入框change事件 - onChangeSpecValueIpt (event, itm) { + onChangeSpecValueIpt(event, itm) { // 更新skuList this.MultiSpecModel.onUpdate(true) }, // 验证最大sku数量 - checkSkuMaxNum () { + checkSkuMaxNum() { const skuList = this.multiSpecData.skuList if (skuList.length >= 50) { this.$message.error(`生成的sku列表数量不能大于50个,当前数量:${skuList.length}个`, 2.5) @@ -268,31 +301,31 @@ export default { }, // 批量设置sku事件 - handleSkuBatch () { + handleSkuBatch() { this.MultiSpecModel.handleSkuBatch() }, // 验证多规格表单 - verifyForm () { + verifyForm() { if (!this.MultiSpecModel.verifyForm()) { this.$message.error(this.MultiSpecModel.getError(), 2) return false } return true }, - showModal () { + showModal() { this.visible = true }, - async handleSelectGoods (goodsId, item) { + async handleSelectGoods(goodsId, item) { const skuList = this.multiSpecData.skuList - const skuItem = skuList.find(sku => sku.goods_id === goodsId) + const skuItem = skuList.find((sku) => sku.goods_id === goodsId) if (skuItem) { this.$message.error('一个商品只能选择一次', 2) return false } - this.getGoodsDetail(goodsId).then(res => { + this.getGoodsDetail(goodsId).then((res) => { const queryGoodsId = this.$route.query.goodsId if (res.spec_type === 20 && queryGoodsId !== goodsId) { this.$message.error('您选择的商品是多规格商品', 2) @@ -300,27 +333,30 @@ export default { } const sku = res.skuList[0] + console.log(res) item.goods_price = sku.goods_price item.cost_price = sku.cost_price item.stock_num = sku.stock_num item.goods_weight = sku.goods_weight item.goods_sku_no = sku.goods_sku_no - // item.goods_name = res.goods_name + item.goods_name = res.goods_name item.goods_id = res.goods_id + item.goods_image = res.goods_image + item.goods_price_min = res.goods_price_min }) + console.log(item) }, // 获取商品详情 - getGoodsDetail (goodsId = null) { + getGoodsDetail(goodsId = null) { if (!goodsId) return false return new Promise((resolve, reject) => { - GoodsApi.detail({ goodsId }) - .then(result => { - resolve(result.data.goodsInfo) - }) + GoodsApi.detail({ goodsId }).then((result) => { + resolve(result.data.goodsInfo) + }) }) - } - } + }, + }, }