|
|
@@ -258,19 +258,47 @@
|
|
|
});
|
|
|
},
|
|
|
methods: {
|
|
|
- async createPdf(){
|
|
|
- uni.showLoading({
|
|
|
- title:'正在生成PDF所需的图片...'
|
|
|
- })
|
|
|
- await this.downloadZtzdfxImg();
|
|
|
- for(const d of this.reportData.dimensionAnalysis){
|
|
|
- const fileurl = await this.generateScoreImage(d);
|
|
|
- this.pdfImages.push(fileurl)
|
|
|
- }
|
|
|
+ // async createPdf(){
|
|
|
+ // uni.showLoading({
|
|
|
+ // title:'正在生成PDF所需的图片...'
|
|
|
+ // })
|
|
|
+ // const imgUrl = await this.downloadZtzdfxImg();
|
|
|
+ // this.pdfImages.push(imgUrl);
|
|
|
+
|
|
|
+ // for(const d of this.reportData.dimensionAnalysis){
|
|
|
+ // const fileurl = await this.generateScoreImage(d);
|
|
|
+ // this.pdfImages.push(fileurl)
|
|
|
+ // }
|
|
|
|
|
|
- this.$showToast(`生成成功,共计${this.pdfImages.length}张`);
|
|
|
- uni.hideLoading();
|
|
|
- console.log(this.pdfImages);
|
|
|
+ // this.$showToast(`生成成功,共计${this.pdfImages.length}张`);
|
|
|
+ // uni.hideLoading();
|
|
|
+ // console.log(this.pdfImages);
|
|
|
+ // },
|
|
|
+ // Promise.all方法,性能更高
|
|
|
+ async createPdf(){
|
|
|
+ uni.showLoading({
|
|
|
+ title:'正在生成PDF所需的图片...'
|
|
|
+ })
|
|
|
+ try {
|
|
|
+ const ztzdfxImgPromise = this.downloadZtzdfxImg();
|
|
|
+ const dimensionImagePromises = this.reportData.dimensionAnalysis.map(d => {
|
|
|
+ return this.generateScoreImage(d);
|
|
|
+ });
|
|
|
+
|
|
|
+ const allImageUrls = await Promise.all([
|
|
|
+ ztzdfxImgPromise,
|
|
|
+ ...dimensionImagePromises
|
|
|
+ ]);
|
|
|
+ this.pdfImages = allImageUrls;
|
|
|
+
|
|
|
+ uni.hideLoading();
|
|
|
+ this.$showToast(`生成成功,共计${this.pdfImages.length}张`);
|
|
|
+ console.log(this.pdfImages);
|
|
|
+ } catch (error) {
|
|
|
+ uni.hideLoading();
|
|
|
+ console.error('生成图片过程中发生错误:', error);
|
|
|
+ uni.showToast({ title: '生成图片失败,请重试', icon: 'none' });
|
|
|
+ }
|
|
|
},
|
|
|
// 绘制主函数
|
|
|
async generateScoreImage(dimensionData) {
|
|
|
@@ -560,8 +588,7 @@
|
|
|
success: async (res) => {
|
|
|
const imgUrl = await this.uploadFilePromise(res.tempFilePath);
|
|
|
console.log(imgUrl,'imgUrl');
|
|
|
- this.pdfImages.push(imgUrl);
|
|
|
- resolve()
|
|
|
+ resolve(imgUrl)
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
console.log('生成图片失败:', err);
|