功能:支持待分配预约与首次排班引导

This commit is contained in:
2026-10-12 23:52:20 +08:00
parent 59608ef57f
commit 3ab615ccd4
26 changed files with 816 additions and 82 deletions
+32 -6
View File
@@ -13,15 +13,38 @@ Page({
artistKeyword: '',
date: dateUtil.formatDate(new Date()),
time: '13:00',
durationMinutes: '',
isUnassigned: false,
loadError: '',
loading: false
},
onLoad(options) {
async onLoad(options) {
this.setData({
id: options.id || ''
})
this.loadArtists()
const loaded = await this.loadAppointment()
if (!loaded) return
await this.loadArtists()
},
async loadAppointment() {
if (!this.data.id) return false
try {
const appointment = await planningApi.appointment(this.data.id)
const startTime = String(appointment.startTime || '')
this.setData({
date: appointment.date || startTime.slice(0, 10) || this.data.date,
time: startTime.slice(11, 16) || this.data.time,
durationMinutes: appointment.durationMinutes || '',
isUnassigned: appointment.assignmentStatus === 'UNASSIGNED' || !appointment.artistId,
loadError: ''
})
return true
} catch (error) {
this.setData({ loadError: error.message || '预约详情加载失败' })
return false
}
},
async loadArtists(preferredArtistId, fallbackEmployee) {
@@ -96,9 +119,11 @@ Page({
addEmployeeFromSelector() {
this.setData({ artistSheetVisible: false })
wx.navigateTo({
url: '/pages/employee-create/index?picker=1',
url: `/pages/employee-create/index?picker=1&date=${encodeURIComponent(this.data.date || '')}&time=${encodeURIComponent(this.data.time || '')}&durationMinutes=${encodeURIComponent(this.data.durationMinutes || '')}`,
success: result => {
result.eventChannel.on('employeeCreated', employee => this.loadArtists(employee.id, employee))
result.eventChannel.on('employeeCreated', employee => {
this.loadArtists(employee.autoSelect === false ? '' : employee.id, employee)
})
}
})
},
@@ -122,10 +147,11 @@ Page({
await planningApi.moveAppointment(this.data.id, {
artistId: Number(this.data.selectedArtistId),
appointmentDate: this.data.date,
appointmentTime: this.data.time
appointmentTime: this.data.time,
durationMinutes: Number(this.data.durationMinutes) || undefined
})
markPlanningRefresh()
wx.showToast({ title: '已改派' })
wx.showToast({ title: this.data.isUnassigned ? '已分配' : '已改派' })
setTimeout(() => wx.navigateBack(), 500)
} catch (error) {
wx.showToast({ title: error.message || '改派失败', icon: 'none' })