Dev #95

Merged
xiaowang merged 2 commits from dev into sit 2026-11-04 00:17:26 +08:00
19 changed files with 443 additions and 65 deletions
@@ -647,6 +647,7 @@ public class PlanningServiceImpl implements PlanningService {
vo.setConflictReason(resolveAppointmentConflictReason(occupancyStatus));
vo.setAmount(order == null ? null : order.getActualAmount());
vo.setRemark(order == null ? null : order.getCustomerRemark());
vo.setCancelReason(order == null ? null : order.getCancelReason());
return vo;
}
@@ -32,4 +32,5 @@ public class PlanningAppointmentVO {
private String conflictReason;
private BigDecimal amount;
private String remark;
private String cancelReason;
}
@@ -504,6 +504,7 @@ class PlanningServiceImplTest {
OrderDO order = order(54L, OrderStatus.PENDING_SERVICE.getCode());
order.setCustomerNameSnapshot("散客预约");
order.setCustomerPhoneSnapshot("13800138000");
order.setCancelReason("门店临时闭店");
OrderItemDO item = new OrderItemDO();
item.setId(64L);
item.setOrderId(54L);
@@ -520,6 +521,7 @@ class PlanningServiceImplTest {
assertNull(result.getCustomerId());
assertEquals("散客预约", result.getCustomerName());
assertEquals("13800138000", result.getCustomerPhone());
assertEquals("门店临时闭店", result.getCancelReason());
verify(userMapper, never()).selectById(org.mockito.ArgumentMatchers.isNull());
}
@@ -1,6 +1,17 @@
const planningApi = require('../../api/planning')
const { markPlanningRefresh } = require('../../utils/planning-refresh')
function displayValue(value, fallback) {
if (value === null || value === undefined) return fallback
const text = String(value).trim()
return !text || text === 'null' || text === 'undefined' ? fallback : text
}
function formatAmount(value) {
const amount = displayValue(value, '')
return amount ? `¥${amount}` : '未记录'
}
Page({
data: {
id: '',
@@ -8,6 +19,11 @@ Page({
avatarText: '',
timeText: '',
isUnassigned: false,
showTransfer: false,
showConfirm: false,
showComplete: false,
showCancel: false,
updating: false,
loadError: ''
},
@@ -31,20 +47,50 @@ Page({
},
applyAppointment(appointment) {
const safeAppointment = appointment || {}
const status = Number(safeAppointment.status)
const historicalBackfill = Boolean(safeAppointment.historicalBackfill)
const isUnassigned = safeAppointment.assignmentStatus === 'UNASSIGNED' || !safeAppointment.artistId
const startTime = displayValue(safeAppointment.startTime, '')
const endTime = displayValue(safeAppointment.endTime, '')
const timeText = historicalBackfill && !startTime
? '时间未记录'
: startTime
? `${startTime.slice(0, 16)}${endTime ? ` - ${endTime.slice(11, 16)}` : ''}`
: displayValue(safeAppointment.date, '时间未记录')
const normalizedAppointment = {
...safeAppointment,
customerNameText: displayValue(safeAppointment.customerName, '散客'),
customerPhoneText: displayValue(safeAppointment.customerPhone, '未留手机号'),
orderNoText: displayValue(safeAppointment.orderNo, '未记录'),
productTitleText: displayValue(safeAppointment.productTitle, '未记录'),
artistNameText: isUnassigned ? '待分配' : displayValue(safeAppointment.artistName, '未记录'),
durationText: Number(safeAppointment.durationMinutes) > 0 ? `${safeAppointment.durationMinutes} 分钟` : '未记录',
amountText: formatAmount(safeAppointment.amount),
statusText: displayValue(safeAppointment.statusText, '状态未知'),
remarkText: displayValue(safeAppointment.remark, '暂无备注'),
cancelReasonText: displayValue(safeAppointment.cancelReason, '')
}
this.setData({
appointment,
isUnassigned: appointment.assignmentStatus === 'UNASSIGNED' || !appointment.artistId,
avatarText: String(appointment.customerName || '客').slice(0, 1),
timeText: appointment.historicalBackfill && !appointment.startTime ? '时间未记录' : `${(appointment.startTime || '').slice(0, 16)} - ${(appointment.endTime || '').slice(11, 16)}`,
appointment: normalizedAppointment,
isUnassigned,
avatarText: normalizedAppointment.customerNameText.slice(0, 1),
timeText,
showTransfer: Boolean(safeAppointment.canEdit) && !historicalBackfill,
showConfirm: Boolean(safeAppointment.canEdit) && !historicalBackfill && !isUnassigned && status === 0,
showComplete: !isUnassigned && (status === 1 || status === 4),
showCancel: Boolean(safeAppointment.canCancel),
loadError: ''
})
},
async updateStatus(status) {
if (this.data.updating || !this.data.appointment.orderId) return
if (status !== 3 && this.data.isUnassigned) {
wx.showToast({ title: '请先分配美甲师', icon: 'none' })
return
}
this.setData({ updating: true })
try {
await planningApi.updateStatus(this.data.appointment.orderId, status, this._cancelReason || '')
markPlanningRefresh()
@@ -52,19 +98,24 @@ Page({
this.loadDetail()
} catch (error) {
wx.showToast({ title: error.message || '操作失败', icon: 'none' })
} finally {
this.setData({ updating: false })
}
},
confirm() {
if (this.data.appointment.historicalBackfill) return
if (!this.data.showConfirm || this.data.updating) return
this.updateStatus(1)
},
complete() {
if (!this.data.showComplete || this.data.updating) return
this.updateStatus(2)
},
cancel() {
if (!this.data.showCancel || this.data.updating) return
this._cancelReason = ''
wx.showModal({
title: '取消预约',
editable: true,
@@ -80,7 +131,7 @@ Page({
},
goTransfer() {
if (this.data.appointment.historicalBackfill) return
if (!this.data.showTransfer) return
wx.navigateTo({ url: `/pages/artist-transfer/index?id=${this.data.id}` })
},
@@ -0,0 +1,98 @@
const assert = require('assert')
const fs = require('fs')
const path = require('path')
global.wx = {
showToast: () => {},
showModal: options => options.success({ confirm: false }),
navigateTo: () => {},
navigateBack: () => {}
}
let definition
global.Page = value => { definition = value }
require('./index')
function createPage() {
return {
...definition,
data: { ...definition.data },
setData(values) { Object.assign(this.data, values) }
}
}
const page = createPage()
page.applyAppointment({
orderId: 1,
orderNo: 'SALON-001',
customerName: '到店客户',
customerPhone: null,
productTitle: null,
artistName: null,
artistId: null,
assignmentStatus: 'UNASSIGNED',
startTime: null,
endTime: null,
durationMinutes: null,
amount: null,
remark: null,
status: 0,
statusText: '待确认',
canEdit: true,
canCancel: true
})
assert.strictEqual(page.data.appointment.customerPhoneText, '未留手机号')
assert.strictEqual(page.data.appointment.productTitleText, '未记录')
assert.strictEqual(page.data.appointment.artistNameText, '待分配')
assert.strictEqual(page.data.appointment.amountText, '未记录')
assert.strictEqual(page.data.appointment.remarkText, '暂无备注')
assert.strictEqual(page.data.appointment.orderNoText, 'SALON-001')
assert.strictEqual(page.data.showTransfer, true)
assert.strictEqual(page.data.showConfirm, false)
assert.strictEqual(page.data.showComplete, false)
assert.strictEqual(page.data.showCancel, true)
assert.strictEqual([
page.data.appointment.customerNameText,
page.data.appointment.customerPhoneText,
page.data.appointment.orderNoText,
page.data.appointment.productTitleText,
page.data.appointment.artistNameText,
page.data.appointment.durationText,
page.data.appointment.amountText,
page.data.appointment.remarkText
].some(value => String(value).includes('null')), false)
page.applyAppointment({
artistId: 9,
assignmentStatus: 'ASSIGNED',
status: 3,
statusText: '已取消',
canEdit: false,
canCancel: false,
cancelReason: '客户临时调整时间'
})
assert.strictEqual(page.data.appointment.cancelReasonText, '客户临时调整时间')
assert.strictEqual(page.data.showTransfer, false)
assert.strictEqual(page.data.showConfirm, false)
assert.strictEqual(page.data.showComplete, false)
assert.strictEqual(page.data.showCancel, false)
page.applyAppointment({
artistId: 9,
assignmentStatus: 'ASSIGNED',
status: 4,
statusText: '服务中',
historicalBackfill: true,
canEdit: false,
canCancel: true
})
assert.strictEqual(page.data.showTransfer, false)
assert.strictEqual(page.data.showComplete, true)
assert.strictEqual(page.data.showCancel, true)
const markup = fs.readFileSync(path.join(__dirname, 'index.wxml'), 'utf8')
const styles = fs.readFileSync(path.join(__dirname, 'index.wxss'), 'utf8')
;['订单编号', '服务项目', '美甲师', '时长', '成交金额', '取消原因', 'remarkText', 'customerPhoneText'].forEach(text => assert(markup.includes(text)))
assert.match(markup, /class="primary-btn transfer-action"/)
assert.match(markup, /class="danger-btn"/)
assert.match(styles, /\.transfer-action\s*\{[^}]*box-shadow/)
@@ -9,44 +9,53 @@
<view class="detail-person">
<view class="avatar">{{avatarText}}</view>
<view>
<text class="customer">{{appointment.customerName}}</text>
<text class="phone">{{appointment.customerPhone}}</text>
<text class="customer">{{appointment.customerNameText}}</text>
<text class="phone">{{appointment.customerPhoneText}}</text>
</view>
</view>
<view class="detail-actions">
<text wx:if="{{appointment.historicalBackfill}}" class="tag">历史补单 · {{appointment.statusText}}</text>
<text wx:else class="tag">{{appointment.statusText}}</text>
<button wx:if="{{!appointment.historicalBackfill}}" class="small-action" bindtap="goTransfer">{{isUnassigned ? '分配美甲师' : '改派'}}</button>
</view>
<text class="status-tag {{appointment.status === 2 ? 'completed' : appointment.status === 3 ? 'cancelled' : ''}}">{{appointment.historicalBackfill ? '历史补单 · ' : ''}}{{appointment.statusText}}</text>
</view>
<view class="detail-grid">
<view>
<text class="label">项目</text>
<text class="value">{{appointment.productTitle}}</text>
<view class="detail-field">
<text class="label">订单编号</text>
<text class="value">{{appointment.orderNoText}}</text>
</view>
<view>
<view class="detail-field">
<text class="label">服务项目</text>
<text class="value">{{appointment.productTitleText}}</text>
</view>
<view class="detail-field">
<text class="label">美甲师</text>
<text class="value">{{isUnassigned ? '待分配' : appointment.artistName}}</text>
<text class="value">{{appointment.artistNameText}}</text>
</view>
<view>
<view class="detail-field">
<text class="label">时间</text>
<text class="value">{{timeText}}</text>
</view>
<view>
<view class="detail-field">
<text class="label">时长</text>
<text class="value">{{appointment.durationMinutes}}分钟</text>
<text class="value">{{appointment.durationText}}</text>
</view>
<view class="detail-field amount-field">
<text class="label">成交金额</text>
<text class="value">{{appointment.amountText}}</text>
</view>
</view>
<view wx:if="{{appointment.cancelReasonText}}" class="cancel-reason">
<text class="label">取消原因</text>
<text class="cancel-reason-text">{{appointment.cancelReasonText}}</text>
</view>
</view>
<view wx:if="{{!loadError}}" class="section">
<view class="section-title">备注</view>
<view class="card note-card">{{appointment.remark || '暂无备注'}}</view>
<view class="card note-card">{{appointment.remarkText}}</view>
</view>
<view wx:if="{{!loadError}}" class="fixed-bottom action-row">
<button wx:if="{{!appointment.historicalBackfill}}" class="secondary-btn" disabled="{{isUnassigned}}" bindtap="confirm">{{isUnassigned ? '待分配' : '确认'}}</button>
<button class="primary-btn" disabled="{{isUnassigned}}" bindtap="complete">{{appointment.historicalBackfill ? '完成补单' : '完成'}}</button>
<button class="danger-btn" bindtap="cancel">取消</button>
<view wx:if="{{!loadError && (showTransfer || showConfirm || showComplete || showCancel)}}" class="fixed-bottom action-row">
<button wx:if="{{showTransfer}}" class="primary-btn transfer-action" loading="{{updating}}" disabled="{{updating}}" bindtap="goTransfer">{{isUnassigned ? '分配美甲师' : '改派美甲师'}}</button>
<button wx:if="{{showConfirm}}" class="secondary-btn" loading="{{updating}}" disabled="{{updating}}" bindtap="confirm">确认预约</button>
<button wx:if="{{showComplete}}" class="secondary-btn" loading="{{updating}}" disabled="{{updating}}" bindtap="complete">{{appointment.historicalBackfill ? '完成补单' : '完成服务'}}</button>
<button wx:if="{{showCancel}}" class="danger-btn" loading="{{updating}}" disabled="{{updating}}" bindtap="cancel">取消预约</button>
</view>
</view>
@@ -1,5 +1,5 @@
.detail-card {
padding: 24rpx;
padding: 28rpx 24rpx;
}
.detail-error {
@@ -23,10 +23,16 @@
.detail-person {
display: flex;
align-items: center;
flex: 1;
min-width: 0;
gap: 18rpx;
}
.detail-person > view:last-child {
flex: 1;
min-width: 0;
}
.avatar {
display: flex;
align-items: center;
@@ -47,9 +53,12 @@
}
.customer {
overflow: hidden;
color: #17211f;
font-size: 32rpx;
font-weight: 800;
text-overflow: ellipsis;
white-space: nowrap;
}
.phone {
@@ -58,20 +67,40 @@
font-size: 24rpx;
}
.detail-actions {
display: flex;
.status-tag {
flex-shrink: 0;
align-items: center;
gap: 10rpx;
padding: 8rpx 14rpx;
border-radius: 999rpx;
background: #edf6ef;
color: #247b63;
font-size: 21rpx;
font-weight: 800;
}
.status-tag.completed {
background: #eef2f1;
color: #67766f;
}
.status-tag.cancelled {
background: #fff0ed;
color: #ad5148;
}
.detail-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 22rpx;
gap: 12rpx;
margin-top: 28rpx;
}
.detail-field {
min-width: 0;
padding: 16rpx;
border-radius: 12rpx;
background: #f6f9f7;
}
.label,
.value {
display: block;
@@ -84,9 +113,36 @@
.value {
margin-top: 8rpx;
overflow-wrap: anywhere;
color: #17211f;
font-size: 28rpx;
font-weight: 700;
line-height: 1.45;
}
.amount-field .value {
color: #b36f3e;
font-size: 32rpx;
}
.cancel-reason {
display: flex;
align-items: flex-start;
gap: 18rpx;
margin-top: 18rpx;
padding: 18rpx;
border-left: 6rpx solid #cc7568;
border-radius: 10rpx;
background: #fff5f3;
}
.cancel-reason-text {
flex: 1;
min-width: 0;
color: #8f4d46;
font-size: 24rpx;
line-height: 1.5;
overflow-wrap: anywhere;
}
.note-card {
@@ -96,9 +152,12 @@
}
.action-row {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
display: flex;
align-items: center;
gap: 14rpx;
padding: 18rpx 20rpx calc(18rpx + env(safe-area-inset-bottom));
background: rgba(255, 255, 255, 0.96);
box-shadow: 0 -8rpx 24rpx rgba(31, 55, 44, 0.08);
}
.action-row .primary-btn,
@@ -107,4 +166,28 @@
width: 100%;
min-width: 0;
max-width: 100%;
flex: 1;
padding: 0 12rpx;
font-size: 23rpx;
white-space: nowrap;
}
.action-row .transfer-action {
flex: 1.25;
box-shadow: 0 8rpx 18rpx rgba(36, 123, 99, 0.18);
}
@media (max-width: 360px) {
.action-row {
gap: 8rpx;
padding-right: 12rpx;
padding-left: 12rpx;
}
.action-row .primary-btn,
.action-row .secondary-btn,
.action-row .danger-btn {
padding: 0 6rpx;
font-size: 20rpx;
}
}
+57 -3
View File
@@ -7,6 +7,7 @@ Page({
data: {
pickerMode: false,
appointmentContext: { date: '', time: '', durationMinutes: '' },
applicationId: '',
employeeColors: EMPLOYEE_COLORS,
onboardingVisible: false,
createdEmployee: null,
@@ -35,7 +36,9 @@ Page({
date: options.date || '',
time: options.time || '',
durationMinutes: options.durationMinutes || ''
}
},
applicationId: options.applicationId || '',
applicationNo: options.applicationNo || ''
})
},
@@ -81,6 +84,12 @@ Page({
},
async submit() {
if (this.data.creating || this.data.avatarUploading) return
if (this.data.createdEmployee) {
if (this.data.applicationId && !this.data.applicationApproved) return this.associateCreatedEmployee()
this.setData({ onboardingVisible: true })
return
}
const form = this.data.form
const nickname = String(form.nickname || '').trim()
const phone = String(form.phone || '').trim()
@@ -106,7 +115,11 @@ Page({
})
const id = result && typeof result === 'object' ? (result.id || result.userId) : result
const employee = { id, name: nickname, title: nickname, avatar: form.avatar || '' }
this.setData({ createdEmployee: employee })
this.setData({ createdEmployee: employee, applicationApproved: false })
if (this.data.applicationId) {
await this.associateCreatedEmployee()
return
}
await this.offerPendingAssociation()
} catch (error) {
wx.showToast({ title: error.message || '新增失败', icon: 'none' })
@@ -115,6 +128,33 @@ Page({
}
},
async associateCreatedEmployee() {
const employee = this.data.createdEmployee
if (!employee || !employee.id || !this.data.applicationId || this.data.associatingApplication) return
this.setData({ associatingApplication: true })
try {
await employeesApi.approveApplication(this.data.applicationId, {
targetArtistUserId: employee.id,
useApplicantNickname: false,
useApplicantAvatar: false
})
this.setData({ applicationApproved: true, associatingApplication: false, onboardingVisible: true })
wx.showToast({ title: '已关联并通过审核', icon: 'success' })
} catch (error) {
this.setData({ associatingApplication: false })
wx.showModal({
title: '关联审核未完成',
content: error.message || '美甲师档案已创建,可重试关联申请。',
confirmText: '重试',
cancelText: '稍后处理',
success: result => {
if (result.confirm) this.associateCreatedEmployee()
else this.setData({ onboardingVisible: true })
}
})
}
},
async offerPendingAssociation() {
try {
const data = await employeesApi.unassociatedApplications()
@@ -180,6 +220,7 @@ Page({
},
setupFirstSchedule() {
if (this.data.applicationId && !this.data.applicationApproved) return
const employee = this.data.createdEmployee
if (!employee || !employee.id) return
const context = this.data.appointmentContext
@@ -202,7 +243,7 @@ Page({
},
skipFirstSchedule() {
if (this.data.savingDefaultSchedule || !this.data.createdEmployee) return
if (this.data.savingDefaultSchedule || !this.data.createdEmployee || (this.data.applicationId && !this.data.applicationApproved)) return
this.setData({ savingDefaultSchedule: true })
employeesApi.saveScheduleRule({
artistId: this.data.createdEmployee.id,
@@ -231,6 +272,10 @@ Page({
},
finishCreated(autoSelect, scheduleSaved) {
if (this.data.applicationId && !this.data.applicationApproved) {
this.setData({ onboardingVisible: true })
return
}
const employee = this.data.createdEmployee
const eventChannel = this.getOpenerEventChannel && this.getOpenerEventChannel()
if (eventChannel && eventChannel.emit) {
@@ -239,5 +284,14 @@ Page({
this.setData({ onboardingVisible: false })
wx.showToast({ title: scheduleSaved ? '排班已保存' : '美甲师已新增', icon: 'success' })
setTimeout(() => wx.navigateBack(), 300)
},
leaveAssociationForLater() {
const employee = this.data.createdEmployee
const eventChannel = this.getOpenerEventChannel && this.getOpenerEventChannel()
if (eventChannel && eventChannel.emit && employee) {
eventChannel.emit('employeeCreated', { ...employee, autoSelect: this.data.pickerMode, scheduleSaved: false })
}
wx.navigateBack()
}
})
@@ -3,10 +3,12 @@ const employeesApi = require('../../api/employees')
let navigatedBack = false
let navigatedTo = ''
let modalConfirm = false
global.wx = {
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
getDeviceInfo: () => ({ platform: 'devtools' }),
showToast: () => {},
showModal: options => options.success({ confirm: modalConfirm }),
navigateBack: () => { navigatedBack = true },
navigateTo: options => { navigatedTo = options.url }
}
@@ -102,6 +104,35 @@ async function run() {
page.data.appointmentContext = { date: '2026-10-12', time: '14:00', durationMinutes: '60' }
page.setupFirstSchedule()
assert.strictEqual(navigatedTo.includes('/pages/schedule-setting/index?id=88&onboarding=1&source=appointment'), true)
let employeeCreateCount = 0
let approvalAttempts = 0
let approvalPayload
page.data.form = { nickname: '申请档案员工', phone: '13800138001', wechatId: '', color: '#8FB89A', avatar: '', avatarUrl: '' }
page.data.createdEmployee = null
page.data.applicationId = '42'
page.data.applicationApproved = false
page.data.onboardingVisible = false
employeesApi.createUser = async () => { employeeCreateCount += 1; return { userId: 90 } }
employeesApi.approveApplication = async (applicationId, payload) => {
approvalAttempts += 1
approvalPayload = { applicationId, ...payload }
if (approvalAttempts === 1) throw new Error('暂时无法审核')
}
await page.submit()
assert.strictEqual(employeeCreateCount, 1)
assert.deepStrictEqual(approvalPayload, {
applicationId: '42',
targetArtistUserId: 90,
useApplicantNickname: false,
useApplicantAvatar: false
})
assert.strictEqual(page.data.createdEmployee.id, 90)
assert.strictEqual(page.data.onboardingVisible, true)
await page.associateCreatedEmployee()
assert.strictEqual(employeeCreateCount, 1)
assert.strictEqual(approvalAttempts, 2)
assert.strictEqual(page.data.applicationApproved, true)
}
run().catch(error => {
@@ -1,7 +1,7 @@
<view class="page no-tab employee-create-page">
<view class="create-intro">
<text class="create-title">新增美甲师档案</text>
<text class="create-subtitle">{{pickerMode ? '保存后自动选择该美甲师' : '保存后即可用于预约指定和美甲师管理'}}</text>
<text class="create-subtitle">{{applicationId ? '保存后将自动关联当前申请并通过审核' : (pickerMode ? '保存后自动选择该美甲师' : '保存后即可用于预约指定和美甲师管理')}}</text>
</view>
<view class="card avatar-card" bindtap="chooseAvatar">
@@ -42,17 +42,24 @@
</view>
<view class="fixed-bottom">
<button class="primary-btn" loading="{{creating}}" disabled="{{avatarUploading || creating}}" bindtap="submit">保存美甲师</button>
<button class="primary-btn" loading="{{creating || associatingApplication}}" disabled="{{avatarUploading || creating || associatingApplication || (applicationId && applicationApproved)}}" bindtap="submit">{{applicationId && !createdEmployee ? '创建并通过审核' : (applicationId && createdEmployee && !applicationApproved ? '重试关联并通过' : '保存美甲师')}}</button>
</view>
<view wx:if="{{onboardingVisible}}" class="onboarding-mask" catchtouchmove="stopTouchMove">
<view class="onboarding-card">
<view class="onboarding-icon">✓</view>
<text class="onboarding-title">美甲师已创建</text>
<text class="onboarding-desc">{{pickerMode ? '设置常规排班后,可继续把当前预约分配给该美甲师。' : '为新美甲师设置首个常规排班,之后即可正常承接预约。'}}</text>
<text class="onboarding-default-note">不立即设置时,将默认全年无休、全天排班(00:00-23:59);实际预约仍受门店营业时间限制,之后可在排班设置中调整。</text>
<button class="primary-btn onboarding-primary" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="setupFirstSchedule">{{pickerMode ? '设置排班并分配' : '立即设置排班'}}</button>
<button class="onboarding-skip" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="skipFirstSchedule">{{pickerMode ? '暂不设置(使用全天排班)' : '不设置,保留全天排班'}}</button>
<view class="onboarding-icon {{applicationId && !applicationApproved ? 'association-failed' : ''}}">{{applicationId && !applicationApproved ? '!' : '✓'}}</view>
<text class="onboarding-title">{{applicationId && !applicationApproved ? '美甲师档案已创建' : (applicationId ? '申请已关联并通过' : '美甲师已创建')}}</text>
<text class="onboarding-desc">{{applicationId && !applicationApproved ? '员工档案已保留,申请仍待处理。关联失败不会重复创建员工,可直接重试。' : (pickerMode ? '设置常规排班后,可继续把当前预约分配给该美甲师。' : '为新美甲师设置首个常规排班,之后即可正常承接预约。')}}</text>
<view wx:if="{{applicationId && !applicationApproved}}" class="association-retry-box">
<text>申请编号 {{applicationNo || applicationId}}</text>
<button class="primary-btn onboarding-primary" loading="{{associatingApplication}}" disabled="{{associatingApplication}}" bindtap="associateCreatedEmployee">重试关联并通过审核</button>
<button class="onboarding-skip" disabled="{{associatingApplication}}" bindtap="leaveAssociationForLater">稍后处理</button>
</view>
<block wx:else>
<text class="onboarding-default-note">不立即设置时,将默认全年无休、全天排班(00:00-23:59);实际预约仍受门店营业时间限制,之后可在排班设置中调整。</text>
<button class="primary-btn onboarding-primary" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="setupFirstSchedule">{{pickerMode ? '设置排班并分配' : '立即设置排班'}}</button>
<button class="onboarding-skip" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="skipFirstSchedule">{{pickerMode ? '暂不设置(使用全天排班)' : '不设置,保留全天排班'}}</button>
</block>
</view>
</view>
<entity-selector-sheet visible="{{associationSheetVisible}}" title="关联待审核申请" keyword="{{associationKeyword}}" placeholder="搜索申请昵称、手机号或编号" items="{{associationItems}}" selected-id="{{associationSelectedId}}" loading="{{associationLoading}}" empty-text="暂无可关联申请" action-text="暂不关联,继续" bind:search="onAssociationSearch" bind:select="selectAssociation" bind:action="skipAssociation" bind:close="skipAssociation" />
@@ -148,8 +148,15 @@
font-weight: 900;
}
.onboarding-icon.association-failed {
background: #fff0ed;
color: #ad5148;
}
.onboarding-title { margin-top: 22rpx; color: #17211f; font-size: 32rpx; font-weight: 900; }
.onboarding-desc { margin-top: 12rpx; color: #837b72; font-size: 23rpx; line-height: 1.7; text-align: center; }
.onboarding-default-note { margin-top: 14rpx; padding: 14rpx 16rpx; border-radius: 12rpx; background: #eff7f2; color: #39705d; font-size: 21rpx; line-height: 1.55; text-align: left; }
.onboarding-primary { width: 100%; margin-top: 30rpx; }
.onboarding-skip { margin-top: 12rpx; background: transparent; color: #7e776f; font-size: 23rpx; }
.association-retry-box { width: 100%; margin-top: 20rpx; padding: 18rpx; box-sizing: border-box; border-radius: 12rpx; background: #fff5f3; color: #8f4d46; font-size: 22rpx; text-align: center; }
.association-retry-box .onboarding-primary { margin-top: 18rpx; }
+20 -5
View File
@@ -50,6 +50,11 @@ Page({
},
onShow() {
if (this._waitingForEmployeeCreate) {
this._waitingForEmployeeCreate = false
this.loadEmployees()
if (this.data.reviewExpanded) this.loadReviewApplications()
}
const app = getApp()
if (!this.data.isManager || !app.globalData.openEmployeeReview) return
app.globalData.openEmployeeReview = false
@@ -128,12 +133,13 @@ Page({
})
if (!artists.length) {
this.setData({ associationSheetVisible: false })
await confirmModal({
title: '暂时无法通过',
content: '当前门店没有未关联微信的美甲师档案,请先新增美甲师,再审核这条申请。',
confirmText: '知道了',
showCancel: false
const result = await confirmModal({
title: '需要先新建美甲师',
content: '当前门店没有未关联微信的美甲师档案。新建后将自动关联这条申请并通过审核。',
confirmText: '去新建',
cancelText: '稍后处理'
})
if (result.confirm) this.createEmployeeForApplication(applicationId, application && application.applicationNo)
}
} catch (error) {
this.setData({ associationError: error.message || '未关联美甲师加载失败' })
@@ -291,6 +297,15 @@ Page({
}
},
createEmployeeForApplication(applicationId, applicationNo) {
if (!applicationId) return
this._waitingForEmployeeCreate = true
wx.navigateTo({
url: `/pages/employee-create/index?applicationId=${encodeURIComponent(applicationId)}&applicationNo=${encodeURIComponent(applicationNo || '')}`,
fail: () => { this._waitingForEmployeeCreate = false }
})
},
onEmployeeAvatarError(event) {
const index = Number(event.currentTarget.dataset.index)
if (!Number.isInteger(index) || !this.data.employees[index]) return
@@ -5,6 +5,7 @@ const path = require('path')
const modalChoices = []
const toasts = []
const modals = []
const navigations = []
global.wx = {
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
getDeviceInfo: () => ({ platform: 'devtools' }),
@@ -12,7 +13,8 @@ global.wx = {
showModal: options => {
modals.push(options)
options.success({ confirm: modalChoices.shift() !== false })
}
},
navigateTo: options => navigations.push(options.url)
}
global.getApp = () => ({ globalData: { userInfo: { type: 2 }, openEmployeeReview: false } })
@@ -83,7 +85,8 @@ async function run() {
page.data.reviewApplications = [application]
await page.approveApplication({ currentTarget: { dataset: { id: 12 } } })
assert.strictEqual(page.data.associationSheetVisible, false)
assert(modals.some(item => String(item.content || '').includes('当前门店没有未关联微信的美甲师档案')))
assert(modals.some(item => item.confirmText === '去新建'))
assert.strictEqual(navigations.pop(), '/pages/employee-create/index?applicationId=12&applicationNo=')
}
run().catch(error => {
@@ -97,6 +97,8 @@
}
.review-item {
box-sizing: border-box;
width: 100%;
gap: 14rpx;
min-width: 0;
flex-wrap: wrap;
@@ -115,7 +117,9 @@
}
.review-info {
box-sizing: border-box;
min-width: 0;
width: 0;
flex: 1;
overflow: hidden;
}
@@ -142,7 +146,9 @@
}
.review-actions {
box-sizing: border-box;
flex: 0 0 auto;
max-width: 100%;
gap: 8rpx;
margin-left: auto;
}
@@ -199,6 +205,12 @@
}
}
@media (min-width: 391px) {
.review-actions {
max-width: 230rpx;
}
}
.review-retry {
width: 150rpx;
min-width: 150rpx;
+7 -4
View File
@@ -121,7 +121,7 @@ function layoutAppointmentBlocks(items, startMinute, minuteScale, laneHeaderHeig
return {
...entry,
top: Math.max(0, entry.itemStart - startMinute) * minuteScale + laneHeaderHeight,
height: entry.durationMinutes * minuteScale,
height: Math.max(40, entry.durationMinutes * minuteScale),
left: Math.round(entry.columnIndex * slotWidth + 12),
width: Math.round(slotWidth - 24),
compact: entry.durationMinutes <= 15,
@@ -167,6 +167,7 @@ Page({
hours: [],
hasTimedAppointments: false,
timelineHeight: 720,
timelineViewportHeight: 720,
laneWidth: 720,
laneItemWidth: 240,
laneHeaderHeight: 54,
@@ -601,7 +602,7 @@ Page({
},
buildDayView(calendar) {
const minuteScale = 4
const minuteScale = 2.5
const daySummary = this.summaryMap(calendar)[this.data.currentDateText] || null
const businessHours = resolveBusinessHours(calendar, this.data.currentDateText)
const filteredArtists = this.data.selectedArtistId
@@ -622,6 +623,7 @@ Page({
hours: [],
hasTimedAppointments: false,
timelineHeight: 0,
timelineViewportHeight: 320,
laneHeaderHeight: 54,
laneItemWidth: 248,
laneWidth: 720,
@@ -644,7 +646,7 @@ Page({
const endMinute = businessHours
? dateUtil.minutesOfDay(businessHours.end)
: Math.min(1440, Math.max(startMinute + 60, Math.ceil(latestAppointmentEnd / 60) * 60))
const timelineHeight = Math.max(560, (endMinute - startMinute) * minuteScale)
const timelineHeight = (endMinute - startMinute) * minuteScale
const laneHeaderHeight = 54
const hours = []
for (let cursor = startMinute; cursor <= endMinute; cursor += 60) {
@@ -663,7 +665,7 @@ Page({
return {
...item,
top: Math.max(0, itemStart - startMinute) * minuteScale + laneHeaderHeight,
height: Math.max(60, (item.durationMinutes || 60) * minuteScale),
height: Math.max(40, (item.durationMinutes || 60) * minuteScale),
left: 12,
width: 224,
compact: Number(item.durationMinutes || 60) <= 15,
@@ -696,6 +698,7 @@ Page({
hours,
hasTimedAppointments: timedAppointments.length > 0,
timelineHeight: timelineHeight + laneHeaderHeight,
timelineViewportHeight: Math.min(820, timelineHeight + laneHeaderHeight),
laneHeaderHeight,
laneItemWidth: 248,
laneWidth: Math.max(720, lanes.reduce((width, lane) => width + (lane.width || 248), 0)),
+7 -5
View File
@@ -123,9 +123,10 @@ async function run() {
assert.strictEqual(dayState.dayLanes[0].artistId, '__unassigned__')
assert.strictEqual(dayState.dayLanes[0].blocks.length, 1)
assert.strictEqual(dayState.unassignedCount, 1)
assert.strictEqual(dayState.timelineHeight, 2934)
assert.strictEqual(dayState.hours.find(item => item.label === '14:00').top, 1014)
assert.strictEqual(dayState.dayLanes[0].blocks[0].height, 240)
assert.strictEqual(dayState.timelineHeight, 1854)
assert.strictEqual(dayState.timelineViewportHeight, 820)
assert.strictEqual(dayState.hours.find(item => item.label === '14:00').top, 654)
assert.strictEqual(dayState.dayLanes[0].blocks[0].height, 150)
const shortAppointmentState = dayPage.buildDayView({
businessStartTime: '10:30',
businessEndTime: '11:30',
@@ -133,9 +134,10 @@ async function run() {
appointments: [{ orderItemId: 9, date: '2026-10-12', startTime: '2026-10-12 10:45:00', durationMinutes: 15, artistId: 1 }]
})
assert.strictEqual(shortAppointmentState.hours[0].top, 54)
assert.strictEqual(shortAppointmentState.hours[1].top, 294)
assert.strictEqual(shortAppointmentState.hours[1].top, 204)
assert.strictEqual(shortAppointmentState.timelineViewportHeight, 204)
const shortAppointmentLane = shortAppointmentState.dayLanes.find(lane => lane.artistId === 1)
assert.strictEqual(shortAppointmentLane.blocks[0].height, 60)
assert.strictEqual(shortAppointmentLane.blocks[0].height, 40)
assert.strictEqual(shortAppointmentLane.blocks[0].compact, true)
const missingHoursPage = createPage({ viewMode: 'day', currentDateText: '2026-10-12' })
const missingHoursEmptyState = missingHoursPage.buildDayView({
+1 -1
View File
@@ -96,7 +96,7 @@
<text class="business-hours-empty-title">预约时间轴暂不可用</text>
<text class="business-hours-empty-desc">请先设置门店营业时间,再安排普通预约。</text>
</view>
<scroll-view wx:else class="day-board card" scroll-y>
<scroll-view wx:else class="day-board card" style="height: {{timelineViewportHeight}}rpx;" scroll-y>
<view class="timeline-wrap" style="height: {{timelineHeight}}rpx;">
<view class="time-axis">
<view wx:for="{{hours}}" wx:key="value" class="time-label" style="top: {{item.top}}rpx;">{{item.label}}</view>
+1 -2
View File
@@ -359,14 +359,13 @@
}
.day-board {
height: 820rpx;
max-height: 820rpx;
margin-top: 12rpx;
overflow: hidden;
}
.timeline-wrap {
position: relative;
min-height: 774rpx;
}
.time-axis {
+1 -1
View File
@@ -3,7 +3,7 @@
<view class="progress-row"><view class="progress-step {{step >= 1 ? 'active' : ''}}"><text>1</text><label>选择身份</label></view><view class="progress-line {{step >= 2 ? 'active' : ''}}"></view><view class="progress-step {{step >= 2 ? 'active' : ''}}"><text>2</text><label>补充资料</label></view><view class="progress-line {{step >= 3 ? 'active' : ''}}"></view><view class="progress-step {{step >= 3 ? 'active' : ''}}"><text>3</text><label>申请状态</label></view></view>
<view wx:if="{{ticketInvalid}}" class="card result-card"><view class="result-icon">!</view><view class="section-title">申请入口已失效</view><view class="section-desc">这次注册凭证已过期或已使用,请返回登录页重新点击微信快捷登录获取新凭证。</view><button class="primary-btn" bindtap="back">重新快捷登录</button></view>
<view wx:elif="{{step === 1}}" class="card form-card"><view class="section-title"><text class="required-mark">*</text>选择工作身份</view><view class="section-desc">无需手机号和密码,审核人会根据你的身份处理申请</view><view class="role-list"><view class="role-option {{role === 'manager' ? 'selected' : ''}}" data-role="manager" bindtap="selectRole"><view class="role-icon">店</view><view class="role-copy"><text class="role-title">店长</text><text class="role-desc">创建并负责一家 Salon 门店</text></view><text class="role-mark">{{role === 'manager' ? '✓' : '○'}}</text></view><view class="role-option {{role === 'staff' ? 'selected' : ''}}" data-role="staff" bindtap="selectRole"><view class="role-icon">员</view><view class="role-copy"><text class="role-title">店员</text><text class="role-desc">加入已有门店协同工作</text></view><text class="role-mark">{{role === 'staff' ? '✓' : '○'}}</text></view></view><button class="primary-btn" bindtap="continueFromRole">继续</button></view>
<view wx:elif="{{step === 2}}" class="card form-card"><view class="section-title">补充资料</view><view class="section-desc">{{role === 'manager' ? '提交后由平台管理员审核' : '提交后由对应店长审核,昵称和头像为必填资料'}}</view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label"><text class="required-mark">*</text>店铺名称</text><input value="{{form.shopName}}" data-field="shopName" bindinput="onInput" placeholder="请输入店铺名称" /></view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label">店铺地址 <text class="optional-mark">选填</text></text><view class="address-entry"><input value="{{form.shopAddress}}" data-field="shopAddress" bindinput="onInput" placeholder="可手动填写门店地址" /><button class="map-pick-btn" bindtap="chooseShopLocation">地图选点</button></view><text class="field-hint">地图选点为可选项,仅用于门店展示和预约导航,不会在后台静默获取位置。</text></view><view wx:if="{{role === 'staff'}}" class="field"><text class="field-label"><text class="required-mark">*</text>选择店铺</text><view class="picker-value {{selectedShopName ? 'filled' : ''}}" bindtap="openShopSheet"><text>{{selectedShopName || '请选择要加入的店铺'}}</text><text class="picker-arrow">›</text></view></view><view wx:if="{{role === 'staff'}}" class="field"><text class="field-label"><text class="required-mark">*</text>昵称</text><input type="nickname" maxlength="20" value="{{form.applicantNickname}}" data-field="applicantNickname" bindinput="onInput" placeholder="点击输入框选择或填写微信昵称" /><text class="field-hint">可从微信昵称中选择,也可以手动填写,最多20个字。</text></view><view wx:if="{{role === 'staff'}}" class="field avatar-pick-field"><text class="field-label"><text class="required-mark">*</text>头像</text><button class="avatar-pick" open-type="chooseAvatar" bindchooseavatar="chooseApplicantAvatar"><image src="{{form.applicantAvatarUrl || '/assets/images/default-user-avatar.png'}}" mode="aspectFill"></image><text>{{avatarUploading ? '上传中...' : '点击选择微信头像'}}</text></button><text class="field-hint">请选择头像,头像会先上传并完成资料登记,提交时只引用已上传的文件。</text></view><view wx:if="{{role === 'staff'}}" class="notice">审核通过前不会获得门店业务权限</view><button class="primary-btn" loading="{{loading}}" disabled="{{avatarUploading}}" bindtap="submit">提交审核</button><view class="back-entry" bindtap="goBackStep">返回上一步</view></view>
<view wx:elif="{{step === 2}}" class="card form-card"><view class="section-title">补充资料</view><view class="section-desc">{{role === 'manager' ? '提交后由平台管理员审核' : '提交后由对应店长审核,昵称和头像为必填资料'}}</view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label"><text class="required-mark">*</text>店铺名称</text><input value="{{form.shopName}}" data-field="shopName" bindinput="onInput" placeholder="请输入店铺名称" /></view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label">店铺地址 <text class="optional-mark">选填</text></text><view class="address-entry"><input value="{{form.shopAddress}}" data-field="shopAddress" bindinput="onInput" placeholder="可手动填写门店地址" /><button class="map-pick-btn" bindtap="chooseShopLocation">地图选点</button></view><text class="field-hint">地图选点为可选项,仅用于门店展示和预约导航,不会在后台静默获取位置。</text></view><view wx:if="{{role === 'staff'}}" class="field"><text class="field-label"><text class="required-mark">*</text>选择店铺</text><view class="picker-value {{selectedShopName ? 'filled' : ''}}" bindtap="openShopSheet"><text>{{selectedShopName || '请选择要加入的店铺'}}</text><text class="picker-arrow">›</text></view></view><view wx:if="{{role === 'staff'}}" class="field"><text class="field-label"><text class="required-mark">*</text>昵称</text><input type="nickname" maxlength="20" value="{{form.applicantNickname}}" data-field="applicantNickname" bindinput="onInput" placeholder="点击输入框选择或填写微信昵称" /><text class="field-hint">可从微信昵称中选择,也可以手动填写,最多20个字。</text></view><view wx:if="{{role === 'staff'}}" class="field avatar-pick-field"><text class="field-label"><text class="required-mark">*</text>头像</text><button class="avatar-pick" open-type="chooseAvatar" bindchooseavatar="chooseApplicantAvatar"><image src="{{form.applicantAvatarUrl || '/assets/images/default-user-avatar.png'}}" mode="aspectFill"></image><text>{{avatarUploading ? '上传中...' : '选择头像'}}</text></button><text class="field-hint">请选择头像,头像会先上传并完成资料登记,提交时只引用已上传的文件。</text></view><view wx:if="{{role === 'staff'}}" class="notice">审核通过前不会获得门店业务权限</view><button class="primary-btn" loading="{{loading}}" disabled="{{avatarUploading}}" bindtap="submit">提交审核</button><view class="back-entry" bindtap="goBackStep">返回上一步</view></view>
<view wx:elif="{{step === 3}}" class="card result-card"><view class="result-icon {{registrationStatusText === '已驳回' ? 'rejected' : registrationStatusText === '已通过' ? 'approved' : ''}}">{{registrationStatusText === '已驳回' ? '!' : registrationStatusText === '已通过' ? '✓' : '…'}}</view><view class="section-title">{{registrationStatusText === '已通过' ? '申请已通过' : registrationStatusText === '已驳回' ? '申请未通过' : '申请已提交'}}</view><view class="section-desc">{{registrationStatusText === '已通过' ? '现在可以返回登录页,使用微信快捷登录。' : registrationStatusText === '已驳回' ? (registrationStatus.rejectReason || '返回登录并重新快捷登录后,可修改资料再次申请。') : (role === 'manager' ? '申请由平台管理员处理,通过后即可使用快捷登录。' : '申请由门店店长处理,通过后即可使用快捷登录。')}}</view><view class="result-status">当前状态:<text>{{registrationStatusText}}</text></view><view class="registration-details"><view class="registration-detail"><text>申请门店</text><text>{{registrationStatus.shopName || selectedShopName || form.shopName || '—'}}</text></view><view class="registration-detail"><text>申请身份</text><text>{{role === 'manager' ? '店长' : '店员'}}</text></view><view wx:if="{{role === 'staff'}}" class="registration-detail"><text>申请昵称</text><text>{{form.applicantNickname || '—'}}</text></view><view wx:if="{{registrationStatus.applicationNo}}" class="registration-detail"><text>申请编号</text><text>{{registrationStatus.applicationNo}}</text></view><view class="registration-detail"><text>提交时间</text><text>{{applicationSubmittedAt || '刚刚'}}</text></view></view><view wx:if="{{contentStatusText}}" class="content-review-status"><text>{{contentStatusText}}</text><text wx:if="{{contentStatusReason}}" class="content-review-reason">{{contentStatusReason}}</text></view><button wx:if="{{registrationStatusText === '已驳回'}}" class="primary-btn" bindtap="reapply">返回登录并重新申请</button><button wx:else class="primary-btn" bindtap="back">返回登录</button></view>
<entity-selector-sheet visible="{{shopSheetVisible}}" title="选择门店" keyword="{{shopKeyword}}" placeholder="搜索门店名称或地址" items="{{shopSelectorItems}}" selected-id="{{form.shopId}}" loading="{{shopLoading}}" error-text="{{shopError}}" empty-text="暂无匹配门店" bind:search="onShopSearch" bind:select="selectShop" bind:retry="loadShops" bind:close="closeShopSheet" />
<view class="safe-note">OpenID 仅用于识别你的微信身份,不会在页面中展示。</view>