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

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
@@ -68,6 +68,9 @@ function buildExceptionSummary(item) {
Page({
data: {
artistId: '',
onboarding: false,
onboardingSource: '',
appointmentContextText: '',
presets: PRESETS,
presetOptions: buildPresetOptions('DOUBLE_REST'),
weekdays: WEEKDAYS,
@@ -95,7 +98,13 @@ Page({
},
onLoad(options) {
this.setData({ artistId: options.id || '' })
const contextParts = [options.date, options.time, options.durationMinutes ? `${options.durationMinutes}分钟` : ''].filter(Boolean)
this.setData({
artistId: options.id || '',
onboarding: options.onboarding === '1',
onboardingSource: options.source || '',
appointmentContextText: contextParts.join(' · ')
})
this.loadRule()
},
@@ -235,7 +244,13 @@ Page({
})
markPlanningRefresh()
wx.showToast({ title: '排班规则已保存', icon: 'success' })
await this.loadRule()
if (this.data.onboarding) {
const eventChannel = this.getOpenerEventChannel && this.getOpenerEventChannel()
if (eventChannel && eventChannel.emit) eventChannel.emit('scheduleSaved', { artistId: this.data.artistId })
setTimeout(() => wx.navigateBack(), 250)
} else {
await this.loadRule()
}
} catch (error) {
const message = error.message || '保存失败'
wx.showModal({ title: '排班保存失败', content: message, showCancel: false, confirmText: '知道了' })
@@ -0,0 +1,54 @@
const assert = require('assert')
const employeesApi = require('../../api/employees')
let navigatedBack = false
global.wx = {
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
getDeviceInfo: () => ({ platform: 'devtools' }),
setStorageSync: () => {},
showToast: () => {},
showModal: () => {},
navigateBack: () => { navigatedBack = true }
}
global.getApp = () => ({ globalData: {} })
global.getCurrentPages = () => []
global.setTimeout = callback => { callback(); return 1 }
let definition
global.Page = value => { definition = value }
require('./index')
let emitted
const page = {
...definition,
data: JSON.parse(JSON.stringify(definition.data)),
getOpenerEventChannel: () => ({ emit: (name, value) => { emitted = { name, value } } }),
setData(values) {
Object.entries(values).forEach(([key, value]) => {
const parts = key.split('.')
let target = this.data
for (let index = 0; index < parts.length - 1; index += 1) target = target[parts[index]]
target[parts[parts.length - 1]] = value
})
}
}
async function run() {
page.data.artistId = '88'
page.data.onboarding = true
page.data.onboardingSource = 'appointment'
employeesApi.saveScheduleRule = async payload => {
assert.strictEqual(payload.artistId, '88')
assert.deepStrictEqual(payload.workDays, [1, 2, 3, 4, 5])
}
await page.save()
assert.deepStrictEqual(emitted, { name: 'scheduleSaved', value: { artistId: '88' } })
assert.strictEqual(navigatedBack, true)
}
run().catch(error => {
console.error(error)
process.exitCode = 1
})
@@ -1,4 +1,8 @@
<view class="page no-tab">
<view wx:if="{{onboarding}}" class="onboarding-context card">
<text class="onboarding-context-title">首次排班设置</text>
<text class="onboarding-context-desc">{{appointmentContextText ? '待承接预约:' + appointmentContextText : '保存常规排班后,员工即可开始承接预约。'}}</text>
</view>
<view class="section">
<view class="section-title">常规排班</view>
<view class="card rule-card">
@@ -28,7 +32,7 @@
</view>
</view>
<view class="section">
<view wx:if="{{!onboarding}}" class="section">
<view class="section-title">特殊日期</view>
<view class="card rule-card">
<view class="field">
@@ -63,6 +67,6 @@
</view>
<view class="fixed-bottom">
<button class="primary-btn" loading="{{saving}}" bindtap="save">保存排班规则</button>
<button class="primary-btn" loading="{{saving}}" bindtap="save">{{onboarding && onboardingSource === 'appointment' ? '保存排班并继续分配' : '保存排班规则'}}</button>
</view>
</view>
@@ -2,6 +2,19 @@
padding: 20rpx 24rpx;
}
.onboarding-context {
display: flex;
flex-direction: column;
gap: 8rpx;
margin-bottom: 20rpx;
padding: 22rpx 24rpx;
border-left: 8rpx solid #d59a52;
background: #fff7ea;
}
.onboarding-context-title { color: #70481c; font-size: 27rpx; font-weight: 900; }
.onboarding-context-desc { color: #8d673b; font-size: 22rpx; line-height: 1.6; }
.preset-grid,
.weekday-grid {
display: flex;