Compare commits

..

No commits in common. "a171d541a34c8054b5d4a007c53198cac9e76836" and "aff42b126db75276c1ed6e9e5dc61547d550c0f1" have entirely different histories.

5 changed files with 260 additions and 229 deletions

View File

@ -215,15 +215,6 @@ export const marketing = {
}); });
}, },
// 积分商品启用状态切换
reverseEnableMemberUnitPointsProduct: data => {
return $http.request({
url: `/merchant-api/memberUnitPointsProduct/reverseEnable`,
method: "post",
data
});
},
// 修改积分商品 // 修改积分商品
updateMembershipPointsProduct: data => { updateMembershipPointsProduct: data => {
return $http.request({ return $http.request({

View File

@ -51,10 +51,6 @@ export const mer_admin = {
data data
); );
}, },
//商品规格分页
getProductSpecificationPage: data => {
return $http.post(`/merchant-api/product/specification/page`, data);
},
//商品概况 //商品概况
getProductOverview: data => { getProductOverview: data => {
return $http.post(`/merchant-api/product/overview`, data); return $http.post(`/merchant-api/product/overview`, data);

View File

@ -172,21 +172,6 @@ export default {
: []; : [];
this.$refs.productSelector.show(shopIdList); this.$refs.productSelector.show(shopIdList);
}, },
handleEnableChange(row) {
//
this.$api.marketing
.reverseEnableMemberUnitPointsProduct({ id: row.id })
.then(() => {
this.$message.success("状态切换成功");
this.$refs.oTable.reload();
})
.catch(err => {
console.error("状态切换失败:", err);
this.$message.error("状态切换失败");
//
row.enable = !row.enable;
});
},
reset() { reset() {
this.formInline = { this.formInline = {
unitType: unitType:
@ -235,35 +220,14 @@ export default {
field: "shopName" field: "shopName"
}, },
{ {
title: "商品原价", title: "兑换所需积分",
align: "center", align: "center",
field: "marketPrice", field: "exchangeRequiredPoints"
type: "jsx",
render: ({ row }) => {
return <span>¥{row.marketPrice}</span>;
}
}, },
{ {
title: "原有商品状态", title: "兑换库存",
align: "center", align: "center",
field: "productStatus", field: "exchangeInventory"
type: "jsx",
render: ({ row }) => {
return <span>{row.productStatus === "UP" ? "上架" : "下架"}</span>;
}
},
{
title: "积分使用模式",
align: "center",
field: "exchangePointsType",
type: "jsx",
render: ({ row }) => {
return (
<span>
{row.exchangePointsType === 1 ? "积分换购" : "积分优惠购"}
</span>
);
}
}, },
{ {
title: "剩余库存", title: "剩余库存",
@ -271,19 +235,33 @@ export default {
field: "surplusInventory" field: "surplusInventory"
}, },
{ {
title: "启用状态", title: "已兑换数量",
align: "center", align: "center",
field: "enable", field: "totalExchangeQuantity"
},
{
title: "兑换限制",
align: "center",
field: "exchangeRestrictions"
},
{
title: "限制类型",
align: "center",
field: "exchangeRestrictionsType",
type: "jsx", type: "jsx",
render: ({ row }) => { render: ({ row }) => {
return ( return (
<el-switch <span>
v-model={row.enable} {row.exchangeRestrictionsType === 1 ? "每日" : "永久"}
onChange={() => this.handleEnableChange(row)} </span>
></el-switch>
); );
} }
}, },
{
title: "创建时间",
align: "center",
field: "createTime"
},
{ {
title: "操作", title: "操作",
fixed: "right", fixed: "right",
@ -297,11 +275,7 @@ export default {
productId: row.productId, productId: row.productId,
productName: row.productName, productName: row.productName,
shopName: row.shopName, shopName: row.shopName,
productSpecName: row.productSpecName, productSpecName: row.productSpecName
productSpecId: row.productSpecId,
attributeValue: row.productSpecName,
marketPrice: row.marketPrice,
surplusInventory: row.surplusInventory
}; };
// 使 // 使
@ -310,8 +284,6 @@ export default {
shopId: row.shopId, shopId: row.shopId,
productId: row.productId, productId: row.productId,
productSpecId: row.productSpecId, productSpecId: row.productSpecId,
attributeValue: row.productSpecName,
marketPrice: row.marketPrice,
exchangeRequiredPoints: row.exchangeRequiredPoints, exchangeRequiredPoints: row.exchangeRequiredPoints,
exchangeInventory: row.exchangeInventory, exchangeInventory: row.exchangeInventory,
exchangeRestrictions: row.exchangeRestrictions, exchangeRestrictions: row.exchangeRestrictions,

View File

@ -12,31 +12,39 @@
<div class="product-info"> <div class="product-info">
<div class="info-item"> <div class="info-item">
<span class="label">商品ID</span> <span class="label">商品ID</span>
<span class="value">{{ productData.productId }}</span> <span class="value">{{
isEdit ? editProductData.productId : productData.id
}}</span>
</div> </div>
<div class="info-item"> <div class="info-item">
<span class="label">商品名称</span> <span class="label">商品名称</span>
<span class="value">{{ productData.productName }}</span> <span class="value">{{
isEdit ? editProductData.productName : productData.name
}}</span>
</div> </div>
<div class="info-item"> <div class="info-item">
<span class="label">归属摊位</span> <span class="label">归属摊位</span>
<span class="value">{{ productData.shopName }}</span> <span class="value">{{
isEdit ? editProductData.shopName : productData.shopId
}}</span>
</div> </div>
<div class="info-item"> <div class="info-item" v-if="!isEdit && productData.description">
<span class="label">规格名称</span> <span class="label">商品描述</span>
<span class="value">{{ productData.attributeValue }}</span> <span class="value">{{ productData.description }}</span>
</div> </div>
<div class="info-item"> <div class="info-item" v-if="!isEdit">
<span class="label">SKU-ID</span> <span class="label">价格范围</span>
<span class="value">{{ productData.productSpecId }}</span> <span class="value"
</div> >¥{{ productData.minSalePrice }} - ¥{{
<div class="info-item"> productData.maxSalePrice
<span class="label">商品原价</span> }}</span
<span class="value">¥{{ productData.marketPrice }}</span> >
</div> </div>
<div class="info-item" v-if="isEdit"> <div class="info-item" v-if="isEdit">
<span class="label">当前剩余库存</span> <span class="label">商品规格</span>
<span class="value">{{ productData.surplusInventory }}</span> <span class="value">{{
editProductData.productSpecName || "默认规格"
}}</span>
</div> </div>
</div> </div>
</div> </div>
@ -45,24 +53,65 @@
<el-form <el-form
ref="configForm" ref="configForm"
:model="configForm" :model="configForm"
:rules="configRules" :rules="dynamicRules"
label-width="140px" label-width="140px"
style="margin-top: 20px" style="margin-top: 20px"
> >
<!-- 商品规格选择 -->
<el-form-item <el-form-item
:label="isEdit ? '添加库存(负数代表减少库存)' : '库存设置'" label="商品规格"
prop="exchangeInventory" prop="productSpecId"
required required
v-if="!isEdit && productSpecificationList.length > 0"
> >
<el-select
v-model="configForm.productSpecId"
placeholder="请选择商品规格"
style="width: 100%"
@change="handleSpecChange"
>
<el-option
v-for="spec in productSpecificationList"
:key="spec.id"
:label="`${spec.attributeValue} - ¥${spec.salePrice}`"
:value="spec.id"
>
<span style="float: left">{{ spec.attributeValue }}</span>
<span style="float: right; color: #8492a6; font-size: 13px"
>¥{{ spec.salePrice }}</span
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="兑换所需积分" prop="exchangeRequiredPoints" required>
<div class="points-input">
<el-button
@click="decreasePoints"
:disabled="configForm.exchangeRequiredPoints <= 1"
>-</el-button
>
<el-input-number
v-model="configForm.exchangeRequiredPoints"
:min="1"
:max="99999"
controls-position="right"
style="width: 200px; margin: 0 10px"
></el-input-number>
<el-button @click="increasePoints">+</el-button>
</div>
</el-form-item>
<el-form-item label="兑换库存" prop="exchangeInventory" required>
<div class="inventory-input"> <div class="inventory-input">
<el-button <el-button
@click="decreaseInventory" @click="decreaseInventory"
:disabled="!isEdit && configForm.exchangeInventory <= 1" :disabled="configForm.exchangeInventory <= 1"
>-</el-button >-</el-button
> >
<el-input-number <el-input-number
v-model="configForm.exchangeInventory" v-model="configForm.exchangeInventory"
:min="isEdit ? -99999 : 1" :min="1"
:max="99999" :max="99999"
controls-position="right" controls-position="right"
style="width: 200px; margin: 0 10px" style="width: 200px; margin: 0 10px"
@ -71,70 +120,37 @@
</div> </div>
</el-form-item> </el-form-item>
<el-form-item label="积分类型" prop="exchangePointsType" required> <el-form-item label="兑换限制" prop="exchangeRestrictions" required>
<el-radio-group v-model="configForm.exchangePointsType"> <div class="limit-input">
<el-radio :label="2">积分优惠购</el-radio>
<el-radio :label="1">积分换购</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
v-if="configForm.exchangePointsType === 1"
label="兑换所需积分设置"
prop="exchangeRequiredPoints"
required
>
<div class="points-input">
<el-button <el-button
@click="decreasePoints" @click="decreaseLimitQuantity"
:disabled="configForm.exchangeRequiredPoints <= 1" :disabled="configForm.exchangeRestrictions <= 0"
>-</el-button >-</el-button
> >
<el-input-number <el-input-number
v-model="configForm.exchangeRequiredPoints" v-model="configForm.exchangeRestrictions"
:min="1" :min="0"
:max="99999" :max="99999"
controls-position="right" controls-position="right"
style="width: 200px; margin: 0 10px" style="width: 200px; margin: 0 10px"
></el-input-number> ></el-input-number>
<el-button @click="increasePoints">+</el-button> <el-button @click="increaseLimitQuantity">+</el-button>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if="configForm.exchangePointsType === 2" label="兑换限制类型"
label="优惠购所需积分" prop="exchangeRestrictionsType"
prop="exchangeRequiredPoints"
required required
> >
<div class="points-input"> <el-select
<el-button v-model="configForm.exchangeRestrictionsType"
@click="decreasePoints" placeholder="请选择限制类型"
:disabled="configForm.exchangeRequiredPoints <= 1"
>-</el-button
>
<el-input-number
v-model="configForm.exchangeRequiredPoints"
:min="1"
:max="99999"
controls-position="right"
style="width: 200px; margin: 0 10px"
></el-input-number>
<el-button @click="increasePoints">+</el-button>
</div>
</el-form-item>
<el-form-item
v-if="configForm.exchangePointsType === 2"
label="优惠购商品价格"
prop="exchangeRequiredAmount"
required
>
<el-input
v-model="configForm.exchangeRequiredAmount"
placeholder="请输入优惠购价格"
style="width: 200px" style="width: 200px"
></el-input> >
<el-option label="每日" :value="1"></el-option>
<el-option label="永久" :value="2"></el-option>
</el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -156,6 +172,8 @@ export default {
isEdit: false, isEdit: false,
submitting: false, submitting: false,
productData: {}, productData: {},
editProductData: {}, //
productSpecificationList: [],
configForm: { configForm: {
id: undefined, id: undefined,
shopId: undefined, shopId: undefined,
@ -163,66 +181,98 @@ export default {
productSpecId: undefined, productSpecId: undefined,
exchangeRequiredPoints: 1, exchangeRequiredPoints: 1,
exchangeInventory: 10, exchangeInventory: 10,
exchangePointsType: 1, // 1: , 2: exchangeRestrictions: 0,
exchangeRequiredAmount: "" exchangeRestrictionsType: 1
}, },
configRules: { configRules: {
exchangeRequiredPoints: [ exchangeRequiredPoints: [
{ required: true, message: "请设置所需积分", trigger: "blur" } { required: true, message: "请设置兑换所需积分", trigger: "blur" }
], ],
exchangeInventory: [ exchangeInventory: [
{ required: true, message: "请设置库存", trigger: "blur" } { required: true, message: "请设置兑换库存", trigger: "blur" }
], ],
exchangePointsType: [ exchangeRestrictions: [
{ required: true, message: "请选择积分类型", trigger: "change" } { required: true, message: "请设置兑换限制", trigger: "blur" }
], ],
exchangeRequiredAmount: [ exchangeRestrictionsType: [
{ { required: true, message: "请选择兑换限制类型", trigger: "change" }
required: true,
message: "请输入优惠购价格",
trigger: "blur",
validator: (rule, value, callback) => {
if (this.configForm.exchangePointsType === 2 && !value) {
callback(new Error("请输入优惠购价格"));
} else {
callback();
}
}
}
] ]
} }
}; };
}, },
computed: {
//
dynamicRules() {
const rules = {
exchangeRequiredPoints: [
{ required: true, message: "请设置兑换所需积分", trigger: "blur" }
],
exchangeInventory: [
{ required: true, message: "请设置兑换库存", trigger: "blur" }
],
exchangeRestrictions: [
{ required: true, message: "请设置兑换限制", trigger: "blur" }
],
exchangeRestrictionsType: [
{ required: true, message: "请选择兑换限制类型", trigger: "change" }
]
};
//
if (!this.isEdit && this.productSpecificationList.length > 1) {
rules.productSpecId = [
{ required: true, message: "请选择商品规格", trigger: "change" }
];
}
return rules;
}
},
methods: { methods: {
show(productData, editData = null, exchangeType = 1) { show(productData, editData = null) {
this.visible = true; this.visible = true;
this.isEdit = !!editData; this.isEdit = !!editData;
this.productData = productData; this.productData = productData;
//
this.productSpecificationList =
productData.productSpecificationList || [];
if (editData) { if (editData) {
// //
this.editProductData = {
productId: productData.productId,
productName: productData.productName,
shopName: productData.shopName,
productSpecName: productData.productSpecName
};
this.configForm = { this.configForm = {
id: editData.id || undefined, id: editData.id || undefined,
shopId: editData.shopId || undefined, shopId: editData.shopId || undefined,
productId: editData.productId || undefined, productId: editData.productId || undefined,
productSpecId: editData.productSpecId || undefined, productSpecId: editData.productSpecId || undefined,
exchangeRequiredPoints: editData.exchangeRequiredPoints || 1, exchangeRequiredPoints: editData.exchangeRequiredPoints || 1,
exchangeInventory: 0, // 0 exchangeInventory: editData.exchangeInventory || 10,
exchangePointsType: editData.exchangePointsType || 1, exchangeRestrictions: editData.exchangeRestrictions || 0,
exchangeRequiredAmount: editData.exchangeRequiredAmount || "" exchangeRestrictionsType: editData.exchangeRestrictionsType || 1
}; };
} else { } else {
// 使 // 使
const defaultSpecId =
this.productSpecificationList.length === 1
? this.productSpecificationList[0].id
: undefined;
this.configForm = { this.configForm = {
id: undefined, id: undefined,
shopId: productData.shopId || undefined, shopId: productData.shopId || undefined,
productId: productData.productId || undefined, productId: productData.id || undefined,
productSpecId: productData.id || undefined, // 使ID productSpecId: defaultSpecId,
exchangeRequiredPoints: 1, exchangeRequiredPoints: 1,
exchangeInventory: 10, exchangeInventory: 10,
exchangePointsType: exchangeType, // 使 exchangeRestrictions: 0,
exchangeRequiredAmount: "" exchangeRestrictionsType: 1
}; };
} }
}, },
@ -232,6 +282,8 @@ export default {
}, },
resetForm() { resetForm() {
this.productData = {}; this.productData = {};
this.editProductData = {};
this.productSpecificationList = [];
this.configForm = { this.configForm = {
id: undefined, id: undefined,
shopId: undefined, shopId: undefined,
@ -239,8 +291,8 @@ export default {
productSpecId: undefined, productSpecId: undefined,
exchangeRequiredPoints: 1, exchangeRequiredPoints: 1,
exchangeInventory: 10, exchangeInventory: 10,
exchangePointsType: 1, exchangeRestrictions: 0,
exchangeRequiredAmount: "" exchangeRestrictionsType: 1
}; };
this.isEdit = false; this.isEdit = false;
this.$refs.configForm && this.$refs.configForm.clearValidate(); this.$refs.configForm && this.$refs.configForm.clearValidate();
@ -250,23 +302,9 @@ export default {
if (valid) { if (valid) {
this.submitting = true; this.submitting = true;
let submitData; const submitData = {
if (this.isEdit) { ...this.configForm
// 使 };
submitData = {
id: this.configForm.id,
exchangeRequiredPoints: this.configForm.exchangeRequiredPoints,
increaseInventory: this.configForm.exchangeInventory, //
exchangeRequiredAmount:
this.configForm.exchangeRequiredAmount || 0,
enable: true //
};
} else {
// 使
submitData = {
...this.configForm
};
}
console.log(submitData); console.log(submitData);
// API // API
@ -298,9 +336,7 @@ export default {
this.configForm.exchangeRequiredPoints++; this.configForm.exchangeRequiredPoints++;
}, },
decreaseInventory() { decreaseInventory() {
if (this.isEdit) { if (this.configForm.exchangeInventory > 1) {
this.configForm.exchangeInventory--;
} else if (this.configForm.exchangeInventory > 1) {
this.configForm.exchangeInventory--; this.configForm.exchangeInventory--;
} }
}, },
@ -314,6 +350,18 @@ export default {
}, },
increaseLimitQuantity() { increaseLimitQuantity() {
this.configForm.exchangeRestrictions++; 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);
}
} }
} }
}; };

View File

@ -9,12 +9,16 @@
<!-- 查询条件 --> <!-- 查询条件 -->
<div class="search-form"> <div class="search-form">
<el-form :inline="true" :model="searchForm" class="demo-form-inline"> <el-form :inline="true" :model="searchForm" class="demo-form-inline">
<el-form-item label="店铺名称"> <el-form-item label="店铺" v-if="storeList.length">
<el-input <el-select v-model="searchForm.shopId" placeholder="请选择店铺">
v-model="searchForm.shopName" <el-option
placeholder="请输入店铺名称搜索" v-for="item in storeList"
clearable :key="item.shopId"
></el-input> :label="item.shopName"
:value="item.shopId"
>
</el-option>
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="商品名称"> <el-form-item label="商品名称">
<el-input <el-input
@ -45,31 +49,47 @@
style="width: 100%" style="width: 100%"
v-loading="loading" v-loading="loading"
> >
<el-table-column prop="productId" label="商品ID" align="center"> <el-table-column prop="shopId" label="商品店铺" align="center">
</el-table-column> </el-table-column>
<el-table-column prop="shopName" label="商品店铺" align="center"> <el-table-column prop="name" label="商品名称" align="center">
</el-table-column> </el-table-column>
<el-table-column prop="attributeValue" label="商品规格" align="center"> <el-table-column prop="id" label="商品ID" align="center">
</el-table-column> </el-table-column>
<el-table-column prop="marketPrice" label="商品价格" align="center"> <el-table-column prop="salePrice" label="商品价格" align="center">
<template slot-scope="scope"> ¥{{ scope.row.marketPrice }} </template> <template slot-scope="scope"> ¥{{ scope.row.salePrice }} </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" width="350"> <el-table-column label="规格" align="center" width="120">
<template slot-scope="scope">
<span
v-if="
scope.row.productSpecificationList &&
scope.row.productSpecificationList.length <= 1
"
>
{{
scope.row.productSpecificationList[0]?.attributeValue ||
"默认规格"
}}
</span>
<span
v-else-if="
scope.row.productSpecificationList &&
scope.row.productSpecificationList.length > 1
"
>
多规格
</span>
<span v-else>默认规格</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="150">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
type="primary" type="primary"
size="small" size="small"
@click="addToPointsMall(scope.row, 1)" @click="addToPointsMall(scope.row)"
style="margin-right: 10px"
> >
添加为积分换购商品 添加为积分商品
</el-button>
<el-button
type="success"
size="small"
@click="addToPointsMall(scope.row, 2)"
>
添加为积分优惠购商品
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -120,7 +140,7 @@ export default {
visible: false, visible: false,
loading: false, loading: false,
searchForm: { searchForm: {
shopName: "", shopId: "",
productName: "", productName: "",
productId: "" productId: ""
}, },
@ -135,6 +155,12 @@ export default {
methods: { methods: {
show(shopIdList) { show(shopIdList) {
this.visible = true; this.visible = true;
// 使
if (Array.isArray(shopIdList) && shopIdList.length > 0) {
this.searchForm.shopId = shopIdList[0];
} else if (shopIdList) {
this.searchForm.shopId = shopIdList;
}
this.loadProducts(); this.loadProducts();
}, },
handleClose() { handleClose() {
@ -143,7 +169,7 @@ export default {
}, },
resetData() { resetData() {
this.searchForm = { this.searchForm = {
shopName: "", shopId: "",
productName: "", productName: "",
productId: "" productId: ""
}; };
@ -159,33 +185,38 @@ export default {
this.loadProducts(); this.loadProducts();
}, },
resetSearch() { resetSearch() {
this.searchForm.shopName = "";
this.searchForm.productName = ""; this.searchForm.productName = "";
this.searchForm.productId = ""; this.searchForm.productId = "";
this.searchProducts(); this.searchProducts();
}, },
loadProducts() { loadProducts() {
this.loading = true; this.loading = true;
// // API
this.$api.mer_admin this.$api.mer_admin
.getProductSpecificationPage({ .getProductPage({
shopIdList: [], // p: {
shopName: this.searchForm.shopName || "", pageNumber: this.pagination.currentPage,
productName: this.searchForm.productName || "", pageSize: this.pagination.pageSize
productId: this.searchForm.productId || "" },
shopId: this.searchForm.shopId,
productName: this.searchForm.productName,
productId: this.searchForm.productId,
productFilterType: "SALE",
merchantId: JSON.parse(sessionStorage.getItem("userInfo")).merchantId,
productQuerySortParam: []
}) })
.then(res => { .then(res => {
console.log("商品规格列表:", res); console.log("商品列表:", res);
this.productList = res.data.data.data || []; this.productList = res.data.data.data || [];
this.pagination.total = this.productList.length; // 使 this.pagination.total = Number(res.data.data.total || 0);
this.loading = false; this.loading = false;
}) })
.catch(err => { .catch(err => {
console.error("获取商品规格列表失败:", err); console.error("获取商品列表失败:", err);
this.productList = []; this.productList = [];
this.pagination.total = 0; this.pagination.total = 0;
this.loading = false; this.loading = false;
this.$message.error("获取商品规格列表失败"); this.$message.error("获取商品列表失败");
}); });
}, },
handleSizeChange(val) { handleSizeChange(val) {
@ -196,16 +227,9 @@ export default {
this.pagination.currentPage = val; this.pagination.currentPage = val;
this.loadProducts(); this.loadProducts();
}, },
addToPointsMall(product, exchangeType) { addToPointsMall(product) {
// //
this.$refs.pointsProductConfig.show( this.$refs.pointsProductConfig.show(product);
{
...product,
productSpecId: product.id
},
null,
exchangeType
);
}, },
handleConfigSuccess() { handleConfigSuccess() {
this.$emit("success"); this.$emit("success");