Add duty_time_range dictionary with day/night presets, parse typed ranges on ensure, and replace time pickers with allow-create select in the schedule dialog. Co-authored-by: Cursor <cursoragent@cursor.com>
103 lines
2.3 KiB
TypeScript
103 lines
2.3 KiB
TypeScript
import request from '@/utils/http'
|
|
|
|
/** 预置 morning|evening|duty,亦可为自定义 dict_value */
|
|
export type ShiftType = string
|
|
export type LinkStatus = 'open' | 'closed'
|
|
|
|
export interface DutyAssignmentItem {
|
|
id?: string
|
|
source: 'assign' | 'grab'
|
|
userId?: string | null
|
|
personName: string
|
|
}
|
|
|
|
export interface DutySlotItem {
|
|
id?: string
|
|
shiftType: ShiftType
|
|
shiftLabel?: string
|
|
capacity: number
|
|
taken?: number
|
|
workPlans?: string[]
|
|
workPlanLabels?: string[]
|
|
/** 备注(与工作安排分离) */
|
|
remark?: string | null
|
|
startTime?: string | null
|
|
endTime?: string | null
|
|
crossDay?: boolean
|
|
timeLabel?: string | null
|
|
assignments: DutyAssignmentItem[]
|
|
}
|
|
|
|
export interface DutyDayItem {
|
|
id?: string | null
|
|
dutyDate: string
|
|
linkStatus: LinkStatus
|
|
accessToken?: string | null
|
|
publicUrl?: string | null
|
|
slots: DutySlotItem[]
|
|
}
|
|
|
|
export function fetchDutyMonth(year: number, month: number) {
|
|
return request.get<DutyDayItem[]>({
|
|
url: '/web/admin/duty',
|
|
params: { year, month }
|
|
})
|
|
}
|
|
|
|
export function fetchDutyDay(dutyDate: string) {
|
|
return request.get<DutyDayItem>({
|
|
url: '/web/admin/duty/day',
|
|
params: { dutyDate }
|
|
})
|
|
}
|
|
|
|
export function saveDutyDay(data: {
|
|
dutyDate: string
|
|
slots: Array<{
|
|
shiftType: ShiftType
|
|
capacity: number
|
|
workPlans?: string[]
|
|
remark?: string | null
|
|
startTime?: string | null
|
|
endTime?: string | null
|
|
crossDay?: boolean
|
|
assignments: DutyAssignmentItem[]
|
|
}>
|
|
linkStatus?: LinkStatus
|
|
}) {
|
|
return request.post<DutyDayItem>({
|
|
url: '/web/admin/duty/day',
|
|
data
|
|
})
|
|
}
|
|
|
|
export function setDutyLinkStatus(dayId: string, linkStatus: LinkStatus) {
|
|
return request.post<DutyDayItem>({
|
|
url: `/web/admin/duty/day/${dayId}/link`,
|
|
data: { linkStatus }
|
|
})
|
|
}
|
|
|
|
export function deleteDutyAssignment(id: string) {
|
|
return request.delete({
|
|
url: `/web/admin/duty/assignments/${id}`
|
|
})
|
|
}
|
|
|
|
export function fetchDutyUserOptions() {
|
|
return request.get<Array<{ label: string; value: string }>>({
|
|
url: '/web/admin/duty/users/options'
|
|
})
|
|
}
|
|
|
|
export function ensureDutyDict(data: {
|
|
dictType: 'duty_shift_type' | 'duty_work_plan' | 'duty_time_range'
|
|
label: string
|
|
preferredValue?: string
|
|
}) {
|
|
return request.post<{ label: string; value: string }>({
|
|
url: '/web/admin/duty/dict/ensure',
|
|
data
|
|
})
|
|
}
|