From e449a5408265e4bd1f6c66f5be28a42efac444ee Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期日, 20 九月 2026 15:22:46 +0800
Subject: [PATCH] 天津豹鸣app 1.需求修改
---
src/pages/qualityManagement/finalInspection/fileList.vue | 109 +++++++++++++++++-------------------------------------
1 files changed, 35 insertions(+), 74 deletions(-)
diff --git a/src/pages/qualityManagement/finalInspection/fileList.vue b/src/pages/qualityManagement/finalInspection/fileList.vue
index 126158d..4c8925e 100644
--- a/src/pages/qualityManagement/finalInspection/fileList.vue
+++ b/src/pages/qualityManagement/finalInspection/fileList.vue
@@ -3,6 +3,15 @@
<!-- 椤甸潰澶撮儴 -->
<PageHeader title="闄勪欢绠$悊"
@back="goBack" />
+ <!-- 闇�姹備節.4锛氫笅杞� PDF 鍚堟牸璇� -->
+ <view class="pdf-bar">
+ <u-button type="primary"
+ size="small"
+ :loading="downloadingPdf"
+ @click="downloadPdf">
+ 涓嬭浇鍚堟牸璇丳DF
+ </u-button>
+ </view>
<!-- 闄勪欢鍒楄〃 -->
<view class="file-list-container">
<view v-if="fileList.length > 0"
@@ -78,10 +87,28 @@
qualityInspectFileListPage,
qualityInspectFileDel,
} from "@/api/qualityManagement/materialInspection";
+ import { downloadQualityInspectPdf } from "@/api/qualityManagement/qualityInspectFile.js";
+ import { openFile } from "@/utils/file";
import { blobValidate } from "@/utils/ruoyi";
// 闄勪欢鍒楄〃
const fileList = ref([]);
+ // 鍚堟牸璇丳DF 涓嬭浇涓�
+ const downloadingPdf = ref(false);
+
+ // 涓嬭浇 PDF 鍚堟牸璇侊紙涓庨檮浠跺悓涓�浠� inspectId锛�
+ const downloadPdf = () => {
+ if (!rulesRegulationsManagementId.value) {
+ showToast("鍙傛暟閿欒");
+ return;
+ }
+ downloadingPdf.value = true;
+ downloadQualityInspectPdf(rulesRegulationsManagementId.value)
+ .catch(() => {})
+ .finally(() => {
+ downloadingPdf.value = false;
+ });
+ };
// 杩斿洖涓婁竴椤�
const goBack = () => {
@@ -259,81 +286,11 @@
});
});
};
- // 涓嬭浇鏂囦欢
+ // 涓嬭浇骞堕瑙堛��
+ // 鍘熸潵璧扮殑鏄� /common/download?...&delete=true 鈥斺�� 浼氭妸鏈嶅姟绔檮浠跺垹鎺夛紝
+ // 涓斿洖璋冮噷寮曠敤浜嗘湭瀹氫箟鐨� resolve/reject銆傛敼涓虹洿鎺ユ寜 url 鎵撳紑銆�
const downloadFile = file => {
- var url =
- config.baseUrl +
- "/common/download?fileName=" +
- encodeURIComponent(file.url) +
- "&delete=true";
- console.log(url, "url");
-
- uni
- .downloadFile({
- url: url,
- responseType: "blob",
- header: { Authorization: "Bearer " + getToken() },
- })
- .then(res => {
- let osType = uni.getStorageSync("deviceInfo").osName;
- let filePath = res.tempFilePath;
- if (osType === "ios") {
- uni.openDocument({
- filePath: filePath,
- showMenu: true,
- success: res => {
- resolve(res);
- },
- fail: err => {
- console.log("uni.openDocument--fail");
- reject(err);
- },
- });
- } else {
- uni.saveFile({
- tempFilePath: filePath,
- success: fileRes => {
- uni.showToast({
- icon: "none",
- mask: true,
- title:
- "鏂囦欢宸蹭繚瀛橈細Android/data/uni.UNI720216F/apps/__UNI__720216F/" +
- fileRes.savedFilePath, //淇濆瓨璺緞
- duration: 3000,
- });
- setTimeout(() => {
- //鎵撳紑鏂囨。鏌ョ湅
- uni.openDocument({
- filePath: fileRes.savedFilePath,
- success: function (res) {
- resolve(fileRes);
- },
- });
- }, 3000);
- },
- fail: err => {
- console.log("uni.save--fail");
- reject(err);
- },
- });
- }
- // const isBlob = blobValidate(res.data);
- // if (isBlob) {
- // const blob = new Blob([res.data], { type: "text/plain" });
- // const url = URL.createObjectURL(blob);
- // const downloadLink = document.getElementById("downloadLink");
- // downloadLink.href = url;
- // downloadLink.download = file.name;
- // downloadLink.click();
- // showToast("涓嬭浇鎴愬姛");
- // } else {
- // showToast("涓嬭浇澶辫触");
- // }
- })
- .catch(err => {
- console.error("涓嬭浇澶辫触:", err);
- showToast("涓嬭浇澶辫触");
- });
+ openFile(file?.url);
};
// 纭鍒犻櫎
@@ -431,6 +388,10 @@
padding: 20rpx;
}
+ .pdf-bar {
+ padding: 16rpx 20rpx 0;
+ }
+
.file-list {
background: #ffffff;
border-radius: 8rpx;
--
Gitblit v1.9.3