Files
zkxw/web-admin/src/utils/production-work-order-tabs.ts
T
zlwuandCursor 8349b0ce73 fix(web-admin): 隐藏生产/质检中试服务 Tab 并从「所有」排除 (#160)
客户已下线中试业务:侧栏不再展示中试 Tab,前端在「所有」列表过滤出库中试数据(含 bizType 缺省)。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-20 14:48:58 +08:00

183 lines
5.7 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 { ProductionWorkOrderItem } from '@/api/production-work-order'
export type ProductionWorkOrderTabKey =
| 'all'
| 'inbound_cell_storage'
| 'inbound_research_donation'
| 'outbound_pilot_service'
| 'outbound_basic_experiment'
| 'outbound_clinical_application'
| 'temporary'
export type ProductionWorkOrderTabGroup = 'all' | 'inbound' | 'outbound' | 'temporary'
export type ProductionWorkOrderTabConfig = {
key: ProductionWorkOrderTabKey
label: string
group: ProductionWorkOrderTabGroup
workOrderType: 'inbound' | 'outbound' | 'temporary'
receptionSource?: 'cell_storage' | 'research_donation'
bizType?: 'pilot_service' | 'basic_experiment' | 'clinical_application'
listLayout: 'inbound-grouped' | 'standalone'
/** 侧栏 Tab 不展示(保留 key 供路由/数据解析) */
hidden?: boolean
}
export const PRODUCTION_WORK_ORDER_TABS: ProductionWorkOrderTabConfig[] = [
{
key: 'all',
label: '所有',
group: 'all',
workOrderType: 'inbound',
listLayout: 'inbound-grouped'
},
{
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: 'standalone',
/** 客户已下线中试业务:侧栏不展示,路由 key 保留供历史解析 */
hidden: true
},
{
key: 'outbound_basic_experiment',
label: '基础实验生产',
group: 'outbound',
workOrderType: 'outbound',
bizType: 'basic_experiment',
listLayout: 'standalone'
},
{
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 PRODUCTION_WORK_ORDER_VISIBLE_TABS = PRODUCTION_WORK_ORDER_TABS.filter(
(t) => !t.hidden
)
export const DEFAULT_PRODUCTION_WORK_ORDER_TAB: ProductionWorkOrderTabKey = 'all'
export function getProductionWorkOrderTab(key: string): ProductionWorkOrderTabConfig | undefined {
return PRODUCTION_WORK_ORDER_TABS.find((t) => t.key === key)
}
export function parseProductionWorkOrderTabKey(raw?: string | null): ProductionWorkOrderTabKey {
const k = (raw || '').trim()
const tab = getProductionWorkOrderTab(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_PRODUCTION_WORK_ORDER_TAB
}
export function toWorkOrderListQuery(tab: ProductionWorkOrderTabConfig) {
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
}): ProductionWorkOrderTabKey {
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 keywordPlaceholderForTab(tab: ProductionWorkOrderTabConfig): string {
if (tab.key === 'all') return '工单号 / 样本编码 / 申请单号 / 产品名称等'
if (tab.key === 'temporary') return '备注'
if (tab.key === 'outbound_basic_experiment') {
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: ProductionWorkOrderItem,
tabKey: ProductionWorkOrderTabKey
): boolean {
if (tabKey === 'all') return !isPilotServiceOutboundWorkOrder(row)
return resolveTabKeyFromWorkOrder(row) === tabKey
}
export function isAllProductionWorkOrderTab(tabKey: ProductionWorkOrderTabKey): boolean {
return tabKey === 'all'
}
/** 列表 Tab 为「所有」时,按工单解析其分类 Tab Key */
export function resolveEffectiveRowTabKey(
listTabKey: ProductionWorkOrderTabKey,
row: ProductionWorkOrderItem
): ProductionWorkOrderTabKey {
return isAllProductionWorkOrderTab(listTabKey) ? resolveTabKeyFromWorkOrder(row) : listTabKey
}
export function tabSupportsInactiveProtocolFilter(tabKey: ProductionWorkOrderTabKey): boolean {
return (
tabKey === 'all' || tabKey === 'inbound_cell_storage' || tabKey === 'inbound_research_donation'
)
}