|
@@ -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);
|
|
|
}
|