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

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
+52 -5
View File
@@ -6,6 +6,9 @@ const DEFAULT_EMPLOYEE_PASSWORD = 'Fingertip@123'
Page({
data: {
pickerMode: false,
appointmentContext: { date: '', time: '', durationMinutes: '' },
onboardingVisible: false,
createdEmployee: null,
form: {
nickname: '',
phone: '',
@@ -20,7 +23,14 @@ Page({
},
onLoad(options) {
this.setData({ pickerMode: options && options.picker === '1' })
this.setData({
pickerMode: options && options.picker === '1',
appointmentContext: {
date: options.date || '',
time: options.time || '',
durationMinutes: options.durationMinutes || ''
}
})
},
onInput(event) {
@@ -54,6 +64,9 @@ Page({
this.setData({ 'form.avatar': '', 'form.avatarUrl': '' })
},
stopTouchMove() {
},
async submit() {
const form = this.data.form
const nickname = String(form.nickname || '').trim()
@@ -83,14 +96,48 @@ Page({
})
const id = result && typeof result === 'object' ? (result.id || result.userId) : result
const employee = { id, name: nickname, title: nickname, avatar: form.avatar || '' }
const eventChannel = this.getOpenerEventChannel && this.getOpenerEventChannel()
if (eventChannel && eventChannel.emit) eventChannel.emit('employeeCreated', employee)
wx.showToast({ title: '员工已新增', icon: 'success' })
setTimeout(() => wx.navigateBack(), 450)
this.setData({ createdEmployee: employee, onboardingVisible: true })
} catch (error) {
wx.showToast({ title: error.message || '新增失败', icon: 'none' })
} finally {
this.setData({ creating: false })
}
},
setupFirstSchedule() {
const employee = this.data.createdEmployee
if (!employee || !employee.id) return
const context = this.data.appointmentContext
const query = [
`id=${encodeURIComponent(employee.id)}`,
'onboarding=1',
`source=${this.data.pickerMode ? 'appointment' : 'employees'}`,
`date=${encodeURIComponent(context.date || '')}`,
`time=${encodeURIComponent(context.time || '')}`,
`durationMinutes=${encodeURIComponent(context.durationMinutes || '')}`
]
wx.navigateTo({
url: `/pages/schedule-setting/index?${query.join('&')}`,
success: result => {
result.eventChannel.on('scheduleSaved', () => {
setTimeout(() => this.finishCreated(true, true), 250)
})
}
})
},
skipFirstSchedule() {
this.finishCreated(!this.data.pickerMode, false)
},
finishCreated(autoSelect, scheduleSaved) {
const employee = this.data.createdEmployee
const eventChannel = this.getOpenerEventChannel && this.getOpenerEventChannel()
if (eventChannel && eventChannel.emit) {
eventChannel.emit('employeeCreated', { ...employee, autoSelect, scheduleSaved })
}
this.setData({ onboardingVisible: false })
wx.showToast({ title: scheduleSaved ? '排班已保存' : '员工已新增', icon: 'success' })
setTimeout(() => wx.navigateBack(), 300)
}
})