diff --git a/web-admin/src/utils/production-mine-task-groups.ts b/web-admin/src/utils/production-mine-task-groups.ts index 2fe85190..c4acfd84 100644 --- a/web-admin/src/utils/production-mine-task-groups.ts +++ b/web-admin/src/utils/production-mine-task-groups.ts @@ -6,7 +6,8 @@ import { resolveTabKeyFromWorkOrder, getProductionWorkOrderTab, toWorkOrderListQuery, - isAllProductionWorkOrderTab + isAllProductionWorkOrderTab, + workOrderMatchesTab } from '@/utils/production-work-order-tabs' import { toAllTabListQuery, workOrderMatchesCategory } from '@/utils/production-work-order-category' import { matchesWorkOrderStatusFilter } from '@/utils/status-tag-registry' @@ -231,9 +232,7 @@ export function filterMineEntriesByWorkOrderSearch( const tabKey = filters.tabKey return entries.filter((entry) => { const row = entry.workOrder - if (!isAllProductionWorkOrderTab(tabKey) && resolveTabKeyFromWorkOrder(row) !== tabKey) { - return false - } + if (!workOrderMatchesTab(row, tabKey)) return false if ( isAllProductionWorkOrderTab(tabKey) && !workOrderMatchesCategory(row, filters.productionCategory || '') diff --git a/web-admin/src/utils/production-work-order-tabs.test.ts b/web-admin/src/utils/production-work-order-tabs.test.ts new file mode 100644 index 00000000..c2846a51 --- /dev/null +++ b/web-admin/src/utils/production-work-order-tabs.test.ts @@ -0,0 +1,32 @@ +import { describe, it } from 'node:test' +import assert from 'node:assert/strict' +import { + PRODUCTION_WORK_ORDER_VISIBLE_TABS, + parseProductionWorkOrderTabKey, + workOrderMatchesTab, + isPilotServiceOutboundWorkOrder +} from './production-work-order-tabs' +import { PRODUCTION_WORK_ORDER_CATEGORY_OPTIONS } from './production-work-order-category' + +describe('production work order tabs — hide pilot service', () => { + it('visible tabs exclude outbound_pilot_service', () => { + assert.ok(!PRODUCTION_WORK_ORDER_VISIBLE_TABS.some((t) => t.key === 'outbound_pilot_service')) + assert.ok(!PRODUCTION_WORK_ORDER_CATEGORY_OPTIONS.some((o) => o.key === 'outbound_pilot_service')) + }) + + it('parse: hidden pilot key and outbound alias fall back safely', () => { + assert.equal(parseProductionWorkOrderTabKey('outbound_pilot_service'), 'all') + assert.equal(parseProductionWorkOrderTabKey('outbound'), 'outbound_basic_experiment') + }) + + it('「所有」excludes pilot outbound (incl. default bizType)', () => { + const pilot = { workOrderType: 'outbound', bizType: 'pilot_service' } + const defaultPilot = { workOrderType: 'outbound' } + const basic = { workOrderType: 'outbound', bizType: 'basic_experiment' } + assert.equal(isPilotServiceOutboundWorkOrder(pilot), true) + assert.equal(isPilotServiceOutboundWorkOrder(defaultPilot), true) + assert.equal(workOrderMatchesTab(pilot as any, 'all'), false) + assert.equal(workOrderMatchesTab(defaultPilot as any, 'all'), false) + assert.equal(workOrderMatchesTab(basic as any, 'all'), true) + }) +}) diff --git a/web-admin/src/utils/production-work-order-tabs.ts b/web-admin/src/utils/production-work-order-tabs.ts index 12bd2905..91674c48 100644 --- a/web-admin/src/utils/production-work-order-tabs.ts +++ b/web-admin/src/utils/production-work-order-tabs.ts @@ -53,7 +53,9 @@ export const PRODUCTION_WORK_ORDER_TABS: ProductionWorkOrderTabConfig[] = [ group: 'outbound', workOrderType: 'outbound', bizType: 'pilot_service', - listLayout: 'standalone' + listLayout: 'standalone', + /** 客户已下线中试业务:侧栏不展示,路由 key 保留供历史解析 */ + hidden: true }, { key: 'outbound_basic_experiment', @@ -97,7 +99,7 @@ export function parseProductionWorkOrderTabKey(raw?: string | null): ProductionW 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 === 'outbound') return 'outbound_basic_experiment' if (k === 'temporary') return 'temporary' return DEFAULT_PRODUCTION_WORK_ORDER_TAB } @@ -145,11 +147,19 @@ export function keywordPlaceholderForTab(tab: ProductionWorkOrderTabConfig): str 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 true + if (tabKey === 'all') return !isPilotServiceOutboundWorkOrder(row) return resolveTabKeyFromWorkOrder(row) === tabKey } diff --git a/web-admin/src/utils/qc-mine-task-groups.ts b/web-admin/src/utils/qc-mine-task-groups.ts index 15aefd61..70c0bcb5 100644 --- a/web-admin/src/utils/qc-mine-task-groups.ts +++ b/web-admin/src/utils/qc-mine-task-groups.ts @@ -10,7 +10,8 @@ import { tabUsesInfusionTimeFilter, getQcWorkOrderTab, toWorkOrderListQuery, - isAllQcWorkOrderTab + isAllQcWorkOrderTab, + workOrderMatchesTab } from '@/utils/qc-work-order-tabs' import { matchesAllTabTriggerSource, @@ -101,9 +102,7 @@ export function filterMineEntriesByWorkOrderSearch( const tab = getQcWorkOrderTab(tabKey)! return entries.filter((entry) => { const row = entry.workOrder - if (!isAllQcWorkOrderTab(tabKey) && resolveTabKeyFromWorkOrder(row) !== tabKey) { - return false - } + if (!workOrderMatchesTab(row, tabKey)) return false if (isAllQcWorkOrderTab(tabKey) && !workOrderMatchesCategory(row, filters.qcCategory || '')) { return false } diff --git a/web-admin/src/utils/qc-work-order-tabs.test.ts b/web-admin/src/utils/qc-work-order-tabs.test.ts new file mode 100644 index 00000000..00d1bbe9 --- /dev/null +++ b/web-admin/src/utils/qc-work-order-tabs.test.ts @@ -0,0 +1,33 @@ +import { describe, it } from 'node:test' +import assert from 'node:assert/strict' +import { + QC_WORK_ORDER_VISIBLE_TABS, + parseQcWorkOrderTabKey, + workOrderMatchesTab, + isPilotServiceOutboundWorkOrder +} from './qc-work-order-tabs' +import { QC_WORK_ORDER_CATEGORY_OPTIONS } from './qc-work-order-category' + +describe('qc work order tabs — hide pilot service', () => { + it('visible tabs exclude outbound_pilot_service', () => { + assert.ok(!QC_WORK_ORDER_VISIBLE_TABS.some((t) => t.key === 'outbound_pilot_service')) + assert.ok(!QC_WORK_ORDER_CATEGORY_OPTIONS.some((o) => o.key === 'outbound_pilot_service')) + }) + + it('parse: hidden pilot key and outbound alias fall back safely', () => { + // 质检默认 Tab 为细胞存储(「所有」本身也是 hidden) + assert.equal(parseQcWorkOrderTabKey('outbound_pilot_service'), 'inbound_cell_storage') + assert.equal(parseQcWorkOrderTabKey('outbound'), 'outbound_basic_experiment') + }) + + it('「所有」excludes pilot outbound (incl. default bizType)', () => { + const pilot = { workOrderType: 'outbound', bizType: 'pilot_service' } + const defaultPilot = { workOrderType: 'outbound' } + const basic = { workOrderType: 'outbound', bizType: 'basic_experiment' } + assert.equal(isPilotServiceOutboundWorkOrder(pilot), true) + assert.equal(isPilotServiceOutboundWorkOrder(defaultPilot), true) + assert.equal(workOrderMatchesTab(pilot as any, 'all'), false) + assert.equal(workOrderMatchesTab(defaultPilot as any, 'all'), false) + assert.equal(workOrderMatchesTab(basic as any, 'all'), true) + }) +}) diff --git a/web-admin/src/utils/qc-work-order-tabs.ts b/web-admin/src/utils/qc-work-order-tabs.ts index 27ced959..ef7cb9b7 100644 --- a/web-admin/src/utils/qc-work-order-tabs.ts +++ b/web-admin/src/utils/qc-work-order-tabs.ts @@ -53,7 +53,9 @@ export const QC_WORK_ORDER_TABS: QcWorkOrderTabConfig[] = [ group: 'outbound', workOrderType: 'outbound', bizType: 'pilot_service', - listLayout: 'outbound-grouped' + listLayout: 'outbound-grouped', + /** 客户已下线中试业务:侧栏不展示,路由 key 保留供历史解析 */ + hidden: true }, { key: 'outbound_basic_experiment', @@ -95,7 +97,7 @@ export function parseQcWorkOrderTabKey(raw?: string | null): QcWorkOrderTabKey { 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 === 'outbound') return 'outbound_basic_experiment' if (k === 'temporary') return 'temporary' return DEFAULT_QC_WORK_ORDER_TAB } @@ -160,8 +162,16 @@ export function filterTimeLabelForTab(tab: QcWorkOrderTabConfig): string { 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 true + if (tabKey === 'all') return !isPilotServiceOutboundWorkOrder(row) return resolveTabKeyFromWorkOrder(row) === tabKey } diff --git a/web-admin/src/views/production/production-work-order/composables/useProductionWorkOrderTabPage.ts b/web-admin/src/views/production/production-work-order/composables/useProductionWorkOrderTabPage.ts index 018e1e9d..792e2c54 100644 --- a/web-admin/src/views/production/production-work-order/composables/useProductionWorkOrderTabPage.ts +++ b/web-admin/src/views/production/production-work-order/composables/useProductionWorkOrderTabPage.ts @@ -22,6 +22,7 @@ import { isAllProductionWorkOrderTab, tabSupportsInactiveProtocolFilter, resolveTabKeyFromWorkOrder, + workOrderMatchesTab, type ProductionWorkOrderTabKey } from '@/utils/production-work-order-tabs' import { toAllTabListQuery } from '@/utils/production-work-order-category' @@ -164,8 +165,16 @@ export function useProductionWorkOrderTabPage( ...listQuery, ...buildPlannedStartTimeParams() }) - tableData.value = res.list || [] - pagination.total = res.total ?? 0 + const rawList = res.list || [] + const list = isAllProductionWorkOrderTab(tabKey.value) + ? rawList.filter((row) => workOrderMatchesTab(row, 'all')) + : rawList + tableData.value = list + // 「所有」前端排除中试时,按本页剔除量修正 total(后端未改) + pagination.total = Math.max( + 0, + (res.total ?? 0) - (rawList.length - list.length) + ) selectedRows.value = selectedRows.value.filter((row) => tableData.value.some((item) => item.id === row.id) ) diff --git a/web-admin/src/views/quality-inspection/qc-work-order/composables/useQcWorkOrderTabPage.ts b/web-admin/src/views/quality-inspection/qc-work-order/composables/useQcWorkOrderTabPage.ts index e80c76a4..2e554c88 100644 --- a/web-admin/src/views/quality-inspection/qc-work-order/composables/useQcWorkOrderTabPage.ts +++ b/web-admin/src/views/quality-inspection/qc-work-order/composables/useQcWorkOrderTabPage.ts @@ -20,6 +20,7 @@ import { isAllQcWorkOrderTab, isInboundSampleQcTab, resolveTabKeyFromWorkOrder, + workOrderMatchesTab, type QcWorkOrderTabKey } from '@/utils/qc-work-order-tabs' import { toAllTabListQuery } from '@/utils/qc-work-order-category' @@ -210,7 +211,10 @@ export function useQcWorkOrderTabPage( ...listQuery, ...timeParams }) - const list = res.list || [] + const rawList = res.list || [] + const list = isAllQcWorkOrderTab(tabKey.value) + ? rawList.filter((row) => workOrderMatchesTab(row, 'all')) + : rawList const ids = list.map((row) => row.id).filter(Boolean) const batchMap = ids.length ? (await fetchQcInspectionBatchesBatch(ids).catch(() => ({}))) || {} @@ -218,7 +222,8 @@ export function useQcWorkOrderTabPage( // 先写入批次摘要,再渲染卡片,避免子组件在 preset 未就绪时逐条请求 inspection-batches presetBatchesByWorkOrderId.value = batchMap tableData.value = list - pagination.total = res.total ?? 0 + // 「所有」前端排除中试时,按本页剔除量修正 total(后端未改) + pagination.total = Math.max(0, (res.total ?? 0) - (rawList.length - list.length)) } finally { loading.value = false }