|
|
@@ -108,7 +108,7 @@ import { ElMessage } from "element-plus";
|
|
|
import { useRoute, useRouter } from "vue-router";
|
|
|
import type { FormInstance } from "element-plus";
|
|
|
import { getCouponDetail, addDiscountCoupon, editDiscountCoupon } from "@/api/modules/couponManagement";
|
|
|
-import { validatePositiveNumber, validatePositiveInteger, validateDateRange } from "@/utils/eleValidate";
|
|
|
+import { validatePositiveNumber, validatePositiveInteger, validateDateRange, validatePriceFormat } from "@/utils/eleValidate";
|
|
|
import { localGet } from "@/utils";
|
|
|
import { getVoucherDetail } from "@/api/modules/voucherManagement";
|
|
|
// ==================== 响应式数据定义 ====================
|
|
|
@@ -175,28 +175,7 @@ const rules = reactive({
|
|
|
minimumSpendingAmount: [
|
|
|
{ required: true, message: "请输入最低消费金额" },
|
|
|
{
|
|
|
- validator: (rule: any, value: any, callback: any) => {
|
|
|
- if (couponModel.value.hasMinimumSpend === 1) {
|
|
|
- if (!value || value.toString().trim() === "") {
|
|
|
- callback(new Error("请输入最低消费金额"));
|
|
|
- return;
|
|
|
- }
|
|
|
- const strValue = value.toString().trim();
|
|
|
- // 检查是否以小数点开头(如 ".1")
|
|
|
- if (strValue.startsWith(".")) {
|
|
|
- callback(new Error("最低消费金额格式不正确"));
|
|
|
- return;
|
|
|
- }
|
|
|
- // 检查是否有前导零(除了单独的"0"或"0."开头的小数)
|
|
|
- if (strValue.length > 1 && strValue.startsWith("0") && strValue !== "0" && !strValue.startsWith("0.")) {
|
|
|
- callback(new Error("最低消费金额必须为正数"));
|
|
|
- return;
|
|
|
- }
|
|
|
- validatePositiveNumber("最低消费金额必须为正数")(rule, value, callback);
|
|
|
- } else {
|
|
|
- callback();
|
|
|
- }
|
|
|
- },
|
|
|
+ validator: validatePriceFormat("整数部分最多6位,小数部分最多2位"),
|
|
|
trigger: "blur"
|
|
|
}
|
|
|
]
|
|
|
@@ -296,23 +275,6 @@ watch(
|
|
|
}
|
|
|
);
|
|
|
|
|
|
-/**
|
|
|
- * 监听最低消费金额变化
|
|
|
- * 当最低消费金额大于0时,自动设置为"是",否则设置为"否"
|
|
|
- */
|
|
|
-// watch(
|
|
|
-// () => couponModel.value.minimumSpendingAmount,
|
|
|
-// newVal => {
|
|
|
-// if (isInitializing.value) return;
|
|
|
-// const amount = Number(newVal);
|
|
|
-// if (!isNaN(amount) && amount > 0) {
|
|
|
-// couponModel.value.hasMinimumSpend = 1;
|
|
|
-// } else {
|
|
|
-// couponModel.value.hasMinimumSpend = 0;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// );
|
|
|
-
|
|
|
// ==================== 事件处理函数 ====================
|
|
|
/**
|
|
|
* 组件挂载时初始化
|