支持跨天预约并新增员工全天排班SQL

This commit is contained in:
2026-07-22 12:21:26 +08:00
parent 0b33d72a1f
commit 73319a1613
17 changed files with 800 additions and 130 deletions
@@ -280,8 +280,8 @@ import type { Appointment, AppointmentForm, Artist, PlanningCalendar, Product }
import type { UserInfo } from '@/types/common'
import { useSessionStore } from '@/stores/session'
import { useToastStore } from '@/stores/toast'
import { formatDate, minutesOfDay, timeFromMinutes } from '@/utils/date'
import { buildAvailableTimeGroups, type AvailableTimeGroup } from '@/utils/available-times'
import { formatDate } from '@/utils/date'
import { buildAvailableTimeGroups, resolveAppointmentCalendarEndDate, type AvailableTimeGroup } from '@/utils/available-times'
import {
buildCustomerCreateDraft,
buildCustomerSearchText,
@@ -1005,7 +1005,11 @@ const refreshAvailableTimes = async (): Promise<void> => {
}
timeLoading.value = true
try {
const calendar = withoutCurrentAppointment(await managerPlanningApi.calendar({ startDate: form.appointmentDate, endDate: form.appointmentDate, artistId: form.artistId }))
const calendar = withoutCurrentAppointment(await managerPlanningApi.calendar({
startDate: form.appointmentDate,
endDate: resolveAppointmentCalendarEndDate(form),
artistId: form.artistId
}))
availableTimeGroups.value = buildAvailableTimeGroups(calendar, form)
timeSelectTip.value = availableTimeGroups.value.length > 0 ? '请选择预约时间' : '当前美甲师当天暂无可约时间'
} finally {
@@ -1033,23 +1037,25 @@ const checkAvailability = async (): Promise<{ ok: boolean; tip?: string }> => {
conflictTip.value = ''
return { ok: true }
}
const startMinute = minutesOfDay(form.appointmentTime)
const endMinute = startMinute + normalizeDuration(form.durationMinutes)
const calendar = withoutCurrentAppointment(await managerPlanningApi.calendar({ startDate: form.appointmentDate, endDate: form.appointmentDate, artistId: form.artistId }))
const calendar = withoutCurrentAppointment(await managerPlanningApi.calendar({
startDate: form.appointmentDate,
endDate: resolveAppointmentCalendarEndDate(form),
artistId: form.artistId
}))
const daySummary = (calendar.daySummaries || []).find(item => item.date === form.appointmentDate)
const businessStartTime = String(daySummary?.businessStartTime || calendar.businessStartTime || '10:00').slice(0, 5)
const businessEndTime = String(daySummary?.businessEndTime || calendar.businessEndTime || '22:00').slice(0, 5)
if (daySummary?.dayStatus === 'rest') {
conflictTip.value = '当前日期为店铺休息日'
conflictLevel.value = 'danger'
return { ok: false, tip: conflictTip.value }
}
if (startMinute < minutesOfDay(businessStartTime) || endMinute > minutesOfDay(businessEndTime)) {
conflictTip.value = `该时间超出营业时间 ${businessStartTime}-${businessEndTime}`
const availableGroups = buildAvailableTimeGroups(calendar, form)
const selectedTime = availableGroups.flatMap(group => group.times).find(item => item.value === form.appointmentTime)
if (!selectedTime) {
conflictTip.value = '当前时间不可预约,请重新选择可约时间'
conflictLevel.value = 'danger'
return { ok: false, tip: conflictTip.value }
}
conflictTip.value = `当前时段 ${form.appointmentTime}-${timeFromMinutes(endMinute)} 可预约`
conflictTip.value = `当前时段 ${selectedTime.rangeText} 可预约`
conflictLevel.value = 'free'
return { ok: true, tip: conflictTip.value }
}