From 29ef7c017c0dbbae7c62933d0fa3220f04cd8f56 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 04 八月 2026 18:00:32 +0800
Subject: [PATCH] 银川 1.归档bug

---
 src/api/mes/pro/workorder/index.ts          |    1 
 src/views/mes/pro/task/index.vue            |   15 +++++--
 src/views/mes/pd/archive/modules/detail.vue |   70 ++++++++++++++++++++++------------
 3 files changed, 57 insertions(+), 29 deletions(-)

diff --git a/src/api/mes/pro/workorder/index.ts b/src/api/mes/pro/workorder/index.ts
index 15a7635..8dacc2e 100644
--- a/src/api/mes/pro/workorder/index.ts
+++ b/src/api/mes/pro/workorder/index.ts
@@ -14,6 +14,7 @@
     productId?: number; // 浜у搧缂栧彿
     productName?: string; // 浜у搧鍚嶇О
     productCode?: string; // 浜у搧缂栫爜
+    itemCode?: string; // 浜у搧缂栫爜锛堢墿鏂欑紪鐮侊級
     productSpecification?: string; // 瑙勬牸鍨嬪彿
     unitMeasureName?: string; // 鍗曚綅鍚嶇О
     quantity?: number; // 鐢熶骇鏁伴噺
diff --git a/src/views/mes/pd/archive/modules/detail.vue b/src/views/mes/pd/archive/modules/detail.vue
index adb24db..e13a306 100644
--- a/src/views/mes/pd/archive/modules/detail.vue
+++ b/src/views/mes/pd/archive/modules/detail.vue
@@ -1,16 +1,34 @@
 <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';
+
+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();
 
 const archiveColumns = [
   { title: '褰掓。缂栧彿', dataIndex: 'archiveCode', key: 'archiveCode' },
@@ -30,40 +48,39 @@
   {
     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) {
+    open.value = true;
+    loading.value = true;
+    detailList.value = [];
+    activeProject.value = '0';
+    try {
+      detailList.value = await getPdArchiveDetailByProduct(props.productCode);
+    } catch {
+      message.error('鑾峰彇褰掓。璇︽儏澶辫触');
+    } finally {
+      loading.value = false;
+    }
+  } else if (!newVal) {
+    open.value = false;
+    detailList.value = [];
   }
-  open.value = true;
-  detailList.value = [];
-  activeProject.value = '0';
-  loading.value = true;
-  try {
-    detailList.value = await getPdArchiveDetailByProduct(productCode);
-  } catch {
-    message.error('鑾峰彇褰掓。璇︽儏澶辫触');
-  } finally {
-    loading.value = false;
-  }
-}
+});
 
 function handleClose() {
-  open.value = false;
-  detailList.value = [];
+  emit('update:visible', false);
 }
-
-defineExpose({ open: handleOpen });
 </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 +127,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>
diff --git a/src/views/mes/pro/task/index.vue b/src/views/mes/pro/task/index.vue
index e4002ea..bd75f40 100644
--- a/src/views/mes/pro/task/index.vue
+++ b/src/views/mes/pro/task/index.vue
@@ -25,7 +25,8 @@
 
 const router = useRouter();
 const ganttTasks = ref<any[]>([]); // 鐢樼壒鍥鹃瑙堟暟鎹�
-const archiveDetailRef = ref<InstanceType<typeof ArchiveDetail>>();
+const archiveVisible = ref(false);
+const archiveProductCode = ref('');
 
 const [ScheduleModal, scheduleModalApi] = useVbenModal({
   connectedComponent: ScheduleForm,
@@ -82,6 +83,12 @@
   } catch {
     message.error('鎺掍骇澶辫触');
   }
+}
+
+/** 鎵撳紑褰掓。璇︽儏 */
+function handleArchive(row: MesProWorkOrderApi.WorkOrder) {
+  archiveProductCode.value = row.productCode || '';
+  archiveVisible.value = true;
 }
 
 /** 鎵撳紑鐢樼壒鍥剧紪杈戦〉闈� */
@@ -169,14 +176,14 @@
               onClick: handleSchedule.bind(null, row),
             },
             {
-              label: '褰掓。',
+              label: '褰掓。璇︽儏',
               type: 'link',
-              onClick: () => archiveDetailRef.value?.open(row.productCode),
+              onClick: handleArchive.bind(null, row),
             },
           ]"
         />
       </template>
     </Grid>
-    <ArchiveDetail ref="archiveDetailRef" />
+    <ArchiveDetail :visible="archiveVisible" :product-code="archiveProductCode" @update:visible="archiveVisible = $event" />
   </Page>
 </template>

--
Gitblit v1.9.3