功能:支持待分配预约与首次排班引导
This commit is contained in:
@@ -84,6 +84,9 @@ Page({
|
||||
dayTotal: 0,
|
||||
freeArtistCount: 0,
|
||||
pendingCount: 0,
|
||||
unassignedCount: 0,
|
||||
rangeUnassignedCount: 0,
|
||||
nearestUnassignedDate: '',
|
||||
canCreateAppointment: true,
|
||||
loading: false,
|
||||
calendarError: '',
|
||||
@@ -327,7 +330,10 @@ Page({
|
||||
hours: [],
|
||||
dayTotal: 0,
|
||||
freeArtistCount: 0,
|
||||
pendingCount: 0
|
||||
pendingCount: 0,
|
||||
unassignedCount: 0,
|
||||
rangeUnassignedCount: 0,
|
||||
nearestUnassignedDate: ''
|
||||
})
|
||||
},
|
||||
|
||||
@@ -362,6 +368,8 @@ Page({
|
||||
businessEndTime: snapshot.businessEndTime,
|
||||
artists: snapshot.artists,
|
||||
calendarError: '',
|
||||
rangeUnassignedCount: snapshot.appointments.filter(item => !item.artistId).length,
|
||||
nearestUnassignedDate: this.findNearestUnassignedDate(snapshot.appointments),
|
||||
...this.buildViewState(snapshot)
|
||||
})
|
||||
},
|
||||
@@ -411,11 +419,16 @@ Page({
|
||||
}))
|
||||
return dateUtil.monthGrid(this.data.currentDateText).map(day => {
|
||||
const summary = summaryMap[day.date] || {}
|
||||
const artistCounts = this.normalizeArtistCounts(summary.artistCounts || artistTemplate, calendar)
|
||||
const unassignedCount = Number(summary.unassignedCount || 0)
|
||||
const artistCounts = this.withUnassignedCount(
|
||||
this.normalizeArtistCounts(summary.artistCounts || artistTemplate, calendar),
|
||||
unassignedCount
|
||||
)
|
||||
return {
|
||||
...day,
|
||||
isPast: day.date < todayText,
|
||||
totalCount: summary.totalCount || 0,
|
||||
unassignedCount,
|
||||
dayStatus: summary.dayStatus || 'free',
|
||||
artistCounts,
|
||||
expandedBlocks: this.data.monthDisplayMode === 'blocks' ? this.buildExpandedBlocks(artistCounts) : [],
|
||||
@@ -431,12 +444,17 @@ Page({
|
||||
const target = dateUtil.addDays(start, index)
|
||||
const date = dateUtil.formatDate(target)
|
||||
const summary = summaryMap[date] || { artistCounts: [], totalCount: 0 }
|
||||
const artistCounts = this.normalizeArtistCounts(summary.artistCounts || [], calendar).filter(count => count.count > 0)
|
||||
const unassignedCount = Number(summary.unassignedCount || 0)
|
||||
const artistCounts = this.withUnassignedCount(
|
||||
this.normalizeArtistCounts(summary.artistCounts || [], calendar),
|
||||
unassignedCount
|
||||
).filter(count => count.count > 0)
|
||||
return {
|
||||
date,
|
||||
weekName: `周${label}`,
|
||||
day: target.getDate(),
|
||||
totalCount: summary.totalCount || 0,
|
||||
unassignedCount,
|
||||
artistCounts: artistCounts.map(count => ({
|
||||
...count,
|
||||
width: Math.max(12, Math.min(100, count.count * 22)),
|
||||
@@ -463,7 +481,7 @@ Page({
|
||||
? (calendar.artists || []).filter(item => String(item.id) === String(this.data.selectedArtistId))
|
||||
: (calendar.artists || [])
|
||||
const dayAppointments = (calendar.appointments || []).filter(item => resolveAppointmentDate(item) === this.data.currentDateText)
|
||||
const lanes = filteredArtists.map(artist => {
|
||||
const employeeLanes = filteredArtists.map(artist => {
|
||||
const blocks = dayAppointments
|
||||
.filter(item => String(item.artistId) === String(artist.id))
|
||||
.map(item => {
|
||||
@@ -475,8 +493,27 @@ Page({
|
||||
timeText: resolveAppointmentTimeText(item)
|
||||
}
|
||||
})
|
||||
return { ...artist, blocks }
|
||||
return { ...artist, artistId: artist.id, blocks }
|
||||
})
|
||||
const unassignedBlocks = dayAppointments
|
||||
.filter(item => !item.artistId)
|
||||
.map(item => {
|
||||
const itemStart = resolveAppointmentStartMinute(item)
|
||||
return {
|
||||
...item,
|
||||
top: Math.max(0, itemStart - startMinute) + laneHeaderHeight,
|
||||
height: Math.max(64, item.durationMinutes || 60),
|
||||
timeText: resolveAppointmentTimeText(item)
|
||||
}
|
||||
})
|
||||
const lanes = this.data.selectedArtistId ? employeeLanes : [{
|
||||
id: '__unassigned__',
|
||||
artistId: '__unassigned__',
|
||||
name: '待分配',
|
||||
color: '#D59A52',
|
||||
blocks: unassignedBlocks,
|
||||
emptyText: '暂无待分配'
|
||||
}, ...employeeLanes]
|
||||
const pendingCount = dayAppointments.filter(item => item.status === 0).length
|
||||
return {
|
||||
dayLanes: lanes,
|
||||
@@ -486,11 +523,48 @@ Page({
|
||||
laneItemWidth: 248,
|
||||
laneWidth: Math.max(720, lanes.length * 248),
|
||||
dayTotal: dayAppointments.length,
|
||||
freeArtistCount: lanes.filter(item => item.blocks.length === 0).length,
|
||||
pendingCount
|
||||
freeArtistCount: employeeLanes.filter(item => item.blocks.length === 0).length,
|
||||
pendingCount,
|
||||
unassignedCount: unassignedBlocks.length
|
||||
}
|
||||
},
|
||||
|
||||
withUnassignedCount(artistCounts, unassignedCount) {
|
||||
if (!unassignedCount) return artistCounts
|
||||
return [{
|
||||
artistId: '__unassigned__',
|
||||
artistName: '待分配',
|
||||
shortName: '待',
|
||||
color: '#D59A52',
|
||||
count: unassignedCount,
|
||||
status: 'pending'
|
||||
}, ...(artistCounts || [])]
|
||||
},
|
||||
|
||||
findNearestUnassignedDate(appointments) {
|
||||
const dates = (appointments || [])
|
||||
.filter(item => !item.artistId)
|
||||
.map(resolveAppointmentDate)
|
||||
.filter(Boolean)
|
||||
.sort()
|
||||
if (!dates.length) return ''
|
||||
const today = dateUtil.formatDate(new Date())
|
||||
return dates.find(date => date >= today) || dates[0]
|
||||
},
|
||||
|
||||
openNearestUnassigned() {
|
||||
if (!this.data.nearestUnassignedDate) return
|
||||
const target = this.data.nearestUnassignedDate
|
||||
this.setData({
|
||||
viewMode: 'day',
|
||||
currentDate: toLocalDate(target),
|
||||
currentDateText: target,
|
||||
selectedArtistId: '',
|
||||
selectedArtistName: '全部员工'
|
||||
})
|
||||
this.loadCalendar()
|
||||
},
|
||||
|
||||
summaryMap(calendar) {
|
||||
return (calendar.daySummaries || []).reduce((map, item) => {
|
||||
map[item.date] = item
|
||||
|
||||
Reference in New Issue
Block a user