Ver Fonte

feat(storeDecoration): 添加营业时间跨天显示支持

- 新增 formatTimeRange 方法处理跨天时间段格式化
- 更新正常营业时间展示逻辑,支持次日时间显示
- 更新特殊营业时间展示逻辑,支持次日时间显示
- 优化时间显示文案,增强用户可读性
congxuesong há 2 semanas atrás
pai
commit
7f63093151
1 ficheiros alterados com 13 adições e 2 exclusões
  1. 13 2
      src/views/storeDecoration/businessHours/index.vue

+ 13 - 2
src/views/storeDecoration/businessHours/index.vue

@@ -191,6 +191,16 @@ interface SpecialHoursItem {
 
 const specialHours = ref<SpecialHoursItem[]>([]);
 
+// 格式化时间段(处理跨天场景,例如 15:21-次日00:21)
+const formatTimeRange = (startTime?: string, endTime?: string) => {
+  if (!startTime || !endTime) return "";
+  // 时间格式为 HH:mm,可以直接按字符串比较
+  if (endTime <= startTime) {
+    return `${startTime}-次日${endTime}`;
+  }
+  return `${startTime}-${endTime}`;
+};
+
 // 正常营业时间对话框
 const normalDialogVisible = ref(false);
 const normalEditIndex = ref<number | null>(null);
@@ -235,7 +245,7 @@ const formatNormalHours = (item: NormalHoursItem) => {
   if (item.timeType === "24hours") {
     return `${dayLabels} 24小时`;
   }
-  return `${dayLabels} ${item.startTime}-${item.endTime}`;
+  return `${dayLabels} ${formatTimeRange(item.startTime, item.endTime)}`;
 };
 
 // 格式化特殊营业时间显示
@@ -244,7 +254,7 @@ const formatSpecialHours = (item: SpecialHoursItem) => {
   if (item.timeType === "24hours") {
     return `${holidayLabels} 24小时`;
   }
-  return `${holidayLabels} ${item.startTime}-${item.endTime}`;
+  return `${holidayLabels} ${formatTimeRange(item.startTime, item.endTime)}`;
 };
 
 // 切换选择日期
@@ -631,6 +641,7 @@ const handleSave = async () => {
 .business-hours-container {
   display: flex;
   flex-direction: column;
+
   //min-height: 100vh;
   height: 100%;
   padding: 20px;