fix(admin): 下单补充省份并移除首页假数据
This commit is contained in:
@@ -6,8 +6,6 @@ Page({
|
|||||||
today: '',
|
today: '',
|
||||||
greeting: '',
|
greeting: '',
|
||||||
todayText: '',
|
todayText: '',
|
||||||
pendingCount: 0,
|
|
||||||
completedCount: 0,
|
|
||||||
recentOrders: [],
|
recentOrders: [],
|
||||||
// 快捷入口:type=quick 为快捷操作(橙色系),type=function 为功能入口(绿色系),分行显示
|
// 快捷入口:type=quick 为快捷操作(橙色系),type=function 为功能入口(绿色系),分行显示
|
||||||
quickEntries: [
|
quickEntries: [
|
||||||
@@ -27,18 +25,6 @@ Page({
|
|||||||
},
|
},
|
||||||
todayIncome: 0,
|
todayIncome: 0,
|
||||||
todayOrderCount: 0,
|
todayOrderCount: 0,
|
||||||
pendingOrder: {
|
|
||||||
count: 1,
|
|
||||||
hospital: '中医院',
|
|
||||||
time: '10:00',
|
|
||||||
price: 88
|
|
||||||
},
|
|
||||||
ongoingOrder: {
|
|
||||||
count: 1,
|
|
||||||
hospital: '康复医院',
|
|
||||||
time: '15:30',
|
|
||||||
price: 128
|
|
||||||
},
|
|
||||||
statusMap: {
|
statusMap: {
|
||||||
pending: '待确认',
|
pending: '待确认',
|
||||||
confirmed: '已确认',
|
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() {
|
async getStats() {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const pad = (n) => String(n).padStart(2, '0');
|
const pad = (n) => String(n).padStart(2, '0');
|
||||||
|
|||||||
@@ -2,6 +2,14 @@
|
|||||||
const API = require('../../utils/api.js')
|
const API = require('../../utils/api.js')
|
||||||
const { calcAge } = require('../../utils/format.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({
|
Page({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,12 +18,15 @@ Page({
|
|||||||
data: {
|
data: {
|
||||||
isEdit: false,
|
isEdit: false,
|
||||||
form: {
|
form: {
|
||||||
hospital: { name: '', department: '', doctor: '' },
|
hospital: { province: '', name: '', department: '', doctor: '' },
|
||||||
schedule: { date: '', startTime: '08:30' },
|
schedule: { date: '', startTime: '08:30' },
|
||||||
escort: { serviceId: -1, serviceName: '' },
|
escort: { serviceId: -1, serviceName: '' },
|
||||||
payment: { totalFee: '' },
|
payment: { totalFee: '', method: '' },
|
||||||
notes: { patientNote: '' }
|
notes: { patientNote: '' }
|
||||||
},
|
},
|
||||||
|
// 省份选项来自服务目录的 areas,后端下单按同一份配置校验
|
||||||
|
provinces: [],
|
||||||
|
provinceIndex: 0,
|
||||||
profileSummary: null,
|
profileSummary: null,
|
||||||
// 新增模式下尚未选择档案时为 true,展示选择占位
|
// 新增模式下尚未选择档案时为 true,展示选择占位
|
||||||
needPickProfile: false,
|
needPickProfile: false,
|
||||||
@@ -25,6 +36,9 @@ Page({
|
|||||||
filteredProfiles: [],
|
filteredProfiles: [],
|
||||||
profileKeyword: '',
|
profileKeyword: '',
|
||||||
serviceOptions: [],
|
serviceOptions: [],
|
||||||
|
// 支付方式选项与回显标签
|
||||||
|
methodOptions: METHOD_OPTIONS,
|
||||||
|
methodLabel: '',
|
||||||
today: '',
|
today: '',
|
||||||
submitting: false
|
submitting: false
|
||||||
},
|
},
|
||||||
@@ -178,6 +192,7 @@ Page({
|
|||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
hospital: {
|
hospital: {
|
||||||
|
province: (order.hospital && order.hospital.province) || '',
|
||||||
name: (order.hospital && order.hospital.name) || '',
|
name: (order.hospital && order.hospital.name) || '',
|
||||||
department: (order.hospital && order.hospital.department) || '',
|
department: (order.hospital && order.hospital.department) || '',
|
||||||
doctor: (order.hospital && order.hospital.doctor) || ''
|
doctor: (order.hospital && order.hospital.doctor) || ''
|
||||||
@@ -192,11 +207,12 @@ Page({
|
|||||||
},
|
},
|
||||||
payment: {
|
payment: {
|
||||||
totalFee: order.payment && order.payment.totalFee ? String(order.payment.totalFee) : '',
|
totalFee: order.payment && order.payment.totalFee ? String(order.payment.totalFee) : '',
|
||||||
|
method: (order.payment && order.payment.method) || '',
|
||||||
paid: !!(order.payment && order.payment.status === 'paid')
|
paid: !!(order.payment && order.payment.status === 'paid')
|
||||||
},
|
},
|
||||||
notes: { patientNote: (order.notes && order.notes.patientNote) || '' }
|
notes: { patientNote: (order.notes && order.notes.patientNote) || '' }
|
||||||
}
|
}
|
||||||
})
|
}, () => { this.syncProvinces(); this.syncMethodLabel() })
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error('获取订单失败', err)
|
console.error('获取订单失败', err)
|
||||||
@@ -275,7 +291,7 @@ Page({
|
|||||||
API.resource.getServices()
|
API.resource.getServices()
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.code !== 0) return
|
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 => {
|
.catch(err => {
|
||||||
console.error('获取服务列表失败', 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) {
|
onServiceChange(e) {
|
||||||
const svc = this.data.serviceOptions[Number(e.detail.value)]
|
const svc = this.data.serviceOptions[Number(e.detail.value)]
|
||||||
@@ -291,7 +348,7 @@ Page({
|
|||||||
this.setData({
|
this.setData({
|
||||||
'form.escort.serviceId': svc.id,
|
'form.escort.serviceId': svc.id,
|
||||||
'form.escort.serviceName': svc.title
|
'form.escort.serviceName': svc.title
|
||||||
})
|
}, () => this.syncProvinces())
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -301,6 +358,23 @@ Page({
|
|||||||
this.setData({ 'form.payment.paid': e.detail.value })
|
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
|
const patient = this.patientInfo
|
||||||
if (!patient || !patient.name) return wx.showToast({ title: '健康档案信息未加载', icon: 'none' })
|
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.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' })
|
if (!form.schedule.date) return wx.showToast({ title: '请选择就诊日期', icon: 'none' })
|
||||||
|
|
||||||
const app = getApp()
|
const app = getApp()
|
||||||
@@ -335,6 +411,7 @@ Page({
|
|||||||
healthProfileId: this.profileId || null,
|
healthProfileId: this.profileId || null,
|
||||||
patient: this.patientInfo,
|
patient: this.patientInfo,
|
||||||
hospital: {
|
hospital: {
|
||||||
|
province: form.hospital.province,
|
||||||
name: form.hospital.name,
|
name: form.hospital.name,
|
||||||
department: form.hospital.department,
|
department: form.hospital.department,
|
||||||
doctor: form.hospital.doctor
|
doctor: form.hospital.doctor
|
||||||
@@ -350,6 +427,7 @@ Page({
|
|||||||
},
|
},
|
||||||
payment: {
|
payment: {
|
||||||
totalFee: form.payment.totalFee ? Number(form.payment.totalFee) : 0,
|
totalFee: form.payment.totalFee ? Number(form.payment.totalFee) : 0,
|
||||||
|
method: form.payment.method || '',
|
||||||
paidFee: 0,
|
paidFee: 0,
|
||||||
status: 'unpaid'
|
status: 'unpaid'
|
||||||
},
|
},
|
||||||
@@ -386,6 +464,7 @@ Page({
|
|||||||
*/
|
*/
|
||||||
updateOrder(form) {
|
updateOrder(form) {
|
||||||
const payload = {
|
const payload = {
|
||||||
|
'hospital.province': form.hospital.province,
|
||||||
'hospital.name': form.hospital.name,
|
'hospital.name': form.hospital.name,
|
||||||
'hospital.department': form.hospital.department,
|
'hospital.department': form.hospital.department,
|
||||||
'hospital.doctor': form.hospital.doctor,
|
'hospital.doctor': form.hospital.doctor,
|
||||||
@@ -394,6 +473,7 @@ Page({
|
|||||||
'escort.serviceId': form.escort.serviceId || -1,
|
'escort.serviceId': form.escort.serviceId || -1,
|
||||||
'escort.serviceName': form.escort.serviceName,
|
'escort.serviceName': form.escort.serviceName,
|
||||||
'payment.totalFee': form.payment.totalFee ? Number(form.payment.totalFee) : 0,
|
'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.paidFee': form.payment.paid ? (form.payment.totalFee ? Number(form.payment.totalFee) : 0) : 0,
|
||||||
'payment.status': form.payment.paid ? 'paid' : 'unpaid',
|
'payment.status': form.payment.paid ? 'paid' : 'unpaid',
|
||||||
'notes.patientNote': form.notes.patientNote
|
'notes.patientNote': form.notes.patientNote
|
||||||
|
|||||||
@@ -40,6 +40,16 @@
|
|||||||
<view class="section">
|
<view class="section">
|
||||||
<view class="section-title">就诊信息</view>
|
<view class="section-title">就诊信息</view>
|
||||||
<view class="info-card">
|
<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">
|
<view class="field">
|
||||||
<text class="field-label">医院</text>
|
<text class="field-label">医院</text>
|
||||||
<input class="field-input" placeholder="请输入医院名称" value="{{form.hospital.name}}" data-key="hospital.name" bindinput="onInput" />
|
<input class="field-input" placeholder="请输入医院名称" value="{{form.hospital.name}}" data-key="hospital.name" bindinput="onInput" />
|
||||||
@@ -104,6 +114,16 @@
|
|||||||
</view>
|
</view>
|
||||||
</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">
|
<view class="field field-textarea">
|
||||||
<text class="field-label">备注</text>
|
<text class="field-label">备注</text>
|
||||||
<textarea class="field-area" placeholder="请输入备注信息(选填)" value="{{form.notes.patientNote}}" data-key="notes.patientNote" bindinput="onInput" />
|
<textarea class="field-area" placeholder="请输入备注信息(选填)" value="{{form.notes.patientNote}}" data-key="notes.patientNote" bindinput="onInput" />
|
||||||
|
|||||||
Reference in New Issue
Block a user