Browse Source

报表打印

master
lijun 2 weeks ago
parent
commit
d4d0b0afbc
  1. 5
      .vscode/settings.json
  2. 3
      config/dev.env.js
  3. 41
      src/views/excelreport/viewer/index.vue

5
.vscode/settings.json

@ -0,0 +1,5 @@
{
"cSpell.words": [
"luckysheet"
]
}

3
config/dev.env.js

@ -4,6 +4,7 @@ const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, { module.exports = merge(prodEnv, {
NODE_ENV: '"development"', NODE_ENV: '"development"',
BASE_API: '"http://39.98.128.49:9095"'
// BASE_API: '"http://39.98.128.49:9095"'
BASE_API: '"https://pay.yyjh66.com:9095"'
//BASE_API: '"http://10.108.26.197:9095"' //BASE_API: '"http://10.108.26.197:9095"'
}) })

41
src/views/excelreport/viewer/index.vue

@ -23,6 +23,9 @@
<i class="iconfont iconpdf"></i>导出pdf <i class="iconfont iconpdf"></i>导出pdf
</el-button> </el-button>
</a> </a>
<el-button type="text" @click="print('gaea_template_pdf')">
<i class="iconfont iconpdf"></i>打印
</el-button>
</div> </div>
<el-form class=""> <el-form class="">
<h2>表格查询</h2> <h2>表格查询</h2>
@ -173,6 +176,36 @@ export default {
} }
}) })
}, },
async print(val) {
let extend = '.pdf';
const result = {};
result["reportCode"] = this.reportCode;
result["setParam"] = JSON.stringify(this.params.setParam);
if (val != "") {
result["exportType"] = val;
if (val === "gaea_template_pdf") {
extend = '.pdf';
}
}
this.getCellStyleData(result);
exportExcel(result).then(res=>{
this.printBlobInIframe(res);
})
},
printBlobInIframe(res) {
const blob = new Blob([res], { type: 'application/pdf' });
const pdfUrl = URL.createObjectURL(blob);
const iframe = document.createElement('iframe');
iframe.src = pdfUrl;
iframe.style.display = 'none';
document.body.appendChild(iframe);
iframe.onload = () => {
iframe.contentWindow.print();
URL.revokeObjectURL(pdfUrl); //
// document.body.removeChild(iframe);
};
},
// json // json
toObject(val) { toObject(val) {
const objfirst = {}; const objfirst = {};
@ -234,9 +267,13 @@ export default {
zoomRatio: 1, // zoomRatio: 1, //
image: [], // image: [], //
showGridLines: 1, //线 showGridLines: 1, //线
dataVerification: {} //
dataVerification: {}, //
} }
]
],
showtoolbar: true, // true
showtoolbarConfig:{
print: false,
}
}; };
options.data = this.sheetData; options.data = this.sheetData;
// console.log(this.sheetData) // console.log(this.sheetData)

Loading…
Cancel
Save