优化
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { DispatchAction, DispatchActions } from './dispatchContracts'
|
||||
import type { DispatchAction, DispatchActions, Reviews } from './dispatchContracts'
|
||||
export const dispatchActionLabels: Record<DispatchAction, string> = {
|
||||
CREATE: '新建排车', EDIT: '维护车辆信息', ADD_CARGO: '添加货物', REMOVE_CARGO: '移除货物', CANCEL: '取消排车',
|
||||
SUBMIT_REVIEW: '提交调度审核', DISPATCH_REVIEW: '调度审核', LOADING_REVIEW: '理货员审核',
|
||||
@@ -12,5 +12,11 @@ export const dispatchActionPermissions: Record<DispatchAction, string> = {
|
||||
RETURN_TO_REVIEW: 'platform:overseas-warehouse:dispatch:edit', PICK: 'lastleg:pda:operate',
|
||||
LOADING_COMPLETE: 'platform:overseas-warehouse:dispatch:loading-complete', ARRANGE_DELIVERY: 'platform:overseas-warehouse:dispatch:transfer-delivery', DEPART: 'platform:overseas-warehouse:dispatch:depart',
|
||||
}
|
||||
export const canDispatchAction = (actions: DispatchActions | undefined, action: DispatchAction, can: (code: string) => boolean) => actions?.[action]?.allowed === true && can(dispatchActionPermissions[action])
|
||||
export const canDispatchAction = (actions: DispatchActions | undefined, action: DispatchAction, can: (code: string) => boolean) => !['ARRANGE_DELIVERY', 'DEPART'].includes(action) && actions?.[action]?.allowed === true && can(dispatchActionPermissions[action])
|
||||
export const displayDispatchValue = (value: unknown) => value === null || value === undefined || value === '' ? '—' : String(value)
|
||||
export function dispatchRejectionReason(reviews: Reviews | undefined): string {
|
||||
if (!reviews) return ''
|
||||
return ([['调度审核', reviews.dispatchReview], ['理货员审核', reviews.loadingReview]] as const)
|
||||
.filter(([, review]) => review.status === 'REJECTED')
|
||||
.map(([label, review]) => `${label}退回:${review.reason?.trim() || '原因未提供'}`).join(';')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user