From d510e2d201a23e9a6955a7646f82b08080ed2f23 Mon Sep 17 00:00:00 2001 From: lik Date: Tue, 3 Nov 2026 16:59:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(admin):=20=E4=B8=8B=E5=8D=95=E8=A1=A5?= =?UTF-8?q?=E5=85=85=E7=9C=81=E4=BB=BD=E5=B9=B6=E7=A7=BB=E9=99=A4=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E5=81=87=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/home/index.js | 23 ---------- pages/order/orderEdit.js | 92 +++++++++++++++++++++++++++++++++++--- pages/order/orderEdit.wxml | 20 +++++++++ 3 files changed, 106 insertions(+), 29 deletions(-) diff --git a/pages/home/index.js b/pages/home/index.js index 3cbfb08..bbf3195 100644 --- a/pages/home/index.js +++ b/pages/home/index.js @@ -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'); diff --git a/pages/order/orderEdit.js b/pages/order/orderEdit.js index 5be4462..c763b71 100644 --- a/pages/order/orderEdit.js +++ b/pages/order/orderEdit.js @@ -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 diff --git a/pages/order/orderEdit.wxml b/pages/order/orderEdit.wxml index 438e248..6838ff6 100644 --- a/pages/order/orderEdit.wxml +++ b/pages/order/orderEdit.wxml @@ -40,6 +40,16 @@ 就诊信息 + + 省份 + + + {{form.hospital.province || '请选择省份'}} + › + + + + 医院 @@ -104,6 +114,16 @@ + + 支付方式 + + + {{methodLabel || '未记录'}} + › + + + + 备注