feat(worker-platform): 接单工单表格「打手」列支持展示寄售供货打手与现货资料
1. 新增 resolveConsignmentWorkerDisplay 工具函数,自动解析工单寄售现货与资料字段(供货打手、游戏角色昵称、游戏ID及联系方式); 2. 优化 renderWorkOrderWorkers 渲染逻辑:当工单为内部寄售现货履约时,打手列带「供货打手」或「内部现货」专属角标,主标题展示打手名/角色名,副标题拼接游戏ID与联系方式,解决原先显示为破折号 - 的问题; 3. 新增 consignment-worker-display 单元测试,更新寄卖库存优化现状与进度追踪文档,前端 57 个测试全绿并通过类型检查。
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import type { WorkOrder } from '@/types/worker-platform'
|
||||
|
||||
function asRecord(value: unknown): Record<string, unknown> {
|
||||
return value && typeof value === 'object' && !Array.isArray(value)
|
||||
? (value as Record<string, unknown>)
|
||||
: {}
|
||||
}
|
||||
|
||||
export type ConsignmentWorkerDisplayInfo = {
|
||||
tagText: '供货打手' | '内部现货'
|
||||
primaryName: string
|
||||
secondaryInfo: string
|
||||
}
|
||||
|
||||
/** 解析寄卖库存/内部现货履约单的供货人与现货资料信息 */
|
||||
export function resolveConsignmentWorkerDisplay(
|
||||
order: WorkOrder,
|
||||
): ConsignmentWorkerDisplayInfo | null {
|
||||
const material = asRecord(order.material)
|
||||
const consignment = asRecord(material.consignment)
|
||||
const boosterFields = asRecord(order.gift?.boosterMaterial?.fields)
|
||||
const hasConsignment =
|
||||
Object.keys(consignment).length > 0 ||
|
||||
Boolean(boosterFields.sourceType === 'consignment' || boosterFields.inventoryNo)
|
||||
|
||||
if (!hasConsignment) return null
|
||||
|
||||
const workerName = String(consignment.workerName || consignment.worker_name || '').trim()
|
||||
const sellerNickname = String(
|
||||
boosterFields.gameNickname || consignment.buyerName || consignment.sellerGameNickname || '',
|
||||
).trim()
|
||||
const sellerGameId = String(
|
||||
boosterFields.gameId || consignment.sellerGameId || consignment.seller_game_id || '',
|
||||
).trim()
|
||||
const sellerContact = String(
|
||||
boosterFields.sellerPhone ||
|
||||
consignment.sellerPhone ||
|
||||
consignment.workerPhone ||
|
||||
boosterFields.sellerContact ||
|
||||
consignment.sellerContact ||
|
||||
'',
|
||||
).trim()
|
||||
|
||||
const primaryName = workerName || sellerNickname || sellerGameId || '内部现货'
|
||||
const secondaryInfo = [
|
||||
workerName && sellerNickname && sellerNickname !== workerName ? sellerNickname : '',
|
||||
sellerGameId ? `ID:${sellerGameId}` : '',
|
||||
!sellerGameId && sellerContact ? sellerContact : '',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' · ')
|
||||
|
||||
return {
|
||||
tagText: workerName ? '供货打手' : '内部现货',
|
||||
primaryName,
|
||||
secondaryInfo,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user