From ceeeb4f3315fbd4e4ca3e91efffcee0a54bc22ee Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期三, 23 九月 2026 17:42:19 +0800
Subject: [PATCH] 资料类型字段显示问题
---
src/views/mes/pd/archive/modules/detail.vue | 97 ++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 80 insertions(+), 17 deletions(-)
diff --git a/src/views/mes/pd/archive/modules/detail.vue b/src/views/mes/pd/archive/modules/detail.vue
index adb24db..f767001 100644
--- a/src/views/mes/pd/archive/modules/detail.vue
+++ b/src/views/mes/pd/archive/modules/detail.vue
@@ -1,28 +1,79 @@
<script lang="ts" setup>
import type { MesPdArchiveApi } from '#/api/mes/pd/archive';
-import { ref } from 'vue';
+import { ref, watch } from 'vue';
-import { Modal, Descriptions, Table, Tabs, message } from 'ant-design-vue';
+import { Modal, Descriptions, Table, Tabs, Spin, message } from 'ant-design-vue';
import { getPdArchiveDetailByProduct } from '#/api/mes/pd/archive';
+import { FilePreviewModal, useFilePreview } from '#/components/file-preview';
+import { DICT_TYPE } from '#/packages/constants/src';
+import { getDictOptions } from '#/packages/effects/hooks/src';
+
+import { getPdDocumentTypeOptions } from '../../project/data';
+
+interface Props {
+ visible: boolean;
+ productCode?: string;
+}
+
+const props = withDefaults(defineProps<Props>(), {
+ productCode: '',
+});
+
+interface Emits {
+ (e: 'update:visible', value: boolean): void;
+}
+
+const emit = defineEmits<Emits>();
const open = ref(false);
const loading = ref(false);
const detailList = ref<MesPdArchiveApi.DetailItem[]>([]);
const activeProject = ref('0');
+const { openPreview, previewState } = useFilePreview();
+
+/** 璧勬枡绫诲瀷涓枃鍚嶏細澶嶇敤椤圭洰璧勬枡鍒楄〃鐨勫悓涓�浠芥槧灏勶紙getPdDocumentTypeOptions锛夛紝閬垮厤涓ゅ缁存姢 */
+function documentTypeText(value?: string) {
+ if (!value) return '-';
+ return (
+ getPdDocumentTypeOptions().find((item) => item.value === value)?.label ??
+ String(value)
+ );
+}
+
+/** 褰掓。鐘舵�佷腑鏂囧悕锛氬瓧鍏� mes_pd_archive_status */
+function archiveStatusText(value?: number) {
+ if (value === undefined || value === null || value === '') return '-';
+ return (
+ getDictOptions(DICT_TYPE.MES_PD_ARCHIVE_STATUS, 'number').find(
+ (item) => Number(item.value) === Number(value),
+ )?.label ?? String(value)
+ );
+}
+
const archiveColumns = [
{ title: '褰掓。缂栧彿', dataIndex: 'archiveCode', key: 'archiveCode' },
{ title: '褰掓。浜�', dataIndex: 'archiverNickname', key: 'archiverNickname' },
- { title: '褰掓。鐘舵��', dataIndex: 'archiveStatus', key: 'archiveStatus' },
+ {
+ title: '褰掓。鐘舵��',
+ dataIndex: 'archiveStatus',
+ key: 'archiveStatus',
+ customRender: ({ text }: { text: number }) => archiveStatusText(text),
+ },
{ title: '褰掓。鏃堕棿', dataIndex: 'archiveTime', key: 'archiveTime' },
{ title: '澶囨敞', dataIndex: 'remark', key: 'remark', ellipsis: true },
];
const documentColumns = [
{ title: '璧勬枡鍚嶇О', dataIndex: 'documentName', key: 'documentName' },
- { title: '璧勬枡绫诲瀷', dataIndex: 'documentType', key: 'documentType' },
+ {
+ title: '璧勬枡绫诲瀷',
+ dataIndex: 'documentType',
+ key: 'documentType',
+ customRender: ({ text }: { text: string }) => documentTypeText(text),
+ },
{ title: '鐗堟湰', dataIndex: 'documentVersion', key: 'documentVersion', width: 80 },
{ title: '鏂囦欢鍚�', dataIndex: 'fileName', key: 'fileName' },
{ title: '涓婁紶浜�', dataIndex: 'uploadUserNickname', key: 'uploadUserNickname' },
@@ -30,21 +81,26 @@
{
title: '鎿嶄綔',
key: 'action',
- width: 80,
+ width: 120,
},
];
-async function handleOpen(productCode?: string) {
- if (!productCode) {
- message.warning('浜у搧缂栫爜涓虹┖锛屾棤娉曟煡鐪嬪綊妗�');
- return;
+watch(() => props.visible, async (newVal) => {
+ if (newVal && props.productCode) {
+ loadData(props.productCode);
+ } else if (!newVal) {
+ open.value = false;
+ detailList.value = [];
}
+});
+
+async function loadData(code: string) {
open.value = true;
+ loading.value = true;
detailList.value = [];
activeProject.value = '0';
- loading.value = true;
try {
- detailList.value = await getPdArchiveDetailByProduct(productCode);
+ detailList.value = await getPdArchiveDetailByProduct(code);
} catch {
message.error('鑾峰彇褰掓。璇︽儏澶辫触');
} finally {
@@ -52,18 +108,22 @@
}
}
-function handleClose() {
- open.value = false;
- detailList.value = [];
+function openModal(code: string) {
+ loadData(code);
}
-defineExpose({ open: handleOpen });
+defineExpose({ open: openModal });
+
+function handleClose() {
+ emit('update:visible', false);
+}
</script>
<template>
+ <FilePreviewModal v-bind="previewState" />
<Modal v-model:open="open" title="褰掓。璇︽儏" width="80%" :footer="null" @cancel="handleClose">
<div v-if="loading" class="flex justify-center py-8">
- <a-spin />
+ <Spin />
</div>
<template v-else>
<Tabs v-if="detailList.length > 0" v-model:active-key="activeProject" type="card">
@@ -110,7 +170,10 @@
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
- <a v-if="record.fileUrl" :href="record.fileUrl" target="_blank" class="text-primary">涓嬭浇</a>
+ <template v-if="record.fileUrl">
+ <a class="mr-2" @click="openPreview(record.fileUrl, record.fileName)">棰勮</a>
+ <a :href="record.fileUrl" target="_blank">涓嬭浇</a>
+ </template>
<span v-else class="text-gray-400">-</span>
</template>
</template>
--
Gitblit v1.9.3