601 lines
17 KiB
Vue
601 lines
17 KiB
Vue
<!-- 质检工单 · 同样本分组(上下文条 + Tab + 单工单卡片) -->
|
||
<template>
|
||
<article :id="cardAnchorId || undefined" class="qc-sample-row">
|
||
<div v-if="!hideContextBar" class="qc-sample-row__ctx">
|
||
<QcWorkOrderSelectCheckbox :work-order-ids="sampleGroupWorkOrderIds" />
|
||
<QcUnfinishedBadge :count="groupUnfinishedBadgeCount" />
|
||
<span class="qc-sample-row__idx">{{ groupIndex }}</span>
|
||
<SampleCodeWithSpecialDisplay
|
||
class="qc-sample-row__code"
|
||
:sample-code="groupContextTitle"
|
||
:is-special="!!contextRow?.isSpecial"
|
||
:special-remark="contextRow?.specialRemark"
|
||
monospace
|
||
/>
|
||
<span class="qc-sample-row__sub">{{ contextSubtitle }}</span>
|
||
<div
|
||
v-if="protocolSiblingLinks.length > 1"
|
||
class="qc-sample-row__protocol-inline"
|
||
aria-label="同协议样本"
|
||
>
|
||
<span class="qc-sample-row__protocol-label">同协议样本</span>
|
||
<span
|
||
v-for="link in protocolSiblingLinks"
|
||
:key="link.anchorId"
|
||
class="qc-sample-row__protocol-chip"
|
||
:class="{ 'is-current': link.anchorId === cardAnchorId }"
|
||
>
|
||
<span class="qc-sample-row__protocol-chip-code">{{ link.labStorageCode }}</span>
|
||
<span v-if="link.sampleTypeName" class="qc-sample-row__protocol-chip-type">
|
||
{{ link.sampleTypeName }}
|
||
</span>
|
||
</span>
|
||
</div>
|
||
<el-tag v-if="showInboundProtocolStatus" :type="protocolStatus.tagType" size="small">
|
||
{{ protocolStatus.label }}
|
||
</el-tag>
|
||
<span v-if="group.workOrders.length > 1" class="qc-sample-row__badge">
|
||
{{ group.workOrders.length }} 条质检
|
||
</span>
|
||
<div v-if="sampleSpecialMarkTarget" class="qc-sample-row__ctx-actions">
|
||
<el-button class="btn-op-item" size="small" @click="openSampleSpecialDialog">
|
||
<el-icon><EditPen /></el-icon>特殊样本
|
||
</el-button>
|
||
</div>
|
||
</div>
|
||
|
||
<QcWorkOrderProtocolPaymentPanel
|
||
v-if="!hideContextBar && showProtocolPaymentAtGroup && protocolPaymentSummary"
|
||
:summary="protocolPaymentSummary"
|
||
compact
|
||
class="qc-sample-row__fee"
|
||
/>
|
||
|
||
<div v-if="group.workOrders.length > 1" class="qc-wo-indep-tabs">
|
||
<div class="qc-wo-indep-tabs__row" role="tablist" aria-label="同样本质检工单">
|
||
<button
|
||
v-for="(wo, tabIndex) in group.workOrders"
|
||
:key="wo.id"
|
||
type="button"
|
||
role="tab"
|
||
class="qc-wo-indep-tabs__btn"
|
||
:class="[
|
||
{ 'is-active': wo.id === activeWorkOrderId },
|
||
triggerSourcePillClass(wo.triggerSource)
|
||
]"
|
||
:aria-selected="wo.id === activeWorkOrderId"
|
||
@click="activeWorkOrderId = wo.id"
|
||
>
|
||
<span class="qc-wo-tab__index">{{ tabIndex + 1 }}</span>
|
||
<span class="qc-wo-tab__source" :class="triggerSourceTabClass(wo.triggerSource)">
|
||
<span class="qc-wo-tab__dot"></span>
|
||
{{ triggerSourceTabLabel(wo) }}
|
||
</span>
|
||
<span class="qc-wo-tab__no">{{ workOrderTabTitle(wo) }}</span>
|
||
<el-tag
|
||
:type="workOrderStatusTagType(wo.workOrderStatus)"
|
||
size="small"
|
||
class="qc-wo-tab__status"
|
||
>
|
||
{{ workOrderStatusLabel(wo.workOrderStatus) }}
|
||
</el-tag>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<QcWorkOrderSingleCard
|
||
v-if="activeRow"
|
||
layout="grouped"
|
||
:row="activeRow"
|
||
:card-meta-config="cardMetaConfig"
|
||
:task-refresh-token="taskRefreshToken"
|
||
:show-work-order-ops="showWorkOrderOps"
|
||
:show-work-order-view-only="showWorkOrderViewOnly"
|
||
:task-list-mode="taskListMode"
|
||
:preset-tasks="activePresetTasks"
|
||
:preset-batches="activePresetBatches"
|
||
:hide-protocol-fee-summary="hideProtocolFeeSummary || showProtocolPaymentAtGroup"
|
||
:hide-sample-special-in-title="!hideContextBar"
|
||
@configure="(row) => emit('configure', row)"
|
||
@view="(row) => emit('view', row)"
|
||
@command="(cmd, row) => emit('command', cmd, row)"
|
||
@tasks-changed="emit('tasks-changed')"
|
||
@sample-special-changed="emit('sample-special-changed')"
|
||
/>
|
||
|
||
<SampleSpecialMarkDialog
|
||
v-model:visible="sampleSpecialDialogVisible"
|
||
:target="sampleSpecialMarkTarget"
|
||
@success="emit('sample-special-changed')"
|
||
/>
|
||
</article>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { ref, computed, watch } from 'vue'
|
||
import type { QcWorkOrder } from '@/api/qc-work-order'
|
||
import type { QcTask } from '@/api/qc-task'
|
||
import type { QcInspectionBatch } from '@/utils/qc-inspection-batch'
|
||
import { workOrderStatusLabel } from '@/utils/qc-labels'
|
||
import type { TagType } from '@/utils/status-tag-registry'
|
||
import {
|
||
type QcWorkOrderSampleGroupModel,
|
||
triggerSourceTabLabel,
|
||
isGateTriggerSource
|
||
} from '@/utils/qc-work-order-groups'
|
||
import type { QcWorkOrderCardMetaConfig } from '@/utils/qc-work-order-card-meta'
|
||
import SampleCodeWithSpecialDisplay from '@/components/business/sample-code-with-special-display/index.vue'
|
||
import {
|
||
buildGroupContextSubtitle,
|
||
cardMetaUsesInboundGroups,
|
||
resolveInboundSampleGroupCardTitle,
|
||
resolveProtocolGroupStatus
|
||
} from '@/utils/qc-work-order-card-meta'
|
||
import type { QcInboundProtocolSiblingLink } from '@/utils/qc-work-order-inbound-sample-cards'
|
||
import { resolveEffectiveRowTabKey } from '@/utils/qc-work-order-tabs'
|
||
import { sumQcWorkOrderGroupUnfinishedBadgeCount } from '@/utils/qc-work-order-unfinished-badge'
|
||
import QcUnfinishedBadge from './QcUnfinishedBadge.vue'
|
||
import QcWorkOrderSelectCheckbox from './QcWorkOrderSelectCheckbox.vue'
|
||
import QcWorkOrderSingleCard from './QcWorkOrderSingleCard.vue'
|
||
import QcWorkOrderProtocolPaymentPanel from './QcWorkOrderProtocolPaymentPanel.vue'
|
||
import SampleSpecialMarkDialog from '@/components/business/sample-special-mark-dialog/index.vue'
|
||
import { resolveInboundSampleSpecialMarkTarget } from '@/utils/inbound-sample-special-mark'
|
||
import { EditPen } from '@element-plus/icons-vue'
|
||
|
||
defineOptions({ name: 'QcWorkOrderSampleGroup' })
|
||
|
||
const props = withDefaults(
|
||
defineProps<{
|
||
group: QcWorkOrderSampleGroupModel
|
||
groupIndex: number
|
||
cardMetaConfig: QcWorkOrderCardMetaConfig
|
||
taskRefreshToken: number
|
||
showWorkOrderOps?: boolean
|
||
showWorkOrderViewOnly?: boolean
|
||
taskListMode?: 'workOrder' | 'mine'
|
||
presetTasksByWorkOrderId?: Record<string, QcTask[]>
|
||
presetBatchesByWorkOrderId?: Record<string, QcInspectionBatch[]>
|
||
hideContextBar?: boolean
|
||
hideProtocolFeeSummary?: boolean
|
||
cardAnchorId?: string
|
||
protocolSiblingLinks?: QcInboundProtocolSiblingLink[]
|
||
showProtocolPaymentAtGroup?: boolean
|
||
}>(),
|
||
{
|
||
showWorkOrderOps: true,
|
||
showWorkOrderViewOnly: false,
|
||
taskListMode: 'workOrder',
|
||
hideContextBar: false,
|
||
hideProtocolFeeSummary: false,
|
||
cardAnchorId: '',
|
||
protocolSiblingLinks: () => [],
|
||
showProtocolPaymentAtGroup: false
|
||
}
|
||
)
|
||
|
||
const emit = defineEmits<{
|
||
configure: [row: QcWorkOrder]
|
||
view: [row: QcWorkOrder]
|
||
command: [cmd: string, row: QcWorkOrder]
|
||
'tasks-changed': []
|
||
'sample-special-changed': []
|
||
}>()
|
||
|
||
const sampleSpecialDialogVisible = ref(false)
|
||
|
||
const sampleSpecialMarkTarget = computed(() =>
|
||
resolveInboundSampleSpecialMarkTarget(props.group.workOrders)
|
||
)
|
||
|
||
function openSampleSpecialDialog() {
|
||
if (!sampleSpecialMarkTarget.value) return
|
||
sampleSpecialDialogVisible.value = true
|
||
}
|
||
|
||
const activeWorkOrderId = ref(props.group.workOrders[0]?.id || '')
|
||
|
||
watch(
|
||
() => props.group.workOrders.map((w) => w.id).join(','),
|
||
() => {
|
||
const ids = props.group.workOrders.map((w) => w.id)
|
||
if (!ids.includes(activeWorkOrderId.value)) {
|
||
activeWorkOrderId.value = ids[0] || ''
|
||
}
|
||
}
|
||
)
|
||
|
||
const activeRow = computed(() =>
|
||
props.group.workOrders.find((w) => w.id === activeWorkOrderId.value)
|
||
)
|
||
|
||
const activePresetTasks = computed(() => {
|
||
const row = activeRow.value
|
||
if (!row || !props.presetTasksByWorkOrderId) return undefined
|
||
return props.presetTasksByWorkOrderId[row.id]
|
||
})
|
||
|
||
const activePresetBatches = computed(() => {
|
||
const row = activeRow.value
|
||
if (!row || !props.presetBatchesByWorkOrderId) return undefined
|
||
return props.presetBatchesByWorkOrderId[row.id] ?? []
|
||
})
|
||
|
||
const contextRow = computed(() => {
|
||
const gate =
|
||
props.group.workOrders.find((w) => isGateTriggerSource(w.triggerSource)) ||
|
||
props.group.workOrders[0]
|
||
return gate
|
||
})
|
||
|
||
function triggerSourceTabClass(source?: string) {
|
||
const ts = source || 'reception'
|
||
if (ts === 'production') return 'qc-wo-tab__source--production'
|
||
if (ts === 'schedule') return 'qc-wo-tab__source--schedule'
|
||
return 'qc-wo-tab__source--reception'
|
||
}
|
||
|
||
function triggerSourcePillClass(source?: string) {
|
||
const ts = source || 'reception'
|
||
if (ts === 'production') return 'qc-wo-indep-tabs__btn--production'
|
||
return 'qc-wo-indep-tabs__btn--reception'
|
||
}
|
||
|
||
const contextSubtitle = computed(() => {
|
||
const row = contextRow.value
|
||
if (!row) return '—'
|
||
const tabKey = resolveEffectiveRowTabKey(props.cardMetaConfig.tabKey, row)
|
||
return buildGroupContextSubtitle(row, tabKey)
|
||
})
|
||
|
||
const showInboundProtocolStatus = computed(() => {
|
||
const row = contextRow.value
|
||
if (!row) return false
|
||
const source = (row.receptionSource || '').trim()
|
||
return source === 'cell_storage' || source === 'research_donation'
|
||
})
|
||
|
||
const protocolStatus = computed(() =>
|
||
contextRow.value
|
||
? resolveProtocolGroupStatus(contextRow.value)
|
||
: { label: '—', tagType: 'info' as TagType }
|
||
)
|
||
|
||
const groupUnfinishedBadgeCount = computed(() =>
|
||
sumQcWorkOrderGroupUnfinishedBadgeCount(props.group.workOrders)
|
||
)
|
||
|
||
const sampleGroupWorkOrderIds = computed(() => props.group.workOrders.map((wo) => wo.id))
|
||
|
||
const protocolPaymentSummary = computed(() => {
|
||
for (const wo of props.group.workOrders) {
|
||
if (wo.paymentSummary) return wo.paymentSummary
|
||
}
|
||
return null
|
||
})
|
||
|
||
const groupContextTitle = computed(() => {
|
||
const row = contextRow.value
|
||
if (!row) return '—'
|
||
const tabKey = resolveEffectiveRowTabKey(props.cardMetaConfig.tabKey, row)
|
||
if (cardMetaUsesInboundGroups(tabKey)) {
|
||
return resolveInboundSampleGroupCardTitle(props.group.workOrders)
|
||
}
|
||
return (props.group.groupTitle || props.group.sampleCode || '').trim() || '—'
|
||
})
|
||
|
||
function workOrderTabTitle(wo: QcWorkOrder) {
|
||
return wo.workOrderNo || '—'
|
||
}
|
||
|
||
function workOrderStatusTagType(status: string): TagType {
|
||
if (status === 'ywc') return 'success'
|
||
if (status === 'ypz') return 'warning'
|
||
if (status === 'yzf') return 'danger'
|
||
return 'info'
|
||
}
|
||
|
||
defineExpose({
|
||
activeWorkOrderId
|
||
})
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
.qc-sample-row {
|
||
display: flex;
|
||
flex-direction: column;
|
||
min-width: 0;
|
||
border: 1px solid #e2e8f0;
|
||
border-radius: 10px;
|
||
background: #fff;
|
||
overflow: hidden;
|
||
transition:
|
||
border-color 0.15s ease,
|
||
box-shadow 0.15s ease;
|
||
|
||
&:hover {
|
||
border-color: #a8d4c4;
|
||
box-shadow: 0 2px 8px rgba(4, 120, 87, 0.08);
|
||
}
|
||
|
||
&--highlight {
|
||
border-color: var(--primary, #10b981);
|
||
box-shadow: 0 0 0 2px rgb(16 185 129 / 18%);
|
||
}
|
||
}
|
||
|
||
.qc-sample-row__protocol-inline {
|
||
display: inline-flex;
|
||
flex-wrap: wrap;
|
||
align-items: center;
|
||
gap: 6px 8px;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.qc-sample-row__protocol-label {
|
||
flex-shrink: 0;
|
||
font-size: 12px;
|
||
color: var(--mint-text-muted, #64748b);
|
||
}
|
||
|
||
.qc-sample-row__protocol-chip {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
min-height: 26px;
|
||
padding: 2px 10px;
|
||
border: 1px solid #d1fae5;
|
||
border-radius: 999px;
|
||
background: #fff;
|
||
font-size: 12px;
|
||
color: #047857;
|
||
|
||
&.is-current {
|
||
border-color: var(--primary, #10b981);
|
||
background: var(--primary-bg, #ecfdf5);
|
||
font-weight: 600;
|
||
}
|
||
}
|
||
|
||
.qc-sample-row__protocol-chip-code {
|
||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||
}
|
||
|
||
.qc-sample-row__protocol-chip-type {
|
||
font-size: 11px;
|
||
color: var(--mint-text-muted, #64748b);
|
||
}
|
||
|
||
.qc-sample-row__fee {
|
||
border-bottom: 1px solid #e2e8f0;
|
||
}
|
||
|
||
.qc-sample-row__ctx {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: center;
|
||
gap: 8px 12px;
|
||
padding: 12px 16px;
|
||
background: linear-gradient(180deg, var(--primary-bg, #ecfdf5) 0%, #fff 100%);
|
||
border-bottom: 1px solid #d1fae5;
|
||
}
|
||
|
||
.qc-sample-row__idx {
|
||
flex-shrink: 0;
|
||
font-size: 12px;
|
||
color: var(--mint-text-muted, #64748b);
|
||
min-width: 20px;
|
||
}
|
||
|
||
.qc-sample-row__code {
|
||
font-size: 14px;
|
||
font-weight: 600;
|
||
color: #1e293b;
|
||
}
|
||
|
||
.qc-sample-row__sub {
|
||
flex: 1;
|
||
min-width: 0;
|
||
font-size: 12px;
|
||
color: var(--mint-text-muted, #64748b);
|
||
line-height: 1.4;
|
||
}
|
||
|
||
.qc-sample-row__badge {
|
||
flex-shrink: 0;
|
||
font-size: 11px;
|
||
font-weight: 600;
|
||
padding: 2px 10px;
|
||
border-radius: 999px;
|
||
background: var(--primary-bg, #ecfdf5);
|
||
color: #047857;
|
||
border: 1px solid #d1fae5;
|
||
}
|
||
|
||
.qc-sample-row__ctx-actions {
|
||
flex-shrink: 0;
|
||
margin-left: auto;
|
||
}
|
||
|
||
.qc-wo-indep-tabs {
|
||
padding: 12px 16px;
|
||
border-bottom: 1px solid #e2e8f0;
|
||
background: #f8fafc;
|
||
}
|
||
|
||
.qc-wo-indep-tabs__row {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: center;
|
||
gap: 24px;
|
||
max-width: 100%;
|
||
}
|
||
|
||
.qc-wo-indep-tabs__btn {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
min-width: 0;
|
||
min-height: 34px;
|
||
padding: 8px 16px;
|
||
border: 2px solid #e2e8f0;
|
||
border-radius: 10px;
|
||
background: #fff;
|
||
font-size: 12px;
|
||
color: #1e293b;
|
||
cursor: pointer;
|
||
white-space: nowrap;
|
||
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
|
||
transition:
|
||
background 0.15s ease,
|
||
color 0.15s ease,
|
||
border-color 0.15s ease,
|
||
box-shadow 0.15s ease;
|
||
|
||
&:focus-visible {
|
||
outline: 2px solid #10b981;
|
||
outline-offset: 2px;
|
||
}
|
||
|
||
&:not(.is-active) {
|
||
.qc-wo-tab__index {
|
||
color: #1e293b;
|
||
background: #e2e8f0;
|
||
}
|
||
|
||
.qc-wo-tab__source--reception,
|
||
.qc-wo-tab__source--schedule {
|
||
color: #047857;
|
||
background: #ecfdf5;
|
||
}
|
||
|
||
.qc-wo-tab__source--production {
|
||
color: #b45309;
|
||
background: #fffbeb;
|
||
}
|
||
|
||
.qc-wo-tab__no {
|
||
color: #1e293b;
|
||
}
|
||
|
||
.qc-wo-tab__status.el-tag,
|
||
.qc-wo-tab__status.el-tag.el-tag--success,
|
||
.qc-wo-tab__status.el-tag.el-tag--warning,
|
||
.qc-wo-tab__status.el-tag.el-tag--danger,
|
||
.qc-wo-tab__status.el-tag.el-tag--info {
|
||
--el-tag-text-color: #1e293b;
|
||
--el-tag-bg-color: #f1f5f9;
|
||
--el-tag-border-color: #e2e8f0;
|
||
color: #1e293b;
|
||
background-color: #f1f5f9;
|
||
border-color: #e2e8f0;
|
||
}
|
||
}
|
||
|
||
&:not(.is-active):hover {
|
||
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
|
||
}
|
||
|
||
&--reception:not(.is-active) {
|
||
border-color: #a7f3d0;
|
||
|
||
&:hover {
|
||
border-color: #047857;
|
||
background: #ecfdf5;
|
||
}
|
||
}
|
||
|
||
&--production:not(.is-active) {
|
||
border-color: #fcd34d;
|
||
|
||
&:hover {
|
||
border-color: #b45309;
|
||
background: #fffbeb;
|
||
}
|
||
}
|
||
|
||
&.is-active {
|
||
color: #fff;
|
||
background: var(--primary, #10b981);
|
||
border-color: var(--primary, #10b981);
|
||
box-shadow: 0 2px 6px rgba(16, 185, 129, 0.28);
|
||
|
||
.qc-wo-tab__index {
|
||
color: #fff;
|
||
background: rgb(255 255 255 / 28%);
|
||
}
|
||
|
||
.qc-wo-tab__source,
|
||
.qc-wo-tab__source--reception,
|
||
.qc-wo-tab__source--schedule,
|
||
.qc-wo-tab__source--production {
|
||
color: #fff;
|
||
background: rgb(255 255 255 / 22%);
|
||
}
|
||
|
||
.qc-wo-tab__no {
|
||
color: #fff;
|
||
}
|
||
|
||
.qc-wo-tab__status.el-tag,
|
||
.qc-wo-tab__status.el-tag.el-tag--success,
|
||
.qc-wo-tab__status.el-tag.el-tag--warning,
|
||
.qc-wo-tab__status.el-tag.el-tag--danger,
|
||
.qc-wo-tab__status.el-tag.el-tag--info {
|
||
--el-tag-text-color: #fff;
|
||
--el-tag-bg-color: rgb(255 255 255 / 22%);
|
||
--el-tag-border-color: rgb(255 255 255 / 35%);
|
||
color: #fff;
|
||
background-color: rgb(255 255 255 / 22%);
|
||
border-color: rgb(255 255 255 / 35%);
|
||
}
|
||
}
|
||
}
|
||
|
||
.qc-wo-tab__index {
|
||
flex-shrink: 0;
|
||
width: 18px;
|
||
height: 18px;
|
||
border-radius: 50%;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-size: 11px;
|
||
font-weight: 700;
|
||
line-height: 1;
|
||
}
|
||
|
||
.qc-wo-tab__source {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 4px;
|
||
padding: 1px 6px;
|
||
border-radius: 4px;
|
||
font-size: 11px;
|
||
font-weight: 600;
|
||
line-height: 1.4;
|
||
}
|
||
|
||
.qc-wo-tab__no {
|
||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||
}
|
||
|
||
.qc-wo-tab__dot {
|
||
display: inline-block;
|
||
width: 6px;
|
||
height: 6px;
|
||
border-radius: 50%;
|
||
flex-shrink: 0;
|
||
background: currentColor;
|
||
}
|
||
|
||
.qc-wo-tab__status {
|
||
margin-left: 2px;
|
||
}
|
||
|
||
.qc-sample-row :deep(.qc-work-order-card) {
|
||
border: none;
|
||
border-radius: 0;
|
||
box-shadow: none;
|
||
}
|
||
</style>
|