Files
zkxw/web-admin/src/views/quality-inspection/qc-work-order/QcWorkOrderTaskResultPanel.vue
T
2026-06-16 15:17:32 +08:00

431 lines
13 KiB
Vue
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.
<!-- 质检工单查看弹窗 — 实验室 / 第三方项目卡片面板 -->
<template>
<div class="qc-wo-task-result-panel">
<template v-if="!tasks.length && configuredItems.length">
<div class="qc-wo-configured-list">
<article
v-for="(item, idx) in configuredItems"
:key="`${item.primary}-${idx}`"
class="qc-wo-configured-item"
>
<span class="qc-wo-configured-item__name">{{ item.primary }}</span>
<span v-if="item.secondary" class="qc-wo-configured-item__sub">{{ item.secondary }}</span>
<span v-if="item.meta" class="qc-wo-configured-item__meta">{{ item.meta }}</span>
</article>
</div>
<p class="qc-wo-task-result-panel__hint">已配置检测项目,任务待派发</p>
</template>
<div v-else-if="tasks.length" class="qc-wo-task-cards">
<article v-for="(task, idx) in tasks" :key="task.id || idx" class="qc-wo-task-card">
<header class="qc-wo-task-card__head">
<div class="qc-wo-task-card__title">
<span v-if="tasks.length > 1" class="qc-wo-task-card__index">{{ idx + 1 }}</span>
<span class="qc-wo-task-card__name">{{ task.itemName || '—' }}</span>
<span v-if="task.itemCode" class="qc-wo-task-card__code">{{ task.itemCode }}</span>
</div>
<div class="qc-wo-task-card__tags">
<el-tag :type="taskStatusTagType(task.taskStatus)" size="small">
{{ taskStatusLabel(task.taskStatus || '') }}
</el-tag>
<el-tag
v-if="task.conclusion === 'tg' || task.conclusion === 'btg'"
:type="conclusionTagType(task.conclusion)"
size="small"
>
{{ task.conclusionLabel || qcTaskConclusionLabel(task.conclusion) }}
</el-tag>
<el-tag v-else type="info" size="small">待结论</el-tag>
</div>
</header>
<div class="qc-wo-task-card__body">
<dl class="qc-wo-task-card__meta">
<div class="qc-wo-task-card__meta-item">
<dt>任务号</dt>
<dd>{{ task.taskNo || '—' }}</dd>
</div>
<div v-if="taskType === 'dsfjc'" class="qc-wo-task-card__meta-item">
<dt>第三方公司</dt>
<dd>{{ task.companyName || '—' }}</dd>
</div>
<div v-if="taskType === 'dsfjc' && task.feeAmount != null" class="qc-wo-task-card__meta-item">
<dt>费用(元)</dt>
<dd>¥{{ formatMoneyDisplay(task.feeAmount) }}</dd>
</div>
<div class="qc-wo-task-card__meta-item">
<dt>完成时间</dt>
<dd>{{ task.completedTime || '—' }}</dd>
</div>
</dl>
<div class="qc-wo-task-card__block">
<div class="qc-wo-task-card__block-label">检测参数</div>
<dl v-if="task.results?.length" class="qc-wo-task-card__params">
<div v-for="(param, pi) in task.results" :key="pi" class="qc-wo-task-card__param">
<dt>
{{ param.paramName
}}<span v-if="param.paramUnit" class="qc-wo-task-card__param-unit"
>({{ param.paramUnit }})</span
>
</dt>
<dd>{{ param.paramValue || '—' }}</dd>
</div>
</dl>
<p v-else class="qc-wo-task-result-panel__empty">—</p>
</div>
<div v-if="task.remark" class="qc-wo-task-card__block">
<div class="qc-wo-task-card__block-label">备注</div>
<p class="qc-wo-task-card__remark">{{ task.remark }}</p>
</div>
<div v-if="taskType === 'sysz' && showMaterialUsage" class="qc-wo-task-card__block">
<div class="qc-wo-task-card__block-label">物料使用</div>
<div v-if="task.materialUsages?.length" class="view-subtable-wrap">
<el-table :data="task.materialUsages" stripe class="list-table view-subtable">
<el-table-column
type="index"
label="序号"
min-width="56"
align="center"
header-align="center"
:index="(index) => index + 1"
/>
<el-table-column
prop="stockInNo"
label="入库编号"
min-width="120"
align="center"
header-align="center"
/>
<el-table-column
prop="materialName"
label="物料名称"
min-width="140"
align="center"
header-align="center"
/>
<el-table-column label="批号" min-width="100" align="center" header-align="center">
<template #default="{ row }">{{ row.batchNo || '—' }}</template>
</el-table-column>
<el-table-column label="领用人" min-width="100" align="center" header-align="center">
<template #default="{ row }">{{ row.receiverName || '—' }}</template>
</el-table-column>
<el-table-column label="用量" min-width="100" align="center" header-align="center">
<template #default="{ row }">
{{ row.qty != null && row.qty !== '' ? row.qty : '—' }}
</template>
</el-table-column>
<el-table-column label="单位" min-width="72" align="center" header-align="center">
<template #default="{ row }">{{ row.unit || '—' }}</template>
</el-table-column>
<el-table-column label="备注" min-width="140" align="center" header-align="center">
<template #default="{ row }">{{ row.remark || '—' }}</template>
</el-table-column>
</el-table>
</div>
<p v-else class="qc-wo-task-result-panel__empty">暂无物料使用记录</p>
</div>
<div class="qc-wo-task-card__block">
<div class="qc-wo-task-card__block-label">{{ attachmentLabel }}</div>
<ProtocolAttachmentReadonly
v-if="task.attachmentFiles?.length"
:files="task.attachmentFiles"
@preview="onAttachmentPreview"
@download="onAttachmentDownload"
/>
<p v-else class="qc-wo-task-result-panel__empty">—</p>
</div>
</div>
</article>
</div>
<p v-else class="qc-wo-task-result-panel__empty">—</p>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { formatMoneyDisplay } from '@/utils/money-format'
import type { QcWorkOrderDetail } from '@/api/qc-work-order'
import { taskStatusLabel, qcTaskConclusionLabel } from '@/utils/qc-labels'
import { SHOW_QC_TASK_MATERIAL_USAGE } from '@/utils/qc-material-ui'
import ProtocolAttachmentReadonly from '@/views/cell-storage/protocol/ProtocolAttachmentReadonly.vue'
import type { QcWorkOrderTaskView } from './composables/useQcWorkOrderTaskViewSections'
import { qcPreviewAttachment, qcDownloadAttachment } from './composables/useQcViewAttachmentHelpers'
defineOptions({ name: 'QcWorkOrderTaskResultPanel' })
type ConfiguredItem = {
primary: string
secondary?: string
meta?: string
}
const props = defineProps<{
taskType: 'sysz' | 'dsfjc'
tasks: QcWorkOrderTaskView[]
labItems?: QcWorkOrderDetail['labItems']
thirdPartyItems?: QcWorkOrderDetail['thirdPartyItems']
}>()
const showMaterialUsage = SHOW_QC_TASK_MATERIAL_USAGE
const attachmentLabel = computed(() => (props.taskType === 'dsfjc' ? '检测材料' : '检测附件'))
const configuredItems = computed<ConfiguredItem[]>(() => {
if (props.taskType === 'sysz') {
return (props.labItems || []).map((li) => ({
primary: li.itemName || '—',
secondary: li.itemCode ? `编码 ${li.itemCode}` : undefined
}))
}
return (props.thirdPartyItems || []).map((li) => ({
primary: li.itemName || '—',
secondary: [li.companyName, li.itemCode ? `编码 ${li.itemCode}` : '']
.filter(Boolean)
.join(' · '),
meta: li.feeAmount != null ? `¥${formatMoneyDisplay(li.feeAmount)}` : undefined
}))
})
function conclusionTagType(conclusion?: string) {
if (conclusion === 'tg') return 'success' as const
if (conclusion === 'btg') return 'danger' as const
return 'info' as const
}
function taskStatusTagType(status?: string) {
if (status === 'ywc') return 'success' as const
if (status === 'jxz') return 'warning' as const
return 'info' as const
}
const onAttachmentPreview = qcPreviewAttachment
const onAttachmentDownload = qcDownloadAttachment
</script>
<style scoped lang="scss">
.qc-wo-task-result-panel {
width: 100%;
}
.qc-wo-task-result-panel__hint,
.qc-wo-task-result-panel__empty {
margin: 0;
font-size: 13px;
color: var(--mint-text-muted, #334155);
line-height: 1.5;
}
.qc-wo-task-result-panel__hint {
margin-top: 10px;
padding-left: 2px;
font-size: 12px;
}
.qc-wo-configured-list {
display: flex;
flex-direction: column;
gap: 8px;
}
.qc-wo-configured-item {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px 12px;
padding: 10px 12px;
border: 1px solid #e2e8f0;
border-radius: 8px;
background: #f8fafc;
}
.qc-wo-configured-item__name {
font-size: 13px;
font-weight: 600;
color: #1e293b;
}
.qc-wo-configured-item__sub {
font-size: 12px;
color: var(--mint-text-muted, #334155);
}
.qc-wo-configured-item__meta {
margin-left: auto;
font-size: 12px;
font-weight: 600;
color: #047857;
}
.qc-wo-task-cards {
display: flex;
flex-direction: column;
gap: 12px;
}
.qc-wo-task-card {
border: 1px solid #e2e8f0;
border-radius: 10px;
background: #fff;
overflow: hidden;
}
.qc-wo-task-card__head {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
justify-content: space-between;
gap: 8px 12px;
padding: 12px 14px;
background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
border-bottom: 1px solid #e2e8f0;
}
.qc-wo-task-card__title {
display: flex;
flex-wrap: wrap;
align-items: baseline;
gap: 6px 10px;
min-width: 0;
flex: 1;
}
.qc-wo-task-card__index {
flex-shrink: 0;
font-size: 11px;
font-weight: 600;
color: #047857;
background: #ecfdf5;
border: 1px solid #a7f3d0;
border-radius: 4px;
padding: 1px 6px;
line-height: 1.4;
}
.qc-wo-task-card__name {
font-size: 14px;
font-weight: 600;
color: #1e293b;
word-break: break-word;
}
.qc-wo-task-card__code {
font-size: 12px;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
color: var(--mint-text-muted, #334155);
}
.qc-wo-task-card__tags {
display: flex;
flex-wrap: wrap;
gap: 6px;
flex-shrink: 0;
}
.qc-wo-task-card__body {
padding: 12px 14px 14px;
display: flex;
flex-direction: column;
gap: 12px;
}
.qc-wo-task-card__meta {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
gap: 10px 16px;
margin: 0;
}
.qc-wo-task-card__meta-item {
display: flex;
flex-direction: column;
gap: 2px;
min-width: 0;
dt {
margin: 0;
font-size: 11px;
line-height: 1.35;
color: var(--mint-text-muted, #334155);
}
dd {
margin: 0;
font-size: 13px;
line-height: 1.4;
color: #1e293b;
word-break: break-word;
}
}
.qc-wo-task-card__block {
padding-top: 10px;
border-top: 1px dashed #e2e8f0;
}
.qc-wo-task-card__block-label {
margin-bottom: 8px;
font-size: 12px;
font-weight: 600;
color: #334155;
line-height: 1.4;
}
.qc-wo-task-card__params {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
gap: 8px 12px;
margin: 0;
padding: 10px 12px;
border: 1px solid #e2e8f0;
border-radius: 8px;
background: #f8fafc;
}
.qc-wo-task-card__param {
display: flex;
flex-direction: column;
gap: 2px;
min-width: 0;
dt {
margin: 0;
font-size: 11px;
line-height: 1.35;
color: var(--mint-text-muted, #334155);
}
dd {
margin: 0;
font-size: 13px;
font-weight: 500;
line-height: 1.4;
color: #1e293b;
word-break: break-word;
}
}
.qc-wo-task-card__param-unit {
font-weight: 400;
color: var(--mint-text-muted, #334155);
}
.qc-wo-task-card__remark {
margin: 0;
font-size: 13px;
line-height: 1.5;
color: #1e293b;
word-break: break-word;
}
.view-subtable-wrap {
border: 1px solid #e2e8f0;
border-radius: 8px;
overflow: hidden;
}
</style>