feat: 积分商品新接口对接
This commit is contained in:
parent
45ba73ebae
commit
a171d541a3
|
@ -215,6 +215,15 @@ 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({
|
||||||
|
|
|
@ -51,6 +51,10 @@ 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);
|
||||||
|
|
|
@ -172,6 +172,21 @@ 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:
|
||||||
|
@ -258,7 +273,16 @@ export default {
|
||||||
{
|
{
|
||||||
title: "启用状态",
|
title: "启用状态",
|
||||||
align: "center",
|
align: "center",
|
||||||
field: "enable"
|
field: "enable",
|
||||||
|
type: "jsx",
|
||||||
|
render: ({ row }) => {
|
||||||
|
return (
|
||||||
|
<el-switch
|
||||||
|
v-model={row.enable}
|
||||||
|
onChange={() => this.handleEnableChange(row)}
|
||||||
|
></el-switch>
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "操作",
|
title: "操作",
|
||||||
|
@ -273,7 +297,11 @@ 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
|
||||||
};
|
};
|
||||||
|
|
||||||
// 直接使用列表中的数据作为编辑数据
|
// 直接使用列表中的数据作为编辑数据
|
||||||
|
@ -282,6 +310,8 @@ 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,
|
||||||
|
|
|
@ -12,39 +12,31 @@
|
||||||
<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">{{
|
<span class="value">{{ productData.productId }}</span>
|
||||||
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">{{
|
<span class="value">{{ productData.productName }}</span>
|
||||||
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">{{
|
<span class="value">{{ productData.shopName }}</span>
|
||||||
isEdit ? editProductData.shopName : productData.shopId
|
|
||||||
}}</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="info-item" v-if="!isEdit && productData.description">
|
<div class="info-item">
|
||||||
<span class="label">商品描述:</span>
|
<span class="label">规格名称:</span>
|
||||||
<span class="value">{{ productData.description }}</span>
|
<span class="value">{{ productData.attributeValue }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="info-item" v-if="!isEdit">
|
<div class="info-item">
|
||||||
<span class="label">价格范围:</span>
|
<span class="label">SKU-ID:</span>
|
||||||
<span class="value"
|
<span class="value">{{ productData.productSpecId }}</span>
|
||||||
>¥{{ productData.minSalePrice }} - ¥{{
|
</div>
|
||||||
productData.maxSalePrice
|
<div class="info-item">
|
||||||
}}</span
|
<span class="label">商品原价:</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">{{
|
<span class="value">{{ productData.surplusInventory }}</span>
|
||||||
editProductData.productSpecName || "默认规格"
|
|
||||||
}}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -53,38 +45,45 @@
|
||||||
<el-form
|
<el-form
|
||||||
ref="configForm"
|
ref="configForm"
|
||||||
:model="configForm"
|
:model="configForm"
|
||||||
:rules="dynamicRules"
|
:rules="configRules"
|
||||||
label-width="140px"
|
label-width="140px"
|
||||||
style="margin-top: 20px"
|
style="margin-top: 20px"
|
||||||
>
|
>
|
||||||
<!-- 商品规格选择 -->
|
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="商品规格"
|
:label="isEdit ? '添加库存(负数代表减少库存)' : '库存设置'"
|
||||||
prop="productSpecId"
|
prop="exchangeInventory"
|
||||||
required
|
required
|
||||||
v-if="!isEdit && productSpecificationList.length > 0"
|
|
||||||
>
|
>
|
||||||
<el-select
|
<div class="inventory-input">
|
||||||
v-model="configForm.productSpecId"
|
<el-button
|
||||||
placeholder="请选择商品规格"
|
@click="decreaseInventory"
|
||||||
style="width: 100%"
|
:disabled="!isEdit && configForm.exchangeInventory <= 1"
|
||||||
@change="handleSpecChange"
|
>-</el-button
|
||||||
>
|
|
||||||
<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>
|
<el-input-number
|
||||||
<span style="float: right; color: #8492a6; font-size: 13px"
|
v-model="configForm.exchangeInventory"
|
||||||
>¥{{ spec.salePrice }}</span
|
:min="isEdit ? -99999 : 1"
|
||||||
>
|
:max="99999"
|
||||||
</el-option>
|
controls-position="right"
|
||||||
</el-select>
|
style="width: 200px; margin: 0 10px"
|
||||||
|
></el-input-number>
|
||||||
|
<el-button @click="increaseInventory">+</el-button>
|
||||||
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="兑换所需积分" prop="exchangeRequiredPoints" required>
|
<el-form-item label="积分类型" prop="exchangePointsType" required>
|
||||||
|
<el-radio-group v-model="configForm.exchangePointsType">
|
||||||
|
<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">
|
<div class="points-input">
|
||||||
<el-button
|
<el-button
|
||||||
@click="decreasePoints"
|
@click="decreasePoints"
|
||||||
|
@ -102,55 +101,40 @@
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="兑换库存" prop="exchangeInventory" required>
|
<el-form-item
|
||||||
<div class="inventory-input">
|
v-if="configForm.exchangePointsType === 2"
|
||||||
|
label="优惠购所需积分"
|
||||||
|
prop="exchangeRequiredPoints"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
<div class="points-input">
|
||||||
<el-button
|
<el-button
|
||||||
@click="decreaseInventory"
|
@click="decreasePoints"
|
||||||
:disabled="configForm.exchangeInventory <= 1"
|
:disabled="configForm.exchangeRequiredPoints <= 1"
|
||||||
>-</el-button
|
>-</el-button
|
||||||
>
|
>
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="configForm.exchangeInventory"
|
v-model="configForm.exchangeRequiredPoints"
|
||||||
:min="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"
|
||||||
></el-input-number>
|
></el-input-number>
|
||||||
<el-button @click="increaseInventory">+</el-button>
|
<el-button @click="increasePoints">+</el-button>
|
||||||
</div>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="兑换限制" prop="exchangeRestrictions" required>
|
|
||||||
<div class="limit-input">
|
|
||||||
<el-button
|
|
||||||
@click="decreaseLimitQuantity"
|
|
||||||
:disabled="configForm.exchangeRestrictions <= 0"
|
|
||||||
>-</el-button
|
|
||||||
>
|
|
||||||
<el-input-number
|
|
||||||
v-model="configForm.exchangeRestrictions"
|
|
||||||
:min="0"
|
|
||||||
:max="99999"
|
|
||||||
controls-position="right"
|
|
||||||
style="width: 200px; margin: 0 10px"
|
|
||||||
></el-input-number>
|
|
||||||
<el-button @click="increaseLimitQuantity">+</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="兑换限制类型"
|
v-if="configForm.exchangePointsType === 2"
|
||||||
prop="exchangeRestrictionsType"
|
label="优惠购商品价格"
|
||||||
|
prop="exchangeRequiredAmount"
|
||||||
required
|
required
|
||||||
>
|
>
|
||||||
<el-select
|
<el-input
|
||||||
v-model="configForm.exchangeRestrictionsType"
|
v-model="configForm.exchangeRequiredAmount"
|
||||||
placeholder="请选择限制类型"
|
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>
|
||||||
|
|
||||||
|
@ -172,8 +156,6 @@ export default {
|
||||||
isEdit: false,
|
isEdit: false,
|
||||||
submitting: false,
|
submitting: false,
|
||||||
productData: {},
|
productData: {},
|
||||||
editProductData: {}, // 编辑模式下的商品数据
|
|
||||||
productSpecificationList: [],
|
|
||||||
configForm: {
|
configForm: {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
shopId: undefined,
|
shopId: undefined,
|
||||||
|
@ -181,98 +163,66 @@ export default {
|
||||||
productSpecId: undefined,
|
productSpecId: undefined,
|
||||||
exchangeRequiredPoints: 1,
|
exchangeRequiredPoints: 1,
|
||||||
exchangeInventory: 10,
|
exchangeInventory: 10,
|
||||||
exchangeRestrictions: 0,
|
exchangePointsType: 1, // 1: 积分换购, 2: 积分优惠购
|
||||||
exchangeRestrictionsType: 1
|
exchangeRequiredAmount: ""
|
||||||
},
|
},
|
||||||
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" }
|
||||||
],
|
],
|
||||||
exchangeRestrictions: [
|
exchangePointsType: [
|
||||||
{ required: true, message: "请设置兑换限制", trigger: "blur" }
|
{ required: true, message: "请选择积分类型", trigger: "change" }
|
||||||
],
|
],
|
||||||
exchangeRestrictionsType: [
|
exchangeRequiredAmount: [
|
||||||
{ 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) {
|
show(productData, editData = null, exchangeType = 1) {
|
||||||
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: editData.exchangeInventory || 10,
|
exchangeInventory: 0, // 编辑模式下默认为0,表示增加库存
|
||||||
exchangeRestrictions: editData.exchangeRestrictions || 0,
|
exchangePointsType: editData.exchangePointsType || 1,
|
||||||
exchangeRestrictionsType: editData.exchangeRestrictionsType || 1
|
exchangeRequiredAmount: editData.exchangeRequiredAmount || ""
|
||||||
};
|
};
|
||||||
} 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.id || undefined,
|
productId: productData.productId || undefined,
|
||||||
productSpecId: defaultSpecId,
|
productSpecId: productData.id || undefined, // 使用规格ID
|
||||||
exchangeRequiredPoints: 1,
|
exchangeRequiredPoints: 1,
|
||||||
exchangeInventory: 10,
|
exchangeInventory: 10,
|
||||||
exchangeRestrictions: 0,
|
exchangePointsType: exchangeType, // 使用传入的积分类型
|
||||||
exchangeRestrictionsType: 1
|
exchangeRequiredAmount: ""
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -282,8 +232,6 @@ export default {
|
||||||
},
|
},
|
||||||
resetForm() {
|
resetForm() {
|
||||||
this.productData = {};
|
this.productData = {};
|
||||||
this.editProductData = {};
|
|
||||||
this.productSpecificationList = [];
|
|
||||||
this.configForm = {
|
this.configForm = {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
shopId: undefined,
|
shopId: undefined,
|
||||||
|
@ -291,8 +239,8 @@ export default {
|
||||||
productSpecId: undefined,
|
productSpecId: undefined,
|
||||||
exchangeRequiredPoints: 1,
|
exchangeRequiredPoints: 1,
|
||||||
exchangeInventory: 10,
|
exchangeInventory: 10,
|
||||||
exchangeRestrictions: 0,
|
exchangePointsType: 1,
|
||||||
exchangeRestrictionsType: 1
|
exchangeRequiredAmount: ""
|
||||||
};
|
};
|
||||||
this.isEdit = false;
|
this.isEdit = false;
|
||||||
this.$refs.configForm && this.$refs.configForm.clearValidate();
|
this.$refs.configForm && this.$refs.configForm.clearValidate();
|
||||||
|
@ -302,9 +250,23 @@ export default {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.submitting = true;
|
this.submitting = true;
|
||||||
|
|
||||||
const submitData = {
|
let submitData;
|
||||||
...this.configForm
|
if (this.isEdit) {
|
||||||
};
|
// 编辑模式使用新的参数格式
|
||||||
|
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
|
||||||
|
@ -336,7 +298,9 @@ export default {
|
||||||
this.configForm.exchangeRequiredPoints++;
|
this.configForm.exchangeRequiredPoints++;
|
||||||
},
|
},
|
||||||
decreaseInventory() {
|
decreaseInventory() {
|
||||||
if (this.configForm.exchangeInventory > 1) {
|
if (this.isEdit) {
|
||||||
|
this.configForm.exchangeInventory--;
|
||||||
|
} else if (this.configForm.exchangeInventory > 1) {
|
||||||
this.configForm.exchangeInventory--;
|
this.configForm.exchangeInventory--;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -350,18 +314,6 @@ 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,16 +9,12 @@
|
||||||
<!-- 查询条件 -->
|
<!-- 查询条件 -->
|
||||||
<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="店铺" v-if="storeList.length">
|
<el-form-item label="店铺名称">
|
||||||
<el-select v-model="searchForm.shopId" placeholder="请选择店铺">
|
<el-input
|
||||||
<el-option
|
v-model="searchForm.shopName"
|
||||||
v-for="item in storeList"
|
placeholder="请输入店铺名称搜索"
|
||||||
:key="item.shopId"
|
clearable
|
||||||
:label="item.shopName"
|
></el-input>
|
||||||
: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
|
||||||
|
@ -49,47 +45,31 @@
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
>
|
>
|
||||||
<el-table-column prop="shopId" label="商品店铺" align="center">
|
<el-table-column prop="productId" label="商品ID" align="center">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="name" label="商品名称" align="center">
|
<el-table-column prop="shopName" label="商品店铺" align="center">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="id" label="商品ID" align="center">
|
<el-table-column prop="attributeValue" label="商品规格" align="center">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="salePrice" label="商品价格" align="center">
|
<el-table-column prop="marketPrice" label="商品价格" align="center">
|
||||||
<template slot-scope="scope"> ¥{{ scope.row.salePrice }} </template>
|
<template slot-scope="scope"> ¥{{ scope.row.marketPrice }} </template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="规格" align="center" width="120">
|
<el-table-column label="操作" align="center" width="350">
|
||||||
<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)"
|
@click="addToPointsMall(scope.row, 1)"
|
||||||
|
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>
|
||||||
|
@ -140,7 +120,7 @@ export default {
|
||||||
visible: false,
|
visible: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
searchForm: {
|
searchForm: {
|
||||||
shopId: "",
|
shopName: "",
|
||||||
productName: "",
|
productName: "",
|
||||||
productId: ""
|
productId: ""
|
||||||
},
|
},
|
||||||
|
@ -155,12 +135,6 @@ 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() {
|
||||||
|
@ -169,7 +143,7 @@ export default {
|
||||||
},
|
},
|
||||||
resetData() {
|
resetData() {
|
||||||
this.searchForm = {
|
this.searchForm = {
|
||||||
shopId: "",
|
shopName: "",
|
||||||
productName: "",
|
productName: "",
|
||||||
productId: ""
|
productId: ""
|
||||||
};
|
};
|
||||||
|
@ -185,38 +159,33 @@ 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
|
||||||
.getProductPage({
|
.getProductSpecificationPage({
|
||||||
p: {
|
shopIdList: [], // 暂时忽略
|
||||||
pageNumber: this.pagination.currentPage,
|
shopName: this.searchForm.shopName || "",
|
||||||
pageSize: this.pagination.pageSize
|
productName: this.searchForm.productName || "",
|
||||||
},
|
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 = Number(res.data.data.total || 0);
|
this.pagination.total = this.productList.length; // 暂时使用数组长度作为总数
|
||||||
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) {
|
||||||
|
@ -227,9 +196,16 @@ export default {
|
||||||
this.pagination.currentPage = val;
|
this.pagination.currentPage = val;
|
||||||
this.loadProducts();
|
this.loadProducts();
|
||||||
},
|
},
|
||||||
addToPointsMall(product) {
|
addToPointsMall(product, exchangeType) {
|
||||||
// 打开积分商品配置弹框
|
// 打开积分商品配置弹框,传递积分类型
|
||||||
this.$refs.pointsProductConfig.show(product);
|
this.$refs.pointsProductConfig.show(
|
||||||
|
{
|
||||||
|
...product,
|
||||||
|
productSpecId: product.id
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
exchangeType
|
||||||
|
);
|
||||||
},
|
},
|
||||||
handleConfigSuccess() {
|
handleConfigSuccess() {
|
||||||
this.$emit("success");
|
this.$emit("success");
|
||||||
|
|
Loading…
Reference in New Issue