feat: 完成营业时间模块拆分并补充页面注释规范

This commit is contained in:
2026-02-16 09:59:44 +08:00
parent 4be997df63
commit 14857549ba
31 changed files with 3726 additions and 1 deletions

View File

@@ -0,0 +1,127 @@
import { requestClient } from '#/api/request';
// ========== 枚举 ==========
/** 时段类型 */
export enum SlotType {
/** 营业 */
Business = 1,
/** 配送 */
Delivery = 2,
/** 自提 */
Pickup = 3,
}
/** 特殊日期类型 */
export enum HolidayType {
/** 休息 */
Closed = 1,
/** 特殊营业 */
Special = 2,
}
// ========== DTO ==========
/** 时段 */
export interface TimeSlotDto {
id: string;
/** 时段类型 */
type: SlotType;
/** 开始时间 HH:mm */
startTime: string;
/** 结束时间 HH:mm */
endTime: string;
/** 容量上限(配送类型) */
capacity?: number;
/** 备注 */
remark?: string;
}
/** 每日营业时间 */
export interface DayHoursDto {
/** 星期几 0=周一 6=周日 */
dayOfWeek: number;
/** 是否营业 */
isOpen: boolean;
/** 时段列表 */
slots: TimeSlotDto[];
}
/** 特殊日期 */
export interface HolidayDto {
id: string;
/** 开始日期 */
startDate: string;
/** 结束日期(单日时与 startDate 相同) */
endDate: string;
/** 类型 */
type: HolidayType;
/** 营业开始时间(特殊营业) */
startTime?: string;
/** 营业结束时间(特殊营业) */
endTime?: string;
/** 原因 */
reason: string;
/** 备注 */
remark?: string;
}
/** 门店营业时间聚合 */
export interface StoreHoursDto {
storeId: string;
weeklyHours: DayHoursDto[];
holidays: HolidayDto[];
}
/** 保存每周时段参数 */
export interface SaveWeeklyHoursParams {
storeId: string;
weeklyHours: DayHoursDto[];
}
/** 保存特殊日期参数 */
export interface SaveHolidayParams {
storeId: string;
holiday: Omit<HolidayDto, 'id'> & { id?: string };
}
/** 复制营业时间参数 */
export interface CopyStoreHoursParams {
/** 源门店ID */
sourceStoreId: string;
/** 目标门店ID列表 */
targetStoreIds: string[];
/** 是否包含每周营业时间 */
includeWeeklyHours?: boolean;
/** 是否包含特殊日期 */
includeHolidays?: boolean;
}
// ========== API ==========
/** 获取门店营业时间 */
export async function getStoreHoursApi(storeId: string) {
return requestClient.get<StoreHoursDto>('/store/hours', {
params: { storeId },
});
}
/** 保存每周营业时间 */
export async function saveWeeklyHoursApi(data: SaveWeeklyHoursParams) {
return requestClient.post('/store/hours/weekly', data);
}
/** 保存特殊日期 */
export async function saveHolidayApi(data: SaveHolidayParams) {
return requestClient.post('/store/hours/holiday', data);
}
/** 删除特殊日期 */
export async function deleteHolidayApi(id: string) {
return requestClient.post('/store/hours/holiday/delete', { id });
}
/** 复制营业时间到其他门店 */
export async function copyStoreHoursApi(data: CopyStoreHoursParams) {
return requestClient.post('/store/hours/copy', data);
}