refactor: 移除未使用的商品规格相关 API 接口与组件,优化用户管理与物流功能

- 删除了与商品规格相关的 API 接口和组件,简化代码结构。
- 更新用户管理功能,确保表单字段与验证规则一致。
- 优化物流添加与编辑功能,确保请求参数的正确性与一致性。
This commit is contained in:
田香琪
2026-07-16 16:52:55 +08:00
parent 7804d4eba6
commit 7e87214b6d
17 changed files with 555 additions and 396 deletions

View File

@@ -13,11 +13,11 @@
style="width: 260px"
/>
</el-form-item>
<el-form-item label="活动时间" class="activity-time-form-item">
<el-form-item label="活动时间" prop="rangeTime" class="activity-time-form-item">
<el-date-picker
type="datetimerange"
:disabled-date="options.disabledDate"
v-model="rangeTime"
v-model="form.rangeTime"
format="YYYY-MM-DD HH:mm:ss"
start-placeholder="开始时间"
end-placeholder="结束时间"
@@ -184,13 +184,13 @@ export default {
},
showCouponSelect: false,
tempCouponList: [],
rangeTime: "",
checkUserList: false,
selectedMember: [],
form: {
promotionName: "",
activityScope: "ALL",
couponActivityType: "REGISTERED",
rangeTime: null,
startTime: "",
endTime: "",
memberDTOS: [],
@@ -201,7 +201,19 @@ export default {
selectCouponList: [],
formRule: {
promotionName: [{ required: true, message: "活动名称不能为空" }],
rangeTime: [{ required: true, message: "请选择活动有效期" }],
rangeTime: [
{
required: true,
validator: (rule, value, callback) => {
if (!value || !Array.isArray(value) || value.length !== 2 || !value[0] || !value[1]) {
callback(new Error("请选择活动有效期"));
} else {
callback();
}
},
trigger: "change",
},
],
description: [{ required: true, message: "请输入范围描述" }],
},
};
@@ -291,49 +303,31 @@ export default {
this.showCouponSelect = true;
},
handleSubmit() {
if (this.form.couponFrequencyEnum !== "") {
if (this.form.activityScope == "ALL") {
this.form.startTime = this.$filters.unixToDate(this.rangeTime[0] / 1000);
this.form.endTime = this.$filters.unixToDate(this.rangeTime[1] / 1000);
if (this.form.couponFrequencyEnum !== "" && this.form.activityScope != "ALL") {
this.$Message.info("自动发券只能全用户发送");
this.form.couponActivityType = "SPECIFY";
this.form.activityScope = "ALL";
return;
}
this.$refs.form.validate((valid) => {
if (valid) {
const params = JSON.parse(JSON.stringify(this.form));
this.submitLoading = true;
delete params.id;
saveActivityCoupon(params).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("优惠券活动创建成功");
this.closeCurrentPage();
}
});
}
});
} else {
this.$Message.info("自动发券只能全用户发送");
this.form.couponActivityType = "SPECIFY";
this.form.activityScope = "ALL";
}
} else {
this.form.startTime = this.$filters.unixToDate(this.rangeTime[0] / 1000);
this.form.endTime = this.$filters.unixToDate(this.rangeTime[1] / 1000);
this.$refs.form.validate((valid) => {
if (!valid) return;
this.$refs.form.validate((valid) => {
if (valid) {
const params = JSON.parse(JSON.stringify(this.form));
this.submitLoading = true;
delete params.id;
saveActivityCoupon(params).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("优惠券活动创建成功");
this.closeCurrentPage();
}
});
this.form.startTime = this.$filters.unixToDate(this.form.rangeTime[0] / 1000);
this.form.endTime = this.$filters.unixToDate(this.form.rangeTime[1] / 1000);
const params = JSON.parse(JSON.stringify(this.form));
delete params.rangeTime;
delete params.id;
this.submitLoading = true;
saveActivityCoupon(params).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("优惠券活动创建成功");
this.closeCurrentPage();
}
});
}
});
},
closeCurrentPage() {
this.$store.commit("removeTag", "add-platform-coupon");

View File

@@ -6,7 +6,7 @@
<div class="form-item-view">
<h4>商品信息</h4>
<el-form-item label="选择商品" prop="scopeType">
<el-form-item label="选择商品" prop="promotionGoodsList">
<el-button type="primary" @click="openSkuList">选择商品</el-button>
</el-form-item>
@@ -116,13 +116,30 @@ export default {
modalType: 0,
form: {
promotionGoodsList: [],
rangeTime: [],
},
id: this.$route.query.id,
submitLoading: false,
selectedGoods: [],
promotionGoodsList: [],
formRule: {
rangeTime: [{ required: true, message: "请选择活动时间" }],
promotionGoodsList: [
{
type: "array",
required: true,
min: 1,
message: "请至少选择一个商品",
trigger: "change",
},
],
rangeTime: [
{
type: "array",
required: true,
message: "请选择活动时间",
trigger: "change",
},
],
},
options: {
disabledDate(date) {
@@ -140,78 +157,80 @@ export default {
methods: {
handleSubmit() {
this.$refs.form.validate((valid) => {
if (valid) {
const params = JSON.parse(JSON.stringify(this.form));
if (this.form.rangeTime[0] === "" || this.form.rangeTime[0] === "") {
this.$Message.error("请选择活动时间");
return;
}
params.startTime = this.$filters.unixToDate(
this.form.rangeTime[0] / 1000
);
params.endTime = this.$filters.unixToDate(
this.form.rangeTime[1] / 1000
);
delete params.rangeTime;
let checkResult = true;
if (this.form.promotionGoodsList.length > 0) {
this.form.promotionGoodsList.forEach((res) => {
if (res.stock <= 0 || res.stock > res.quantity) {
checkResult = false;
this.$Message.error("活动库存不能为0且不能超过商品库存");
return;
}
if (!regular.money.test(res.settlementPrice)) {
checkResult = false;
this.$Message.error("结算价格金额格式不正确");
return;
}
if (res.settlementPrice < 0 || res.settlementPrice > res.price) {
checkResult = false;
this.$Message.error("结算价格金额不能为0且不能超过商品价格");
return;
}
if (!regular.money.test(res.highestPrice)) {
checkResult = false;
this.$Message.error("最高可砍金额格式错误");
return;
}
if (res.highestPrice <= 0 || res.highestPrice > res.price) {
checkResult = false;
this.$Message.error("最高可砍金额不能为0且不能超过商品价格");
return;
}
if (!regular.money.test(res.lowestPrice)) {
checkResult = false;
this.$Message.error("最低可砍金额格式错误");
return;
}
if (res.lowestPrice <= 0 || res.lowestPrice > res.price) {
checkResult = false;
this.$Message.error("最低可砍金额不能为0");
return;
}
if (parseInt(res.lowestPrice) > parseInt(res.highestPrice)) {
checkResult = false;
this.$Message.error("最低砍价金额不能大于最高砍价金额");
return;
}
});
}
if (!checkResult) {
return;
}
this.submitLoading = true;
saveKanJiaActivityGoods(params).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("砍价活动修改成功");
this.closeCurrentPage();
}
});
if (!valid) {
return;
}
if (!this.form.promotionGoodsList.length) {
this.$Message.warning("请至少选择一个商品");
return;
}
const params = JSON.parse(JSON.stringify(this.form));
const [start, end] = this.form.rangeTime || [];
const startDate = start instanceof Date ? start : new Date(start);
const endDate = end instanceof Date ? end : new Date(end);
params.startTime = this.$filters.unixToDate(startDate.getTime() / 1000);
params.endTime = this.$filters.unixToDate(endDate.getTime() / 1000);
delete params.rangeTime;
let checkResult = true;
this.form.promotionGoodsList.forEach((res) => {
if (res.stock <= 0 || res.stock > res.quantity) {
checkResult = false;
this.$Message.error("活动库存不能为0且不能超过商品库存");
return;
}
if (!regular.money.test(res.settlementPrice)) {
checkResult = false;
this.$Message.error("结算价格金额格式不正确");
return;
}
if (res.settlementPrice < 0 || res.settlementPrice > res.price) {
checkResult = false;
this.$Message.error("结算价格金额不能为0且不能超过商品价格");
return;
}
if (!regular.money.test(res.highestPrice)) {
checkResult = false;
this.$Message.error("最高可砍金额格式错误");
return;
}
if (res.highestPrice <= 0 || res.highestPrice > res.price) {
checkResult = false;
this.$Message.error("最高可砍金额不能为0且不能超过商品价格");
return;
}
if (!regular.money.test(res.lowestPrice)) {
checkResult = false;
this.$Message.error("最低可砍金额格式错误");
return;
}
if (res.lowestPrice <= 0 || res.lowestPrice > res.price) {
checkResult = false;
this.$Message.error("最低可砍金额不能为0");
return;
}
if (parseInt(res.lowestPrice) > parseInt(res.highestPrice)) {
checkResult = false;
this.$Message.error("最低砍价金额不能大于最高砍价金额");
return;
}
});
if (!checkResult) {
return;
}
this.submitLoading = true;
saveKanJiaActivityGoods(params).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success(
this.modalType === 1 ? "砍价活动修改成功" : "砍价活动添加成功"
);
this.closeCurrentPage();
}
});
});
},
closeCurrentPage() {
@@ -232,6 +251,15 @@ export default {
},
delGoods(index) {
this.form.promotionGoodsList.splice(index, 1);
this.touchPromotionGoodsValidate();
},
touchPromotionGoodsValidate() {
this.$nextTick(() => {
const form = this.$refs.form;
if (form && typeof form.validateField === "function") {
form.validateField("promotionGoodsList", () => {});
}
});
},
selectedGoodsData(item) {
let list = [];
@@ -252,6 +280,7 @@ export default {
});
});
this.form.promotionGoodsList = list;
this.touchPromotionGoodsValidate();
},
},
};

View File

@@ -62,17 +62,16 @@
style="width: 260px"
/>
</el-form-item>
<el-form-item label="活动时间" prop="rangeTime">
<el-form-item label="活动时间" prop="rangeTime" class="kanjia-activity-time-form-item">
<el-date-picker
:disabled="onlyView"
v-model="form.rangeTime"
type="datetimerange"
format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
start-placeholder="开始时间"
end-placeholder="结束时间"
:disabled-date="disabledDate"
style="width: 360px"
placeholder="请选择"
:disabled-date="options.disabledDate"
/>
</el-form-item>
<div>
@@ -154,9 +153,21 @@ export default {
{ required: true, message: "请输入最高可砍金额" },
{ validator: checkHighestPrice },
],
rangeTime: [{ required: true, message: "请选择活动时间" }],
rangeTime: [
{
type: "array",
required: true,
message: "请选择活动时间",
trigger: "change",
},
],
stock: [{ required: true, message: "请输入活动库存" }],
},
options: {
disabledDate(date) {
return date && date.valueOf() < Date.now() - 86400000;
},
},
};
},
async mounted() {
@@ -166,9 +177,6 @@ export default {
}
},
methods: {
disabledDate(date) {
return date && date.getTime() < Date.now() - 86400000;
},
getKanJiaActivityGoods() {
getKanJiaActivityGoodsById(this.id).then((res) => {
this.form = res.result;
@@ -177,58 +185,62 @@ export default {
},
handleSubmit() {
this.$refs.form.validate((valid) => {
if (valid) {
const params = JSON.parse(JSON.stringify(this.form));
if (!this.form.rangeTime || this.form.rangeTime.length !== 2) {
this.$Message.error("请选择活动时间");
return;
}
params.startTime = this.form.rangeTime[0];
params.endTime = this.form.rangeTime[1];
delete params.rangeTime;
if (params.stock <= 0 || params.stock > params.goodsSku.quantity) {
this.$Message.error("活动库存不能为0且不能超过商品库存");
return;
}
if (!regular.money.test(params.settlementPrice)) {
this.$Message.error("结算价格金额格式不正确");
return;
}
if (params.settlementPrice < 0 || params.settlementPrice > params.price) {
this.$Message.error("结算价格金额不能为0且不能超过商品价格");
return;
}
if (!regular.money.test(params.highestPrice)) {
this.$Message.error("最高可砍金额格式错误");
return;
}
if (params.highestPrice <= 0 || params.highestPrice > params.price) {
this.$Message.error("最高可砍金额不能为0且不能超过商品价格");
return;
}
if (!regular.money.test(params.lowestPrice)) {
this.$Message.error("最低可砍金额格式错误");
return;
}
if (params.lowestPrice <= 0 || params.lowestPrice > params.price) {
this.$Message.error("最低可砍金额不能为0");
return;
}
if (params.lowestPrice > params.highestPrice) {
this.$Message.error("最低砍价金额不能大于最高砍价金额");
return;
}
this.submitLoading = true;
editKanJiaActivityGoods(params).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("砍价活动修改成功");
this.closeCurrentPage();
}
});
if (!valid) {
return;
}
const params = JSON.parse(JSON.stringify(this.form));
const [start, end] = this.form.rangeTime || [];
if (!start || !end) {
this.$Message.error("请选择活动时间");
return;
}
const startDate = start instanceof Date ? start : new Date(start);
const endDate = end instanceof Date ? end : new Date(end);
params.startTime = this.$filters.unixToDate(startDate.getTime() / 1000);
params.endTime = this.$filters.unixToDate(endDate.getTime() / 1000);
delete params.rangeTime;
if (params.stock <= 0 || params.stock > params.goodsSku.quantity) {
this.$Message.error("活动库存不能为0且不能超过商品库存");
return;
}
if (!regular.money.test(params.settlementPrice)) {
this.$Message.error("结算价格金额格式不正确");
return;
}
if (params.settlementPrice < 0 || params.settlementPrice > params.price) {
this.$Message.error("结算价格金额不能为0且不能超过商品价格");
return;
}
if (!regular.money.test(params.highestPrice)) {
this.$Message.error("最高可砍金额格式错误");
return;
}
if (params.highestPrice <= 0 || params.highestPrice > params.price) {
this.$Message.error("最高可砍金额不能为0且不能超过商品价格");
return;
}
if (!regular.money.test(params.lowestPrice)) {
this.$Message.error("最低可砍金额格式错误");
return;
}
if (params.lowestPrice <= 0 || params.lowestPrice > params.price) {
this.$Message.error("最低可砍金额不能为0");
return;
}
if (params.lowestPrice > params.highestPrice) {
this.$Message.error("最低砍价金额不能大于最高砍价金额");
return;
}
this.submitLoading = true;
editKanJiaActivityGoods(params).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("砍价活动修改成功");
this.closeCurrentPage();
}
});
});
},
closeCurrentPage() {
@@ -252,4 +264,12 @@ h4 {
line-height: 40px;
text-align: left;
}
.kanjia-activity-time-form-item {
:deep(.el-date-editor) {
width: 360px !important;
max-width: 360px;
flex-grow: 0;
}
}
</style>