|
@@ -45,6 +45,7 @@
|
|
|
</el-row>
|
|
|
<el-row v-if="btnType == 'show'" style="margin: 10px 20px;">
|
|
|
<el-button type="primary" size="mini" icon="el-icon-download" @click="downloadReport">下载</el-button>
|
|
|
+ <el-button type="warning" size="mini" icon="el-icon-printer" @click="printExcel">打印</el-button>
|
|
|
<el-button type="danger" size="mini" icon="el-icon-circle-close" @click="cancelSaveReport">取消</el-button>
|
|
|
</el-row>
|
|
|
<div id="luckysheet"
|
|
@@ -102,6 +103,10 @@
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
|
|
|
+ <div id="print-area" style="display: none;position: absolute;z-index: 0;top: 0;width: 100%;height: 100vh;overflow: hidden;">
|
|
|
+ <div id="print-html" ref="printPayFeeNew"></div>
|
|
|
+ </div>
|
|
|
+
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -118,6 +123,7 @@ import {
|
|
|
} from "@/api/datasource";
|
|
|
import {insertEChart, exportExcel, packtable} from 'luckytool'
|
|
|
import ExcelJS from 'exceljs'
|
|
|
+import Print from 'print-js'
|
|
|
|
|
|
export default {
|
|
|
name: "index",
|
|
@@ -355,7 +361,7 @@ export default {
|
|
|
let name = '${' + source.itemGroupId + '.' + itemName + '}'
|
|
|
if (item.v.v === name) {
|
|
|
let dataList = source.dataList
|
|
|
- for (let i = 0; i < dataList.length; i ++) {
|
|
|
+ for (let i = 0; i < dataList.length; i++) {
|
|
|
let p_r = parseInt(item.r) + i
|
|
|
luckysheet.setCellValue(p_r, item.c, dataList[i].dv)
|
|
|
}
|
|
@@ -625,6 +631,52 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
+ /** 打印操作 */
|
|
|
+ printExcel() {
|
|
|
+ const loading = showLoading(this, '请稍候···')
|
|
|
+ let src = luckysheet.getScreenshot(); // 生成base64图片
|
|
|
+ let $img = `<img src=${src} style="width: 100%; position: absolute; left: 0px" />`;
|
|
|
+ document.querySelector("#print-area").style.display = "block";
|
|
|
+ this.$nextTick(() => {
|
|
|
+ document.querySelector("#print-html").innerHTML = $img;
|
|
|
+ setTimeout(() => {
|
|
|
+ Print({
|
|
|
+ printable: 'print-html',
|
|
|
+ type: 'html',
|
|
|
+ documentTitle: '文档标题',
|
|
|
+ header: '统计图',
|
|
|
+ headerStyle: 'font-weight:400;text-align:center;',
|
|
|
+ style: '@page {margin: 0 10mm};', // 不打印页眉和页脚
|
|
|
+ honorColor: true, // 是否打印彩色文本
|
|
|
+ targetStyles: ['*'] // 允许打印所有样式属性
|
|
|
+ }) // Print.js插件
|
|
|
+ document.querySelector("#print-area").style.display = "none";
|
|
|
+ loading.close()
|
|
|
+ }, 2000)
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /** 自定义选中区域 */
|
|
|
+ getExcelRowColumn() {
|
|
|
+ const sheetData = luckysheet.getSheetData();
|
|
|
+ let objRowColumn = {
|
|
|
+ row: [null, null], //行
|
|
|
+ column: [null, null], //列
|
|
|
+ };
|
|
|
+ sheetData.forEach((item, index) => {
|
|
|
+ //行数
|
|
|
+ item.forEach((it, itemIndex) => {
|
|
|
+ console.log(it)
|
|
|
+ if (it !== null) {
|
|
|
+ if (objRowColumn.row[0] == null) objRowColumn.row[0] = index; // row第一位
|
|
|
+ objRowColumn.row[1] = index; //row第二位
|
|
|
+ if (objRowColumn.column[0] == null)
|
|
|
+ objRowColumn.column[0] = itemIndex; //column第一位
|
|
|
+ objRowColumn.column[1] = itemIndex; //column第二位
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return objRowColumn;
|
|
|
+ },
|
|
|
/** 取消保存报表 */
|
|
|
cancelSaveReport() {
|
|
|
luckysheet.destroy()
|
|
@@ -640,7 +692,7 @@ export default {
|
|
|
this.dialogReportTemplateVisible = false
|
|
|
this.dialogDownloadReportTypeVisible = false
|
|
|
}
|
|
|
- },
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
@@ -687,6 +739,7 @@ export default {
|
|
|
overflow: auto;
|
|
|
height: 100%;
|
|
|
height: calc(100% - 40px);
|
|
|
+
|
|
|
ul {
|
|
|
display: flex;
|
|
|
flex-wrap: wrap;
|