From d9c209aecf592804ba2d119a65eddc1f73bd913c Mon Sep 17 00:00:00 2001
From: WXL <1785969728@qq.com>
Date: 星期三, 28 二月 2024 15:09:03 +0800
Subject: [PATCH] 11
---
src/views/project/fund/performancedetails/index.vue | 89 +++++++++++++++++++++++++-------------------
1 files changed, 51 insertions(+), 38 deletions(-)
diff --git a/src/views/project/fund/performancedetails/index.vue b/src/views/project/fund/performancedetails/index.vue
index f00fb88..1a26ee2 100644
--- a/src/views/project/fund/performancedetails/index.vue
+++ b/src/views/project/fund/performancedetails/index.vue
@@ -2516,7 +2516,7 @@
this.tableDatatop = [];
this.fileListto = [];
this.invoicefileListto = [];
- this.pdfimg = '';
+ this.pdfimg = "";
this.invoicepdfimg = [];
this.pdfimgsrcList = [];
this.invoicepdfimgsrcList = [];
@@ -2525,26 +2525,32 @@
this.pdfVisible = true;
if (this.rbDetails[index].annexfilesList) {
- this.rbDetails[index].annexfilesList.forEach((value, indexson) => {
- const pdfimg = this.Networkheader + "/prod-api" + value.url;
- fetch(pdfimg, config)
- .then(response => response.blob())
- .then(blob => {
- // 灏嗚幏鍙栫殑鏁版嵁娴佽浆鎹负URL
- this.fileListto.push({
- name: value.name,
- url: URL.createObjectURL(blob)
+
+ const fetchPromises = this.rbDetails[index].annexfilesList.map(
+ (value, indexson) => {
+ const pdfimg = this.Networkheader + "/prod-api" + value.url;
+ return fetch(pdfimg, config)
+ .then(response => response.blob())
+ .then(blob => {
+ return {
+ name: value.name,
+ url: URL.createObjectURL(blob)
+ };
+ })
+ .catch(error => {
+ console.error("Error loading image", error);
+ return null;
});
- if (this.fileListto.length == 1) {
- this.pdfimg = URL.createObjectURL(blob);
- }
- this.pdfimgsrcList.push(URL.createObjectURL(blob));
- })
- .catch(error => {
- console.error("Error loading image", error);
- return;
- });
+ }
+ );
+
+ Promise.all(fetchPromises).then(fileListto => {
+ this.fileListto = fileListto.filter(item => item !== null);
+ this.pdfimg = this.fileListto[0].url;
+ console.log(this.pdfimg, "pdfimg");
+ this.pdfimgsrcList = this.fileListto.map(item => item.url);
});
+
this.previewpdf = true;
} else {
this.fileListto = [];
@@ -2553,26 +2559,31 @@
}
//鍙戠エ
if (this.rbDetails[index].invoicefilesList) {
- this.rbDetails[index].invoicefilesList.forEach((value, indexson) => {
- const pdfimg = this.Networkheader + "/prod-api" + value.url;
- fetch(pdfimg, config)
- .then(response => response.blob())
- .then(blob => {
- // 灏嗚幏鍙栫殑鏁版嵁娴佽浆鎹负URL
- this.invoicefileListto.push({
- name: value.name,
- url: URL.createObjectURL(blob)
+ const fetchPromises = this.rbDetails[index].invoicefilesList.map(
+ (value, indexson) => {
+ const pdfimg = this.Networkheader + "/prod-api" + value.url;
+ return fetch(pdfimg, config)
+ .then(response => response.blob())
+ .then(blob => {
+ return {
+ name: value.name,
+ url: URL.createObjectURL(blob)
+ };
+ })
+ .catch(error => {
+ console.error("Error loading image", error);
+ return null;
});
- if (this.invoicefileListto.length == 1) {
- this.invoicepdfimg = URL.createObjectURL(blob);
- }
- this.invoicepdfimgsrcList.push(URL.createObjectURL(blob));
- })
- .catch(error => {
- console.error("Error loading image", error);
- return;
- });
+ }
+ );
+
+ Promise.all(fetchPromises).then(invoicefileListto => {
+ this.invoicefileListto = invoicefileListto.filter(item => item !== null);
+ this.invoicepdfimg = this.invoicefileListto[0].url;
+ console.log(this.invoicepdfimg, "invoicepdfimg");
+ this.invoicepdfimgsrcList = this.invoicefileListto.map(item => item.url);
});
+
this.previewpdf = true;
} else {
this.invoicefileListto = [];
@@ -2580,11 +2591,13 @@
this.pdftitle = "";
}
- if (this.activeName == 1) {
+ if (this.activeName == "common") {
this.pdftitle = "鍏�" + this.pdfimgsrcList.length + "椤�";
} else {
this.pdftitle = "鍏�" + this.invoicepdfimgsrcList.length + "椤�";
}
+ console.log(this.fileListto, "this.fileListto");
+ console.log(this.rbDetails[index].annexfilesList, "annexfilesList");
},
// 鐐瑰嚮宸蹭笂浼犳枃浠�
--
Gitblit v1.9.3