|
|
@@ -269,6 +269,11 @@ const toggleHoliday = (holiday: string) => {
|
|
|
|
|
|
// 打开添加正常营业时间对话框
|
|
|
const openAddNormalDialog = () => {
|
|
|
+ // 检查是否已有正常营业时间(添加时检查,编辑时不检查)
|
|
|
+ if (normalHours.value.length > 0) {
|
|
|
+ ElMessage.warning("已有正常营业时间");
|
|
|
+ return;
|
|
|
+ }
|
|
|
normalEditIndex.value = null;
|
|
|
resetNormalForm();
|
|
|
normalDialogVisible.value = true;
|
|
|
@@ -345,6 +350,11 @@ const confirmNormalHours = () => {
|
|
|
|
|
|
// 打开添加特殊营业时间对话框
|
|
|
const openAddSpecialDialog = () => {
|
|
|
+ // 检查是否已有5个特殊营业时间(添加时检查,编辑时不检查)
|
|
|
+ if (specialHours.value.length >= 5) {
|
|
|
+ ElMessage.warning("最多添加5个特殊营业时间");
|
|
|
+ return;
|
|
|
+ }
|
|
|
specialEditIndex.value = null;
|
|
|
resetSpecialForm();
|
|
|
specialDialogVisible.value = true;
|
|
|
@@ -383,6 +393,23 @@ const resetSpecialForm = () => {
|
|
|
specialEditIndex.value = null;
|
|
|
};
|
|
|
|
|
|
+// 检查特殊营业时间日期是否重复
|
|
|
+const checkDateDuplicate = (holidays: string[]): boolean => {
|
|
|
+ // 过滤出其他特殊营业时间(排除当前编辑的项)
|
|
|
+ const otherSpecialHours = specialHours.value.filter((item, index) => index !== specialEditIndex.value);
|
|
|
+
|
|
|
+ // 检查新添加/编辑的特殊营业时间的日期是否与其他特殊营业时间的日期有重复
|
|
|
+ for (let i = 0; i < otherSpecialHours.length; i++) {
|
|
|
+ const item = otherSpecialHours[i];
|
|
|
+ // 检查是否有任何节假日重复
|
|
|
+ if (holidays.some(holiday => item.holidays.includes(holiday))) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+};
|
|
|
+
|
|
|
// 确认特殊营业时间
|
|
|
const confirmSpecialHours = () => {
|
|
|
if (specialForm.selectedHolidays.length === 0) {
|
|
|
@@ -394,6 +421,12 @@ const confirmSpecialHours = () => {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // 检查日期是否重复
|
|
|
+ if (checkDateDuplicate(specialForm.selectedHolidays)) {
|
|
|
+ ElMessage.warning("特殊营业时间的日期不能重复");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
const newItem: SpecialHoursItem = {
|
|
|
holidays: [...specialForm.selectedHolidays],
|
|
|
timeType: specialForm.timeType,
|