b5df6609
“wangming”
```
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
import {
apiStatusToUi,
buildYysjTimestampRange,
dateTimeToSlotRange,
formatDateYMD,
formatTimeHM,
pickRowField
} from '@/utils/appointmentHelper'
const STATUS_COLORS = ['blue', 'orange', 'green', 'purple', 'teal']
export function mapStoreScheduleItem(item, colorIndex = 0) {
const yysj = pickRowField(item, 'yysj', 'Yysj')
const yyjs = pickRowField(item, 'yyjs', 'Yyjs')
const date = formatDateYMD(yysj)
const startTime = formatTimeHM(yysj)
const endTime = formatTimeHM(yyjs || yysj)
const fStatus = pickRowField(item, 'F_Status', 'f_Status')
const status = apiStatusToUi(fStatus)
const therapistIds = Array.isArray(item.therapistIds) ? item.therapistIds.filter(Boolean) : []
const therapistNames = Array.isArray(item.therapistNames) ? item.therapistNames.filter(Boolean) : []
const itemLabels = Array.isArray(item.itemLabels) ? item.itemLabels : []
return {
id: pickRowField(item, 'id', 'Id'),
memberId: pickRowField(item, 'gk', 'Gk'),
memberName: pickRowField(item, 'gkxm', 'Gkxm') || '无',
date,
startTime,
endTime,
roomId: pickRowField(item, 'roomId', 'RoomId') || '',
roomName: pickRowField(item, 'roomName', 'RoomName') || '',
therapistIds,
therapistNames,
status,
fStatus,
remark: pickRowField(item, 'remark', 'Remark') || '',
itemLabels,
items: [],
colorKey: STATUS_COLORS[colorIndex % STATUS_COLORS.length]
}
}
export function buildWeekRangeTimestamps(weekStart) {
if (!weekStart) return ''
const start = new Date(weekStart)
const end = new Date(start)
end.setDate(end.getDate() + 6)
end.setHours(23, 59, 59, 999)
return buildYysjTimestampRange(start, end)
}
export function toSlotIndex(timeStr) {
if (!timeStr) return null
const [h, m] = String(timeStr).split(':').map(Number)
if (Number.isNaN(h) || Number.isNaN(m)) return null
return h * 2 + (m >= 30 ? 1 : 0)
}
export function slotIndexToTime(slotIndex) {
const h = Math.floor(slotIndex / 2)
const m = (slotIndex % 2) * 30
return `${String(h).padStart(2, '0')}:${m === 0 ? '00' : '30'}`
}
export function attachSlotRange(booking) {
const range = dateTimeToSlotRange(
`${booking.date} ${booking.startTime}`,
`${booking.date} ${booking.endTime}`
)
const slotStart = range ? range.startSlot : toSlotIndex(booking.startTime)
const slotEnd = range ? range.endSlot : (toSlotIndex(booking.endTime) || (slotStart != null ? slotStart + 2 : 0))
return {
...booking,
slotStart: slotStart == null ? 0 : slotStart,
slotEnd: slotEnd == null ? 0 : slotEnd
}
}
/** 考勤日状态 → 排班格人事状态 */
export function mapAttendanceDayToScheduleStatus(dayItem) {
if (!dayItem) return { type: 'normal', text: '正常' }
const text = (dayItem.statusText || '').trim()
const key = (dayItem.statusKey || '').trim()
if (text.includes('请假') || text.includes('病假') || key === 'leave') {
return { type: 'leave', text: text || '请假' }
}
if (text.includes('休息') || text.includes('休假') || key === 'rest') {
return { type: 'vacation', text: text || '休息' }
}
return { type: 'normal', text: text || '正常' }
}
|