This commit is contained in:
lcw
2026-04-28 11:26:26 +08:00
parent 9fa073546b
commit cd8347d3d1
120 changed files with 8751 additions and 3896 deletions

View File

@ -59,6 +59,7 @@ import { useRoute } from 'vue-router'
import { reactive, ref, onMounted, getCurrentInstance } from "vue";
import { getItem } from '@//utils/storage.js'
import { deleteWjZzzAddEntity, getWjZzzAddEntity } from '@//api/qbcj.js'
import { saveAs } from 'file-saver';
import AddForm from "./components/addForm.vue";
const { proxy } = getCurrentInstance();
const detailDiloag = ref();
@ -180,30 +181,14 @@ const downloadFile = async (item) => {
let successCount = 0;
let failCount = 0;
proxy.$message.info(`开始下载${downloadCount}个文件...`);
// 并行下载所有文件
const downloadPromises = dataList.map(async (fileData, index) => {
try {
// fileData.url = "http://47.108.232.77:9000/image/2025-01-06/081102a5418e4146beea277d18018e07.jpeg";
// 使用fetch获取文件内容
const downloadUrl = fileData.url.replace(/^https?:\/\/[^/]+/, '/zyminio');
const response = await fetch(downloadUrl);
if (!response.ok) throw new Error('文件下载失败');
// 将响应转换为Blob对象
const blob = await response.blob();
// 创建下载链接
const downloadLink = document.createElement('a');
downloadLink.href = URL.createObjectURL(blob);
// 设置下载文件的名称,避免冲突
const fileName = dataList.length > 1 ? `${item.wjmc}_${index + 1}` : item.wjmc;
downloadLink.download = fileName;
// 触发下载
document.body.appendChild(downloadLink);
downloadLink.click();
// 清理
setTimeout(() => {
document.body.removeChild(downloadLink);
URL.revokeObjectURL(downloadLink.href);
}, 100);
saveAs(blob, fileName);
successCount++;
} catch (error) {
console.error(`文件${index + 1}下载失败:`, error);
@ -211,10 +196,8 @@ const downloadFile = async (item) => {
}
});
// 等待所有下载完成
await Promise.all(downloadPromises);
// 显示下载结果
if (failCount === 0) {
proxy.$message.success(`成功下载${successCount}个文件`);
} else if (successCount === 0) {