完善服务模块缺少付款页的bug
This commit is contained in:
161
utils/homecareStatus.uts
Normal file
161
utils/homecareStatus.uts
Normal file
@@ -0,0 +1,161 @@
|
||||
// =============================================================================
|
||||
// 居家服务统一状态常量与映射
|
||||
// 说明:
|
||||
// - 本文件对齐数据库 ec_care_tasks.status 口径与 ORDER_* 枚举。
|
||||
// - delivery / consumer 两端共用同一套状态常量,禁止各自维护不同文案。
|
||||
// - 状态流转必须由后端 RPC 推导,前端只做展示与权限判断。
|
||||
// =============================================================================
|
||||
|
||||
// 工单主状态(来自 ec_care_tasks.status)
|
||||
export const ORDER_CREATED = 'ORDER_CREATED'
|
||||
export const ORDER_ASSIGNED = 'ORDER_ASSIGNED'
|
||||
export const ORDER_ACCEPTED = 'ORDER_ACCEPTED'
|
||||
export const ORDER_REJECTED = 'ORDER_REJECTED'
|
||||
export const ORDER_CHECKED_IN = 'ORDER_CHECKED_IN'
|
||||
export const ORDER_IN_SERVICE = 'ORDER_IN_SERVICE'
|
||||
export const ORDER_EXCEPTION = 'ORDER_EXCEPTION'
|
||||
export const ORDER_COMPLETED = 'ORDER_COMPLETED'
|
||||
export const ACCEPTANCE_PENDING = 'ACCEPTANCE_PENDING'
|
||||
export const ACCEPTED = 'ACCEPTED'
|
||||
export const ACCEPTANCE_REJECTED = 'ACCEPTANCE_REJECTED'
|
||||
export const SETTLEMENT_READY = 'SETTLEMENT_READY'
|
||||
export const ARCHIVED = 'ARCHIVED'
|
||||
export const ORDER_CANCELLED = 'ORDER_CANCELLED'
|
||||
export const ORDER_CLOSED = 'ORDER_CLOSED'
|
||||
|
||||
// 合法状态集合(用于校验)
|
||||
export const HOMEcare_TASK_STATUSES: Array<string> = [
|
||||
ORDER_CREATED,
|
||||
ORDER_ASSIGNED,
|
||||
ORDER_ACCEPTED,
|
||||
ORDER_REJECTED,
|
||||
ORDER_CHECKED_IN,
|
||||
ORDER_IN_SERVICE,
|
||||
ORDER_EXCEPTION,
|
||||
ORDER_COMPLETED,
|
||||
ACCEPTANCE_PENDING,
|
||||
ACCEPTED,
|
||||
ACCEPTANCE_REJECTED,
|
||||
SETTLEMENT_READY,
|
||||
ARCHIVED,
|
||||
ORDER_CANCELLED,
|
||||
ORDER_CLOSED
|
||||
]
|
||||
|
||||
// consumer 端展示文案
|
||||
export function getHomecareTaskStatusText(status: string): string {
|
||||
if (status == ORDER_CREATED) return '待安排服务'
|
||||
if (status == ORDER_ASSIGNED) return '已安排服务人员,等待接单'
|
||||
if (status == ORDER_ACCEPTED) return '服务人员已接单,等待上门'
|
||||
if (status == ORDER_REJECTED) return '正在重新安排人员'
|
||||
if (status == ORDER_CHECKED_IN) return '服务人员已到达'
|
||||
if (status == ORDER_IN_SERVICE) return '服务进行中'
|
||||
if (status == ORDER_EXCEPTION) return '服务处理异常中'
|
||||
if (status == ORDER_COMPLETED) return '服务已完成,待验收'
|
||||
if (status == ACCEPTANCE_PENDING) return '待验收'
|
||||
if (status == ACCEPTED) return '已验收'
|
||||
if (status == ACCEPTANCE_REJECTED) return '验收未通过'
|
||||
if (status == SETTLEMENT_READY) return '待结算'
|
||||
if (status == ARCHIVED) return '已归档'
|
||||
if (status == ORDER_CANCELLED) return '已取消'
|
||||
if (status == ORDER_CLOSED) return '已关闭'
|
||||
return status
|
||||
}
|
||||
|
||||
// 主题色/标签色(用于 UI 标签)
|
||||
export function getHomecareTaskStatusTheme(status: string): string {
|
||||
if (status == ORDER_CREATED) return 'warning'
|
||||
if (status == ORDER_ASSIGNED) return 'primary'
|
||||
if (status == ORDER_ACCEPTED) return 'primary'
|
||||
if (status == ORDER_REJECTED) return 'danger'
|
||||
if (status == ORDER_CHECKED_IN) return 'success'
|
||||
if (status == ORDER_IN_SERVICE) return 'success'
|
||||
if (status == ORDER_EXCEPTION) return 'danger'
|
||||
if (status == ORDER_COMPLETED) return 'primary'
|
||||
if (status == ACCEPTANCE_PENDING) return 'warning'
|
||||
if (status == ACCEPTED) return 'success'
|
||||
if (status == ACCEPTANCE_REJECTED) return 'danger'
|
||||
if (status == SETTLEMENT_READY) return 'warning'
|
||||
if (status == ARCHIVED) return 'info'
|
||||
if (status == ORDER_CANCELLED) return 'info'
|
||||
if (status == ORDER_CLOSED) return 'info'
|
||||
return 'default'
|
||||
}
|
||||
|
||||
// 给定角色与状态,返回允许的前端操作标识
|
||||
export function getHomecareTaskAllowedActions(status: string, role: string): Array<string> {
|
||||
const actions = [] as Array<string>
|
||||
if (role == 'FAMILY_USER' || role == 'consumer') {
|
||||
if (status == ORDER_COMPLETED || status == ACCEPTANCE_PENDING) {
|
||||
actions.push('confirm_acceptance')
|
||||
actions.push('reject_acceptance')
|
||||
}
|
||||
}
|
||||
if (role == 'HOMECARE_WORKER' || role == 'delivery' || role == 'staff') {
|
||||
if (status == ORDER_ASSIGNED) {
|
||||
actions.push('accept')
|
||||
actions.push('reject')
|
||||
}
|
||||
if (status == ORDER_ACCEPTED) {
|
||||
actions.push('checkin')
|
||||
actions.push('report_exception')
|
||||
}
|
||||
if (status == ORDER_CHECKED_IN) {
|
||||
actions.push('start_service')
|
||||
actions.push('report_exception')
|
||||
}
|
||||
if (status == ORDER_IN_SERVICE) {
|
||||
actions.push('save_record')
|
||||
actions.push('upload_evidence')
|
||||
actions.push('report_exception')
|
||||
actions.push('finish_service')
|
||||
}
|
||||
}
|
||||
if (role == 'HOMECARE_DISPATCHER' || role == 'dispatcher') {
|
||||
if (status == ORDER_CREATED || status == ORDER_REJECTED || status == ORDER_EXCEPTION) {
|
||||
actions.push('dispatch')
|
||||
}
|
||||
}
|
||||
return actions
|
||||
}
|
||||
|
||||
// 将旧 hss / delivery 前端状态归一化为 ORDER_* 状态
|
||||
export function normalizeToOrderStatus(raw: string): string {
|
||||
const s = raw.trim().toUpperCase()
|
||||
if (s == 'CREATED' || s == 'SUBMITTED') return ORDER_CREATED
|
||||
if (s == 'PAID') return ORDER_CREATED
|
||||
if (s == 'ASSIGNED' || s == 'PENDING_ASSIGNMENT' || s == 'PENDING_DISPATCH' || s == 'PENDING_ACCEPT') return ORDER_ASSIGNED
|
||||
if (s == 'ACCEPTED' || s == 'PENDING_ACCEPT') return ORDER_ACCEPTED
|
||||
if (s == 'REJECTED') return ORDER_REJECTED
|
||||
if (s == 'DEPARTED' || s == 'ON_THE_WAY' || s == 'WAITING_DEPARTURE') return ORDER_ACCEPTED
|
||||
if (s == 'ARRIVED' || s == 'CHECKED_IN') return ORDER_CHECKED_IN
|
||||
if (s == 'IN_SERVICE' || s == 'SERVING') return ORDER_IN_SERVICE
|
||||
if (s == 'COMPLETED') return ORDER_COMPLETED
|
||||
if (s == 'PENDING_ACCEPTANCE' || s == 'PENDING_CONFIRM' || s == 'PENDING_SUBMIT') return ACCEPTANCE_PENDING
|
||||
if (s == 'ACCEPTED_BY_USER') return ACCEPTED
|
||||
if (s == 'REVIEWED') return ACCEPTED
|
||||
if (s == 'SETTLED') return SETTLEMENT_READY
|
||||
if (s == 'EXCEPTION' || s == 'ABNORMAL' || s == 'EXCEPTION_PENDING') return ORDER_EXCEPTION
|
||||
if (s == 'CANCELLED') return ORDER_CANCELLED
|
||||
if (s == 'ARCHIVED') return ARCHIVED
|
||||
if (s == 'ORDER_CREATED') return ORDER_CREATED
|
||||
if (s == 'ORDER_ASSIGNED') return ORDER_ASSIGNED
|
||||
if (s == 'ORDER_ACCEPTED') return ORDER_ACCEPTED
|
||||
if (s == 'ORDER_REJECTED') return ORDER_REJECTED
|
||||
if (s == 'ORDER_CHECKED_IN') return ORDER_CHECKED_IN
|
||||
if (s == 'ORDER_IN_SERVICE') return ORDER_IN_SERVICE
|
||||
if (s == 'ORDER_EXCEPTION') return ORDER_EXCEPTION
|
||||
if (s == 'ORDER_COMPLETED') return ORDER_COMPLETED
|
||||
if (s == 'ACCEPTANCE_PENDING') return ACCEPTANCE_PENDING
|
||||
if (s == 'ACCEPTED') return ACCEPTED
|
||||
if (s == 'ACCEPTANCE_REJECTED') return ACCEPTANCE_REJECTED
|
||||
if (s == 'SETTLEMENT_READY') return SETTLEMENT_READY
|
||||
if (s == 'ORDER_CANCELLED') return ORDER_CANCELLED
|
||||
if (s == 'ORDER_CLOSED') return ORDER_CLOSED
|
||||
return raw
|
||||
}
|
||||
|
||||
// 判断是否为已关闭/终态
|
||||
export function isHomecareTaskClosed(status: string): boolean {
|
||||
return status == ARCHIVED || status == ORDER_CANCELLED || status == ORDER_CLOSED || status == ACCEPTED || status == SETTLEMENT_READY
|
||||
}
|
||||
Reference in New Issue
Block a user