From cd8b52bdf89a4d1101f72e0ece9f4df22a3d3f7a Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 15 十月 2026 16:03:32 +0800
Subject: [PATCH] feat(mdm): 物料列表隐藏辅单位与销售价列

---
 src/views/mes/pd/archive/modules/detail.vue |  242 ++++++++++++++++++++++++++++++++----------------
 1 files changed, 160 insertions(+), 82 deletions(-)

diff --git a/src/views/mes/pd/archive/modules/detail.vue b/src/views/mes/pd/archive/modules/detail.vue
index 9eeee80..365fad1 100644
--- a/src/views/mes/pd/archive/modules/detail.vue
+++ b/src/views/mes/pd/archive/modules/detail.vue
@@ -1,30 +1,88 @@
 <script lang="ts" setup>
 import type { MesPdArchiveApi } from '#/api/mes/pd/archive';
 
-import { ref } from 'vue';
+import { ref, watch } from 'vue';
 
-import { useVbenModal } from '#/packages/effects/common-ui/src';
-import { DICT_TYPE } from '#/packages/constants/src';
-
-import { Descriptions, Table, Tabs } 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)
+  );
+}
+
+/**
+ * 璧勬枡鏂囦欢鍦板潃锛氬悗绔彧鍥� attachmentList锛堥檮浠朵腑闂磋〃锛夛紝涓氬姟琛ㄦ病鏈� fileUrl 瀛楁锛�
+ * 杩欓噷鍙栫涓�涓檮浠剁殑璁块棶鍦板潃锛屾病鏈夐檮浠跺氨杩斿洖绌轰覆锛堟ā鏉块噷鏄剧ず銆�-銆嶏級銆�
+ */
+function documentFileUrl(record: MesPdArchiveApi.DocumentInfo) {
+  const blob = record.attachmentList?.[0];
+  return blob?.url || blob?.downloadURL || '';
+}
+
+/** 褰掓。鐘舵�佷腑鏂囧悕锛氬瓧鍏� 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' },
@@ -32,89 +90,109 @@
   {
     title: '鎿嶄綔',
     key: 'action',
-    width: 80,
+    width: 120,
   },
 ];
 
-const [Modal, modalApi] = useVbenModal({
-  async onOpenChange(isOpen: boolean) {
-    if (!isOpen) {
-      detailList.value = [];
-      activeProject.value = '0';
-      return;
-    }
-    const data = modalApi.getData<{ productCode: number }>();
-    loading.value = true;
-    try {
-      detailList.value = await getPdArchiveDetailByProduct(data.productCode);
-      activeProject.value = '0';
-    } finally {
-      loading.value = false;
-    }
-  },
+watch(() => props.visible, async (newVal) => {
+  if (newVal && props.productCode) {
+    loadData(props.productCode);
+  } else if (!newVal) {
+    open.value = false;
+    detailList.value = [];
+  }
 });
 
-defineExpose({
-  open: (productCode: number) => modalApi.setData({ productCode }).open(),
-});
+async function loadData(code: string) {
+  open.value = true;
+  loading.value = true;
+  detailList.value = [];
+  activeProject.value = '0';
+  try {
+    detailList.value = await getPdArchiveDetailByProduct(code);
+  } catch {
+    message.error('鑾峰彇褰掓。璇︽儏澶辫触');
+  } finally {
+    loading.value = false;
+  }
+}
+
+function openModal(code: string) {
+  loadData(code);
+}
+
+defineExpose({ open: openModal });
+
+function handleClose() {
+  emit('update:visible', false);
+}
 </script>
 
 <template>
-  <Modal class="w-4/5" title="褰掓。璇︽儏" :loading="loading">
-    <Tabs v-if="detailList.length > 0" v-model:active-key="activeProject" type="card">
-      <Tabs.TabPane
-        v-for="(detail, index) in detailList"
-        :key="String(index)"
-        :tab="detail.project.taskName || '椤圭洰'"
-      >
-        <!-- 椤圭洰淇℃伅 -->
-        <Descriptions :column="3" bordered size="small" class="mb-4">
-          <Descriptions.Item label="浠诲姟缂栫爜">{{ detail.project.taskCode }}</Descriptions.Item>
-          <Descriptions.Item label="浠诲姟鍚嶇О">{{ detail.project.taskName }}</Descriptions.Item>
-          <Descriptions.Item label="浜у搧缂栫爜">{{ detail.project.productCode }}</Descriptions.Item>
-          <Descriptions.Item label="浜у搧鍚嶇О">{{ detail.project.productName }}</Descriptions.Item>
-          <Descriptions.Item label="鐗堟湰鍙�">{{ detail.project.version }}</Descriptions.Item>
-          <Descriptions.Item label="涓昏璁″笀">{{ detail.project.chiefDesignerNickname }}</Descriptions.Item>
-          <Descriptions.Item label="瀹℃牳浜�">{{ detail.project.reviewerNickname }}</Descriptions.Item>
-          <Descriptions.Item label="璁″垝瀹屾垚">{{ detail.project.planFinishTime }}</Descriptions.Item>
-        </Descriptions>
-
-        <!-- 褰掓。璁板綍 -->
-        <div class="mb-4">
-          <h4 class="mb-2 text-sm font-medium">褰掓。璁板綍</h4>
-          <Table
-            :columns="archiveColumns"
-            :data-source="detail.archives"
-            :pagination="false"
-            bordered
-            row-key="id"
-            size="small"
-          />
-        </div>
-
-        <!-- 璁捐璧勬枡 -->
-        <div>
-          <h4 class="mb-2 text-sm font-medium">璁捐璧勬枡</h4>
-          <Table
-            :columns="documentColumns"
-            :data-source="detail.documents"
-            :pagination="false"
-            bordered
-            row-key="id"
-            size="small"
-          >
-            <template #bodyCell="{ column, record }">
-              <template v-if="column.key === 'action'">
-                <a v-if="record.fileUrl" :href="record.fileUrl" target="_blank" class="text-primary">涓嬭浇</a>
-                <span v-else class="text-gray-400">-</span>
-              </template>
-            </template>
-          </Table>
-        </div>
-      </Tabs.TabPane>
-    </Tabs>
-    <div v-else class="py-8 text-center text-gray-400">
-      鏆傛棤褰掓。璁板綍
+  <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">
+      <Spin />
     </div>
+    <template v-else>
+      <Tabs v-if="detailList.length > 0" v-model:active-key="activeProject" type="card">
+        <Tabs.TabPane
+          v-for="(detail, index) in detailList"
+          :key="String(index)"
+          :tab="detail.project.taskName || '椤圭洰'"
+        >
+          <!-- 椤圭洰淇℃伅 -->
+          <Descriptions :column="3" bordered size="small" class="mb-4">
+            <Descriptions.Item label="浠诲姟缂栫爜">{{ detail.project.taskCode }}</Descriptions.Item>
+            <Descriptions.Item label="浠诲姟鍚嶇О">{{ detail.project.taskName }}</Descriptions.Item>
+            <Descriptions.Item label="浜у搧缂栫爜">{{ detail.project.productCode }}</Descriptions.Item>
+            <Descriptions.Item label="浜у搧鍚嶇О">{{ detail.project.productName }}</Descriptions.Item>
+            <Descriptions.Item label="鐗堟湰鍙�">{{ detail.project.version }}</Descriptions.Item>
+            <Descriptions.Item label="涓昏璁″笀">{{ detail.project.chiefDesignerNickname }}</Descriptions.Item>
+            <Descriptions.Item label="瀹℃牳浜�">{{ detail.project.reviewerNickname }}</Descriptions.Item>
+            <Descriptions.Item label="璁″垝瀹屾垚">{{ detail.project.planFinishTime }}</Descriptions.Item>
+          </Descriptions>
+
+          <!-- 褰掓。璁板綍 -->
+          <div class="mb-4">
+            <h4 class="mb-2 text-sm font-medium">褰掓。璁板綍</h4>
+            <Table
+              :columns="archiveColumns"
+              :data-source="detail.archives"
+              :pagination="false"
+              bordered
+              row-key="id"
+              size="small"
+            />
+          </div>
+
+          <!-- 璁捐璧勬枡 -->
+          <div>
+            <h4 class="mb-2 text-sm font-medium">璁捐璧勬枡</h4>
+            <Table
+              :columns="documentColumns"
+              :data-source="detail.documents"
+              :pagination="false"
+              bordered
+              row-key="id"
+              size="small"
+            >
+              <template #bodyCell="{ column, record }">
+                <template v-if="column.key === 'action'">
+                  <template v-if="documentFileUrl(record)">
+                    <a class="mr-2" @click="openPreview(documentFileUrl(record), record.fileName)">棰勮</a>
+                    <a :href="documentFileUrl(record)" target="_blank">涓嬭浇</a>
+                  </template>
+                  <span v-else class="text-gray-400">-</span>
+                </template>
+              </template>
+            </Table>
+          </div>
+        </Tabs.TabPane>
+      </Tabs>
+      <div v-else class="py-8 text-center text-gray-400">
+        鏆傛棤褰掓。璁板綍
+      </div>
+    </template>
   </Modal>
 </template>

--
Gitblit v1.9.3