feat(web-admin): 质检工单与任务附件互相只读可见 (#182)

工单附件弹窗汇总本工单任务附件只读;任务/三方公司结果弹窗展示工单附件只读;任务之间仍互不可见。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-12-02 18:28:35 +08:00
1 parent 31c78855ce
commit 6258cccca2
3 files changed
+247 -2

No files matched your search

@@ -121,6 +121,20 @@
:attachment-required="false"
upload-folder="qc-third-party"
/>
<div class="work-order-attachments-ro">
<div class="work-order-attachments-ro__title">
<span>工单附件</span>
<el-tag size="small" type="info">只读</el-tag>
</div>
<ProtocolAttachmentReadonly
v-if="workOrderAttachmentFiles.length"
:files="workOrderAttachmentFiles"
size="compact"
@preview="onAttachmentPreview"
@download="onAttachmentDownload"
/>
<span v-else class="shared-section__empty">暂无工单附件</span>
</div>
</div>
</el-form>
</DialogFormBody>
@@ -186,9 +200,12 @@
tasks: QcTask[]
readonly?: boolean
operateScope: QcTaskOperateScope
/** 工单级附件 URL 串(只读展示,不可在此修改) */
workOrderAttachments?: string
}>(),
{
readonly: false
readonly: false,
workOrderAttachments: ''
}
)
@@ -224,6 +241,10 @@
}))
)
const workOrderAttachmentFiles = computed(() =>
qcAttachmentFilesFromCommaUrls(props.workOrderAttachments || '')
)
function onVisibleChange(v: boolean) {
emit('update:visible', v)
}
@@ -529,6 +550,22 @@
}
}
.work-order-attachments-ro {
margin-top: 14px;
padding-top: 12px;
border-top: 1px solid var(--mint-border, #e2e8f0);
&__title {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 10px;
font-size: 13px;
font-weight: 700;
color: #1e293b;
}
}
.result-conclusion-row {
:deep(.el-form-item) {
margin-bottom: 0;
@@ -1,4 +1,4 @@
<!-- 质检工单 · 工单级附件上传弹窗 -->
<!-- 质检工单 · 工单级附件上传弹窗(只读汇总任务附件) -->
<!-- eslint-disable vue/no-v-model-argument -->
<template>
<el-dialog
@@ -35,6 +35,37 @@
/>
</el-form>
<section class="task-attachment-summary">
<div class="task-attachment-summary__title">
<span>任务附件汇总</span>
<el-tag size="small" type="info">只读</el-tag>
</div>
<div v-loading="taskLoading" class="task-attachment-summary__body">
<p v-if="!taskLoading && !taskAttachmentGroups.length" class="task-attachment-summary__empty">
暂无任务附件
</p>
<div
v-for="group in taskAttachmentGroups"
:key="group.taskId"
class="task-attachment-group"
>
<div class="task-attachment-group__head">
<span class="task-attachment-group__name">{{ group.itemName }}</span>
<el-tag size="small" :type="group.taskType === 'dsfjc' ? 'primary' : 'success'">
{{ group.taskTypeLabel }}
</el-tag>
</div>
<p class="task-attachment-group__meta">{{ group.attachmentKindLabel }}</p>
<ProtocolAttachmentReadonly
:files="group.files"
size="compact"
@preview="handlePreview"
@download="handleDownload"
/>
</div>
</div>
</section>
<template #footer>
<el-button class="btn-ghost" @click="emit('update:modelValue', false)">
<el-icon><Close /></el-icon>
@@ -52,14 +83,32 @@
import { ElMessage } from 'element-plus'
import { Check, Close } from '@element-plus/icons-vue'
import ProtocolFinanceConfirmFields from '@/components/business/protocol-finance-confirm-fields/index.vue'
import ProtocolAttachmentReadonly from '@/views/cell-storage/protocol/ProtocolAttachmentReadonly.vue'
import {
financeAttachmentsToUrlString,
type FinanceAttachmentItem
} from '@/components/business/protocol-finance-confirm-fields/finance-attachments'
import { fetchUpdateQcWorkOrder, type QcWorkOrder } from '@/api/qc-work-order'
import { fetchQcTaskList, type QcTask } from '@/api/qc-task'
import { taskTypeLabel } from '@/utils/qc-labels'
import {
qcAttachmentFilesFromCommaUrls,
qcAttachmentFullUrl,
qcPreviewAttachment
} from './composables/useQcViewAttachmentHelpers'
import { downloadAttachmentFile } from '@/utils/download-attachment'
defineOptions({ name: 'QcWorkOrderAttachmentDialog' })
type TaskAttachmentGroup = {
taskId: string
itemName: string
taskType: string
taskTypeLabel: string
attachmentKindLabel: string
files: Array<Record<string, unknown>>
}
const props = defineProps<{
modelValue: boolean
workOrder: QcWorkOrder | null
@@ -71,7 +120,10 @@
}>()
const submitting = ref(false)
const taskLoading = ref(false)
const attachmentFiles = ref<FinanceAttachmentItem[]>([])
const taskAttachmentGroups = ref<TaskAttachmentGroup[]>([])
let loadSeq = 0
function urlsToFinanceItems(urls: string) {
return (urls || '')
@@ -86,20 +138,79 @@
}))
}
function taskFiles(task: QcTask) {
if (Array.isArray(task.attachmentFiles) && task.attachmentFiles.length) {
return task.attachmentFiles.map((f, i) => ({
id: f.id || `task_att_${task.id}_${i}`,
fileUrl: f.fileUrl,
fileName: f.fileName || '',
fileType: f.fileType || ''
}))
}
return qcAttachmentFilesFromCommaUrls(task.thirdPartyAttachments || '')
}
async function loadTaskAttachmentGroups(workOrderId: string) {
const seq = ++loadSeq
taskLoading.value = true
try {
const res = await fetchQcTaskList({
workOrderId,
page: 1,
pageSize: 200
})
if (seq !== loadSeq) return
const groups: TaskAttachmentGroup[] = []
for (const task of res.list || []) {
const files = taskFiles(task)
if (!files.length) continue
const type = String(task.taskType || '')
groups.push({
taskId: task.id,
itemName: task.itemName || task.taskNo || '未命名任务',
taskType: type,
taskTypeLabel: taskTypeLabel(type),
attachmentKindLabel: type === 'dsfjc' ? '检测材料' : '检测附件',
files
})
}
taskAttachmentGroups.value = groups
} catch {
if (seq === loadSeq) taskAttachmentGroups.value = []
} finally {
if (seq === loadSeq) taskLoading.value = false
}
}
watch(
() => [props.modelValue, props.workOrder] as const,
([visible, workOrder]) => {
if (!visible || !workOrder) {
attachmentFiles.value = []
taskAttachmentGroups.value = []
return
}
attachmentFiles.value = urlsToFinanceItems(workOrder.attachments || '')
if (workOrder.id) {
void loadTaskAttachmentGroups(workOrder.id)
} else {
taskAttachmentGroups.value = []
}
},
{ immediate: true }
)
function resetForm() {
attachmentFiles.value = []
taskAttachmentGroups.value = []
}
function handlePreview(file: Record<string, unknown>) {
qcPreviewAttachment(file)
}
function handleDownload(file: Record<string, unknown>) {
downloadAttachmentFile(file, { fullFileUrl: qcAttachmentFullUrl })
}
async function handleSubmit() {
@@ -154,4 +265,59 @@
color: #1e293b;
word-break: break-all;
}
.task-attachment-summary {
margin-top: 8px;
padding-top: 12px;
border-top: 1px solid var(--mint-border, #e2e8f0);
}
.task-attachment-summary__title {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 12px;
font-size: 14px;
font-weight: 700;
color: #1e293b;
}
.task-attachment-summary__body {
min-height: 48px;
}
.task-attachment-summary__empty {
margin: 0;
font-size: 13px;
color: var(--mint-text-muted, #64748b);
}
.task-attachment-group {
margin-bottom: 12px;
padding: 12px;
border: 1px solid var(--mint-border, #e2e8f0);
border-radius: 10px;
background: #fcfffe;
}
.task-attachment-group__head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-bottom: 4px;
}
.task-attachment-group__name {
min-width: 0;
font-size: 13px;
font-weight: 650;
color: #1e293b;
}
.task-attachment-group__meta {
margin: 0 0 10px;
font-size: 12px;
color: var(--mint-text-muted, #64748b);
}
</style>
@@ -411,6 +411,20 @@
:attachment-required="resultAttachmentRequired"
:upload-folder="resultUploadFolder"
/>
<div class="result-work-order-attachments">
<div class="result-work-order-attachments__title">
<span>工单附件</span>
<el-tag size="small" type="info">只读</el-tag>
</div>
<ProtocolAttachmentReadonly
v-if="workOrderAttachmentFiles.length"
:files="workOrderAttachmentFiles"
size="compact"
@preview="handleViewAttachmentPreview"
@download="handleViewAttachmentDownload"
/>
<p v-else class="result-work-order-attachments__empty">暂无工单附件</p>
</div>
</div>
</div>
</el-form>
@@ -431,6 +445,7 @@
:tasks="companyDialogTasks"
:readonly="companyDialogReadonly"
:operate-scope="operateScope"
:work-order-attachments="String(props.workOrder?.attachments || '')"
@saved="handleTaskMutationSuccess"
/>
@@ -700,6 +715,7 @@
import { downloadAttachmentFile } from '@/utils/download-attachment'
import { resolveCellProductSpecDisplay } from '@/utils/cell-product-spec'
import { qcAttachmentFilesFromCommaUrls } from './composables/useQcViewAttachmentHelpers'
defineOptions({ name: 'QcWorkOrderTaskSubList' })
@@ -959,6 +975,10 @@
/** 检测材料/附件改为选填;工单级附件在卡片右上角维护 */
const resultAttachmentRequired = computed(() => false)
const workOrderAttachmentFiles = computed(() =>
qcAttachmentFilesFromCommaUrls(String(props.workOrder?.attachments || ''))
)
const resultUploadFolder = computed(() =>
resultTaskType.value === 'dsfjc' ? 'qc-third-party' : 'qc-lab'
)
@@ -2014,6 +2034,28 @@
margin-bottom: 0;
}
}
.result-work-order-attachments {
margin-top: 14px;
padding-top: 12px;
border-top: 1px solid var(--mint-border, #e2e8f0);
}
.result-work-order-attachments__title {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 10px;
font-size: 13px;
font-weight: 700;
color: #1e293b;
}
.result-work-order-attachments__empty {
margin: 0;
font-size: 13px;
color: var(--mint-text-muted, #64748b);
}
}
.biz-dialog-form {