From 8d38c90274d925c962954df206da14ef2833ab44 Mon Sep 17 00:00:00 2001 From: lik Date: Thu, 5 Nov 2026 18:55:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=E8=AE=A2=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=8C=89=E5=8F=96=E6=B6=88=E7=8A=B6=E6=80=81=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=B8=8E=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 displayStatus,展示状态优先取 cancelStatus(待取消/已取消) - 首页最近订单、订单列表与筛选统一按展示状态统计 - 拉取订单包含已取消记录,筛选改在本页完成 - 取消操作只写 cancelStatus,不再覆盖服务状态 --- pages/home/index.js | 10 ++++++++++ pages/home/index.wxml | 4 ++-- pages/order/index.js | 31 ++++++++++++++++++++++++------- pages/order/index.wxml | 10 +++++----- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/pages/home/index.js b/pages/home/index.js index bbf3195..f48b0af 100644 --- a/pages/home/index.js +++ b/pages/home/index.js @@ -1,6 +1,14 @@ // 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: '', @@ -28,6 +36,7 @@ Page({ statusMap: { pending: '待确认', confirmed: '已确认', + cancel_requested: '待取消', in_progress: '进行中', completed: '已完成', cancelled: '已取消' @@ -136,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 }); diff --git a/pages/home/index.wxml b/pages/home/index.wxml index 6fc272f..5207e78 100644 --- a/pages/home/index.wxml +++ b/pages/home/index.wxml @@ -86,8 +86,8 @@ {{item.patient.name}} {{item.escort.serviceName}} - - {{statusMap[item.status] || item.status}} + + {{statusMap[item.displayStatus] || item.displayStatus}} diff --git a/pages/order/index.js b/pages/order/index.js index 24aea3b..b04fe63 100644 --- a/pages/order/index.js +++ b/pages/order/index.js @@ -23,6 +23,14 @@ const STATUS_FILTERS = [ { 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({ /** @@ -85,7 +93,7 @@ Page({ }; orders.forEach(order => { - switch (order.status) { + switch (resolveDisplayStatus(order)) { case 'pending': stats.pending++; break; @@ -162,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: { @@ -188,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) @@ -214,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; @@ -342,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() }; } diff --git a/pages/order/index.wxml b/pages/order/index.wxml index bb4ff71..3e8c86f 100644 --- a/pages/order/index.wxml +++ b/pages/order/index.wxml @@ -62,7 +62,7 @@ > - + {{item.statusText}} @@ -113,28 +113,28 @@ 取消 确认 开始服务