Files
Ubuntu b8bbf21599 feat(客户商城): 下单客户账号与小程序商城二期
正常客户开户/停用/重置;order_customer 三重闸;mall-panel 商品、地址、下单;价格/客户由服务端推导;菜单与账户入口修复。
2026-10-28 21:06:36 +08:00

135 lines
4.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const ROLE_OPTIONS = [
{ value: 'admin', label: '管理员', hint: '管理员/超级管理员账号' },
{ value: 'operator', label: '运营', hint: '运营角色或订单管理权限账号' },
{ value: 'purchaser', label: '采购员', hint: '使用采购员账号登录' },
{ value: 'supplier', label: '供应商', hint: '使用供应商管理中创建的账号' },
{ value: 'warehouse', label: '仓管员', hint: '到货验收、加工与验收' },
{ value: 'picker', label: '分拣员', hint: '分拣复核、提交出库' },
{ value: 'order_entry', label: '录单员', hint: '使用录单权限账号登录' },
{ value: 'order_customer', label: '下单客户', hint: '客户商城账号' },
{ value: 'delivery', label: '配送员', hint: '配送任务、验货上车' },
];
const ROLE_LABELS = {
admin: '管理员',
operator: '运营',
purchaser: '采购员',
supplier: '供应商',
warehouse: '仓管员',
inspector: '检验人员',
picker: '分拣员',
order_entry: '录单员',
delivery: '配送员',
order_customer: '下单客户',
};
const SESSION_KEY = 'canteen.mp.session';
/** 录单常用加工方式(与 Web processingMethods 对齐) */
const PROCESSING_METHOD_OPTIONS = [
'原材料',
'净菜',
'切配',
'熟食',
'砍',
'去皮',
'切片',
'切块',
'切丝',
'切段',
'切丁',
'清洗',
'洗净',
'打包',
'分装',
'剁碎',
'去根',
'去叶',
];
const ORDER_STATUS_LABELS = {
20: '待分配',
30: '待备货',
40: '待验收',
41: '拒收待处理',
45: '待分拣',
50: '待配送',
60: '配送中',
90: '已完成',
};
/**
* 散客录单(哨兵客户 `__RETAIL__`)在**未完成**时的状态名。
* 它没有备货/验收/分拣/配送(全额库存抵扣 + 一键完结)⇒ 显示「待备货」是错的。
* 文案与 Web 端**逐字同词**(开发者定稿),不新增说法。
*/
const RETAIL_PENDING_DEDUCT_LABEL = '待扣除';
/** 订单完成状态(状态链 20→30→40→45→50→60→**90** 的终点,与 Web `ORDER_COMPLETED_STATUS` 同值) */
const ORDER_COMPLETED_STATUS = 90;
/**
* 解析订单状态显示名。
* · 散客录单且未完成 ⇒ 「待扣除」(Web 同款)
* · 其余(含已完成的散客单)逐字沿用 `ORDER_STATUS_LABELS`,不改既有表现
* 设计:docs/design/20261015-小程序订单列表与详情跟随散客录单(待扣除·一键完结).md
*/
function resolveOrderStatusLabel(status, isRetail) {
const code = Number(status);
if (isRetail === true && Number.isFinite(code) && code < ORDER_COMPLETED_STATUS) {
return RETAIL_PENDING_DEDUCT_LABEL;
}
return ORDER_STATUS_LABELS[status] || (status === null || status === undefined ? '' : String(status));
}
const ORDER_ADVANCE_LABELS = {
20: '确认分配',
30: '确认备货',
40: '确认验收',
45: '分拣出库',
50: '开始配送',
60: '完成配送',
};
const DELIVERY_TIME_SLOT_LABELS = {
morning: '上午',
afternoon: '下午',
evening: '晚上',
noon: '中午',
all: '全天',
custom: '自定义',
};
function deliveryTimeSlotLabel(value) {
const key = String(value || '').trim().toLowerCase();
if (!key) return '';
return DELIVERY_TIME_SLOT_LABELS[key] || value;
}
function displayCustomerDeliveryDeadline(raw) {
const trimmed = String(raw || '').trim();
if (!trimmed) return '';
const m = trimmed.match(/^(\d{1,2})[::](\d{2})(?::\d{2})?$/);
if (!m) return trimmed;
const hour = Number(m[1]);
const minute = Number(m[2]);
if (!Number.isInteger(hour) || !Number.isInteger(minute)) return trimmed;
if (hour < 0 || hour > 23 || minute < 0 || minute > 59) return trimmed;
return `${String(hour).padStart(2, '0')}:${String(minute).padStart(2, '0')}`;
}
module.exports = {
ROLE_OPTIONS,
ROLE_LABELS,
SESSION_KEY,
PROCESSING_METHOD_OPTIONS,
ORDER_STATUS_LABELS,
ORDER_ADVANCE_LABELS,
ORDER_COMPLETED_STATUS,
RETAIL_PENDING_DEDUCT_LABEL,
resolveOrderStatusLabel,
DELIVERY_TIME_SLOT_LABELS,
deliveryTimeSlotLabel,
displayCustomerDeliveryDeadline,
};