Files
zkxw/web-admin/src/utils/qc-work-order-tabs.ts
T
2026-07-06 16:59:53 +08:00

183 lines
5.6 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_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' | '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'
},
{
key: 'outbound_basic_experiment',
label: '基础实验质检',
group: 'outbound',
workOrderType: 'outbound',
bizType: 'basic_experiment',
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_pilot_service'
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 === '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') {
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') return '交付时间'
if (tab.group === 'outbound') return '输注时间'
return '创建时间'
}
export function workOrderMatchesTab(row: QcWorkOrder, tabKey: QcWorkOrderTabKey): boolean {
if (tabKey === 'all') return true
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
}