Jelajahi Sumber

fix(groupPackage):修复有效期字段绑定及验证逻辑- 修改有效期字段名称 effectiveDateValue为 expirationDateList
- 更新相关表单验证规则引用新字段名
- 调整不可用日期类型的判断条件 unavailableDates 为 disableDateType
- 移除不再使用的视频地址列表变量 videoUrlList- 删除冗余的跳过分组验证标记 skipLastGroupValidation- 优化删除自定义日期后的表单重新验证逻辑
- 注释掉冗余的有效期文案赋值逻辑- 清理导入模块中未使用的 Check 图标组件

congxuesong 1 bulan lalu
induk
melakukan
68e21fd58f
1 mengubah file dengan 16 tambahan dan 22 penghapusan
  1. 16 22
      src/views/groupPackageManagement/newGroup.vue

+ 16 - 22
src/views/groupPackageManagement/newGroup.vue

@@ -247,9 +247,9 @@
                 <span class="expiration-label">天内有效</span>
               </div>
             </el-form-item>
-            <el-form-item label="" prop="effectiveDateValue" v-else>
+            <el-form-item label="" prop="expirationDateList" v-else>
               <el-date-picker
-                v-model="storeInfoModel.effectiveDateValue"
+                v-model="storeInfoModel.expirationDateList"
                 type="daterange"
                 value-format="YYYY-MM-DD"
                 range-separator="-"
@@ -448,7 +448,7 @@
  */
 import { ref, reactive, onMounted, watch, nextTick, computed } from "vue";
 import { ElMessage, ElMessageBox } from "element-plus";
-import { Plus, Delete, ArrowDown, ArrowUp, Picture, Check } from "@element-plus/icons-vue";
+import { Plus, Delete, ArrowDown, ArrowUp, Picture } from "@element-plus/icons-vue";
 import {
   saveStoreInfo,
   editStoreInfo,
@@ -666,7 +666,7 @@ const rules = reactive({
       trigger: "blur"
     }
   ],
-  effectiveDateValue: [
+  expirationDateList: [
     {
       required: true,
       validator: (rule: any, value: any, callback: any) => {
@@ -704,7 +704,7 @@ const rules = reactive({
     {
       required: true,
       validator: (rule: any, value: any, callback: any) => {
-        if (storeInfoModel.value.unavailableDates === 1) {
+        if (storeInfoModel.value.disableDateType === 1) {
           if (!value || value.length === 0) {
             callback(new Error("至少需要选择一个星期"));
             return;
@@ -719,7 +719,7 @@ const rules = reactive({
     {
       required: true,
       validator: (rule: any, value: any, callback: any) => {
-        if (storeInfoModel.value.unavailableDates === 1) {
+        if (storeInfoModel.value.disableDateType === 1) {
           if (!value || value.length === 0) {
             callback(new Error("至少需要选择一个节日"));
             return;
@@ -826,7 +826,7 @@ const storeInfoModel = ref<any>({
   // 有效期设置:0-指定天数,1-指定时间段内可用
   effectiveDateType: 0,
   expirationDate: 0,
-  effectiveDateValue: [],
+  expirationDateList: [],
   // 不可用日期设置:0-全部日期可用,1-限制日期,2-自定义不可用日期
   disableDateType: 0,
   // 限制日期 - 星期选择(数组,存储选中的星期值)
@@ -877,8 +877,6 @@ const unavailableDatesList = ref([
   { value: 1, label: "限制日期" },
   { value: 2, label: "自定义不可用日期" }
 ]);
-//图片集合
-const videoUrlList = ref<string[]>([]);
 // 自定义不可用日期列表
 const dates = ref([]);
 
@@ -938,9 +936,6 @@ const visibleGroups = computed(() => {
   return lifeGroupBuyThalis.value.map((group, index) => ({ group, originalIndex: index }));
 });
 
-// 标记是否跳过最后一个分组的验证(用于添加新分组时)
-let skipLastGroupValidation = false;
-
 // ==================== 监听器 ====================
 
 /**
@@ -948,7 +943,7 @@ let skipLastGroupValidation = false;
  * 当切换到自定义不可用日期时,确保至少有一个日期项
  */
 watch(
-  () => storeInfoModel.value.unavailableDates,
+  () => storeInfoModel.value.disableDateType,
   newVal => {
     if (newVal === 2) {
       // 切换到自定义不可用日期时,如果dates为空,则添加一个默认项
@@ -1032,7 +1027,6 @@ onMounted(async () => {
   if (type.value != "add") {
     let res: any = await getStoreDetail({ id: id.value } as any);
     storeInfoModel.value = res.data as any;
-    videoUrlList.value = (res.data as any).businessLicenseAddress || [];
     let imageList: any[] = [];
     handleImageParam((res.data as any).businessLicenseAddress || [], imageList);
     storeInfoModel.value.imageList = imageList;
@@ -1080,14 +1074,14 @@ onMounted(async () => {
       groupCollapsedStates.value = [false];
     }
     // 确保自定义不可用日期字段存在
-    if (storeInfoModel.value.unavailableDates === 2) {
+    if (storeInfoModel.value.disableDateType === 2) {
       if (!dates.value || dates.value.length === 0) {
         dates.value = [null];
       }
     }
   } else {
     // 新增模式下,如果默认选择自定义不可用日期,确保dates至少有一个元素
-    if (storeInfoModel.value.unavailableDates === 2) {
+    if (storeInfoModel.value.disableDateType === 2) {
       if (!dates.value || dates.value.length === 0) {
         dates.value = [null];
       }
@@ -1174,6 +1168,10 @@ const removeDate = (index: number) => {
     return;
   }
   dates.value.splice(index, 1);
+  // 删除日期项后,重新验证表单以清除旧的验证错误
+  nextTick(() => {
+    ruleFormRef.value?.validateField("customUnavailableDates");
+  });
 };
 
 /**
@@ -1303,9 +1301,6 @@ const addGroup = () => {
     }
   }
 
-  // 记录旧分组的数量,用于后续只验证旧分组
-  const oldGroupsCount = lifeGroupBuyThalis.value.length;
-
   // 添加新分组
   lifeGroupBuyThalis.value.push({
     groupName: "",
@@ -1342,7 +1337,6 @@ const addGroup = () => {
             packageFormRef.value?.clearValidate(prop);
           });
         }
-        skipLastGroupValidation = false;
       }, 150);
     });
   });
@@ -1734,9 +1728,9 @@ const packageFormRules = computed(() => {
 const handleSubmit = (type?) => {
   let params: any = { ...storeInfoModel.value };
   if (params.effectiveDateType == 0) {
-    params.couponCompDate = `用户购买${params.expirationDate}天内有效`;
+    // params.couponCompDate = `用户购买${params.expirationDate}天内有效`;
   } else {
-    params.effectiveDateValue = params.effectiveDateValue.join(",");
+    params.expirationDateList = params.expirationDateList.join(",");
   }
   if (params.disableDateType == 1) {
     params.disableDateValue = params.unavailableWeekdays.join(",") + ";" + params.unavailableHolidays.join(",");