From 26492664662cf38e05f886e3c28cefa257cb455a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BD=99=E5=90=8C=E5=AD=A6?= <2495967527@qq.com>
Date: Tue, 24 Dec 2024 18:30:47 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=8D=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/utils/index.js | 24 +++
src/views/modules/bank-card/index.vue | 14 +-
src/views/modules/coupon/index.vue | 38 ++--
.../modules/coupon/popup/add-or-update.vue | 134 ++++++++++---
.../modules/coupon/popup/full-reduction.vue | 172 ++++++++++++----
src/views/modules/coupon/popup/new-powder.vue | 189 ++++++++++++++----
6 files changed, 447 insertions(+), 124 deletions(-)
diff --git a/src/utils/index.js b/src/utils/index.js
index 31f271d..31edfcf 100644
--- a/src/utils/index.js
+++ b/src/utils/index.js
@@ -113,6 +113,30 @@ export function deepClone(obj) {
return result;
}
+/**
+ * 获取时间
+ * @param {*} min
+ * @param {*} max
+ */
+export function getDay(day) {
+ let today = new Date();
+ let targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
+ today.setTime(targetday_milliseconds); //注意,这行是关键代码
+ let tYear = today.getFullYear();
+ let tMonth = today.getMonth();
+ let tDate = today.getDate();
+ tMonth = doHandleMonth(tMonth + 1);
+ tDate = doHandleMonth(tDate);
+ return tYear + "-" + tMonth + "-" + tDate;
+}
+function doHandleMonth(month) {
+ let m = month;
+ if (month.toString().length === 1) {
+ m = "0" + month;
+ }
+ return m;
+}
+
export function isNumberStr(str) {
return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str);
}
diff --git a/src/views/modules/bank-card/index.vue b/src/views/modules/bank-card/index.vue
index 1abb680..222c471 100644
--- a/src/views/modules/bank-card/index.vue
+++ b/src/views/modules/bank-card/index.vue
@@ -181,11 +181,15 @@ export default {
render: ({ row }) => {
let defaultBank = () => {
if (row.default) {
- this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
+ this.$confirm(
+ "此操作将设置该银行卡为默认银行卡, 是否继续?",
+ "提示",
+ {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning",
+ }
+ )
.then(() => {
this.$api.mer_admin
.defaultBank({
diff --git a/src/views/modules/coupon/index.vue b/src/views/modules/coupon/index.vue
index 35a7036..a3d4bf0 100644
--- a/src/views/modules/coupon/index.vue
+++ b/src/views/modules/coupon/index.vue
@@ -123,7 +123,7 @@ export default {
formInline: {
marketId: "",
shopId: "",
- queryStatus: "",
+ queryStatus: "q",
name: "",
},
tableProp: {
@@ -140,7 +140,7 @@ export default {
created() {
this.formInline = {
name: "",
- queryStatus: "",
+ queryStatus: "1",
marketId: this.marketId,
shopId: this.shopId,
};
@@ -185,7 +185,7 @@ export default {
Reset() {
this.formInline = {
name: "",
- queryStatus: "",
+ queryStatus: "1",
marketId: this.marketId,
shopId: this.shopId,
};
@@ -294,11 +294,11 @@ export default {
align: "center",
field: "money",
},
- {
- title: "折扣",
- align: "center",
- field: "discount",
- },
+ // {
+ // title: "折扣",
+ // align: "center",
+ // field: "discount",
+ // },
{
title: "最低消费",
align: "center",
@@ -386,16 +386,18 @@ export default {
});
}
};
- return (
-
- );
+ if (row.status == 1) {
+ return (
+
+ );
+ }
},
},
{
diff --git a/src/views/modules/coupon/popup/add-or-update.vue b/src/views/modules/coupon/popup/add-or-update.vue
index 61d9872..fe48401 100644
--- a/src/views/modules/coupon/popup/add-or-update.vue
+++ b/src/views/modules/coupon/popup/add-or-update.vue
@@ -8,7 +8,7 @@
:modalHandles="modalHandles"
>
-
+
-
+
-
+
-
+
+
-
+
-
+
{
+ return time.getTime() < Date.now() - 8.64e7;
+ },
+ },
+ rules: {
+ name: [
+ {
+ required: true,
+ message: "请输入优惠券名称",
+ trigger: ["blur", "change"],
+ },
+ ],
+ useStartTime: [
+ {
+ required: true,
+ message: "请选择使用日期",
+ trigger: ["blur", "change"],
+ },
+ ],
+ receiveStartTime: [
+ {
+ required: true,
+ message: "请选择领取日期",
+ trigger: ["blur", "change"],
+ },
+ ],
+ money: [
+ {
+ required: true,
+ message: "请输入优惠金额",
+ trigger: ["blur", "change"],
+ },
+ ],
+ total: [
+ {
+ required: true,
+ message: "请输入发放数量",
+ trigger: ["blur", "change"],
+ },
+ ],
+ limitedNum: [
+ {
+ required: true,
+ message: "请选择每人限领",
+ trigger: ["blur", "change"],
+ },
+ ],
+ },
};
},
+ watch: {
+ "modalConfig.show"(newVal) {
+ if (!newVal) {
+ //关闭弹窗清空校验
+ this.$refs.modalForm.resetFields();
+ this.collectionDate = [];
+ }
+ },
+ },
methods: {
queryTableData(pageNo, pageSize) {},
toggle(e) {
@@ -169,6 +243,11 @@ export default {
}
return {
add: (row) => {
+ this.usageDate = [getDay(0), getDay(14)];
+ let month = getDay(0).slice(5, 7);
+ let day = getDay(0).slice(8, 10);
+ console.log(month, day);
+
this.formInline = {
marketId: row.marketId,
shopId: row.shopId,
@@ -180,16 +259,18 @@ export default {
receiveType: "MANUAL",
couponType: "MONEY",
isTimeReceive: 1, //0-不限时,1-限时
- name: "",
- useStartTime: "",
- useEndTime: "",
+ name: `无门槛优惠卷${month}${day}`,
+ useStartTime: getDay(0),
+ useEndTime: getDay(14),
receiveStartTime: "",
receiveEndTime: "",
money: "",
total: 10000,
- limitedNum: 0,
+ limitedNum: 1,
minPrice: 0,
- usableRange: "PARTIAL_GOODS", //部分商品-PARTIAL_GOODS 所有商品-ALL_GOODS 部分摊位-PARTIAL_SHOP
+ usableRange: "ALL", //部分商品-PARTIAL_GOODS 所有商品-ALL_GOODS 部分摊位-PARTIAL_SHOP
+ targetIds: [],
+ status: 1,
};
// this.$refs.modal.resetFields();
});
@@ -202,6 +283,7 @@ export default {
},
init(row) {},
usageDateChange(e) {
+ console.log(e);
if (e) {
this.modalData.useStartTime = e[0];
this.modalData.useEndTime = e[1];
@@ -245,16 +327,18 @@ export default {
type: "primary",
handle: () => {
console.log(this.modalData);
- let data = { ...this.modalData };
- data.targetIds = [data.targetIds];
- console.log(this.modalData, data);
- this.$api.coupon
- .addCoupon({ ...data, ...this.formInline })
- .then((res) => {
- console.log(res);
- this.$emit("queryList");
- this.toggle();
- });
+ this.$refs.modalForm.validate((valid) => {
+ console.log(valid);
+ if (valid) {
+ this.$api.coupon
+ .addCoupon({ ...this.modalData, ...this.formInline })
+ .then((res) => {
+ console.log(res);
+ this.$emit("queryList");
+ this.toggle();
+ });
+ }
+ });
},
},
];
diff --git a/src/views/modules/coupon/popup/full-reduction.vue b/src/views/modules/coupon/popup/full-reduction.vue
index 71f08ac..b7e19b6 100644
--- a/src/views/modules/coupon/popup/full-reduction.vue
+++ b/src/views/modules/coupon/popup/full-reduction.vue
@@ -8,8 +8,8 @@
:modalHandles="modalHandles"
>
-
-
+
+
-
+
-
+
-
+
满
-
- 元
-
+
+
+
减
-
- 元
-
+
+
+
-
请选择
-
-
+ -->
+
+
+
-
+
{
+ return time.getTime() < Date.now() - 8.64e7;
+ },
+ },
+ rules: {
+ name: [
+ {
+ required: true,
+ message: "请输入优惠券名称",
+ trigger: ["blur", "change"],
+ },
+ ],
+ useStartTime: [
+ {
+ required: true,
+ message: "请选择使用日期",
+ trigger: ["blur", "change"],
+ },
+ ],
+ receiveStartTime: [
+ {
+ required: true,
+ message: "请选择领取日期",
+ trigger: ["blur", "change"],
+ },
+ ],
+ minPrice: [
+ {
+ required: true,
+ message: "请输入满减条件",
+ trigger: ["blur", "change"],
+ },
+ ],
+ money: [
+ {
+ required: true,
+ message: "请输入优惠金额",
+ trigger: ["blur", "change"],
+ },
+ ],
+ total: [
+ {
+ required: true,
+ message: "请输入发放数量",
+ trigger: ["blur", "change"],
+ },
+ ],
+ limitedNum: [
+ {
+ required: true,
+ message: "请选择每人限领",
+ trigger: ["blur", "change"],
+ },
+ ],
+ },
};
},
+ watch: {
+ "modalConfig.show"(newVal) {
+ if (!newVal) {
+ //关闭弹窗清空校验
+ this.$refs.modalForm.resetFields();
+ this.collectionDate = [];
+ }
+ },
+ },
methods: {
queryTableData(pageNo, pageSize) {},
toggle(e) {
@@ -207,6 +300,9 @@ export default {
}
return {
add: (row) => {
+ this.usageDate = [getDay(0), getDay(14)];
+ let month = getDay(0).slice(5, 7);
+ let day = getDay(0).slice(8, 10);
this.formInline = {
marketId: row.marketId,
shopId: row.shopId,
@@ -214,20 +310,22 @@ export default {
this.modalConfig.title = `添加${row.label}`;
this.$nextTick(() => {
this.modalData = {
- category: "NO_THRESHOLD",
+ category: "MAX_OUT",
receiveType: "MANUAL",
couponType: "MONEY",
isTimeReceive: 1, //0-不限时,1-限时
- name: "",
- useStartTime: "",
- useEndTime: "",
+ name: `满减卷${month}${day}`,
+ useStartTime: getDay(0),
+ useEndTime: getDay(14),
receiveStartTime: "",
receiveEndTime: "",
money: "",
total: 10000,
limitedNum: 0,
minPrice: 0,
- usableRange: "PARTIAL_GOODS", //部分商品-PARTIAL_GOODS 所有商品-ALL_GOODS 部分摊位-PARTIAL_SHOP
+ usableRange: "ALL", //部分商品-PARTIAL_GOODS 所有商品-ALL_GOODS 部分摊位-PARTIAL_SHOP
+ status: 1,
+ targetIds: [],
};
// this.$refs.modal.resetFields();
});
@@ -283,16 +381,18 @@ export default {
type: "primary",
handle: () => {
console.log(this.modalData);
- let data = { ...this.modalData };
- data.targetIds = [data.targetIds];
- console.log(this.modalData, data);
- this.$api.coupon
- .addCoupon({ ...data, ...this.formInline })
- .then((res) => {
- console.log(res);
- this.$emit("queryList");
- this.toggle();
- });
+
+ this.$refs.modalForm.validate((valid) => {
+ if (valid) {
+ this.$api.coupon
+ .addCoupon({ ...this.modalData, ...this.formInline })
+ .then((res) => {
+ console.log(res);
+ this.$emit("queryList");
+ this.toggle();
+ });
+ }
+ });
},
},
];
diff --git a/src/views/modules/coupon/popup/new-powder.vue b/src/views/modules/coupon/popup/new-powder.vue
index e3867f6..5667651 100644
--- a/src/views/modules/coupon/popup/new-powder.vue
+++ b/src/views/modules/coupon/popup/new-powder.vue
@@ -17,7 +17,7 @@
>
-
+
+
+
+
+
+
+
+
@@ -55,7 +89,7 @@
(单位:元)
满
-
+
+
+
减
-
+
+
+
- (单位:元)
-
+
{
+ return time.getTime() < Date.now() - 8.64e7;
+ },
+ },
rules: {
name: [
{
@@ -191,11 +238,32 @@ export default {
},
{ min: 1, max: 10, message: "长度10字符以内", trigger: "blur" },
],
- day: [
+ useStartTime: [
{
required: true,
- message: "请输入领取后有效天数",
- trigger: "blur",
+ message: "请选择使用日期",
+ trigger: ["blur", "change"],
+ },
+ ],
+ receiveStartTime: [
+ {
+ required: true,
+ message: "请选择领取日期",
+ trigger: ["blur", "change"],
+ },
+ ],
+ // day: [
+ // {
+ // required: true,
+ // message: "请输入领取后有效天数",
+ // trigger: "blur",
+ // },
+ // ],
+ minPrice: [
+ {
+ required: true,
+ message: "请输入满减条件",
+ trigger: ["blur", "change"],
},
],
money: [
@@ -222,6 +290,16 @@ export default {
},
};
},
+ watch: {
+ "modalConfig.show"(newVal) {
+ if (!newVal) {
+ //关闭弹窗清空校验
+ this.$refs.modalForm.resetFields();
+ this.collectionDate = [];
+ this.threshold = false;
+ }
+ },
+ },
methods: {
queryTableData(pageNo, pageSize) {},
toggle(e) {
@@ -235,6 +313,9 @@ export default {
}
return {
add: (row) => {
+ this.usageDate = [getDay(0), getDay(14)];
+ let month = getDay(0).slice(5, 7);
+ let day = getDay(0).slice(8, 10);
this.formInline = {
marketId: row.marketId,
shopId: row.shopId,
@@ -245,14 +326,20 @@ export default {
category: "FIRST_ATTENTION",
receiveType: "MANUAL",
couponType: "MONEY",
- isTimeReceive: 0, //0-不限时,1-限时
- name: "",
- day: "7",
+ isTimeReceive: 1, //0-不限时,1-限时
+ name: `新粉优惠卷${month}${day}`,
+ // day: "7",
+ useStartTime: getDay(0),
+ useEndTime: getDay(14),
+ receiveStartTime: "",
+ receiveEndTime: "",
money: "",
total: 10000,
- limitedNum: 0,
+ limitedNum: 1,
minPrice: 0,
- usableRange: "ALL_GOODS", //部分商品-PARTIAL_GOODS 所有商品-ALL_GOODS 部分摊位-PARTIAL_SHOP
+ usableRange: "ALL", //部分商品-PARTIAL_GOODS 所有商品-ALL_GOODS 部分摊位-PARTIAL_SHOP
+ status: 1,
+ targetIds: [],
};
// this.$refs.modal.resetFields();
});
@@ -264,6 +351,24 @@ export default {
};
},
init(row) {},
+ usageDateChange(e) {
+ if (e) {
+ this.modalData.useStartTime = e[0];
+ this.modalData.useEndTime = e[1];
+ } else {
+ this.modalData.useStartTime = "";
+ this.modalData.useEndTime = "";
+ }
+ },
+ collectionDateChange(e) {
+ if (e) {
+ this.modalData.receiveStartTime = e[0];
+ this.modalData.receiveEndTime = e[1];
+ } else {
+ this.modalData.receiveStartTime = "";
+ this.modalData.receiveEndTime = "";
+ }
+ },
changeThreshold(e) {
if (e) {
this.modalData.minPrice = 0;
@@ -288,13 +393,17 @@ export default {
type: "primary",
handle: () => {
console.log(this.modalData);
- this.$api.coupon
- .addCoupon({ ...this.modalData, ...this.formInline })
- .then((res) => {
- console.log(res);
- this.$emit("queryList");
- this.toggle();
- });
+ this.$refs.modalForm.validate((valid) => {
+ if (valid) {
+ this.$api.coupon
+ .addCoupon({ ...this.modalData, ...this.formInline })
+ .then((res) => {
+ console.log(res);
+ this.$emit("queryList");
+ this.toggle();
+ });
+ }
+ });
},
},
];