完善店员申请关联与预约页面
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user