From 67517b477cbb05cd9dbe467b16192d95b9e2695f Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期三, 17 四月 2024 16:50:51 +0800
Subject: [PATCH] 月度统计报表模块 前端开发+列表的接口联调
---
src/views/overview/previewExcel.vue | 35 ++++++++++++++++++++++++++---------
1 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/src/views/overview/previewExcel.vue b/src/views/overview/previewExcel.vue
index ab9ff1e..39e9dc0 100644
--- a/src/views/overview/previewExcel.vue
+++ b/src/views/overview/previewExcel.vue
@@ -1,5 +1,11 @@
<template>
<div>
+
+ <!-- <button @click="cropAndDownload">鎴彇鍥剧墖</button> -->
+ <!-- 鏄剧ず瑁佸壀鍚庣殑鍥剧墖 -->
+ <!-- <div style="width: 800px;">
+ <img style="width: 100%;" id="export-pdf" v-if="croppedImage" :src="croppedImage" alt="Cropped Image" />
+ </div> -->
<div ref="elementToCrop" >
<div style="width: 100%;">
<vue-office-excel :minRowLength="0" :src="excel" @rendered="rendered"/>
@@ -19,17 +25,16 @@
},
data() {
return {
- excel: '',//excel鏂囨。鍦板潃
- cutAfterWidth:this.$route.params.cutAfterWidth,//瑁佸壀鍚庤鍑忓幓鐨勫
+ excel:'',
+ cutAfterWidth:0,
+ // croppedImage: null, // 鍥剧墖
};
},
computed: {
},
created() {
- console.log(this.$route.params.baseOperationType,"鐪嬬湅")
- if(this.$route.params.baseOperationType!=undefined){
- this.excel=this.$route.params.url
- }
+ this.excel=this.$route.query.url
+ this.cutAfterWidth=this.$route.query.cutAfterWidth
},
mounted() {
},
@@ -38,8 +43,8 @@
methods: {
rendered(){
console.log("娓叉煋瀹屾垚")
- if(this.$route.params.baseOperationType!=undefined){
- this.excel=this.$route.params.url
+ if(this.$route.query.url){
+ this.excel=this.$route.query.url
this.cropAndDownload()
}
},
@@ -55,7 +60,9 @@
canvas,
50, // 寮�濮嬭鍓殑宸︿晶浣嶇疆
20, // 寮�濮嬭鍓殑涓婁晶浣嶇疆
- croppedCanvas.width-this.cutAfterWidth, // 瑁佸壀鍚庣殑瀹藉害
+ croppedCanvas.width=croppedCanvas.width/100*this.cutAfterWidth,
+ // croppedCanvas.width-=croppedCanvas.width/100*46.7, // 瑁佸壀鍚庣殑瀹藉害 鍏ュ簱鍗曚繚鐣欏師鍥惧搴�53.3%
+ // croppedCanvas.width-=croppedCanvas.width/100*49.2, // 瑁佸壀鍚庣殑瀹藉害 鍑哄簱鍗曚繚鐣欏師鍥惧搴�50.8%
croppedCanvas.height-300, // 瑁佸壀鍚庣殑楂樺害
0, // 鏂癈anvas涓粯鍒剁殑宸︿晶浣嶇疆
0, // 鏂癈anvas涓粯鍒剁殑涓婁晶浣嶇疆
@@ -81,9 +88,19 @@
const scaledHeight = canvas.height * scale;
// 灏哻anvas鍏冪礌杞崲涓簆ng锛屾彃鍏ュ埌PDF鏂囨。涓�
pdf.addImage(croppedImage, "PNG",0,0,scaledWidth,scaledHeight);
+
+ // 锛堝彲閫夛級浣犱篃鍙互灏嗚鍓悗鐨勫浘鐗囦繚瀛樹负鏂囦欢
+ // this.saveCroppedImageToFile(croppedImage);
// 淇濆瓨PDF鏂囨。
pdf.save("export.pdf");
},
+ // 锛堝彲閫夛級淇濆瓨瑁佸壀鍚庣殑鍥剧墖涓烘枃浠�
+ saveCroppedImageToFile(dataUrl) {
+ const link = document.createElement("a");
+ link.href = dataUrl;
+ link.download = "cropped_image.png";
+ link.click();
+ },
},
components: {
VueOfficeExcel,
--
Gitblit v1.8.0