|
|
@@ -308,9 +308,9 @@
|
|
|
<el-form-item label="" prop="customUnavailableDates" v-else-if="storeInfoModel.disableDateType == 2">
|
|
|
<div class="date-picker-container">
|
|
|
<el-button :icon="Plus" class="add-date-btn" type="primary" @click="addDate"> 添加日期 </el-button>
|
|
|
- <div v-for="(item, index) in dates" :key="index" class="date-item">
|
|
|
+ <div v-for="(item, index) in storeInfoModel.disableDateList" :key="index" class="date-item">
|
|
|
<el-date-picker
|
|
|
- v-model="dates[index]"
|
|
|
+ v-model="storeInfoModel.disableDateList[index]"
|
|
|
type="daterange"
|
|
|
value-format="YYYY-MM-DD"
|
|
|
range-separator="-"
|
|
|
@@ -326,7 +326,7 @@
|
|
|
size="small"
|
|
|
class="delete-btn"
|
|
|
@click="removeDate(index)"
|
|
|
- v-show="dates.length > 1"
|
|
|
+ v-show="storeInfoModel.disableDateList.length > 1"
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -735,21 +735,21 @@ const rules = reactive({
|
|
|
required: true,
|
|
|
validator: (rule: any, value: any, callback: any) => {
|
|
|
if (storeInfoModel.value.disableDateType === 2) {
|
|
|
- if (!dates.value || dates.value.length === 0) {
|
|
|
+ if (!storeInfoModel.value.disableDateList || storeInfoModel.value.disableDateList.length === 0) {
|
|
|
callback(new Error("至少需要添加一个自定义不可用日期"));
|
|
|
return;
|
|
|
}
|
|
|
const today = new Date();
|
|
|
today.setHours(0, 0, 0, 0);
|
|
|
// 验证每个日期项是否已填写
|
|
|
- for (let i = 0; i < dates.value.length; i++) {
|
|
|
- if (!dates.value[i] || dates.value[i].length !== 2) {
|
|
|
+ for (let i = 0; i < storeInfoModel.value.disableDateList.length; i++) {
|
|
|
+ if (!storeInfoModel.value.disableDateList[i] || storeInfoModel.value.disableDateList[i].length !== 2) {
|
|
|
callback(new Error(`第${i + 1}个日期项未完整填写`));
|
|
|
return;
|
|
|
}
|
|
|
// 验证开始时间和结束时间不能早于当前时间
|
|
|
- const startDate = new Date(dates.value[i][0]);
|
|
|
- const endDate = new Date(dates.value[i][1]);
|
|
|
+ const startDate = new Date(storeInfoModel.value.disableDateList[i][0]);
|
|
|
+ const endDate = new Date(storeInfoModel.value.disableDateList[i][1]);
|
|
|
if (startDate < today) {
|
|
|
callback(new Error(`第${i + 1}个日期项的开始时间不能早于当前时间`));
|
|
|
return;
|
|
|
@@ -833,6 +833,8 @@ const storeInfoModel = ref<any>({
|
|
|
unavailableWeekdays: [],
|
|
|
// 限制日期 - 节日选择(数组,存储选中的节日值)
|
|
|
unavailableHolidays: [],
|
|
|
+ // 自定义不可用日期列表
|
|
|
+ disableDateList: [],
|
|
|
// 预约规则
|
|
|
reservationRules: "",
|
|
|
// 使用规则
|
|
|
@@ -877,8 +879,6 @@ const unavailableDatesList = ref([
|
|
|
{ value: 1, label: "限制日期" },
|
|
|
{ value: 2, label: "自定义不可用日期" }
|
|
|
]);
|
|
|
-// 自定义不可用日期列表
|
|
|
-const dates = ref([]);
|
|
|
|
|
|
// 星期选项列表
|
|
|
const weekdayList = ref([
|
|
|
@@ -946,9 +946,9 @@ watch(
|
|
|
() => storeInfoModel.value.disableDateType,
|
|
|
newVal => {
|
|
|
if (newVal === 2) {
|
|
|
- // 切换到自定义不可用日期时,如果dates为空,则添加一个默认项
|
|
|
- if (!dates.value || dates.value.length === 0) {
|
|
|
- dates.value = [null];
|
|
|
+ // 切换到自定义不可用日期时,如果disableDateList为空,则添加一个默认项
|
|
|
+ if (!storeInfoModel.value.disableDateList || storeInfoModel.value.disableDateList.length === 0) {
|
|
|
+ storeInfoModel.value.disableDateList = [null];
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
@@ -1075,15 +1075,16 @@ onMounted(async () => {
|
|
|
}
|
|
|
// 确保自定义不可用日期字段存在
|
|
|
if (storeInfoModel.value.disableDateType === 2) {
|
|
|
- if (!dates.value || dates.value.length === 0) {
|
|
|
- dates.value = [null];
|
|
|
+ // 后端直接返回 disableDateList 字段,如果为空则初始化为默认值
|
|
|
+ if (!storeInfoModel.value.disableDateList || storeInfoModel.value.disableDateList.length === 0) {
|
|
|
+ storeInfoModel.value.disableDateList = [null];
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- // 新增模式下,如果默认选择自定义不可用日期,确保dates至少有一个元素
|
|
|
+ // 新增模式下,如果默认选择自定义不可用日期,确保disableDateList至少有一个元素
|
|
|
if (storeInfoModel.value.disableDateType === 2) {
|
|
|
- if (!dates.value || dates.value.length === 0) {
|
|
|
- dates.value = [null];
|
|
|
+ if (!storeInfoModel.value.disableDateList || storeInfoModel.value.disableDateList.length === 0) {
|
|
|
+ storeInfoModel.value.disableDateList = [null];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1155,7 +1156,7 @@ const handlePictureCardPreview = (file: any) => {
|
|
|
* 添加自定义不可用日期
|
|
|
*/
|
|
|
const addDate = () => {
|
|
|
- dates.value.push(null);
|
|
|
+ storeInfoModel.value.disableDateList.push(null);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
@@ -1163,11 +1164,11 @@ const addDate = () => {
|
|
|
* @param index 要删除的日期索引
|
|
|
*/
|
|
|
const removeDate = (index: number) => {
|
|
|
- if (dates.value.length <= 1) {
|
|
|
+ if (storeInfoModel.value.disableDateList.length <= 1) {
|
|
|
ElMessage.warning("至少需要保留一个日期项");
|
|
|
return;
|
|
|
}
|
|
|
- dates.value.splice(index, 1);
|
|
|
+ storeInfoModel.value.disableDateList.splice(index, 1);
|
|
|
// 删除日期项后,重新验证表单以清除旧的验证错误
|
|
|
nextTick(() => {
|
|
|
ruleFormRef.value?.validateField("customUnavailableDates");
|
|
|
@@ -1737,7 +1738,7 @@ const handleSubmit = (type?) => {
|
|
|
delete params.unavailableWeekdays;
|
|
|
delete params.unavailableHolidays;
|
|
|
} else if (params.disableDateType == 2) {
|
|
|
- params.disableDateValue = dates.value.map(subArray => subArray.join(",")).join(";");
|
|
|
+ // params.disableDateValue = params.disableDateList.map(subArray => subArray.join(",")).join(";");
|
|
|
}
|
|
|
params.invoiceType = params.invoiceInformation.join(",");
|
|
|
const output = lifeGroupBuyThalis.value.flatMap(group =>
|