Compare commits
7
Commits
435852a09d
...
4cbf6e7906
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cbf6e7906 | ||
|
|
0e648c19ba | ||
|
|
8d38c90274 | ||
|
|
a6e308f034 | ||
|
|
4fa2d2d113 | ||
|
|
d510e2d201 | ||
|
|
7de8a2ae23 |
+13
-6
@@ -8,10 +8,10 @@ Page({
|
||||
scrollToMessage: '',
|
||||
expandedIds: {},
|
||||
quickQuestions: [
|
||||
'今日待处理订单有哪些?',
|
||||
'最近客户反馈统计',
|
||||
'如何修改服务价格?',
|
||||
'陪诊员排班情况'
|
||||
'今天有哪些待处理订单?',
|
||||
'下一单的服务时间和医院',
|
||||
'这家医院的科室位置和挂号流程',
|
||||
'陪诊需要带哪些材料?'
|
||||
]
|
||||
},
|
||||
|
||||
@@ -45,9 +45,15 @@ Page({
|
||||
})
|
||||
|
||||
this.socket.onMessage((data) => {
|
||||
if (data && data.type === 'ai') {
|
||||
if (!data || !data.type) return
|
||||
if (data.type === 'ai') {
|
||||
this.handleAIReply(data)
|
||||
} else if (data && data.type === 'system') {
|
||||
} else if (data.type === 'end') {
|
||||
this.setData({ isTyping: false })
|
||||
} else if (data.type === 'error') {
|
||||
// 权限不足、频次限制等服务端拒绝必须展示,否则用户只看到一直输入中
|
||||
this.handleAIError(data.content || '服务处理失败,请稍后重试')
|
||||
} else if (data.type === 'system') {
|
||||
console.log('[AIChat] System:', data.content)
|
||||
}
|
||||
})
|
||||
@@ -204,6 +210,7 @@ Page({
|
||||
this.socket.send({
|
||||
type: type,
|
||||
content: content,
|
||||
ts: new Date().toISOString(),
|
||||
userId: user ? user._id : '',
|
||||
token: user ? user.security.token : '',
|
||||
appId: app.globalData.appId || '',
|
||||
|
||||
+10
-23
@@ -1,13 +1,19 @@
|
||||
// pages/home/index.js
|
||||
const API = require('../../utils/api.js')
|
||||
|
||||
// 取消与 status 解耦:展示状态优先取 cancelStatus
|
||||
function resolveDisplayStatus(order) {
|
||||
const cancelStatus = order?.cancelStatus || 'none'
|
||||
if (cancelStatus === 'cancelled') return 'cancelled'
|
||||
if (cancelStatus === 'requested') return 'cancel_requested'
|
||||
return order?.status || 'pending'
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
today: '',
|
||||
greeting: '',
|
||||
todayText: '',
|
||||
pendingCount: 0,
|
||||
completedCount: 0,
|
||||
recentOrders: [],
|
||||
// 快捷入口:type=quick 为快捷操作(橙色系),type=function 为功能入口(绿色系),分行显示
|
||||
quickEntries: [
|
||||
@@ -27,21 +33,10 @@ Page({
|
||||
},
|
||||
todayIncome: 0,
|
||||
todayOrderCount: 0,
|
||||
pendingOrder: {
|
||||
count: 1,
|
||||
hospital: '中医院',
|
||||
time: '10:00',
|
||||
price: 88
|
||||
},
|
||||
ongoingOrder: {
|
||||
count: 1,
|
||||
hospital: '康复医院',
|
||||
time: '15:30',
|
||||
price: 128
|
||||
},
|
||||
statusMap: {
|
||||
pending: '待确认',
|
||||
confirmed: '已确认',
|
||||
cancel_requested: '待取消',
|
||||
in_progress: '进行中',
|
||||
completed: '已完成',
|
||||
cancelled: '已取消'
|
||||
@@ -99,15 +94,6 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
onOrderCardTap(e) {
|
||||
const { type } = e.currentTarget.dataset
|
||||
const title = type === 'pending' ? '待接单' : '进行中'
|
||||
wx.showToast({
|
||||
title: `${title} 订单列表`,
|
||||
icon: 'none'
|
||||
})
|
||||
},
|
||||
|
||||
async getStats() {
|
||||
const now = new Date();
|
||||
const pad = (n) => String(n).padStart(2, '0');
|
||||
@@ -159,6 +145,7 @@ Page({
|
||||
item.schedule.date = item.schedule.startTime
|
||||
? `${dateText} ${item.schedule.startTime}`
|
||||
: `${dateText} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
||||
item.displayStatus = resolveDisplayStatus(item);
|
||||
return item;
|
||||
});
|
||||
this.setData({ recentOrders: records });
|
||||
|
||||
@@ -86,8 +86,8 @@
|
||||
<view class="order-line1">
|
||||
<text class="order-patient">{{item.patient.name}}</text>
|
||||
<text class="order-service">{{item.escort.serviceName}}</text>
|
||||
<view class="status-tag status-{{item.status}}">
|
||||
<text>{{statusMap[item.status] || item.status}}</text>
|
||||
<view class="status-tag status-{{item.displayStatus}}">
|
||||
<text>{{statusMap[item.displayStatus] || item.displayStatus}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="order-line2">
|
||||
|
||||
+34
-7
@@ -6,6 +6,7 @@ const { calcAge } = require('../../utils/format.js')
|
||||
const STATUS_MAP = {
|
||||
pending: { label: '待确认', text: '待确认', color: '#f59f00' },
|
||||
confirmed: { label: '已确认', text: '已确认', color: '#1abc9c' },
|
||||
cancel_requested: { label: '待取消', text: '待取消', color: '#f59f00' },
|
||||
in_progress: { label: '进行中', text: '进行中', color: '#20c997' },
|
||||
completed: { label: '已完成', text: '已完成', color: '#51cf66' },
|
||||
cancelled: { label: '已取消', text: '已取消', color: '#ff6b6b' }
|
||||
@@ -15,12 +16,21 @@ const STATUS_MAP = {
|
||||
const STATUS_FILTERS = [
|
||||
{ label: '全部', value: '', count: 0 },
|
||||
{ label: '待确认', value: 'pending', count: 0 },
|
||||
{ label: '待取消', value: 'cancel_requested', count: 0 },
|
||||
{ label: '已确认', value: 'confirmed', count: 0 },
|
||||
{ label: '进行中', value: 'in_progress', count: 0 },
|
||||
{ label: '已完成', value: 'completed', count: 0 },
|
||||
{ label: '已取消', value: 'cancelled', count: 0 }
|
||||
];
|
||||
|
||||
// 取消与 status 解耦:展示状态优先取 cancelStatus
|
||||
function resolveDisplayStatus(order) {
|
||||
const cancelStatus = order?.cancelStatus || 'none'
|
||||
if (cancelStatus === 'cancelled') return 'cancelled'
|
||||
if (cancelStatus === 'requested') return 'cancel_requested'
|
||||
return order?.status || 'pending'
|
||||
}
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
@@ -31,6 +41,7 @@ Page({
|
||||
stats: {
|
||||
total: 0,
|
||||
pending: 0,
|
||||
cancelRequested: 0,
|
||||
confirmed: 0,
|
||||
inProgress: 0,
|
||||
completed: 0,
|
||||
@@ -74,6 +85,7 @@ Page({
|
||||
const stats = {
|
||||
total: orders.length,
|
||||
pending: 0,
|
||||
cancelRequested: 0,
|
||||
confirmed: 0,
|
||||
inProgress: 0,
|
||||
completed: 0,
|
||||
@@ -81,10 +93,13 @@ Page({
|
||||
};
|
||||
|
||||
orders.forEach(order => {
|
||||
switch (order.status) {
|
||||
switch (resolveDisplayStatus(order)) {
|
||||
case 'pending':
|
||||
stats.pending++;
|
||||
break;
|
||||
case 'cancel_requested':
|
||||
stats.cancelRequested++;
|
||||
break;
|
||||
case 'confirmed':
|
||||
stats.confirmed++;
|
||||
break;
|
||||
@@ -116,6 +131,9 @@ Page({
|
||||
case 'pending':
|
||||
count = stats.pending;
|
||||
break;
|
||||
case 'cancel_requested':
|
||||
count = stats.cancelRequested;
|
||||
break;
|
||||
case 'confirmed':
|
||||
count = stats.confirmed;
|
||||
break;
|
||||
@@ -152,9 +170,11 @@ Page({
|
||||
processOrders(orders) {
|
||||
return orders.map(order => {
|
||||
const age = calcAge(order.patient?.birth)
|
||||
const displayStatus = resolveDisplayStatus(order)
|
||||
return {
|
||||
...order,
|
||||
statusText: STATUS_MAP[order.status]?.text || order.status,
|
||||
displayStatus,
|
||||
statusText: STATUS_MAP[displayStatus]?.text || displayStatus,
|
||||
patientFirstChar: (order.patient?.name || '?')[0],
|
||||
patientAgeText: age ? `${age}岁` : '',
|
||||
schedule: {
|
||||
@@ -178,7 +198,9 @@ Page({
|
||||
const params = {
|
||||
page,
|
||||
pageSize,
|
||||
status: 'pending,confirmed,in_progress,completed,cancelled'
|
||||
// 筛选在本页按展示状态完成,因此一次取回含已取消在内的全部订单
|
||||
status: 'pending,confirmed,in_progress,completed',
|
||||
includeCancelled: 1
|
||||
};
|
||||
|
||||
API.escort.getAllRecords(params)
|
||||
@@ -204,7 +226,7 @@ Page({
|
||||
|
||||
const { currentStatus } = this.data;
|
||||
const orderList = currentStatus
|
||||
? allOrders.filter(order => order.status === currentStatus)
|
||||
? allOrders.filter(order => order.displayStatus === currentStatus)
|
||||
: allOrders;
|
||||
total = orderList.length;
|
||||
|
||||
@@ -332,10 +354,15 @@ Page({
|
||||
|
||||
const orderList = this.data.orderList.map(order => {
|
||||
if (order._id === id) {
|
||||
// 取消只写 cancelStatus,status 保留取消前的服务状态
|
||||
const next = newStatus === 'cancelled'
|
||||
? { ...order, cancelStatus: 'cancelled', cancelledAt: new Date().toISOString() }
|
||||
: { ...order, status: newStatus }
|
||||
const displayStatus = resolveDisplayStatus(next)
|
||||
return {
|
||||
...order,
|
||||
status: newStatus,
|
||||
statusText: STATUS_MAP[newStatus]?.text || newStatus,
|
||||
...next,
|
||||
displayStatus,
|
||||
statusText: STATUS_MAP[displayStatus]?.text || displayStatus,
|
||||
'meta.updatetime': new Date().toISOString()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
>
|
||||
<!-- 卡片头部 -->
|
||||
<view class="card-top">
|
||||
<view class="status-badge status-{{item.status}}">
|
||||
<view class="status-badge status-{{item.displayStatus}}">
|
||||
<text>{{item.statusText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -113,28 +113,28 @@
|
||||
<view class="action-area">
|
||||
<view
|
||||
class="action-btn btn-ghost"
|
||||
wx:if="{{item.status === 'pending'}}"
|
||||
wx:if="{{item.displayStatus === 'pending'}}"
|
||||
data-id="{{item._id}}"
|
||||
data-action="cancel"
|
||||
catchtap="onOrderAction"
|
||||
>取消</view>
|
||||
<view
|
||||
class="action-btn btn-solid"
|
||||
wx:if="{{item.status === 'pending'}}"
|
||||
wx:if="{{item.displayStatus === 'pending'}}"
|
||||
data-id="{{item._id}}"
|
||||
data-action="confirm"
|
||||
catchtap="onOrderAction"
|
||||
>确认</view>
|
||||
<view
|
||||
class="action-btn btn-solid"
|
||||
wx:if="{{item.status === 'confirmed'}}"
|
||||
wx:if="{{item.displayStatus === 'confirmed'}}"
|
||||
data-id="{{item._id}}"
|
||||
data-action="start"
|
||||
catchtap="onOrderAction"
|
||||
>开始服务</view>
|
||||
<view
|
||||
class="action-btn btn-solid"
|
||||
wx:if="{{item.status === 'in_progress'}}"
|
||||
wx:if="{{item.displayStatus === 'in_progress'}}"
|
||||
data-id="{{item._id}}"
|
||||
data-action="complete"
|
||||
catchtap="onOrderAction"
|
||||
|
||||
@@ -4,6 +4,7 @@ const API = require('../../utils/api.js')
|
||||
const STATUS_MAP = {
|
||||
pending: '待确认',
|
||||
confirmed: '已确认',
|
||||
cancel_requested: '待取消',
|
||||
in_progress: '进行中',
|
||||
completed: '已完成',
|
||||
cancelled: '已取消'
|
||||
@@ -12,18 +13,41 @@ const STATUS_MAP = {
|
||||
const STATUS_DESC_MAP = {
|
||||
pending: '订单已创建,等待确认',
|
||||
confirmed: '订单已确认,等待服务',
|
||||
cancel_requested: '用户已申请取消,待确认',
|
||||
in_progress: '陪诊服务正在进行',
|
||||
completed: '陪诊服务已完成',
|
||||
cancelled: '订单已取消'
|
||||
}
|
||||
|
||||
// 取消与 status 解耦:展示状态优先取 cancelStatus
|
||||
function resolveDisplayStatus(order) {
|
||||
const cancelStatus = order?.cancelStatus || 'none'
|
||||
if (cancelStatus === 'cancelled') return 'cancelled'
|
||||
if (cancelStatus === 'requested') return 'cancel_requested'
|
||||
return order?.status || 'pending'
|
||||
}
|
||||
|
||||
const PAYMENT_STATUS_MAP = {
|
||||
unpaid: '未支付',
|
||||
partial: '部分支付',
|
||||
paid: '已支付',
|
||||
refunding: '退款中',
|
||||
refunded: '已退款'
|
||||
}
|
||||
|
||||
// 支付方式:与 schema 的 payment.method 枚举一一对应
|
||||
const PAYMENT_METHOD_MAP = {
|
||||
online_wechat: '线上微信',
|
||||
offline_cash: '线下现金',
|
||||
offline_transfer: '线下转账'
|
||||
}
|
||||
|
||||
// 支付渠道:用户下单时的选择,历史订单缺失按线下解释
|
||||
const PAY_CHANNEL_MAP = {
|
||||
online_wechat: '微信支付',
|
||||
offline: '线下支付'
|
||||
}
|
||||
|
||||
function formatDate(timestamp) {
|
||||
if (!timestamp) return ''
|
||||
const date = new Date(timestamp)
|
||||
@@ -62,11 +86,16 @@ Page({
|
||||
createtimeText: '',
|
||||
updatetimeText: '',
|
||||
paymentStatusText: '',
|
||||
paymentMethodText: '',
|
||||
payChannelText: '',
|
||||
showQueryRefundBtn: false,
|
||||
queryingRefund: false,
|
||||
attendantSexText: '',
|
||||
sexRequirementText: '',
|
||||
// 操作按钮配置
|
||||
showConfirmBtn: false,
|
||||
showCancelBtn: false,
|
||||
cancelBtnText: '取消订单',
|
||||
showStartBtn: false,
|
||||
showCompleteBtn: false
|
||||
},
|
||||
@@ -110,7 +139,8 @@ Page({
|
||||
},
|
||||
|
||||
applyOrderData(order) {
|
||||
const status = order.status || 'pending'
|
||||
const cancelStatus = order.cancelStatus || 'none'
|
||||
const status = resolveDisplayStatus(order)
|
||||
const attendant = order.attendant || {}
|
||||
const schedule = order.schedule || {}
|
||||
const payment = order.payment || {}
|
||||
@@ -124,6 +154,7 @@ Page({
|
||||
healthProfileId: order.healthProfileId || '',
|
||||
statusText: STATUS_MAP[status] || status,
|
||||
statusDesc: STATUS_DESC_MAP[status] || '',
|
||||
statusClass: status,
|
||||
attendantFirstChar: (attendant.name || '?')[0],
|
||||
scheduleDateText: formatDate(schedule.date),
|
||||
scheduleStartTimeText: schedule.startTime || '',
|
||||
@@ -131,14 +162,21 @@ Page({
|
||||
createtimeText: formatDateTime(meta.createtime),
|
||||
updatetimeText: formatDateTime(meta.updatetime),
|
||||
paymentStatusText: PAYMENT_STATUS_MAP[payment.status] || payment.status || '未支付',
|
||||
paymentMethodText: PAYMENT_METHOD_MAP[payment.method] || '',
|
||||
payChannelText: PAY_CHANNEL_MAP[payment.payChannel || 'offline'] || '',
|
||||
// 退款回调丢失时由管理端主动查退款补写终态
|
||||
showQueryRefundBtn: payment.status === 'refunding',
|
||||
queryingRefund: false,
|
||||
attendantSexText: attendant.sex === 'male' ? '男' : attendant.sex === 'female' ? '女' : '',
|
||||
sexRequirementText: escort.sexRequirement === 'male' ? '要求男陪诊' : escort.sexRequirement === 'female' ? '要求女陪诊' : '不限',
|
||||
// 操作按钮(任何状态下均可编辑订单信息)
|
||||
showEditBtn: true,
|
||||
showConfirmBtn: status === 'pending',
|
||||
showCancelBtn: status === 'pending',
|
||||
showStartBtn: status === 'confirmed',
|
||||
showCompleteBtn: status === 'in_progress'
|
||||
showConfirmBtn: cancelStatus === 'none' && status === 'pending',
|
||||
showCancelBtn: cancelStatus === 'requested'
|
||||
|| (cancelStatus === 'none' && (status === 'pending' || status === 'confirmed')),
|
||||
cancelBtnText: cancelStatus === 'requested' ? '同意取消' : '取消订单',
|
||||
showStartBtn: cancelStatus === 'none' && status === 'confirmed',
|
||||
showCompleteBtn: cancelStatus === 'none' && status === 'in_progress'
|
||||
})
|
||||
},
|
||||
|
||||
@@ -227,6 +265,33 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
// 主动查询退款结果:退款回调丢失时补写终态
|
||||
async onQueryRefund() {
|
||||
if (this.data.queryingRefund) return
|
||||
this.setData({ queryingRefund: true })
|
||||
wx.showLoading({ title: '查询中...' })
|
||||
try {
|
||||
const res = await API.escort.queryRefund(this.data.orderId)
|
||||
wx.hideLoading()
|
||||
if (res.code !== 0) {
|
||||
wx.showToast({ title: res.msg || '查询失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const status = res.data?.refund?.status
|
||||
wx.showToast({
|
||||
title: status === 'success' ? '退款已成功' : '查询完成',
|
||||
icon: status === 'success' ? 'success' : 'none'
|
||||
})
|
||||
this.loadOrderDetail(this.data.orderId)
|
||||
} catch (err) {
|
||||
wx.hideLoading()
|
||||
console.error('查询退款结果失败', err)
|
||||
wx.showToast({ title: '网络错误', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ queryingRefund: false })
|
||||
}
|
||||
},
|
||||
|
||||
async updateStatus(newStatus) {
|
||||
wx.showLoading({ title: '处理中...' })
|
||||
try {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<block wx:if="{{loaded && order}}">
|
||||
<!-- 顶部状态栏 -->
|
||||
<view class="status-header status-{{order.status}}">
|
||||
<view class="status-header status-{{statusClass}}">
|
||||
<view class="status-content">
|
||||
<text class="status-text">{{statusText}}</text>
|
||||
<text class="status-desc">{{statusDesc}}</text>
|
||||
@@ -125,6 +125,29 @@
|
||||
<text class="info-label">支付状态</text>
|
||||
<text class="info-value">{{paymentStatusText}}</text>
|
||||
</view>
|
||||
<view class="info-row" wx:if="{{payChannelText}}">
|
||||
<text class="info-label">支付渠道</text>
|
||||
<text class="info-value">{{payChannelText}}</text>
|
||||
</view>
|
||||
<view class="info-row" wx:if="{{paymentMethodText}}">
|
||||
<text class="info-label">支付方式</text>
|
||||
<text class="info-value">{{paymentMethodText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 病历与诉求 -->
|
||||
<view class="info-section" wx:if="{{order.inquiry.medicalHistory || order.inquiry.demand}}">
|
||||
<text class="section-title">病历与诉求</text>
|
||||
<view class="info-card">
|
||||
<view class="note-block" wx:if="{{order.inquiry.medicalHistory}}">
|
||||
<text class="note-label">病历</text>
|
||||
<text class="note-content">{{order.inquiry.medicalHistory}}</text>
|
||||
</view>
|
||||
<view class="note-block" wx:if="{{order.inquiry.demand}}">
|
||||
<text class="note-label">诉求</text>
|
||||
<text class="note-content">{{order.inquiry.demand}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -167,9 +190,10 @@
|
||||
</view>
|
||||
|
||||
<!-- 底部操作 -->
|
||||
<view class="bottom-actions" wx:if="{{showEditBtn || showConfirmBtn || showCancelBtn || showStartBtn || showCompleteBtn}}">
|
||||
<view class="bottom-actions" wx:if="{{showEditBtn || showConfirmBtn || showCancelBtn || showStartBtn || showCompleteBtn || showQueryRefundBtn}}">
|
||||
<view class="action-btn btn-ghost" wx:if="{{showQueryRefundBtn}}" bindtap="onQueryRefund">查询退款结果</view>
|
||||
<view class="action-btn btn-ghost" wx:if="{{showEditBtn}}" bindtap="onEdit">编辑订单</view>
|
||||
<view class="action-btn btn-ghost" wx:if="{{showCancelBtn}}" bindtap="onCancel">取消订单</view>
|
||||
<view class="action-btn btn-ghost" wx:if="{{showCancelBtn}}" bindtap="onCancel">{{cancelBtnText}}</view>
|
||||
<view class="action-btn btn-solid" wx:if="{{showConfirmBtn}}" bindtap="onConfirm">确认订单</view>
|
||||
<view class="action-btn btn-solid" wx:if="{{showStartBtn}}" bindtap="onStart">开始服务</view>
|
||||
<view class="action-btn btn-solid" wx:if="{{showCompleteBtn}}" bindtap="onComplete">完成服务</view>
|
||||
|
||||
+113
-9
@@ -2,6 +2,14 @@
|
||||
const API = require('../../utils/api.js')
|
||||
const { calcAge } = require('../../utils/format.js')
|
||||
|
||||
// 支付方式选项:与 schema 的 payment.method 枚举一一对应,空串表示未记录
|
||||
const METHOD_OPTIONS = [
|
||||
{ value: '', label: '未记录' },
|
||||
{ value: 'online_wechat', label: '线上微信' },
|
||||
{ value: 'offline_cash', label: '线下现金' },
|
||||
{ value: 'offline_transfer', label: '线下转账' }
|
||||
]
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
@@ -10,12 +18,16 @@ Page({
|
||||
data: {
|
||||
isEdit: false,
|
||||
form: {
|
||||
hospital: { name: '', department: '', doctor: '' },
|
||||
hospital: { province: '', name: '', department: '', doctor: '' },
|
||||
schedule: { date: '', startTime: '08:30' },
|
||||
escort: { serviceId: -1, serviceName: '' },
|
||||
payment: { totalFee: '' },
|
||||
notes: { patientNote: '' }
|
||||
payment: { totalFee: '', method: '' },
|
||||
notes: { patientNote: '' },
|
||||
inquiry: { medicalHistory: '', demand: '' }
|
||||
},
|
||||
// 省份选项来自服务目录的 areas,后端下单按同一份配置校验
|
||||
provinces: [],
|
||||
provinceIndex: 0,
|
||||
profileSummary: null,
|
||||
// 新增模式下尚未选择档案时为 true,展示选择占位
|
||||
needPickProfile: false,
|
||||
@@ -25,6 +37,11 @@ Page({
|
||||
filteredProfiles: [],
|
||||
profileKeyword: '',
|
||||
serviceOptions: [],
|
||||
// 支付方式选项与回显标签
|
||||
methodOptions: METHOD_OPTIONS,
|
||||
methodLabel: '',
|
||||
// 存在未支付流水时金额锁定:需先关单/取消后再改价
|
||||
amountLocked: false,
|
||||
today: '',
|
||||
submitting: false
|
||||
},
|
||||
@@ -163,7 +180,11 @@ Page({
|
||||
}
|
||||
const sexLabel = p.sex === 'male' ? '男' : (p.sex === 'female' ? '女' : '')
|
||||
const age = calcAge(p.birth)
|
||||
this.originalTotalFee = Number(order.payment && order.payment.totalFee) || 0
|
||||
const amountLocked = (order.payment?.status || 'unpaid') === 'unpaid'
|
||||
&& !!order.payment?.paymentRecordId
|
||||
this.setData({
|
||||
amountLocked,
|
||||
// 有关联档案时交由 patient-info 按 ID 加载(不读缓存,以档案最新数据为准)
|
||||
profileId: order.healthProfileId || '',
|
||||
// 无关联档案时用订单 patient 快照兜底展示姓名/性别/年龄/电话;
|
||||
@@ -178,6 +199,7 @@ Page({
|
||||
},
|
||||
form: {
|
||||
hospital: {
|
||||
province: (order.hospital && order.hospital.province) || '',
|
||||
name: (order.hospital && order.hospital.name) || '',
|
||||
department: (order.hospital && order.hospital.department) || '',
|
||||
doctor: (order.hospital && order.hospital.doctor) || ''
|
||||
@@ -192,11 +214,16 @@ Page({
|
||||
},
|
||||
payment: {
|
||||
totalFee: order.payment && order.payment.totalFee ? String(order.payment.totalFee) : '',
|
||||
method: (order.payment && order.payment.method) || '',
|
||||
paid: !!(order.payment && order.payment.status === 'paid')
|
||||
},
|
||||
notes: { patientNote: (order.notes && order.notes.patientNote) || '' }
|
||||
notes: { patientNote: (order.notes && order.notes.patientNote) || '' },
|
||||
inquiry: {
|
||||
medicalHistory: (order.inquiry && order.inquiry.medicalHistory) || '',
|
||||
demand: (order.inquiry && order.inquiry.demand) || ''
|
||||
}
|
||||
}
|
||||
})
|
||||
}, () => { this.syncProvinces(); this.syncMethodLabel() })
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('获取订单失败', err)
|
||||
@@ -275,7 +302,7 @@ Page({
|
||||
API.resource.getServices()
|
||||
.then(res => {
|
||||
if (res.code !== 0) return
|
||||
this.setData({ serviceOptions: (res.data && res.data.services) || [] })
|
||||
this.setData({ serviceOptions: (res.data && res.data.services) || [] }, () => this.syncProvinces())
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('获取服务列表失败', err)
|
||||
@@ -283,7 +310,48 @@ Page({
|
||||
},
|
||||
|
||||
/**
|
||||
* 服务名称选择:同时记录服务ID与服务名称
|
||||
* 同步省份选项:优先取当前服务的 areas,未选服务时取所有服务的并集。
|
||||
* 后端下单校验使用同一份服务目录,避免前后端省份口径不一致。
|
||||
*/
|
||||
syncProvinces() {
|
||||
const { serviceOptions, form } = this.data
|
||||
let areas = []
|
||||
|
||||
if (form.escort.serviceId !== -1) {
|
||||
const svc = serviceOptions.find(item => Number(item.id) === Number(form.escort.serviceId))
|
||||
if (svc && Array.isArray(svc.areas)) areas = svc.areas
|
||||
}
|
||||
|
||||
if (areas.length === 0) {
|
||||
const set = new Set()
|
||||
serviceOptions.forEach(item => (item.areas || []).forEach(area => set.add(area)))
|
||||
areas = Array.from(set)
|
||||
}
|
||||
|
||||
if (areas.length === 0) return
|
||||
|
||||
const current = form.hospital.province
|
||||
const province = areas.includes(current) ? current : areas[0]
|
||||
this.setData({
|
||||
provinces: areas,
|
||||
provinceIndex: Math.max(0, areas.indexOf(province)),
|
||||
'form.hospital.province': province
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 省份选择
|
||||
*/
|
||||
onProvinceChange(e) {
|
||||
const index = Number(e.detail.value)
|
||||
this.setData({
|
||||
provinceIndex: index,
|
||||
'form.hospital.province': this.data.provinces[index] || ''
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 服务名称选择:同时记录服务ID与服务名称,并同步该服务的省份范围
|
||||
*/
|
||||
onServiceChange(e) {
|
||||
const svc = this.data.serviceOptions[Number(e.detail.value)]
|
||||
@@ -291,7 +359,7 @@ Page({
|
||||
this.setData({
|
||||
'form.escort.serviceId': svc.id,
|
||||
'form.escort.serviceName': svc.title
|
||||
})
|
||||
}, () => this.syncProvinces())
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -301,6 +369,23 @@ Page({
|
||||
this.setData({ 'form.payment.paid': e.detail.value })
|
||||
},
|
||||
|
||||
/**
|
||||
* 支付方式选择
|
||||
*/
|
||||
onMethodChange(e) {
|
||||
const option = METHOD_OPTIONS[Number(e.detail.value)]
|
||||
if (!option) return
|
||||
this.setData({ 'form.payment.method': option.value }, () => this.syncMethodLabel())
|
||||
},
|
||||
|
||||
/**
|
||||
* 同步支付方式回显标签
|
||||
*/
|
||||
syncMethodLabel() {
|
||||
const option = METHOD_OPTIONS.find(item => item.value === this.data.form.payment.method)
|
||||
this.setData({ methodLabel: option ? option.label : '未记录' })
|
||||
},
|
||||
|
||||
/**
|
||||
* 提交订单(新增或保存修改)
|
||||
*/
|
||||
@@ -312,7 +397,9 @@ Page({
|
||||
// 患者信息取自档案/订单
|
||||
const patient = this.patientInfo
|
||||
if (!patient || !patient.name) return wx.showToast({ title: '健康档案信息未加载', icon: 'none' })
|
||||
if (!form.hospital.province) return wx.showToast({ title: '请选择省份', icon: 'none' })
|
||||
if (!form.hospital.name) return wx.showToast({ title: '请输入医院名称', icon: 'none' })
|
||||
if (form.escort.serviceId === -1) return wx.showToast({ title: '请选择服务', icon: 'none' })
|
||||
if (!form.schedule.date) return wx.showToast({ title: '请选择就诊日期', icon: 'none' })
|
||||
|
||||
const app = getApp()
|
||||
@@ -335,6 +422,7 @@ Page({
|
||||
healthProfileId: this.profileId || null,
|
||||
patient: this.patientInfo,
|
||||
hospital: {
|
||||
province: form.hospital.province,
|
||||
name: form.hospital.name,
|
||||
department: form.hospital.department,
|
||||
doctor: form.hospital.doctor
|
||||
@@ -350,11 +438,16 @@ Page({
|
||||
},
|
||||
payment: {
|
||||
totalFee: form.payment.totalFee ? Number(form.payment.totalFee) : 0,
|
||||
method: form.payment.method || '',
|
||||
paidFee: 0,
|
||||
status: 'unpaid'
|
||||
},
|
||||
notes: {
|
||||
patientNote: form.notes.patientNote
|
||||
},
|
||||
inquiry: {
|
||||
medicalHistory: form.inquiry.medicalHistory,
|
||||
demand: form.inquiry.demand
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,7 +478,15 @@ Page({
|
||||
* 编辑模式:保存修改
|
||||
*/
|
||||
updateOrder(form) {
|
||||
if (this.data.amountLocked) {
|
||||
const nextTotalFee = form.payment.totalFee ? Number(form.payment.totalFee) : 0
|
||||
if (nextTotalFee !== (this.originalTotalFee || 0)) {
|
||||
return wx.showToast({ title: '存在未支付流水,请先关闭后再修改金额', icon: 'none' })
|
||||
}
|
||||
}
|
||||
|
||||
const payload = {
|
||||
'hospital.province': form.hospital.province,
|
||||
'hospital.name': form.hospital.name,
|
||||
'hospital.department': form.hospital.department,
|
||||
'hospital.doctor': form.hospital.doctor,
|
||||
@@ -394,9 +495,12 @@ Page({
|
||||
'escort.serviceId': form.escort.serviceId || -1,
|
||||
'escort.serviceName': form.escort.serviceName,
|
||||
'payment.totalFee': form.payment.totalFee ? Number(form.payment.totalFee) : 0,
|
||||
'payment.method': form.payment.method || '',
|
||||
'payment.paidFee': form.payment.paid ? (form.payment.totalFee ? Number(form.payment.totalFee) : 0) : 0,
|
||||
'payment.status': form.payment.paid ? 'paid' : 'unpaid',
|
||||
'notes.patientNote': form.notes.patientNote
|
||||
'notes.patientNote': form.notes.patientNote,
|
||||
'inquiry.medicalHistory': form.inquiry.medicalHistory,
|
||||
'inquiry.demand': form.inquiry.demand
|
||||
}
|
||||
|
||||
this.setData({ submitting: true })
|
||||
|
||||
@@ -323,6 +323,13 @@ page {
|
||||
color: #1a1a2e;
|
||||
}
|
||||
|
||||
.field-tip {
|
||||
display: block;
|
||||
margin-top: 8rpx;
|
||||
font-size: 24rpx;
|
||||
color: #e6a23c;
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
margin-top: 16rpx;
|
||||
height: 96rpx;
|
||||
|
||||
@@ -40,6 +40,16 @@
|
||||
<view class="section">
|
||||
<view class="section-title">就诊信息</view>
|
||||
<view class="info-card">
|
||||
<view class="field">
|
||||
<text class="field-label">省份</text>
|
||||
<picker class="field-picker" mode="selector" range="{{provinces}}" value="{{provinceIndex}}" bindchange="onProvinceChange">
|
||||
<view class="field-value {{form.hospital.province ? '' : 'placeholder'}}">
|
||||
{{form.hospital.province || '请选择省份'}}
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<view class="field">
|
||||
<text class="field-label">医院</text>
|
||||
<input class="field-input" placeholder="请输入医院名称" value="{{form.hospital.name}}" data-key="hospital.name" bindinput="onInput" />
|
||||
@@ -93,7 +103,8 @@
|
||||
|
||||
<view class="field">
|
||||
<text class="field-label">费用(元)</text>
|
||||
<input class="field-input" type="digit" placeholder="请输入服务费用" value="{{form.payment.totalFee}}" data-key="payment.totalFee" bindinput="onInput" />
|
||||
<input class="field-input" type="digit" placeholder="请输入服务费用" value="{{form.payment.totalFee}}" data-key="payment.totalFee" bindinput="onInput" disabled="{{amountLocked}}" />
|
||||
<text class="field-tip" wx:if="{{amountLocked}}">存在未支付流水,金额已锁定</text>
|
||||
</view>
|
||||
|
||||
<view class="field">
|
||||
@@ -104,6 +115,26 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="field">
|
||||
<text class="field-label">支付方式</text>
|
||||
<picker class="field-picker" mode="selector" range="{{methodOptions}}" range-key="label" bindchange="onMethodChange">
|
||||
<view class="field-value">
|
||||
{{methodLabel || '未记录'}}
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<view class="field field-textarea">
|
||||
<text class="field-label">病历</text>
|
||||
<textarea class="field-area" placeholder="请输入病历信息(选填)" value="{{form.inquiry.medicalHistory}}" data-key="inquiry.medicalHistory" bindinput="onInput" />
|
||||
</view>
|
||||
|
||||
<view class="field field-textarea">
|
||||
<text class="field-label">诉求</text>
|
||||
<textarea class="field-area" placeholder="请输入陪诊诉求(选填)" value="{{form.inquiry.demand}}" data-key="inquiry.demand" bindinput="onInput" />
|
||||
</view>
|
||||
|
||||
<view class="field field-textarea">
|
||||
<text class="field-label">备注</text>
|
||||
<textarea class="field-area" placeholder="请输入备注信息(选填)" value="{{form.notes.patientNote}}" data-key="notes.patientNote" bindinput="onInput" />
|
||||
|
||||
@@ -21,6 +21,8 @@ const API = {
|
||||
updateRecord: (id, data) => request.put(`/health/escort-record/${id}`, data),
|
||||
updateStatus: (id, data) => request.patch(`/health/escort-record/${id}/status`, data),
|
||||
deleteRecord: (id) => request.delete(`/health/escort-record/${id}`),
|
||||
// 退款回调丢失时的人工兜底:主动查询微信退款结果并补写终态
|
||||
queryRefund: (id) => request.post(`/health/escort-record/${id}/refund/query`),
|
||||
},
|
||||
|
||||
healthProfile: {
|
||||
|
||||
Reference in New Issue
Block a user