功能:支持待分配预约与首次排班引导
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
|
||||
|
||||
@@ -60,10 +60,21 @@ async function run() {
|
||||
page.data.monthDisplayMode = 'count'
|
||||
const monthDays = definition.buildMonthDays.call(page, {
|
||||
artists: [{ id: 1, name: '员工', shortName: '员', color: '#000' }],
|
||||
daySummaries: []
|
||||
daySummaries: [{ date: dateUtil.formatDate(dateUtil.startOfMonth(page.data.currentDateText)), totalCount: 2, unassignedCount: 1, artistCounts: [] }]
|
||||
})
|
||||
assert.strictEqual(monthDays.length, 42)
|
||||
assert.strictEqual(monthDays.every(item => item.expandedBlocks.length === 0 && item.rowBlocks.length === 0), true)
|
||||
assert.strictEqual(monthDays.some(item => item.artistCounts.some(count => count.artistId === '__unassigned__' && count.count === 1)), true)
|
||||
|
||||
const dayPage = createPage({ currentDateText: '2026-10-12', selectedArtistId: '' })
|
||||
const dayState = dayPage.buildDayView({
|
||||
businessStartTime: '10:00',
|
||||
businessEndTime: '22:00',
|
||||
artists: [{ id: 1, name: '员工', color: '#000' }],
|
||||
appointments: [{ orderItemId: 8, date: '2026-10-12', startTime: '2026-10-12 14:00:00', durationMinutes: 60, artistId: null }]
|
||||
})
|
||||
assert.strictEqual(dayState.dayLanes[0].artistId, '__unassigned__')
|
||||
assert.strictEqual(dayState.dayLanes[0].blocks.length, 1)
|
||||
assert.strictEqual(dayState.unassignedCount, 1)
|
||||
|
||||
const requestPage = createPage({ viewMode: 'day', currentDateText: '2026-10-11' })
|
||||
let calendarRequests = 0
|
||||
|
||||
@@ -28,6 +28,11 @@
|
||||
<text class="chip-count">{{item.rangeCount || 0}}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view wx:if="{{!selectedArtistId && rangeUnassignedCount > 0}}" class="unassigned-notice" bindtap="openNearestUnassigned">
|
||||
<view class="chip-dot unassigned-dot"></view>
|
||||
<text>有 {{rangeUnassignedCount}} 个预约待分配员工</text>
|
||||
<text class="unassigned-link">立即处理 ›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{profilePromptVisible}}" class="profile-prompt-mask">
|
||||
@@ -65,6 +70,10 @@
|
||||
<text class="summary-value">{{pendingCount}}</text>
|
||||
<text class="summary-label">待确认</text>
|
||||
</view>
|
||||
<view class="summary-item card unassigned-summary">
|
||||
<text class="summary-value">{{unassignedCount}}</text>
|
||||
<text class="summary-label">待分配</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<scroll-view class="day-board card" scroll-y>
|
||||
@@ -84,12 +93,12 @@
|
||||
<text class="block-meta">{{block.timeText}} · {{block.productTitle}}</text>
|
||||
<text class="block-status">{{block.statusText}}</text>
|
||||
<view class="block-actions" catchtap="stopTap">
|
||||
<text wx:if="{{block.status === 0}}" data-id="{{block.orderItemId}}" data-status="1" catchtap="quickUpdateStatus">确认</text>
|
||||
<text data-id="{{block.orderItemId}}" catchtap="quickTransfer">改派</text>
|
||||
<text wx:if="{{block.status === 0 && block.assignmentStatus !== 'UNASSIGNED'}}" data-id="{{block.orderItemId}}" data-status="1" catchtap="quickUpdateStatus">确认</text>
|
||||
<text data-id="{{block.orderItemId}}" catchtap="quickTransfer">{{block.assignmentStatus === 'UNASSIGNED' ? '分配' : '改派'}}</text>
|
||||
<text data-id="{{block.orderItemId}}" catchtap="quickCancel">取消</text>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{item.blocks.length === 0}}" class="lane-empty">全天可约</view>
|
||||
<view wx:if="{{item.blocks.length === 0}}" class="lane-empty">{{item.emptyText || '全天可约'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
@@ -236,12 +236,38 @@
|
||||
color: #9a9288;
|
||||
}
|
||||
|
||||
.unassigned-notice {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 14rpx;
|
||||
padding: 14rpx 16rpx;
|
||||
border-radius: 12rpx;
|
||||
background: #fff4e5;
|
||||
color: #8b5e24;
|
||||
font-size: 22rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.unassigned-dot {
|
||||
flex: none;
|
||||
background: #d59a52;
|
||||
}
|
||||
|
||||
.unassigned-link {
|
||||
margin-left: auto;
|
||||
color: #a56b24;
|
||||
}
|
||||
|
||||
.day-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.unassigned-summary .summary-value {
|
||||
color: #c57d27;
|
||||
}
|
||||
|
||||
.summary-item {
|
||||
padding: 16rpx;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user