This commit is contained in:
zlwu committed 2026-06-16 12:36:29 +08:00
1 parent 7e04ebecc4
commit 0bf107d4f7
186 files changed
+29150 -21498

No files matched your search

@@ -1,24 +1,28 @@
import type { ProductionWorkOrderItem } from '@/api/production-work-order'
import { fetchProductionWorkOrderDetail } from '@/api/production-work-order'
import { fetchMyProductionTasks } from '@/api/production-task'
export type ProductionWorkOrderTypeTab = 'inbound' | 'temporary' | 'outbound'
import type { ProductionWorkOrderTabKey } from '@/utils/production-work-order-tabs'
import {
resolveTabKeyFromWorkOrder,
tabUsesInfusionTimeFilter,
getProductionWorkOrderTab,
toWorkOrderListQuery
} from '@/utils/production-work-order-tabs'
export type ProductionTaskMineFilters = {
keyword?: string
taskStatus?: string
workOrderType?: ProductionWorkOrderTypeTab
tabKey: ProductionWorkOrderTabKey
}
export type MineWorkOrderSearchFilters = {
keyword?: string
workOrderStatus?: string
bizType?: string
createTimeStart?: string
createTimeEnd?: string
infusionTimeStart?: string
infusionTimeEnd?: string
activeTypeTab: ProductionWorkOrderTypeTab
tabKey: ProductionWorkOrderTabKey
}
export type ProductionTaskRow = Record<string, any>
@@ -26,7 +30,7 @@ export type ProductionTaskRow = Record<string, any>
export type MineWorkOrderEntry = {
workOrderId: string
workOrder: ProductionWorkOrderItem
activeTypeTab: ProductionWorkOrderTypeTab
tabKey: ProductionWorkOrderTabKey
tasks: ProductionTaskRow[]
}
@@ -43,43 +47,51 @@ function dateInRange(value: string | undefined, start?: string, end?: string): b
function keywordMatchesWorkOrder(
row: ProductionWorkOrderItem,
keyword: string,
tab: ProductionWorkOrderTypeTab
tabKey: ProductionWorkOrderTabKey
): boolean {
const kw = keyword.trim().toLowerCase()
if (!kw) return true
const tab = getProductionWorkOrderTab(tabKey)!
const fields =
tab === 'temporary'
tabKey === 'temporary'
? [row.workOrderNo]
: tab === 'outbound'
? [row.workOrderNo, row.applicationNo, row.applicationName]
: [row.workOrderNo, row.sampleCode, row.labStorageCode]
: tabKey === 'outbound_basic_experiment'
? [row.workOrderNo, row.applicationNo, row.projectTitle, row.customerName, row.applicationName]
: tab.group === 'outbound'
? [row.workOrderNo, row.applicationNo, row.applicationName, row.patientName]
: [row.workOrderNo, row.sampleCode, row.labStorageCode]
return fields.some((f) => (f || '').toLowerCase().includes(kw))
}
export function resolveWorkOrderTypeTab(task: ProductionTaskRow): ProductionWorkOrderTypeTab {
const t = String(task.workOrderType || task.orderSource || 'inbound').trim()
if (t === 'outbound' || t === 'temporary' || t === 'inbound') return t
return 'inbound'
export function resolveWorkOrderTabKey(task: ProductionTaskRow): ProductionWorkOrderTabKey {
return resolveTabKeyFromWorkOrder({
workOrderType: task.workOrderType || task.orderSource,
receptionSource: task.receptionSource,
bizType: task.bizType
})
}
export function buildWorkOrderFromTasks(tasks: ProductionTaskRow[]): ProductionWorkOrderItem {
const t = tasks[0]
const woType = resolveWorkOrderTypeTab(t)
const tabKey = resolveWorkOrderTabKey(t)
const tab = getProductionWorkOrderTab(tabKey)!
return {
id: t.workOrderId,
workOrderNo: t.workOrderNo || '—',
workOrderType: woType,
workOrderType: tab.workOrderType,
workOrderStatus: t.workOrderStatus || '',
protocolNo: t.protocolNo || '',
sampleCode: t.sampleCode || '',
receptionSource: t.receptionSource,
receptionSourceLabel: t.receptionSourceLabel,
protocolStatus: t.protocolStatus,
bizType: woType === 'outbound' ? t.bizType : undefined,
bizTypeLabel: woType === 'outbound' ? t.bizTypeLabel : undefined,
bizType: tab.group === 'outbound' ? t.bizType : undefined,
bizTypeLabel: tab.group === 'outbound' ? t.bizTypeLabel : undefined,
applicationNo: t.applicationNo,
applicationName: t.applicationName,
channelName: t.channelName,
projectTitle: t.projectTitle,
customerName: t.customerName,
patientName: t.patientName,
sortNo: t.sortNo,
totalCourseCount: t.totalCourseCount,
@@ -109,7 +121,7 @@ export function groupMineTasksByWorkOrder(tasks: ProductionTaskRow[]): MineWorkO
return {
workOrderId,
workOrder: buildWorkOrderFromTasks(groupTasks),
activeTypeTab: resolveWorkOrderTypeTab(groupTasks[0]),
tabKey: resolveWorkOrderTabKey(groupTasks[0]),
tasks: groupTasks
}
})
@@ -127,6 +139,8 @@ async function fetchMineTasksByScope(
scope: 'current' | 'history',
filters: ProductionTaskMineFilters
): Promise<ProductionTaskRow[]> {
const tab = getProductionWorkOrderTab(filters.tabKey)!
const listQuery = toWorkOrderListQuery(tab)
const pageSize = MINE_TASK_FETCH_PAGE_SIZE
let page = 1
const all: ProductionTaskRow[] = []
@@ -138,7 +152,9 @@ async function fetchMineTasksByScope(
pageSize,
keyword: filters.keyword || undefined,
taskStatus: filters.taskStatus || undefined,
workOrderType: filters.workOrderType || undefined
workOrderType: listQuery.workOrderType,
receptionSource: listQuery.receptionSource,
bizType: listQuery.bizType
})
const list = res.list || []
all.push(...list)
@@ -189,7 +205,8 @@ export async function enrichMineEntriesWithWorkOrders(
...detail,
paymentSummary: detail.paymentSummary ?? entry.workOrder.paymentSummary,
feeSummary: detail.feeSummary ?? entry.workOrder.feeSummary
}
},
tabKey: resolveTabKeyFromWorkOrder(detail)
}
})
}
@@ -198,15 +215,15 @@ export function filterMineEntriesByWorkOrderSearch(
entries: MineWorkOrderEntry[],
filters: MineWorkOrderSearchFilters
): MineWorkOrderEntry[] {
const tab = filters.activeTypeTab
const tabKey = filters.tabKey
const tab = getProductionWorkOrderTab(tabKey)!
return entries.filter((entry) => {
const row = entry.workOrder
if (row.workOrderType && row.workOrderType !== tab) return false
if (entry.activeTypeTab !== tab) return false
if (resolveTabKeyFromWorkOrder(row) !== tabKey) return false
if (entry.tabKey !== tabKey) return false
if (filters.workOrderStatus && row.workOrderStatus !== filters.workOrderStatus) return false
if (tab === 'outbound' && filters.bizType && row.bizType !== filters.bizType) return false
if (!keywordMatchesWorkOrder(row, filters.keyword || '', tab)) return false
if (tab === 'outbound') {
if (!keywordMatchesWorkOrder(row, filters.keyword || '', tabKey)) return false
if (tabUsesInfusionTimeFilter(tab)) {
if (!dateInRange(row.infusionTime, filters.infusionTimeStart, filters.infusionTimeEnd)) {
return false
}
@@ -0,0 +1,263 @@
import type { ProductionWorkOrderItem } from '@/api/production-work-order'
import { receptionSourceLabel } from '@/utils/qc-labels'
import {
donationStatusLabel,
donationStatusTagType,
protocolStatusLabel,
protocolStatusTagType
} from '@/utils/status-tag-registry'
import type { TagType } from '@/utils/status-tag-registry'
import type { ProductionWorkOrderTabKey } from '@/utils/production-work-order-tabs'
import { formatMoneyDisplay } from '@/utils/money-format'
export type CardMetaFieldKind = 'text' | 'tag'
export type CardMetaField = {
label: string
kind?: CardMetaFieldKind
getValue: (row: ProductionWorkOrderItem) => string
getTagType?: (row: ProductionWorkOrderItem) => TagType | undefined
visible?: (row: ProductionWorkOrderItem) => boolean
wide?: boolean
}
export type ProductionWorkOrderCardMetaConfig = {
tabKey: ProductionWorkOrderTabKey
showProtocolFeeSummary: boolean
showOutboundFeeSummary: boolean
metaFields: CardMetaField[]
allowDispatchQc: boolean
allowSampleReception: boolean
allowDispatchComplete: boolean
allowEditRemark: boolean
allowDelete: boolean
}
const RECEPTION_OVER_HOURS_MS = 24 * 60 * 60 * 1000
function formatOutboundScheduleSortNo(row: ProductionWorkOrderItem) {
const n = row.sortNo
if (n == null || n === '' || Number(n) <= 0) return '—'
return `第${Number(n)}次`
}
function formatOutboundScheduleTotalCount(row: ProductionWorkOrderItem) {
const n = row.totalCourseCount
if (n == null || n === '' || Number(n) <= 0) return '—'
return `共${Number(n)}次`
}
function parseReceptionTime(value?: string | null): Date | null {
const s = String(value || '').trim()
if (!s) return null
const dt = new Date(s.replace(/-/g, '/'))
return Number.isNaN(dt.getTime()) ? null : dt
}
function receptionOver24HoursLabel(receptionTime?: string | null): string {
const dt = parseReceptionTime(receptionTime)
if (!dt) return '—'
if (Date.now() - dt.getTime() > RECEPTION_OVER_HOURS_MS) return '是'
return '否'
}
function receptionOver24HoursTagType(receptionTime?: string | null): TagType {
const dt = parseReceptionTime(receptionTime)
if (!dt) return 'info'
if (Date.now() - dt.getTime() > RECEPTION_OVER_HOURS_MS) return 'danger'
return 'success'
}
function protocolStatusLabelForTab(
row: ProductionWorkOrderItem,
tabKey: ProductionWorkOrderTabKey
): string {
const status = String(row.protocolStatus || '')
if (tabKey === 'inbound_research_donation') return donationStatusLabel(status)
return protocolStatusLabel(status)
}
function protocolStatusTagTypeForTab(
row: ProductionWorkOrderItem,
tabKey: ProductionWorkOrderTabKey
): TagType {
const status = String(row.protocolStatus || '')
if (tabKey === 'inbound_research_donation') return donationStatusTagType(status)
return protocolStatusTagType(status)
}
function buildInboundMetaFields(tabKey: ProductionWorkOrderTabKey): CardMetaField[] {
const fields: CardMetaField[] = [
{ label: '样本编码', getValue: (row) => row.sampleCode || '—' },
{ label: '实验室入库编码', getValue: (row) => row.labStorageCode || '—' }
]
if (tabKey === 'inbound_cell_storage') {
fields.push({
label: '来源类型',
kind: 'tag',
getValue: (row) => row.receptionSourceLabel || receptionSourceLabel(row.receptionSource || 'cell_storage'),
getTagType: () => 'success'
})
}
fields.push(
{
label: tabKey === 'inbound_research_donation' ? '捐赠状态' : '协议状态',
kind: 'tag',
getValue: (row) => protocolStatusLabelForTab(row, tabKey),
getTagType: (row) => protocolStatusTagTypeForTab(row, tabKey),
visible: (row) => !!String(row.protocolStatus || '').trim()
},
{ label: '样本类型', getValue: (row) => row.sampleTypeName || '—' },
{ label: '接收经手人', getValue: (row) => row.handlerName || '—' },
{
label: '是否超24小时',
kind: 'tag',
getValue: (row) => receptionOver24HoursLabel(row.receptionTime),
getTagType: (row) => receptionOver24HoursTagType(row.receptionTime),
visible: (row) => !!row.receptionTime
},
{ label: '接收时间', getValue: (row) => row.receptionTime || '—' },
{ label: '创建时间', getValue: (row) => row.createTime || '—' },
{
label: '备注',
getValue: (row) => row.remark || '—',
visible: (row) => !!row.remark,
wide: true
}
)
return fields
}
const outboundPilotClinicalFields: CardMetaField[] = [
{ label: '申请单号', getValue: (row) => row.applicationNo || '—' },
{ label: '申请单名称', getValue: (row) => row.applicationName || '—' },
{ label: '渠道名称', getValue: (row) => row.channelName || '—' },
{ label: '患者姓名', getValue: (row) => row.patientName || '—' },
{ label: '第几次', getValue: formatOutboundScheduleSortNo },
{ label: '总次数', getValue: formatOutboundScheduleTotalCount },
{ label: '输注时间', getValue: (row) => row.infusionTime || '—' },
{ label: '创建时间', getValue: (row) => row.createTime || '—' },
{
label: '备注',
getValue: (row) => row.remark || '—',
visible: (row) => !!row.remark,
wide: true
}
]
const outboundBasicExperimentFields: CardMetaField[] = [
{ label: '申请单号', getValue: (row) => row.applicationNo || '—' },
{
label: '课题名称',
getValue: (row) => row.projectTitle || row.applicationName || '—'
},
{ label: '客户名称', getValue: (row) => row.customerName || '—' },
{ label: '交付时间', getValue: (row) => row.infusionTime || '—' },
{
label: '售卖金额',
getValue: (row) => {
const amount = row.feeSummary?.saleAmount
if (amount == null || amount === '') return '—'
return `¥${formatMoneyDisplay(amount)}`
},
visible: (row) => row.feeSummary?.saleAmount != null && row.feeSummary?.saleAmount !== ''
},
{ label: '创建时间', getValue: (row) => row.createTime || '—' },
{
label: '备注',
getValue: (row) => row.remark || '—',
visible: (row) => !!row.remark,
wide: true
}
]
const temporaryFields: CardMetaField[] = [
{ label: '备注', getValue: (row) => row.remark || '—' },
{ label: '创建时间', getValue: (row) => row.createTime || '—' }
]
const CARD_META_BY_TAB: Record<ProductionWorkOrderTabKey, ProductionWorkOrderCardMetaConfig> = {
inbound_cell_storage: {
tabKey: 'inbound_cell_storage',
showProtocolFeeSummary: true,
showOutboundFeeSummary: false,
metaFields: buildInboundMetaFields('inbound_cell_storage'),
allowDispatchQc: true,
allowSampleReception: true,
allowDispatchComplete: true,
allowEditRemark: true,
allowDelete: true
},
inbound_research_donation: {
tabKey: 'inbound_research_donation',
showProtocolFeeSummary: false,
showOutboundFeeSummary: false,
metaFields: buildInboundMetaFields('inbound_research_donation'),
allowDispatchQc: true,
allowSampleReception: true,
allowDispatchComplete: true,
allowEditRemark: true,
allowDelete: true
},
outbound_pilot_service: {
tabKey: 'outbound_pilot_service',
showProtocolFeeSummary: false,
showOutboundFeeSummary: false,
metaFields: outboundPilotClinicalFields,
allowDispatchQc: false,
allowSampleReception: false,
allowDispatchComplete: true,
allowEditRemark: true,
allowDelete: false
},
outbound_basic_experiment: {
tabKey: 'outbound_basic_experiment',
showProtocolFeeSummary: false,
showOutboundFeeSummary: true,
metaFields: outboundBasicExperimentFields,
allowDispatchQc: false,
allowSampleReception: false,
allowDispatchComplete: true,
allowEditRemark: true,
allowDelete: false
},
outbound_clinical_application: {
tabKey: 'outbound_clinical_application',
showProtocolFeeSummary: false,
showOutboundFeeSummary: true,
metaFields: outboundPilotClinicalFields,
allowDispatchQc: false,
allowSampleReception: false,
allowDispatchComplete: true,
allowEditRemark: true,
allowDelete: false
},
temporary: {
tabKey: 'temporary',
showProtocolFeeSummary: false,
showOutboundFeeSummary: false,
metaFields: temporaryFields,
allowDispatchQc: false,
allowSampleReception: false,
allowDispatchComplete: false,
allowEditRemark: false,
allowDelete: true
}
}
/** 旧 3 Tab 兼容映射(P5 壳层改造前) */
const LEGACY_TAB_MAP: Record<'inbound' | 'outbound' | 'temporary', ProductionWorkOrderTabKey> = {
inbound: 'inbound_cell_storage',
outbound: 'outbound_pilot_service',
temporary: 'temporary'
}
export function getCardMetaConfig(tabKey: ProductionWorkOrderTabKey): ProductionWorkOrderCardMetaConfig {
return CARD_META_BY_TAB[tabKey]
}
export function getCardMetaConfigForLegacyTab(
activeTypeTab: 'inbound' | 'outbound' | 'temporary'
): ProductionWorkOrderCardMetaConfig {
return getCardMetaConfig(LEGACY_TAB_MAP[activeTypeTab])
}
@@ -0,0 +1,154 @@
import type { ProductionWorkOrderItem } from '@/api/production-work-order'
export type ProductionWorkOrderTabKey =
| 'inbound_cell_storage'
| 'inbound_research_donation'
| 'outbound_pilot_service'
| 'outbound_basic_experiment'
| 'outbound_clinical_application'
| 'temporary'
export type ProductionWorkOrderTabGroup = '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: '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: '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 = 'inbound_cell_storage'
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_pilot_service'
if (k === 'temporary') return 'temporary'
return DEFAULT_PRODUCTION_WORK_ORDER_TAB
}
export function toWorkOrderListQuery(tab: ProductionWorkOrderTabConfig) {
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 tabUsesInfusionTimeFilter(tab: ProductionWorkOrderTabConfig): boolean {
return tab.group === 'outbound'
}
export function keywordPlaceholderForTab(tab: ProductionWorkOrderTabConfig): string {
if (tab.key === 'temporary') return '工单号'
if (tab.key === 'outbound_basic_experiment') {
return '工单号/申请单号/课题名称/客户'
}
if (tab.group === 'outbound') return '工单号/申请单号/申请单名称/患者'
return '工单号/样本编码/入库编码'
}
export function filterTimeLabelForTab(tab: ProductionWorkOrderTabConfig): string {
if (tab.key === 'outbound_basic_experiment') return '交付时间'
if (tab.group === 'outbound') return '输注时间'
return '创建时间'
}
export function filterTimeHintForTab(tab: ProductionWorkOrderTabConfig): string {
if (tab.group === 'outbound') {
return tab.key === 'outbound_basic_experiment'
? '默认展示近 30 天内交付的工单。'
: '默认展示近 30 天内输注的工单。'
}
return '默认展示近 30 天内创建的工单。'
}
export function workOrderMatchesTab(
row: ProductionWorkOrderItem,
tabKey: ProductionWorkOrderTabKey
): boolean {
return resolveTabKeyFromWorkOrder(row) === tabKey
}
+56 -28
View File
@@ -2,32 +2,36 @@ import type { QcWorkOrder } from '@/api/qc-work-order'
import { fetchQcWorkOrderDetail } from '@/api/qc-work-order'
import { fetchMyQcTaskList, type QcTask } from '@/api/qc-task'
import { groupInboundQcWorkOrders } from '@/utils/qc-work-order-groups'
export type QcWorkOrderTypeTab = 'inbound' | 'temporary' | 'outbound' | 'all'
import type { QcWorkOrderTabKey } from '@/utils/qc-work-order-tabs'
import {
resolveTabKeyFromWorkOrder,
tabUsesInfusionTimeFilter,
getQcWorkOrderTab,
toWorkOrderListQuery
} from '@/utils/qc-work-order-tabs'
export type QcTaskMineFilters = {
keyword?: string
taskType?: string
taskStatus?: string
qcBizType?: string
tabKey: QcWorkOrderTabKey
}
export type MineWorkOrderSearchFilters = {
keyword?: string
workOrderStatus?: string
bizType?: string
triggerSource?: string
createTimeStart?: string
createTimeEnd?: string
infusionTimeStart?: string
infusionTimeEnd?: string
activeTypeTab: QcWorkOrderTypeTab
tabKey: QcWorkOrderTabKey
}
export type MineWorkOrderEntry = {
workOrderId: string
workOrder: QcWorkOrder
activeTypeTab: QcWorkOrderTypeTab
tabKey: QcWorkOrderTabKey
tasks: QcTask[]
}
@@ -41,15 +45,18 @@ function dateInRange(value: string | undefined, start?: string, end?: string): b
return true
}
function keywordMatchesWorkOrder(row: QcWorkOrder, keyword: string, tab: QcWorkOrderTypeTab): boolean {
function keywordMatchesWorkOrder(row: QcWorkOrder, keyword: string, tabKey: QcWorkOrderTabKey): boolean {
const kw = keyword.trim().toLowerCase()
if (!kw) return true
const tab = getQcWorkOrderTab(tabKey)!
const fields =
tab === 'temporary'
tabKey === 'temporary'
? [row.workOrderNo]
: tab === 'outbound'
? [row.workOrderNo, row.applicationNo, row.applicationName]
: [row.workOrderNo, row.sampleCode, row.labStorageCode]
: tabKey === 'outbound_basic_experiment'
? [row.workOrderNo, row.applicationNo, row.projectTitle, row.customerName, row.applicationName]
: tab.group === 'outbound'
? [row.workOrderNo, row.applicationNo, row.applicationName, row.patientName]
: [row.workOrderNo, row.sampleCode, row.labStorageCode]
return fields.some((f) => (f || '').toLowerCase().includes(kw))
}
@@ -57,16 +64,17 @@ export function filterMineEntriesByWorkOrderSearch(
entries: MineWorkOrderEntry[],
filters: MineWorkOrderSearchFilters
): MineWorkOrderEntry[] {
const tab = filters.activeTypeTab
const tabKey = filters.tabKey
const tab = getQcWorkOrderTab(tabKey)!
return entries.filter((entry) => {
const row = entry.workOrder
if (resolveTabKeyFromWorkOrder(row) !== tabKey) return false
if (filters.workOrderStatus && row.workOrderStatus !== filters.workOrderStatus) return false
if (tab === 'inbound' && filters.triggerSource && row.triggerSource !== filters.triggerSource) {
if (tab.group === 'inbound' && filters.triggerSource && row.triggerSource !== filters.triggerSource) {
return false
}
if (tab === 'outbound' && filters.bizType && row.bizType !== filters.bizType) return false
if (!keywordMatchesWorkOrder(row, filters.keyword || '', tab)) return false
if (tab === 'outbound') {
if (!keywordMatchesWorkOrder(row, filters.keyword || '', tabKey)) return false
if (tabUsesInfusionTimeFilter(tab)) {
if (!dateInRange(row.infusionTime, filters.infusionTimeStart, filters.infusionTimeEnd)) {
return false
}
@@ -78,6 +86,8 @@ export function filterMineEntriesByWorkOrderSearch(
}
export async function fetchAllMineTasks(filters: QcTaskMineFilters): Promise<QcTask[]> {
const tab = getQcWorkOrderTab(filters.tabKey)!
const listQuery = toWorkOrderListQuery(tab)
const pageSize = MINE_TASK_FETCH_PAGE_SIZE
let page = 1
const all: QcTask[] = []
@@ -89,7 +99,9 @@ export async function fetchAllMineTasks(filters: QcTaskMineFilters): Promise<QcT
keyword: filters.keyword || undefined,
taskType: filters.taskType || undefined,
taskStatus: filters.taskStatus || undefined,
qcBizType: filters.qcBizType || undefined
qcBizType: tab.workOrderType,
receptionSource: listQuery.receptionSource,
bizType: listQuery.bizType
})
const list = res.list || []
all.push(...list)
@@ -149,15 +161,27 @@ export function buildMineTableRows(pageEntries: MineWorkOrderEntry[]): {
}
}
export function resolveWorkOrderTypeTab(task: QcTask): QcWorkOrderTypeTab {
const t = (task.qcBizType || task.orderSource || 'inbound').trim()
if (t === 'outbound' || t === 'temporary' || t === 'inbound') return t
return 'inbound'
export function resolveWorkOrderTabKey(task: QcTask): QcWorkOrderTabKey {
const woType = task.qcBizType || task.orderSource || 'inbound'
if (woType === 'outbound') {
return resolveTabKeyFromWorkOrder({
workOrderType: 'outbound',
bizType: task.receptionSource
})
}
if (woType === 'temporary') {
return 'temporary'
}
return resolveTabKeyFromWorkOrder({
workOrderType: 'inbound',
receptionSource: task.receptionSource
})
}
export function buildWorkOrderFromTasks(tasks: QcTask[]): QcWorkOrder {
const t = tasks[0]
const woType = resolveWorkOrderTypeTab(t)
const tabKey = resolveWorkOrderTabKey(t)
const woType = getQcWorkOrderTab(tabKey)?.workOrderType || 'inbound'
return {
id: t.workOrderId,
workOrderNo: t.workOrderNo || '—',
@@ -208,7 +232,7 @@ export function groupMineTasksByWorkOrder(tasks: QcTask[]): MineWorkOrderEntry[]
return {
workOrderId,
workOrder: buildWorkOrderFromTasks(groupTasks),
activeTypeTab: resolveWorkOrderTypeTab(groupTasks[0]),
tabKey: resolveWorkOrderTabKey(groupTasks[0]),
tasks: groupTasks
}
})
@@ -230,12 +254,16 @@ export type MineCardListModel = {
}
/** 入库走 SampleGroup,出库/临时走 SingleCard standalone */
export function buildMineCardListModel(tasks: QcTask[]): MineCardListModel {
const entries = groupMineTasksByWorkOrder(tasks)
export function buildMineCardListModel(
tasks: QcTask[],
tabKey: QcWorkOrderTabKey
): MineCardListModel {
const entries = groupMineTasksByWorkOrder(tasks).filter((e) => e.tabKey === tabKey)
const presetTasksByWorkOrderId = buildPresetTasksMap(entries)
const inboundEntries = entries.filter((e) => e.activeTypeTab === 'inbound')
const standaloneEntries = entries.filter((e) => e.activeTypeTab !== 'inbound')
const inboundGroups = groupInboundQcWorkOrders(inboundEntries.map((e) => e.workOrder))
const tab = getQcWorkOrderTab(tabKey)!
const useInboundGroups = tab.listLayout === 'inbound-grouped'
const inboundGroups = useInboundGroups ? groupInboundQcWorkOrders(entries.map((e) => e.workOrder)) : []
const standaloneEntries = useInboundGroups ? [] : entries
return {
inboundGroups,
standaloneEntries,
@@ -0,0 +1,260 @@
import type { QcWorkOrder } from '@/api/qc-work-order'
import { qcBizTypeLabel } from '@/utils/qc-labels'
import {
donationStatusLabel,
donationStatusTagType,
protocolStatusLabel,
protocolStatusTagType,
qcBizTypeTagType
} from '@/utils/status-tag-registry'
import type { TagType } from '@/utils/status-tag-registry'
import type { QcWorkOrderTabKey } from '@/utils/qc-work-order-tabs'
import { getQcWorkOrderTab } from '@/utils/qc-work-order-tabs'
import { formatMoneyDisplay } from '@/utils/money-format'
export type CardMetaFieldKind = 'text' | 'tag'
export type CardMetaField = {
label: string
kind?: CardMetaFieldKind
getValue: (row: QcWorkOrder) => string
getTagType?: (row: QcWorkOrder) => TagType | undefined
visible?: (row: QcWorkOrder) => boolean
wide?: boolean
}
export type QcWorkOrderCardMetaConfig = {
tabKey: QcWorkOrderTabKey
listLayout: 'inbound-grouped' | 'standalone'
showTriggerTag: boolean
showProtocolFeeSummary: boolean
showOutboundFeeSummary: boolean
metaFields: CardMetaField[]
buildGroupContextParts: (row: QcWorkOrder) => string[]
allowEditTemporary: boolean
allowEditRemark: boolean
allowDelete: boolean
}
function formatDetectMethods(row: QcWorkOrder) {
const parts: string[] = []
if (row.hasLab) parts.push('实验室')
if (row.hasThirdParty) parts.push('第三方')
return parts.length ? parts.join(' / ') : '—'
}
function formatQcTarget(row: QcWorkOrder) {
if ((row.triggerSource || 'reception') === 'production') {
const parts = [row.cellProductCode, row.cellProductName].filter(Boolean)
return parts.length ? parts.join(' · ') : '—'
}
return '原始样本'
}
function formatOutboundScheduleSortNo(row: QcWorkOrder) {
const n = row.sortNo
if (n == null || n === '' || Number(n) <= 0) return '—'
return `第${Number(n)}次`
}
function formatOutboundScheduleTotalCount(row: QcWorkOrder) {
const n = row.totalCourseCount
if (n == null || n === '' || Number(n) <= 0) return '—'
return `共${Number(n)}次`
}
function formatTempCellProductField(row: QcWorkOrder, value?: string | null) {
if (row.workOrderType !== 'temporary') return '—'
return String(value || '').trim() || '—'
}
function protocolStatusLabelBySource(status: string, source: string): string {
return source === 'research_donation' ? donationStatusLabel(status) : protocolStatusLabel(status)
}
function protocolStatusTagTypeBySource(status: string, source: string): TagType {
return source === 'research_donation' ? donationStatusTagType(status) : protocolStatusTagType(status)
}
const commonTailFields: CardMetaField[] = [
{ label: '检测方式', getValue: formatDetectMethods },
{ label: '创建时间', getValue: (row) => row.createTime || '—' },
{
label: '备注',
getValue: (row) => row.remark || '—',
visible: (row) => !!row.remark,
wide: true
}
]
const inboundGroupedFields: CardMetaField[] = [
{ label: '质检对象', getValue: formatQcTarget },
{
label: '关联生产工单',
getValue: (row) => row.productionWorkOrderNo || '—',
visible: (row) => (row.triggerSource || 'reception') === 'production'
},
{ label: '实验室入库编码', getValue: (row) => row.labStorageCode || '—' },
...commonTailFields
]
const outboundPilotClinicalFields: CardMetaField[] = [
{ label: '申请单号', getValue: (row) => row.applicationNo || '—' },
{ label: '申请单名称', getValue: (row) => row.applicationName || '—' },
{ label: '渠道名称', getValue: (row) => row.channelName || '—' },
{ label: '患者姓名', getValue: (row) => row.patientName || '—' },
{ label: '第几次', getValue: formatOutboundScheduleSortNo },
{ label: '总次数', getValue: formatOutboundScheduleTotalCount },
{ label: '输注时间', getValue: (row) => row.infusionTime || '—' },
...commonTailFields
]
const outboundBasicExperimentFields: CardMetaField[] = [
{ label: '申请单号', getValue: (row) => row.applicationNo || '—' },
{ label: '课题名称', getValue: (row) => row.projectTitle || row.applicationName || '—' },
{ label: '客户名称', getValue: (row) => row.customerName || '—' },
{ label: '交付时间', getValue: (row) => row.infusionTime || '—' },
{
label: '售卖金额',
getValue: (row) => {
const amount = row.feeSummary?.saleAmount
if (amount == null || amount === '') return '—'
return `¥${formatMoneyDisplay(amount)}`
}
},
...commonTailFields
]
const temporaryFields: CardMetaField[] = [
{
label: '业务类型',
kind: 'tag',
getValue: (row) => row.qcBizTypeLabel || qcBizTypeLabel('temporary'),
getTagType: () => qcBizTypeTagType('temporary')
},
{
label: '产品编码',
getValue: (row) => formatTempCellProductField(row, row.cellProductCode)
},
{
label: '产品名称',
getValue: (row) => formatTempCellProductField(row, row.cellProductName)
},
{
label: '产品类型',
getValue: (row) => formatTempCellProductField(row, row.cellProductTypeName)
},
...commonTailFields
]
function buildCellStorageGroupContext(row: QcWorkOrder): string[] {
const parts: string[] = []
if (row.sampleTypeName) parts.push(row.sampleTypeName)
if (row.protocolNo) parts.push(`协议 ${row.protocolNo}`)
if (row.protocolStatus) {
parts.push(protocolStatusLabelBySource(String(row.protocolStatus), 'cell_storage'))
}
if (row.receptionTime) parts.push(`接收 ${row.receptionTime}`)
if (row.handlerName) parts.push(row.handlerName)
return parts
}
function buildDonationGroupContext(row: QcWorkOrder): string[] {
const parts: string[] = []
if (row.sampleTypeName) parts.push(row.sampleTypeName)
if (row.protocolNo) parts.push(`捐赠 ${row.protocolNo}`)
if (row.protocolStatus) {
parts.push(donationStatusLabel(String(row.protocolStatus)))
}
if (row.receptionTime) parts.push(`接收 ${row.receptionTime}`)
if (row.handlerName) parts.push(row.handlerName)
return parts
}
const CARD_META_BY_TAB: Record<QcWorkOrderTabKey, QcWorkOrderCardMetaConfig> = {
inbound_cell_storage: {
tabKey: 'inbound_cell_storage',
listLayout: 'inbound-grouped',
showTriggerTag: true,
showProtocolFeeSummary: true,
showOutboundFeeSummary: false,
metaFields: inboundGroupedFields,
buildGroupContextParts: buildCellStorageGroupContext,
allowEditTemporary: false,
allowEditRemark: true,
allowDelete: true
},
inbound_research_donation: {
tabKey: 'inbound_research_donation',
listLayout: 'inbound-grouped',
showTriggerTag: true,
showProtocolFeeSummary: false,
showOutboundFeeSummary: false,
metaFields: inboundGroupedFields,
buildGroupContextParts: buildDonationGroupContext,
allowEditTemporary: false,
allowEditRemark: true,
allowDelete: true
},
outbound_pilot_service: {
tabKey: 'outbound_pilot_service',
listLayout: 'standalone',
showTriggerTag: false,
showProtocolFeeSummary: false,
showOutboundFeeSummary: false,
metaFields: outboundPilotClinicalFields,
buildGroupContextParts: () => [],
allowEditTemporary: false,
allowEditRemark: true,
allowDelete: false
},
outbound_basic_experiment: {
tabKey: 'outbound_basic_experiment',
listLayout: 'standalone',
showTriggerTag: false,
showProtocolFeeSummary: false,
showOutboundFeeSummary: true,
metaFields: outboundBasicExperimentFields,
buildGroupContextParts: () => [],
allowEditTemporary: false,
allowEditRemark: true,
allowDelete: false
},
outbound_clinical_application: {
tabKey: 'outbound_clinical_application',
listLayout: 'standalone',
showTriggerTag: false,
showProtocolFeeSummary: false,
showOutboundFeeSummary: true,
metaFields: outboundPilotClinicalFields,
buildGroupContextParts: () => [],
allowEditTemporary: false,
allowEditRemark: true,
allowDelete: false
},
temporary: {
tabKey: 'temporary',
listLayout: 'standalone',
showTriggerTag: false,
showProtocolFeeSummary: false,
showOutboundFeeSummary: false,
metaFields: temporaryFields,
buildGroupContextParts: () => [],
allowEditTemporary: true,
allowEditRemark: false,
allowDelete: true
}
}
export function getCardMetaConfig(tabKey: QcWorkOrderTabKey): QcWorkOrderCardMetaConfig {
return CARD_META_BY_TAB[tabKey]
}
export function buildGroupContextSubtitle(row: QcWorkOrder, tabKey: QcWorkOrderTabKey): string {
const parts = getCardMetaConfig(tabKey).buildGroupContextParts(row)
return parts.length ? parts.join(' · ') : '—'
}
export function cardMetaUsesInboundGroups(tabKey: QcWorkOrderTabKey): boolean {
return getQcWorkOrderTab(tabKey)?.listLayout === 'inbound-grouped'
}
+151
View File
@@ -0,0 +1,151 @@
import type { QcWorkOrder } from '@/api/qc-work-order'
export type QcWorkOrderTabKey =
| 'inbound_cell_storage'
| 'inbound_research_donation'
| 'outbound_pilot_service'
| 'outbound_basic_experiment'
| 'outbound_clinical_application'
| 'temporary'
export type QcWorkOrderTabGroup = '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' | 'standalone'
/** 侧栏 Tab 不展示(保留 key 供路由/数据解析) */
hidden?: boolean
}
export const QC_WORK_ORDER_TABS: QcWorkOrderTabConfig[] = [
{
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: '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 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) {
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 === 'temporary') return '工单号'
if (tab.key === 'outbound_basic_experiment') {
return '工单号/申请单号/课题名称/客户'
}
if (tab.group === 'outbound') return '工单号/申请单号/申请单名称/患者'
return '工单号/样本编码/入库编码'
}
export function filterTimeLabelForTab(tab: QcWorkOrderTabConfig): string {
if (tab.key === 'outbound_basic_experiment') return '交付时间'
if (tab.group === 'outbound') return '输注时间'
return '创建时间'
}
export function filterTimeHintForTab(tab: QcWorkOrderTabConfig): string {
if (tab.group === 'outbound') {
return tab.key === 'outbound_basic_experiment'
? '默认展示近 30 天内交付的工单。'
: '默认展示近 30 天内输注的工单。'
}
return '默认展示近 30 天内创建的工单。'
}
export function workOrderMatchesTab(row: QcWorkOrder, tabKey: QcWorkOrderTabKey): boolean {
return resolveTabKeyFromWorkOrder(row) === tabKey
}