Files
zkxw/web-admin/src/utils/qc-work-order-tabs.ts
T
cykjandCursor c22a0d1eb0 feat(market): 完善临床科研与委托加工上线能力
补齐项目组负责人审批、费用信息、合作客户、生产出库菜单、申请单号 LCKY 前缀及配套 SQL 迁移,并同步相关前后端与单测。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-30 18:51:37 +08:00

205 lines
6.5 KiB
TypeScript
Raw 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.
import type { QcWorkOrder } from '@/api/qc-work-order'
export type QcWorkOrderTabKey =
| 'all'
| 'inbound_cell_storage'
| 'inbound_research_donation'
| 'outbound_pilot_service'
| 'outbound_basic_experiment'
| 'outbound_contract_processing'
| 'outbound_clinical_application'
| 'temporary'
export type QcWorkOrderTabGroup = 'all' | 'inbound' | 'outbound' | 'temporary'
export type QcWorkOrderTabConfig = {
key: QcWorkOrderTabKey
label: string
group: QcWorkOrderTabGroup
workOrderType?: 'inbound' | 'outbound' | 'temporary'
receptionSource?: 'cell_storage' | 'research_donation'
bizType?: 'pilot_service' | 'basic_experiment' | 'contract_processing' | 'clinical_application'
listLayout: 'inbound-grouped' | 'outbound-grouped' | 'standalone'
/** 侧栏 Tab 不展示(保留 key 供路由/数据解析) */
hidden?: boolean
}
export const QC_WORK_ORDER_TABS: QcWorkOrderTabConfig[] = [
{
key: 'all',
label: '所有',
group: 'all',
listLayout: 'standalone',
hidden: true
},
{
key: 'inbound_cell_storage',
label: '细胞存储质检',
group: 'inbound',
workOrderType: 'inbound',
receptionSource: 'cell_storage',
listLayout: 'inbound-grouped'
},
{
key: 'inbound_research_donation',
label: '科研捐赠质检',
group: 'inbound',
workOrderType: 'inbound',
receptionSource: 'research_donation',
listLayout: 'inbound-grouped'
},
{
key: 'outbound_pilot_service',
label: '中试服务质检',
group: 'outbound',
workOrderType: 'outbound',
bizType: 'pilot_service',
listLayout: 'outbound-grouped',
/** 与市场中试菜单一致:侧栏 Tab 隐藏,保留 key 供历史工单解析 */
hidden: true
},
{
key: 'outbound_basic_experiment',
label: '临床科研质检',
group: 'outbound',
workOrderType: 'outbound',
bizType: 'basic_experiment',
listLayout: 'outbound-grouped'
},
{
key: 'outbound_contract_processing',
label: '委托加工质检',
group: 'outbound',
workOrderType: 'outbound',
bizType: 'contract_processing',
listLayout: 'outbound-grouped'
},
{
key: 'outbound_clinical_application',
label: '临床应用质检',
group: 'outbound',
workOrderType: 'outbound',
bizType: 'clinical_application',
listLayout: 'standalone',
hidden: true
},
{
key: 'temporary',
label: '临时质检',
group: 'temporary',
workOrderType: 'temporary',
listLayout: 'standalone'
}
]
/** 质检工单 / 我的质检任务 Tab 栏展示项(不含 hidden) */
export const QC_WORK_ORDER_VISIBLE_TABS = QC_WORK_ORDER_TABS.filter((t) => !t.hidden)
export const DEFAULT_QC_WORK_ORDER_TAB: QcWorkOrderTabKey = 'inbound_cell_storage'
export function getQcWorkOrderTab(key: string): QcWorkOrderTabConfig | undefined {
return QC_WORK_ORDER_TABS.find((t) => t.key === key)
}
export function parseQcWorkOrderTabKey(raw?: string | null): QcWorkOrderTabKey {
const k = (raw || '').trim()
const tab = getQcWorkOrderTab(k)
if (tab && !tab.hidden) return tab.key
if (k === 'inbound') return 'inbound_cell_storage'
if (k === 'outbound') return 'outbound_basic_experiment'
if (k === 'temporary') return 'temporary'
return DEFAULT_QC_WORK_ORDER_TAB
}
export function toWorkOrderListQuery(tab: QcWorkOrderTabConfig) {
if (tab.key === 'all') {
return {
workOrderType: undefined as string | undefined,
receptionSource: undefined as string | undefined,
bizType: undefined as string | undefined
}
}
return {
workOrderType: tab.workOrderType,
receptionSource: tab.receptionSource,
bizType: tab.bizType
}
}
export function resolveTabKeyFromWorkOrder(row: {
workOrderType?: string
receptionSource?: string
bizType?: string
}): QcWorkOrderTabKey {
const wt = row.workOrderType || 'inbound'
if (wt === 'temporary') return 'temporary'
if (wt === 'outbound') {
const bt = row.bizType || 'pilot_service'
if (bt === 'basic_experiment') return 'outbound_basic_experiment'
if (bt === 'contract_processing') return 'outbound_contract_processing'
if (bt === 'clinical_application') return 'outbound_clinical_application'
return 'outbound_pilot_service'
}
return row.receptionSource === 'research_donation'
? 'inbound_research_donation'
: 'inbound_cell_storage'
}
export function tabUsesInfusionTimeFilter(tab: QcWorkOrderTabConfig): boolean {
return tab.group === 'outbound'
}
export function keywordPlaceholderForTab(tab: QcWorkOrderTabConfig): string {
if (tab.key === 'all') return '工单号 / 样本编码 / 母亲姓名 / 申请单号 / 产品名称等'
if (tab.key === 'temporary') return '工单号 / 外部编号'
if (tab.key === 'outbound_basic_experiment' || tab.key === 'outbound_contract_processing') {
return '工单号/申请单号/课题名称/客户'
}
if (tab.group === 'outbound') return '工单号/申请单号/申请单名称/患者'
if (tab.key === 'inbound_research_donation') {
return '工单号/捐赠单号/样本编码/入库编码/母亲姓名'
}
if (tab.group === 'inbound') {
return '工单号/协议号/样本编码/入库编码/母亲姓名'
}
return '工单号/样本编码/入库编码'
}
export function filterTimeLabelForTab(tab: QcWorkOrderTabConfig): string {
if (tab.key === 'all') return '创建时间'
if (tab.key === 'outbound_basic_experiment' || tab.key === 'outbound_contract_processing') {
return '交付时间'
}
if (tab.group === 'outbound') return '输注时间'
return '创建时间'
}
/** 出库中试服务(含 bizType 缺省落成中试) */
export function isPilotServiceOutboundWorkOrder(row: {
workOrderType?: string
bizType?: string
}): boolean {
return resolveTabKeyFromWorkOrder(row) === 'outbound_pilot_service'
}
export function workOrderMatchesTab(row: QcWorkOrder, tabKey: QcWorkOrderTabKey): boolean {
if (tabKey === 'all') return !isPilotServiceOutboundWorkOrder(row)
return resolveTabKeyFromWorkOrder(row) === tabKey
}
export function isAllQcWorkOrderTab(tabKey: QcWorkOrderTabKey): boolean {
return tabKey === 'all'
}
export function isInboundSampleQcTab(tabKey: QcWorkOrderTabKey): boolean {
return tabKey === 'inbound_cell_storage' || tabKey === 'inbound_research_donation'
}
/** 列表 Tab 为「所有」时,按工单解析其分类 Tab Key */
export function resolveEffectiveRowTabKey(
listTabKey: QcWorkOrderTabKey,
row: QcWorkOrder
): QcWorkOrderTabKey {
return isAllQcWorkOrderTab(listTabKey) ? resolveTabKeyFromWorkOrder(row) : listTabKey
}