生产/质检入库卡片展示样本状态并支持【样本废弃】;市场 Web 列表与移动市场部卡片补充样本状态及问号查看作废原因;样本表新增 void_desc,人工作废不联动接收但全部作废时自动作废协议(#131)。 Co-authored-by: Cursor <cursoragent@cursor.com>
575 lines
17 KiB
Vue
575 lines
17 KiB
Vue
<!-- 质检工单 · 同协议多样本分组(协议组头 + 样本 Tab + SampleGroup) -->
|
||
<template>
|
||
<article class="qc-protocol-row">
|
||
<div
|
||
class="qc-protocol-row__ctx"
|
||
:class="{ 'qc-protocol-row__ctx--has-sample-tabs': group.sampleGroups.length > 1 }"
|
||
>
|
||
<div class="qc-protocol-row__ctx-left">
|
||
<QcWorkOrderSelectCheckbox :work-order-ids="activeSampleGroupWorkOrderIds" />
|
||
<QcUnfinishedBadge :count="groupUnfinishedBadgeCount" />
|
||
<span class="qc-protocol-row__idx">{{ groupIndex }}</span>
|
||
<SampleCodeWithSpecialDisplay
|
||
v-if="group.sampleGroups.length === 1"
|
||
class="qc-protocol-row__sample-code"
|
||
:sample-code="singleSampleGroupTitle(group.sampleGroups[0])"
|
||
:is-special="!!group.sampleGroups[0]?.workOrders[0]?.isSpecial"
|
||
:special-remark="group.sampleGroups[0]?.workOrders[0]?.specialRemark"
|
||
monospace
|
||
/>
|
||
<template v-if="protocolUserInfo.motherName || protocolUserInfo.newbornName">
|
||
<span v-if="protocolUserInfo.motherName" class="qc-protocol-row__user">
|
||
母亲 {{ protocolUserInfo.motherName }}
|
||
</span>
|
||
<span v-if="protocolUserInfo.newbornName" class="qc-protocol-row__user">
|
||
新生儿 {{ protocolUserInfo.newbornName }}
|
||
</span>
|
||
</template>
|
||
<el-tag :type="protocolStatus.tagType" size="small">
|
||
{{ protocolStatus.label }}
|
||
</el-tag>
|
||
<span class="qc-protocol-row__sub">
|
||
{{ sampleCountLabel }}
|
||
<template v-if="progressLabel"> · {{ progressLabel }}</template>
|
||
</span>
|
||
</div>
|
||
|
||
<div
|
||
v-if="group.sampleGroups.length > 1"
|
||
class="qc-protocol-row__ctx-center qc-protocol-sample-tabs"
|
||
role="tablist"
|
||
aria-label="同协议样本"
|
||
>
|
||
<button
|
||
v-for="(sampleGroup, tabIndex) in group.sampleGroups"
|
||
:key="sampleTabKey(sampleGroup)"
|
||
type="button"
|
||
role="tab"
|
||
class="qc-wo-indep-tabs__btn qc-wo-indep-tabs__btn--reception"
|
||
:class="{ 'is-active': sampleTabKey(sampleGroup) === activeSampleKey }"
|
||
:aria-selected="sampleTabKey(sampleGroup) === activeSampleKey"
|
||
@click="activeSampleKey = sampleTabKey(sampleGroup)"
|
||
>
|
||
<span class="qc-wo-tab__index">{{ tabIndex + 1 }}</span>
|
||
<SampleCodeWithSpecialDisplay
|
||
class="qc-wo-tab__no"
|
||
:sample-code="sampleGroupTitle(sampleGroup)"
|
||
:is-special="!!sampleGroup.workOrders[0]?.isSpecial"
|
||
:special-remark="sampleGroup.workOrders[0]?.specialRemark"
|
||
monospace
|
||
/>
|
||
<span
|
||
v-if="sampleTypeLabel(sampleGroup)"
|
||
class="qc-wo-tab__source qc-wo-tab__source--reception"
|
||
>
|
||
{{ sampleTypeLabel(sampleGroup) }}
|
||
</span>
|
||
<el-tag
|
||
v-if="gateWorkOrder(sampleGroup)"
|
||
:type="sampleTabStatusTagType(sampleGroup)"
|
||
size="small"
|
||
class="qc-wo-tab__status"
|
||
>
|
||
{{ sampleTabStatusLabel(sampleGroup) }}
|
||
</el-tag>
|
||
</button>
|
||
</div>
|
||
|
||
<div class="qc-protocol-row__ctx-right">
|
||
<el-button
|
||
v-if="activeSampleSpecialMarkTarget"
|
||
class="btn-op-item"
|
||
size="small"
|
||
@click="openSampleSpecialDialog"
|
||
>
|
||
<el-icon><EditPen /></el-icon>特殊样本
|
||
</el-button>
|
||
<span v-if="group.workOrders.length > 1" class="qc-protocol-row__badge">
|
||
{{ group.workOrders.length }} 条质检
|
||
</span>
|
||
</div>
|
||
</div>
|
||
|
||
<QcWorkOrderProtocolPaymentPanel
|
||
v-if="protocolPaymentSummary"
|
||
:summary="protocolPaymentSummary"
|
||
compact
|
||
class="qc-protocol-row__fee"
|
||
/>
|
||
|
||
<QcWorkOrderSampleGroup
|
||
v-if="activeSampleGroup"
|
||
:group="activeSampleGroup"
|
||
:group-index="groupIndex"
|
||
: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-by-work-order-id="presetTasksByWorkOrderId"
|
||
:preset-batches-by-work-order-id="presetBatchesByWorkOrderId"
|
||
hide-context-bar
|
||
:hide-protocol-fee-summary="!!protocolPaymentSummary"
|
||
@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')"
|
||
@sample-voided="emit('sample-voided')"
|
||
/>
|
||
|
||
<SampleSpecialMarkDialog
|
||
v-model:visible="sampleSpecialDialogVisible"
|
||
:target="activeSampleSpecialMarkTarget"
|
||
@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 QcWorkOrderProtocolGroupModel,
|
||
type QcWorkOrderSampleGroupModel,
|
||
resolveGateWorkOrderForSampleGroup
|
||
} 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 {
|
||
buildProtocolGroupProgressLabel,
|
||
resolveInboundSampleGroupCardTitle,
|
||
resolveProtocolGroupPaymentSummary,
|
||
resolveProtocolGroupStatus
|
||
} from '@/utils/qc-work-order-card-meta'
|
||
import QcWorkOrderSampleGroup from './QcWorkOrderSampleGroup.vue'
|
||
import QcWorkOrderProtocolPaymentPanel from './QcWorkOrderProtocolPaymentPanel.vue'
|
||
import { sumQcWorkOrderGroupUnfinishedBadgeCount } from '@/utils/qc-work-order-unfinished-badge'
|
||
import QcUnfinishedBadge from './QcUnfinishedBadge.vue'
|
||
import QcWorkOrderSelectCheckbox from './QcWorkOrderSelectCheckbox.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: 'QcWorkOrderProtocolGroup' })
|
||
|
||
const props = withDefaults(
|
||
defineProps<{
|
||
group: QcWorkOrderProtocolGroupModel
|
||
groupIndex: number
|
||
cardMetaConfig: QcWorkOrderCardMetaConfig
|
||
taskRefreshToken: number
|
||
showWorkOrderOps?: boolean
|
||
showWorkOrderViewOnly?: boolean
|
||
taskListMode?: 'workOrder' | 'mine'
|
||
presetTasksByWorkOrderId?: Record<string, QcTask[]>
|
||
presetBatchesByWorkOrderId?: Record<string, QcInspectionBatch[]>
|
||
}>(),
|
||
{
|
||
showWorkOrderOps: true,
|
||
showWorkOrderViewOnly: false,
|
||
taskListMode: 'workOrder'
|
||
}
|
||
)
|
||
|
||
const emit = defineEmits<{
|
||
configure: [row: QcWorkOrder]
|
||
view: [row: QcWorkOrder]
|
||
command: [cmd: string, row: QcWorkOrder]
|
||
'tasks-changed': []
|
||
'sample-special-changed': []
|
||
'sample-voided': []
|
||
}>()
|
||
|
||
const sampleSpecialDialogVisible = ref(false)
|
||
|
||
function sampleTabKey(sampleGroup: QcWorkOrderSampleGroupModel) {
|
||
return sampleGroup.groupKey
|
||
}
|
||
|
||
function sampleGroupTitle(sampleGroup: QcWorkOrderSampleGroupModel) {
|
||
return resolveInboundSampleGroupCardTitle(sampleGroup.workOrders)
|
||
}
|
||
|
||
function singleSampleGroupTitle(sampleGroup?: QcWorkOrderSampleGroupModel) {
|
||
if (!sampleGroup) return '—'
|
||
return sampleGroupTitle(sampleGroup)
|
||
}
|
||
|
||
const activeSampleKey = ref(
|
||
props.group.sampleGroups[0] ? sampleTabKey(props.group.sampleGroups[0]) : ''
|
||
)
|
||
|
||
watch(
|
||
() => props.group.sampleGroups.map((g) => sampleTabKey(g)).join(','),
|
||
() => {
|
||
const keys = props.group.sampleGroups.map((g) => sampleTabKey(g))
|
||
if (!keys.includes(activeSampleKey.value)) {
|
||
activeSampleKey.value = keys[0] || ''
|
||
}
|
||
}
|
||
)
|
||
|
||
const activeSampleGroup = computed(() =>
|
||
props.group.sampleGroups.find((g) => sampleTabKey(g) === activeSampleKey.value)
|
||
)
|
||
|
||
const activeSampleGroupWorkOrderIds = computed(
|
||
() => activeSampleGroup.value?.workOrders.map((wo) => wo.id) || []
|
||
)
|
||
|
||
const activeSampleSpecialMarkTarget = computed(() => {
|
||
const group = activeSampleGroup.value
|
||
if (!group) return null
|
||
return resolveInboundSampleSpecialMarkTarget(group.workOrders)
|
||
})
|
||
|
||
function openSampleSpecialDialog() {
|
||
if (!activeSampleSpecialMarkTarget.value) return
|
||
sampleSpecialDialogVisible.value = true
|
||
}
|
||
|
||
const gateRow = computed(() =>
|
||
resolveGateWorkOrderForSampleGroup(
|
||
props.group.sampleGroups[0]?.workOrders || props.group.workOrders
|
||
)
|
||
)
|
||
|
||
const protocolStatus = computed(() =>
|
||
gateRow.value
|
||
? resolveProtocolGroupStatus(gateRow.value)
|
||
: { label: '', tagType: 'info' as TagType }
|
||
)
|
||
|
||
const sampleCountLabel = computed(() => `${props.group.sampleGroups.length} 个样本`)
|
||
|
||
const progressLabel = computed(() => buildProtocolGroupProgressLabel(props.group))
|
||
|
||
const groupUnfinishedBadgeCount = computed(() =>
|
||
sumQcWorkOrderGroupUnfinishedBadgeCount(props.group.workOrders)
|
||
)
|
||
|
||
const protocolPaymentSummary = computed(() => resolveProtocolGroupPaymentSummary(props.group))
|
||
|
||
const protocolUserInfo = computed(() => {
|
||
const gate = gateRow.value
|
||
return {
|
||
motherName: (gate?.motherName || '').trim(),
|
||
newbornName: (gate?.newbornName || '').trim()
|
||
}
|
||
})
|
||
|
||
function sampleTypeLabel(sampleGroup: QcWorkOrderSampleGroupModel) {
|
||
const gate = resolveGateWorkOrderForSampleGroup(sampleGroup.workOrders)
|
||
return (gate?.sampleTypeName || sampleGroup.workOrders[0]?.sampleTypeName || '').trim()
|
||
}
|
||
|
||
function gateWorkOrder(sampleGroup: QcWorkOrderSampleGroupModel) {
|
||
return resolveGateWorkOrderForSampleGroup(sampleGroup.workOrders)
|
||
}
|
||
|
||
function sampleTabStatusLabel(sampleGroup: QcWorkOrderSampleGroupModel) {
|
||
const gate = gateWorkOrder(sampleGroup)
|
||
return gate ? workOrderStatusLabel(gate.workOrderStatus) : ''
|
||
}
|
||
|
||
function sampleTabStatusTagType(sampleGroup: QcWorkOrderSampleGroupModel): TagType {
|
||
const gate = gateWorkOrder(sampleGroup)
|
||
return gate ? workOrderStatusTagType(gate.workOrderStatus) : 'info'
|
||
}
|
||
|
||
function workOrderStatusTagType(status: string): TagType {
|
||
if (status === 'ywc') return 'success'
|
||
if (status === 'ypz') return 'warning'
|
||
if (status === 'yzf') return 'danger'
|
||
return 'info'
|
||
}
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
.qc-protocol-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);
|
||
}
|
||
|
||
&:has(.qc-work-order-card--completed) {
|
||
border-color: #fcd34d;
|
||
background: #fffbeb;
|
||
|
||
&:hover {
|
||
border-color: #fbbf24;
|
||
box-shadow: 0 4px 12px rgba(217, 119, 6, 0.1);
|
||
}
|
||
|
||
.qc-protocol-row__ctx {
|
||
background: linear-gradient(180deg, #fef3c7 0%, #fffbeb 100%);
|
||
border-bottom-color: #fde68a;
|
||
}
|
||
}
|
||
}
|
||
|
||
.qc-protocol-row__ctx {
|
||
display: grid;
|
||
grid-template-columns: minmax(0, 1fr) auto;
|
||
align-items: center;
|
||
gap: 12px 16px;
|
||
padding: 12px 16px;
|
||
background: linear-gradient(180deg, var(--primary-bg, #ecfdf5) 0%, #fff 100%);
|
||
border-bottom: 1px solid #d1fae5;
|
||
}
|
||
|
||
.qc-protocol-row__ctx--has-sample-tabs {
|
||
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
|
||
}
|
||
|
||
.qc-protocol-row__ctx-left {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: center;
|
||
gap: 8px 12px;
|
||
min-width: 0;
|
||
justify-self: start;
|
||
}
|
||
|
||
.qc-protocol-row__ctx-center {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 12px 24px;
|
||
min-width: 0;
|
||
justify-self: center;
|
||
max-width: 100%;
|
||
}
|
||
|
||
.qc-protocol-row__ctx-right {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: flex-end;
|
||
min-width: 0;
|
||
justify-self: end;
|
||
}
|
||
|
||
@media (max-width: 960px) {
|
||
.qc-protocol-row__ctx,
|
||
.qc-protocol-row__ctx--has-sample-tabs {
|
||
grid-template-columns: 1fr;
|
||
}
|
||
|
||
.qc-protocol-row__ctx-center {
|
||
justify-self: stretch;
|
||
justify-content: flex-start;
|
||
}
|
||
|
||
.qc-protocol-row__ctx-right {
|
||
justify-self: start;
|
||
}
|
||
}
|
||
|
||
.qc-protocol-row__idx {
|
||
flex-shrink: 0;
|
||
font-size: 12px;
|
||
color: var(--mint-text-muted, #64748b);
|
||
min-width: 20px;
|
||
}
|
||
|
||
.qc-protocol-row__sample-code {
|
||
font-size: 14px;
|
||
font-weight: 600;
|
||
color: #1e293b;
|
||
}
|
||
|
||
.qc-protocol-row__user {
|
||
font-size: 13px;
|
||
font-weight: 500;
|
||
color: var(--mint-text, #1e293b);
|
||
line-height: 1.4;
|
||
}
|
||
|
||
.qc-protocol-row__sub {
|
||
font-size: 12px;
|
||
color: var(--mint-text-muted, #64748b);
|
||
line-height: 1.4;
|
||
}
|
||
|
||
.qc-protocol-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-protocol-row__fee {
|
||
border-bottom: 1px solid #e2e8f0;
|
||
}
|
||
|
||
.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__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;
|
||
}
|
||
}
|
||
|
||
&.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 {
|
||
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__status {
|
||
margin-left: 2px;
|
||
}
|
||
|
||
.qc-protocol-row :deep(.qc-sample-row) {
|
||
border: none;
|
||
border-radius: 0;
|
||
box-shadow: none;
|
||
}
|
||
|
||
.qc-protocol-row :deep(.qc-sample-row:hover) {
|
||
border-color: transparent;
|
||
box-shadow: none;
|
||
}
|
||
</style>
|