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/utils/detail.tsx | 56 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 47 insertions(+), 9 deletions(-) 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