fix(admin): 下单补充省份并移除首页假数据

This commit is contained in:
lik
2026-11-03 16:59:56 +08:00
parent 7de8a2ae23
commit d510e2d201
3 changed files with 106 additions and 29 deletions
-23
View File
@@ -6,8 +6,6 @@ Page({
today: '',
greeting: '',
todayText: '',
pendingCount: 0,
completedCount: 0,
recentOrders: [],
// 快捷入口:type=quick 为快捷操作(橙色系),type=function 为功能入口(绿色系),分行显示
quickEntries: [
@@ -27,18 +25,6 @@ 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: '已确认',
@@ -99,15 +85,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');
+86 -6
View File
@@ -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,15 @@ 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: '' },
payment: { totalFee: '', method: '' },
notes: { patientNote: '' }
},
// 省份选项来自服务目录的 areas,后端下单按同一份配置校验
provinces: [],
provinceIndex: 0,
profileSummary: null,
// 新增模式下尚未选择档案时为 true,展示选择占位
needPickProfile: false,
@@ -25,6 +36,9 @@ Page({
filteredProfiles: [],
profileKeyword: '',
serviceOptions: [],
// 支付方式选项与回显标签
methodOptions: METHOD_OPTIONS,
methodLabel: '',
today: '',
submitting: false
},
@@ -178,6 +192,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 +207,12 @@ 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) || '' }
}
})
}, () => { this.syncProvinces(); this.syncMethodLabel() })
})
.catch(err => {
console.error('获取订单失败', err)
@@ -275,7 +291,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 +299,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 +348,7 @@ Page({
this.setData({
'form.escort.serviceId': svc.id,
'form.escort.serviceName': svc.title
})
}, () => this.syncProvinces())
},
/**
@@ -301,6 +358,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 +386,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 +411,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,6 +427,7 @@ Page({
},
payment: {
totalFee: form.payment.totalFee ? Number(form.payment.totalFee) : 0,
method: form.payment.method || '',
paidFee: 0,
status: 'unpaid'
},
@@ -386,6 +464,7 @@ Page({
*/
updateOrder(form) {
const payload = {
'hospital.province': form.hospital.province,
'hospital.name': form.hospital.name,
'hospital.department': form.hospital.department,
'hospital.doctor': form.hospital.doctor,
@@ -394,6 +473,7 @@ 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
+20
View File
@@ -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" />
@@ -104,6 +114,16 @@
</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.notes.patientNote}}" data-key="notes.patientNote" bindinput="onInput" />