From 5ea8ca7e632c53accf7dfddb3a4a80d98064f379 Mon Sep 17 00:00:00 2001 From: lzhizhao <790086754@qq.com> Date: Mon, 11 Aug 2025 23:44:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A7=AF=E5=88=86=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=A2=9E=E5=88=A0=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/marketing/points-mall/index.vue | 68 +++++--- .../popup/points-product-config.vue | 156 +++++++++++++++--- .../points-mall/popup/product-selector.vue | 26 ++- 3 files changed, 205 insertions(+), 45 deletions(-) diff --git a/src/views/modules/marketing/points-mall/index.vue b/src/views/modules/marketing/points-mall/index.vue index 616dd81..f13439a 100644 --- a/src/views/modules/marketing/points-mall/index.vue +++ b/src/views/modules/marketing/points-mall/index.vue @@ -112,21 +112,37 @@ export default { : 2, marketId: this.marketId, shopId: this.shopId, - shopIdList: this.shopId ? [this.shopId] : [] + shopIdList: [] // 初始为空,等待storeList加载完成后设置 }; this.$nextTick(() => { this.$refs.oTable.reload(); }); }, + watch: { + // 监听storeList变化,设置默认选择所有店铺 + storeList: { + handler(newStoreList) { + if ( + newStoreList && + newStoreList.length > 0 && + this.formInline.shopIdList.length === 0 + ) { + // 默认选择所有店铺 + this.formInline.shopIdList = newStoreList.map(store => store.shopId); + } + }, + immediate: true // 立即执行一次 + } + }, methods: { queryList(pageNo, pageSize) { // 使用新的积分商品分页接口 const queryParams = { shopIdList: this.formInline.shopIdList || [], - productId: this.formInline.productId || 0, + productId: this.formInline.productId || "", productName: this.formInline.productName || "", - productSpecId: this.formInline.productSpecId || 0, - productSpecName: this.formInline.productSpecName || "", + // productSpecId: this.formInline.productSpecId || "", + // productSpecName: this.formInline.productSpecName || "", // 添加分页参数以备后续使用 pageNumber: pageNo, pageSize: pageSize @@ -136,7 +152,10 @@ export default { .membershipPointsProductPage(queryParams) .then(res => { console.log(res); - this.$refs.oTable.complete(res.data || [], Number(res.total || 0)); + this.$refs.oTable.complete( + res.data.data.data || [], + Number(res.data.data.total || 0) + ); }) .catch(err => { console.error("查询积分商品失败:", err); @@ -161,7 +180,7 @@ export default { : 2, marketId: this.marketId, shopId: this.shopId, - shopIdList: this.shopId ? [this.shopId] : [], + shopIdList: this.storeList.map(store => store.shopId), // 重置时也选择所有店铺 productId: "", productName: "", productSpecId: "", @@ -251,22 +270,27 @@ export default { width: "200px", render: ({ row }) => { let edit = () => { - this.$api.marketing - .PointsProductDetail({ - id: row.id - }) - .then(res => { - const productData = { - productId: row.productId, - productName: row.productName, - shopName: row.shopName - }; - this.$refs.pointsProductConfig.show( - productData, - res.data.data - ); - }) - .catch(err => {}); + // 直接使用列表数据,不调用详情接口 + const productData = { + productId: row.productId, + productName: row.productName, + shopName: row.shopName, + productSpecName: row.productSpecName + }; + + // 直接使用列表中的数据作为编辑数据 + const editData = { + id: row.id, + shopId: row.shopId, + productId: row.productId, + productSpecId: row.productSpecId, + exchangeRequiredPoints: row.exchangeRequiredPoints, + exchangeInventory: row.exchangeInventory, + exchangeRestrictions: row.exchangeRestrictions, + exchangeRestrictionsType: row.exchangeRestrictionsType + }; + + this.$refs.pointsProductConfig.show(productData, editData); }; let deleteProduct = () => { this.$api.marketing diff --git a/src/views/modules/marketing/points-mall/popup/points-product-config.vue b/src/views/modules/marketing/points-mall/popup/points-product-config.vue index 9a9648a..df46400 100644 --- a/src/views/modules/marketing/points-mall/popup/points-product-config.vue +++ b/src/views/modules/marketing/points-mall/popup/points-product-config.vue @@ -7,20 +7,44 @@ :close-on-click-modal="false" @close="handleClose" > - -
+ +
商品ID: - {{ productData.productId }} + {{ + isEdit ? editProductData.productId : productData.id + }}
商品名称: - {{ productData.productName }} + {{ + isEdit ? editProductData.productName : productData.name + }}
归属摊位: - {{ productData.shopName }} + {{ + isEdit ? editProductData.shopName : productData.shopId + }} +
+
+ 商品描述: + {{ productData.description }} +
+
+ 价格范围: + ¥{{ productData.minSalePrice }} - ¥{{ + productData.maxSalePrice + }} +
+
+ 商品规格: + {{ + editProductData.productSpecName || "默认规格" + }}
@@ -29,10 +53,37 @@ + + + + + {{ spec.attributeValue }} + ¥{{ spec.salePrice }} + + + +
1) { + rules.productSpecId = [ + { required: true, message: "请选择商品规格", trigger: "change" } + ]; + } + + return rules; + } + }, methods: { show(productData, editData = null) { this.visible = true; this.isEdit = !!editData; this.productData = productData; + // 设置商品规格列表 + this.productSpecificationList = + productData.productSpecificationList || []; + if (editData) { // 编辑模式,填充现有数据 + this.editProductData = { + productId: productData.productId, + productName: productData.productName, + shopName: productData.shopName, + productSpecName: productData.productSpecName + }; + this.configForm = { - id: editData.id || 0, - shopId: editData.shopId || 0, - productId: editData.productId || 0, - productSpecId: editData.productSpecId || 0, + id: editData.id || undefined, + shopId: editData.shopId || undefined, + productId: editData.productId || undefined, + productSpecId: editData.productSpecId || undefined, exchangeRequiredPoints: editData.exchangeRequiredPoints || 1, exchangeInventory: editData.exchangeInventory || 10, exchangeRestrictions: editData.exchangeRestrictions || 0, @@ -167,11 +259,16 @@ export default { }; } else { // 新增模式,使用默认值 + const defaultSpecId = + this.productSpecificationList.length === 1 + ? this.productSpecificationList[0].id + : undefined; + this.configForm = { - id: 0, - shopId: productData.shopId || 0, - productId: productData.productId || 0, - productSpecId: productData.productSpecId || 0, + id: undefined, + shopId: productData.shopId || undefined, + productId: productData.id || undefined, + productSpecId: defaultSpecId, exchangeRequiredPoints: 1, exchangeInventory: 10, exchangeRestrictions: 0, @@ -185,11 +282,13 @@ export default { }, resetForm() { this.productData = {}; + this.editProductData = {}; + this.productSpecificationList = []; this.configForm = { - id: 0, - shopId: 0, - productId: 0, - productSpecId: 0, + id: undefined, + shopId: undefined, + productId: undefined, + productSpecId: undefined, exchangeRequiredPoints: 1, exchangeInventory: 10, exchangeRestrictions: 0, @@ -206,6 +305,7 @@ export default { const submitData = { ...this.configForm }; + console.log(submitData); // 根据是否编辑模式调用不同的API const apiCall = this.isEdit @@ -250,6 +350,18 @@ export default { }, increaseLimitQuantity() { this.configForm.exchangeRestrictions++; + }, + // 处理规格选择变化 + handleSpecChange(specId) { + const selectedSpec = this.productSpecificationList.find( + spec => spec.id === specId + ); + if (selectedSpec) { + // 可以根据选中的规格自动设置一些默认值 + console.log("选中的规格:", selectedSpec); + // 例如:根据规格的库存设置默认兑换库存 + // this.configForm.exchangeInventory = Math.min(selectedSpec.stockNum, 10); + } } } }; diff --git a/src/views/modules/marketing/points-mall/popup/product-selector.vue b/src/views/modules/marketing/points-mall/popup/product-selector.vue index fe6346e..4a58375 100644 --- a/src/views/modules/marketing/points-mall/popup/product-selector.vue +++ b/src/views/modules/marketing/points-mall/popup/product-selector.vue @@ -9,7 +9,7 @@
- + + + +