Jelajahi Sumber

feat(duty): update frontend API types for dict and time fields

Co-authored-by: Cursor <cursoragent@cursor.com>
zlwu 2 bulan lalu
induk
melakukan
a98ec0443a
2 mengubah file dengan 31 tambahan dan 5 penghapusan
  1. 23 2
      web-admin/src/api/duty.ts
  2. 8 3
      web-admin/src/api/public-duty.ts

+ 23 - 2
web-admin/src/api/duty.ts

@@ -1,6 +1,7 @@
 import request from '@/utils/http'
 
-export type ShiftType = 'morning' | 'evening' | 'duty'
+/** 预置 morning|evening|duty,亦可为自定义 dict_value */
+export type ShiftType = string
 export type LinkStatus = 'open' | 'closed'
 
 export interface DutyAssignmentItem {
@@ -16,8 +17,14 @@ export interface DutySlotItem {
   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[]
 }
 
@@ -49,7 +56,11 @@ export function saveDutyDay(data: {
   slots: Array<{
     shiftType: ShiftType
     capacity: number
+    workPlans?: string[]
     remark?: string | null
+    startTime?: string | null
+    endTime?: string | null
+    crossDay?: boolean
     assignments: DutyAssignmentItem[]
   }>
   linkStatus?: LinkStatus
@@ -78,3 +89,13 @@ export function fetchDutyUserOptions() {
     url: '/web/admin/duty/users/options'
   })
 }
+
+export function ensureDutyDict(data: {
+  dictType: 'duty_shift_type' | 'duty_work_plan'
+  label: string
+}) {
+  return request.post<{ label: string; value: string }>({
+    url: '/web/admin/duty/dict/ensure',
+    data
+  })
+}

+ 8 - 3
web-admin/src/api/public-duty.ts

@@ -1,5 +1,4 @@
 import { publicPlGet, publicPlPost } from '@/utils/http/public-pl'
-import type { ShiftType } from '@/api/duty'
 
 export interface PublicDutyUserOption {
   id: string
@@ -8,11 +7,17 @@ export interface PublicDutyUserOption {
 
 export interface PublicDutySlot {
   id?: string
-  shiftType: ShiftType
+  shiftType: string
   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: Array<{ id?: string; source: string; personName: string; userId?: string }>
 }
 
@@ -26,7 +31,7 @@ export interface PublicDutyPage {
 
 export interface PublicDutyGrabResult {
   dutyDate: string
-  shiftType: ShiftType
+  shiftType: string
   shiftLabel: string
   personName: string
   userId?: string