mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-11-13 04:18:55 +08:00
Merge branch 'vue3'
This commit is contained in:
@@ -200,15 +200,21 @@ export default {
|
||||
submitLoading: false,
|
||||
selectCouponList: [],
|
||||
formRule: {
|
||||
promotionName: [{ required: true, message: "活动名称不能为空", trigger: "blur" }],
|
||||
promotionName: [{ required: true, message: "活动名称不能为空" }],
|
||||
rangeTime: [
|
||||
{
|
||||
type: "array",
|
||||
required: true,
|
||||
message: "请选择活动有效期",
|
||||
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: "请输入范围描述" }],
|
||||
},
|
||||
};
|
||||
},
|
||||
@@ -297,6 +303,7 @@ export default {
|
||||
this.showCouponSelect = true;
|
||||
},
|
||||
handleSubmit() {
|
||||
// 自动发券只能全用户发送:如有自动发券且非全用户,提示并强制切换
|
||||
if (
|
||||
this.form.couponActivityType === "AUTO_COUPON" &&
|
||||
this.form.activityScope !== "ALL"
|
||||
@@ -326,15 +333,16 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
// 统一取时间逻辑
|
||||
const [start, end] = this.form.rangeTime;
|
||||
const startDate = start instanceof Date ? start : new Date(start);
|
||||
const endDate = end instanceof Date ? end : new Date(end);
|
||||
this.form.startTime = this.$filters.unixToDate(startDate.getTime() / 1000);
|
||||
this.form.endTime = this.$filters.unixToDate(endDate.getTime() / 1000);
|
||||
|
||||
const params = JSON.parse(JSON.stringify(this.form));
|
||||
params.startTime = this.$filters.unixToDate(startDate.getTime() / 1000);
|
||||
params.endTime = this.$filters.unixToDate(endDate.getTime() / 1000);
|
||||
delete params.rangeTime;
|
||||
delete params.id;
|
||||
|
||||
this.submitLoading = true;
|
||||
saveActivityCoupon(params).then((res) => {
|
||||
this.submitLoading = false;
|
||||
|
||||
@@ -68,10 +68,10 @@
|
||||
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"
|
||||
placeholder="请选择"
|
||||
:disabled-date="options.disabledDate"
|
||||
/>
|
||||
</el-form-item>
|
||||
<div>
|
||||
@@ -153,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() {
|
||||
@@ -165,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;
|
||||
@@ -176,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() {
|
||||
|
||||
Reference in New Issue
Block a user