Răsfoiți Sursa

1、报表详情添加下载excel文件

lhy 11 luni în urmă
părinte
comite
de625332e3

+ 2 - 2
PrintServer/src/main/java/com/jd/printserver/controller/PrintServerController.java

@@ -265,8 +265,8 @@ public class PrintServerController extends BaseController {
         } catch (IOException e) {
             return error("报表文件持久化失败");
         }
-//        JacobUtils.excelToPDF(outPath, printParam);
-        xlsToPdfUtil.excelToPDF(outPath, printParam);
+        JacobUtils.excelToPDF(outPath, printParam);
+//        xlsToPdfUtil.excelToPDF(outPath, printParam);
 //        String uuid = IdUtil.simpleUUID();
 //        QueueUtil.setQueue(uuid, outPath, printParam);
 //        while (!QueueUtil.isSuccess(uuid)) {

+ 2 - 1
industry-admin/src/views/report/reportTable/reportDetail.vue

@@ -109,7 +109,8 @@ export default
         this.sendMsg({
           cmd: 'download',
           data:{
-            dtype:downloadType
+            dtype:downloadType,
+            reportTableName: this.reportTableName
           }
         })
       },

+ 20 - 8
industry-system/industry-da/src/main/resources/static/reportSheet/js/report-history.js

@@ -12,6 +12,7 @@ layui.use(['_$', 'rightMenu'], function() {
 		indexFn.initPage({
 			reportId: reportId
 		},() =>{
+			/** printQuality 最高图表质量 */
 			layui.excelUtil.downloadExcel('print-excel', 10, (index, buf) => {
 				const formData = new FormData()
 				formData.append('file', new Blob([buf], {
@@ -98,6 +99,18 @@ window.onload = function() {
 				}
 			})
 		} else if(json.cmd=='download'){
+			let reportTableName = 'print_excel'
+			if(json.data.reportTableName){
+				reportTableName = json.data.reportTableName
+			}
+			reportTableName += "_" + new Date().format("yyyyMMddHHmmss")
+			// 1 excel
+			if(json.data.dtype == 1){
+				/** printQuality 最高图表质量 */
+				layui.excelUtil.downloadExcel(reportTableName, 10)
+				return
+			}
+			// 2 pdf
 			const range = luckysheet.getRange()
 			if (range.length > 1) {
 				layer.msg('请选择单个打印区域!', {icon: 2})
@@ -113,16 +126,15 @@ window.onload = function() {
 			let data = {
 				bottomMargin: "10",
 				leftMargin: "10",
-				orientation: "2",
-				paperSize: "9",
+				orientation: "2",/** 横向 */
+				paperSize: "9",/** A4 */
 				printArea: "",
-				printQuality: "1",
-				printScale: "1",
-				printType: "1",
+				printQuality: "10", /** printQuality 最高图表质量 */
+				printScale: "2", /** 所有列在一页 */
 				rightMargin: "10",
 				scale: "",
 				topMargin: "10",
-				wordQuality: "600"
+				wordQuality: "600" /** 文档质量 */
 			};
 			layui.excelUtil.xlsxToPdf({
 				data,
@@ -130,7 +142,7 @@ window.onload = function() {
 					let fileName = localStorage.getItem('url') + '/' + json.data;
 					console.log(json.data);
 					let url = fileName;
-					let name=json.data.split('/').pop();
+					let ext=json.data.split('.').pop();
 					let xhr = new XMLHttpRequest();
 					xhr.open('get',url,true);
 					xhr.responseType = 'blob';
@@ -141,7 +153,7 @@ window.onload = function() {
 							let blob = new Blob([xhr.response]);
 							let url = window.URL.createObjectURL(blob);
 							a.href = url;
-							a.download = name;
+							a.download = reportTableName + "." + ext;
 							a.click();
 							window.URL.revokeObjectURL(url);
 						}