+
-
-
+
+
@@ -175,7 +207,7 @@
:max-collapse-tags="3"
collapse-tags
clearable
- style="width: 100%"
+ style="width: 300px"
@change="selectFoodsConfirm"
>
@@ -200,6 +232,7 @@
v-model="form.validDays"
placeholder="请输入有效期"
style="width: 200px"
+ :maxlength="5"
v-if="form.validType == 'fixed'"
input-style="text-align: center;"
@input="validDaysInput"
@@ -229,6 +262,7 @@
placeholder="请输入隔天生效日期"
style="width: 300px"
input-style="text-align: center;"
+ :maxlength="5"
@input="daysToTakeEffectInput"
>
隔
@@ -301,6 +335,7 @@
placeholder="请输入总发放数量"
style="width: 200px"
input-style="text-align: center;"
+ :maxlength="5"
@input="giveNumInput"
>
张
@@ -322,6 +357,7 @@
placeholder="请输入每人限领量"
style="width: 200px"
input-style="text-align: center;"
+ :maxlength="5"
@input="getLimitInput"
>
张
@@ -346,6 +382,7 @@
placeholder="需小于或等于每人限领量"
style="width: 255px"
input-style="text-align: center;"
+ :maxlength="5"
@input="useLimitInput"
>
张/每人1天
@@ -420,12 +457,14 @@
import _ from "lodash";
import { dayjs } from "element-plus";
import { ref, reactive, onMounted } from "vue";
+import { filterNumberInput } from "@/utils";
import { getBranchPage, getProductList, getCategoryList, addCoupon } from "@/api/coupon/index.js";
const shopInfo = ref("");
const dialogVisible = ref(false);
const titleOptions = reactive({
+ name: "优惠券名称",
title: "添加优惠券",
couponTypeList: [
{
@@ -566,7 +605,7 @@ const form = ref({
discountRate: "", // 折扣%
maxDiscountAmount: "", // 可抵扣最大金额 元
useRule: "price_asc", // 使用规则:price_asc-价格低到高,price_desc-高到低
- discountNum: "", // 抵扣数量
+ discountNum: 1, // 抵扣数量
otherCouponShare: 1, // 与其它优惠共享:0-否,1-是
});
@@ -585,7 +624,7 @@ function reset() {
// 自定义校验使用门槛
const fullAmountValidate = (rule, value, callback) => {
- if (form.value.fullAmount <= 0) {
+ if (form.value.fullAmount < 0) {
callback(new Error("请输入使用门槛"));
} else if (form.value.discountAmount <= 0) {
callback(new Error("请输入满减金额"));
@@ -594,7 +633,8 @@ const fullAmountValidate = (rule, value, callback) => {
}
};
const fullAmountValidate2 = (rule, value, callback) => {
- if (form.value.fullAmount <= 0) {
+ console.log(form.value.fullAmount);
+ if (form.value.fullAmount < 0 || form.value.fullAmount === "") {
callback(new Error("请输入使用门槛"));
} else {
callback();
@@ -812,6 +852,7 @@ function show(t, obj = null) {
}
});
let m = titleOptions.couponTypeList.find((item) => item.value == t);
+ titleOptions.name = `${m.label}名称`;
if (obj && obj.id) {
titleOptions.title = `编辑${m.label}`;
@@ -919,6 +960,9 @@ function convertTimeToDate(timeStr, options = {}) {
const time = 500;
const discountNumInput = _.debounce(function (value) {
form.value.discountNum = filterNumberInput(value, true);
+ if (form.value.discountNum == "") {
+ form.value.discountNum = 1;
+ }
}, time);
const discountRateInput = _.debounce(function (value) {
@@ -957,51 +1001,6 @@ const useLimitInput = _.debounce(function (value) {
}
}, time);
-/**
- * 过滤输入,只允许数字和最多两位小数
- * @param {string} value - 输入框当前值
- * @param {boolean} isIntegerOnly - 是否只允许正整数(无小数点),开启时最小值为1
- * @returns {string} 过滤后的合法值
- */
-function filterNumberInput(value, isIntegerOnly = false) {
- // 第一步就过滤所有非数字和非小数点的字符(包括字母)
- let filtered = value.replace(/[^\d.]/g, "");
-
- // 整数模式处理
- if (isIntegerOnly) {
- // 移除所有小数点
- filtered = filtered.replace(/\./g, "");
-
- // 处理前导零
- filtered = filtered.replace(/^0+(\d)/, "$1") || filtered;
-
- // 空值处理(允许临时删除)
- if (filtered === "") {
- return "";
- }
-
- // 最小值限制
- if (filtered === "0" || parseInt(filtered, 10) < 1) {
- return "1";
- }
-
- return filtered;
- }
-
- // 小数模式处理
- const parts = filtered.split(".");
- if (parts.length > 1) {
- filtered = parts[0] + "." + (parts[1].substring(0, 2) || "");
- }
-
- // 处理前导零
- if (filtered.startsWith("0") && filtered.length > 1 && !filtered.startsWith("0.")) {
- filtered = filtered.replace(/^0+(\d)/, "$1");
- }
-
- return filtered;
-}
-
defineExpose({
show,
});
diff --git a/src/views/marketing_center/components/headerCard.vue b/src/views/marketing_center/components/headerCard.vue
index ce69abe..0e2c36c 100644
--- a/src/views/marketing_center/components/headerCard.vue
+++ b/src/views/marketing_center/components/headerCard.vue
@@ -10,7 +10,7 @@