优化配送订单状态中文展示
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
"gasorder-contract-products:check": "node scripts/check-gasorder-contract-product-display.mjs",
|
||||
"gasorder-creator:check": "node scripts/check-gasorder-creator-linkage.mjs",
|
||||
"gasorder-list-display:check": "node scripts/check-gasorder-list-display.mjs",
|
||||
"gasorder-status-display:check": "node scripts/check-gasorder-status-display.mjs",
|
||||
"product-ownership:check": "node scripts/check-product-ownership-action.mjs",
|
||||
"product-ownership-display:check": "node scripts/check-product-ownership-display.mjs",
|
||||
"product-lifecycle-display:check": "node scripts/check-product-lifecycle-display.mjs",
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 功能:检查配送订单详情和状态记录使用中文状态及明确空值文案。
|
||||
* 版本:v1.0.0
|
||||
*/
|
||||
import fs from 'node:fs';
|
||||
|
||||
const display = fs.readFileSync(new URL('../src/api/resource-display.ts', import.meta.url), 'utf8');
|
||||
const checks = [
|
||||
[display.includes("0: '草稿'"), '缺少状态记录原状态“草稿”文案'],
|
||||
[display.includes("16: '已创建'"), '缺少配送订单“已创建”状态文案'],
|
||||
[display.includes("34: '待确认'"), '缺少配送订单“待确认”状态文案'],
|
||||
[display.includes("key === 'previous_order_status' && Number(value) === 0"), '异常前订单状态 0 未单独处理'],
|
||||
[display.includes("return '暂未分配'"), '缺少未分配工作人员文案'],
|
||||
];
|
||||
|
||||
for (const [passed, message] of checks) {
|
||||
if (!passed) throw new Error(message);
|
||||
}
|
||||
|
||||
console.log('配送订单状态展示检查通过:状态中文化,哨兵值和未分配人员语义明确。');
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* 功能:统一资源列表与详情页面的字段名称、关系、金额、状态和时间展示。
|
||||
* 版本:v1.3.0
|
||||
* 版本:v1.4.0
|
||||
*/
|
||||
import dayjs from 'dayjs';
|
||||
import { staffRoleLabel } from './resource-staff-relation';
|
||||
@@ -141,6 +141,24 @@ export function contractStatusLabel(status: number) {
|
||||
);
|
||||
}
|
||||
|
||||
/** 将配送订单业务状态转换为状态机约定的中文名称。 */
|
||||
export function gasorderStatusLabel(status: number) {
|
||||
return (
|
||||
{
|
||||
0: '草稿',
|
||||
16: '已创建',
|
||||
18: '已分配',
|
||||
19: '充装中',
|
||||
20: '已就绪',
|
||||
21: '异常',
|
||||
22: '已取消',
|
||||
23: '已完成',
|
||||
33: '配送中',
|
||||
34: '待确认',
|
||||
}[status] ?? `未知(${status})`
|
||||
);
|
||||
}
|
||||
|
||||
/** 选择关系记录的首选可读名称。 */
|
||||
export function optionLabel(option: ResourceRow) {
|
||||
return String(
|
||||
@@ -227,10 +245,16 @@ function relationLabel(
|
||||
export function displayRawValue(key: string, value: unknown) {
|
||||
// 历史合同可能缺少到期时间,明确提示补录,避免将数据缺失误认为无期限合同。
|
||||
if (key === 'expired_at' && (value == null || value === '')) return '待补录';
|
||||
// 配送订单尚未分配时不存在工作人员标识,使用业务语义替代通用占位符。
|
||||
if (key === 'staff_account_identity' && (value == null || value === ''))
|
||||
return '暂未分配';
|
||||
if (value == null || value === '') return '-';
|
||||
if (typeof value === 'boolean') return value ? '是' : '否';
|
||||
if (key === 'status') return recordStatusLabel(Number(value));
|
||||
if (key === 'contract_status') return contractStatusLabel(Number(value));
|
||||
if (key === 'previous_order_status' && Number(value) === 0) return '无';
|
||||
if (['order_status', 'previous_order_status', 'from_status', 'to_status'].includes(key))
|
||||
return gasorderStatusLabel(Number(value));
|
||||
if (key === 'action') {
|
||||
return (
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user