2026-11-06 10:50:49 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<Dialog v-model="visible" title="查看成果" width="900px">
|
|
|
|
|
|
<div class="result-heading">
|
|
|
|
|
|
<div
|
|
|
|
|
|
><strong>{{ task?.task_name }}</strong
|
|
|
|
|
|
><p>{{ task?.task_no }}</p></div
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-button :loading="loading" @click="refresh">刷新成果</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-select-v2
|
|
|
|
|
|
v-if="units.length"
|
|
|
|
|
|
v-model="unitId"
|
|
|
|
|
|
:options="unitOptions"
|
|
|
|
|
|
:disabled="loading"
|
|
|
|
|
|
filterable
|
|
|
|
|
|
placeholder="选择样件"
|
|
|
|
|
|
class="unit-select"
|
|
|
|
|
|
aria-label="选择成果样件"
|
|
|
|
|
|
@change="loadUnit"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div v-loading="loading" class="result-body">
|
|
|
|
|
|
<el-alert v-if="error" :title="error" type="error" :closable="false" />
|
|
|
|
|
|
<el-table v-else :data="data?.deliveries || []" empty-text="本样件尚无比对成果">
|
|
|
|
|
|
<el-table-column label="成果版本" min-width="165">
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<strong>{{ row.external_no }}</strong>
|
|
|
|
|
|
<div class="secondary">{{ row.current ? '对应当前扫描与资料' : '历史版本' }}</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="交付状态" width="100">
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<el-tag :type="row.status === 'DELIVERED' ? 'success' : 'warning'">
|
|
|
|
|
|
{{ row.status === 'DELIVERED' ? '已确认交付' : '待确认' }}
|
|
|
|
|
|
</el-tag>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2026-11-13 15:12:31 +08:00
|
|
|
|
<el-table-column label="归档与交付时间" min-width="230">
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<div>归档:{{ formatNullableDate(row.create_time) }}</div>
|
|
|
|
|
|
<div class="secondary">交付:{{ formatNullableDate(row.confirmed_at) }}</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2026-11-06 10:50:49 +08:00
|
|
|
|
<el-table-column label="下载" min-width="270">
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
link
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
v-hasPermi="['lab:data:download']"
|
|
|
|
|
|
:disabled="loading || downloading"
|
|
|
|
|
|
@click="downloadFile(row.stl_id)"
|
|
|
|
|
|
>下载STL</el-button
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
link
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
v-hasPermi="['lab:data:download']"
|
|
|
|
|
|
:disabled="loading || downloading"
|
|
|
|
|
|
@click="downloadFile(row.pdf_id)"
|
|
|
|
|
|
>下载PDF</el-button
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
v-if="row.status === 'DELIVERED'"
|
|
|
|
|
|
link
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
v-hasPermi="['lab:data:download']"
|
|
|
|
|
|
:disabled="loading || downloading"
|
|
|
|
|
|
@click="downloadPackage(row)"
|
|
|
|
|
|
>打包下载</el-button
|
|
|
|
|
|
>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<p class="secondary">历史版本保留原文件;交付状态和当前版本分别显示。</p>
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<el-button @click="visible = false">关闭</el-button>
|
|
|
|
|
|
<el-button type="primary" plain @click="trace">任务追溯</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</Dialog>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
2026-11-13 15:12:31 +08:00
|
|
|
|
import { formatNullableDate } from '@/utils/formatTime'
|
2026-11-06 10:50:49 +08:00
|
|
|
|
import * as Api from '@/api/lab/dimension'
|
|
|
|
|
|
const router = useRouter(),
|
|
|
|
|
|
message = useMessage()
|
|
|
|
|
|
const reader = inject('dimensionResultReader', Api.detail)
|
|
|
|
|
|
const downloader = inject('dimensionResultDownloader', Api.download)
|
|
|
|
|
|
const visible = ref(false),
|
|
|
|
|
|
loading = ref(false),
|
|
|
|
|
|
downloading = ref(false),
|
|
|
|
|
|
error = ref('')
|
|
|
|
|
|
const task = ref<any>(),
|
|
|
|
|
|
units = ref<any[]>([]),
|
|
|
|
|
|
unitId = ref(''),
|
|
|
|
|
|
data = ref<any>()
|
|
|
|
|
|
const unitOptions = computed(() =>
|
|
|
|
|
|
units.value.map((u) => ({ value: String(u.id), label: u.unit_no }))
|
|
|
|
|
|
)
|
|
|
|
|
|
let generation = 0
|
|
|
|
|
|
function invalidate() {
|
|
|
|
|
|
generation++
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
data.value = undefined
|
|
|
|
|
|
}
|
|
|
|
|
|
async function loadUnit() {
|
|
|
|
|
|
const current = ++generation
|
|
|
|
|
|
data.value = undefined
|
|
|
|
|
|
error.value = ''
|
|
|
|
|
|
loading.value = true
|
|
|
|
|
|
try {
|
|
|
|
|
|
const result = await reader(task.value.id, unitId.value || 0)
|
|
|
|
|
|
if (current !== generation || !visible.value) return
|
|
|
|
|
|
units.value = result.units || []
|
|
|
|
|
|
if (!unitId.value && units.value.length) {
|
|
|
|
|
|
unitId.value = String(units.value[0].id)
|
|
|
|
|
|
await loadUnit()
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
data.value = result
|
|
|
|
|
|
} catch (e: any) {
|
|
|
|
|
|
if (current === generation && visible.value)
|
|
|
|
|
|
error.value = e.message || '成果读取失败,请刷新重试'
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
if (current === generation) loading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
function open(row: any) {
|
|
|
|
|
|
generation++
|
|
|
|
|
|
task.value = row
|
|
|
|
|
|
units.value = []
|
|
|
|
|
|
unitId.value = ''
|
|
|
|
|
|
data.value = undefined
|
|
|
|
|
|
visible.value = true
|
|
|
|
|
|
loadUnit()
|
|
|
|
|
|
}
|
|
|
|
|
|
const refresh = () => {
|
|
|
|
|
|
if (!loading.value) loadUnit()
|
|
|
|
|
|
}
|
|
|
|
|
|
async function downloadFile(id: any) {
|
|
|
|
|
|
if (downloading.value || loading.value) return
|
|
|
|
|
|
const file = data.value?.files?.find((f) => String(f.id) === String(id))
|
|
|
|
|
|
if (!file) return message.error('成果文件信息缺失,请刷新后重试')
|
|
|
|
|
|
await download(id, file.file_name)
|
|
|
|
|
|
}
|
|
|
|
|
|
async function downloadPackage(row: any) {
|
|
|
|
|
|
if (downloading.value || loading.value || row.status !== 'DELIVERED') return
|
|
|
|
|
|
await download(row.id, `${task.value.task_no}-${unitId.value}-${row.external_no}.zip`, true)
|
|
|
|
|
|
}
|
|
|
|
|
|
async function download(id: any, name: string, pack = false) {
|
|
|
|
|
|
downloading.value = true
|
|
|
|
|
|
try {
|
|
|
|
|
|
await downloader(id, name, pack)
|
|
|
|
|
|
} catch (e: any) {
|
|
|
|
|
|
message.error(e.message || '下载失败,请重试')
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
downloading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
function trace() {
|
|
|
|
|
|
visible.value = false
|
|
|
|
|
|
router.push('/lab/dimension/workbench/' + task.value.id)
|
|
|
|
|
|
}
|
|
|
|
|
|
watch(visible, (value) => {
|
|
|
|
|
|
if (!value) invalidate()
|
|
|
|
|
|
})
|
|
|
|
|
|
onBeforeUnmount(invalidate)
|
|
|
|
|
|
defineExpose({ open })
|
|
|
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.result-heading {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
gap: 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.result-heading p,
|
|
|
|
|
|
.secondary {
|
|
|
|
|
|
color: var(--el-text-color-secondary);
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
line-height: 1.7;
|
|
|
|
|
|
}
|
|
|
|
|
|
.unit-select {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
margin: 12px 0 18px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.result-body {
|
|
|
|
|
|
min-height: 120px;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|