From 06e4c8c1bad514992186d94a65c0dc6250e34716 Mon Sep 17 00:00:00 2001
From: zhangwei <1504152376@qq.com>
Date: 星期四, 28 八月 2025 13:33:32 +0800
Subject: [PATCH] '解决招标文件pdf无法加载问题'

---
 src/views/system/dept/detail.vue          |   41 ++------------------
 src/views/system/component/pdfPreview.vue |    2 -
 src/views/system/dept/utils/detail.tsx    |   56 +++++++++++++++++++++++----
 3 files changed, 51 insertions(+), 48 deletions(-)

diff --git a/src/views/system/component/pdfPreview.vue b/src/views/system/component/pdfPreview.vue
index 8681f05..1e71bab 100644
--- a/src/views/system/component/pdfPreview.vue
+++ b/src/views/system/component/pdfPreview.vue
@@ -31,8 +31,6 @@
 
   isLoading.value = false;
 };
-console.log(props.fileInfo, "props.fileInfo");
-
 const pdfUrl = props.fileInfo.filePath;
 // 鐢╢etch鑾峰彇鏂囦欢娴侊紝寮哄埗杞负棰勮鏍煎紡
 fetch(pdfUrl)
diff --git a/src/views/system/dept/detail.vue b/src/views/system/dept/detail.vue
index ddb1e97..eec662e 100644
--- a/src/views/system/dept/detail.vue
+++ b/src/views/system/dept/detail.vue
@@ -24,46 +24,13 @@
 import IconParkSolidBack from "~icons/icon-park-solid/back";
 
 const { openDialog } = useDept(ref({}));
-const { openUploadDialog, state, changeDialog } = useDetail();
+const { openUploadDialog, state, changeDialog, getDetailList } = useDetail();
 defineOptions({
   name: "itemdetail"
 });
-const convertFujianToObjects = (fujianStr, fujianNameStr) => {
-  // 鍒嗗壊瀛楃涓蹭负鏁扮粍骞惰繃婊ょ┖鍊�
-  const srcArray = fujianStr.split(",").filter(Boolean);
-  const nameArray = fujianNameStr.split(",").filter(Boolean);
 
-  // 鎻愬彇鏂囦欢鍚庣紑浣滀负valu
-  const getFileExtension = fileName => {
-    const lastDotIndex = fileName.lastIndexOf(".");
-    // 濡傛灉娌℃湁鍚庣紑鎴栨枃浠跺悕浠ョ偣缁撳熬锛岃繑鍥炵┖瀛楃涓�
-    if (lastDotIndex === -1 || lastDotIndex === fileName.length - 1) {
-      return "";
-    }
-    return fileName.slice(lastDotIndex + 1).toLowerCase();
-  };
-
-  // 鏄犲皠涓虹洰鏍囧璞℃暟缁�
-  return srcArray.map((src, index) => {
-    // 纭繚鍚嶇О鏁扮粍鏈夊搴旂储寮曠殑鍏冪礌
-    const name = nameArray[index]?.trim() || `鏈煡鏂囦欢${index + 1}`;
-
-    return {
-      name: name,
-      filePath: src.trim(),
-      fileType: getFileExtension(name)
-    };
-  });
-};
 onMounted(async () => {
-  let res = await getTenderOrderDetail({ id: props.nowID });
-  state.nowInfo = res.result;
-  if (state.nowInfo.fujian) {
-    state.nowInfo.fujianList = convertFujianToObjects(
-      state.nowInfo.fujian,
-      state.nowInfo.fujianName
-    );
-  }
+  getDetailList(props.nowID);
 });
 const backListPage = () => {
   emit("backListPage");
@@ -217,8 +184,8 @@
                         class="flex items-center cursor-pointer"
                         @click="
                           previewPdf({
-                            name: state.nowInfo.zhaobiaowenjian,
-                            filePath: state.nowInfo.zhaobiaowenjianName,
+                            name: state.nowInfo.zhaobiaowenjianName,
+                            filePath: state.nowInfo.zhaobiaowenjian,
                             fileType: 'pdf'
                           })
                         "
diff --git a/src/views/system/dept/utils/detail.tsx b/src/views/system/dept/utils/detail.tsx
index 37982e6..ac10c22 100644
--- a/src/views/system/dept/utils/detail.tsx
+++ b/src/views/system/dept/utils/detail.tsx
@@ -16,8 +16,44 @@
 } from "@/api/item/index";
 
 const formRef = ref();
+const convertFujianToObjects = (fujianStr, fujianNameStr) => {
+  // 鍒嗗壊瀛楃涓蹭负鏁扮粍骞惰繃婊ょ┖鍊�
+  const srcArray = fujianStr.split(",").filter(Boolean);
+  const nameArray = fujianNameStr.split(",").filter(Boolean);
 
+  // 鎻愬彇鏂囦欢鍚庣紑浣滀负valu
+  const getFileExtension = fileName => {
+    const lastDotIndex = fileName.lastIndexOf(".");
+    // 濡傛灉娌℃湁鍚庣紑鎴栨枃浠跺悕浠ョ偣缁撳熬锛岃繑鍥炵┖瀛楃涓�
+    if (lastDotIndex === -1 || lastDotIndex === fileName.length - 1) {
+      return "";
+    }
+    return fileName.slice(lastDotIndex + 1).toLowerCase();
+  };
+
+  // 鏄犲皠涓虹洰鏍囧璞℃暟缁�
+  return srcArray.map((src, index) => {
+    // 纭繚鍚嶇О鏁扮粍鏈夊搴旂储寮曠殑鍏冪礌
+    const name = nameArray[index]?.trim() || `鏈煡鏂囦欢${index + 1}`;
+
+    return {
+      name: name,
+      filePath: src.trim(),
+      fileType: getFileExtension(name)
+    };
+  });
+};
 export function useDetail() {
+  async function getDetailList(id) {
+    const res = await getTenderOrderDetail({ id });
+    state.nowInfo = res.result;
+    if (state.nowInfo.fujian) {
+      state.nowInfo.fujianList = convertFujianToObjects(
+        state.nowInfo.fujian,
+        state.nowInfo.fujianName
+      );
+    }
+  }
   async function openUploadDialog(title = "涓婁紶", row?: TenderInfo) {
     const detail = await changeDetail({ id: row.id });
     if (detail.result) {
@@ -65,9 +101,10 @@
                 console.log(options, index, button);
                 cHangeDelete({ id: row?.id }).then(res => {
                   if (res.code == "200") {
-                    getTenderOrderDetail({ id: row?.tenderId }).then(res => {
-                      state.nowInfo = res.result;
-                    });
+                    getDetailList(row?.tenderId);
+                    // getTenderOrderDetail({ id: row?.tenderId }).then(res => {
+                    //   state.nowInfo = res.result;
+                    // });
                     closeDialog(options, index); // 鍏抽棴寮规
                   } else {
                     // closeLoading();
@@ -96,9 +133,10 @@
             res = await changezhaobiao(curData);
           }
           if (res.code == "200") {
-            getTenderOrderDetail({ id: row?.id }).then(res => {
-              state.nowInfo = res.result;
-            });
+            getDetailList(row?.id);
+            // getTenderOrderDetail({ id: row?.id }).then(res => {
+            //   state.nowInfo = res.result;
+            // });
             done(); // 鍏抽棴寮规
           } else {
             closeLoading();
@@ -245,14 +283,14 @@
     );
     // 鎷兼帴鏃堕棿鎴冲拰闅忔満鏁�
     return (
-      `${dirPath}${filename}${timestamp}_${randomNumber}` +
-      filename.match(/\.[^.]+$/)
+      `${dirPath}${timestamp}_${randomNumber}` + filename.match(/\.[^.]+$/)
     );
   }
   return {
     openUploadDialog,
     state,
     generateTimestampWithRandom,
-    changeDialog
+    changeDialog,
+    getDetailList
   };
 }

--
Gitblit v1.9.1