|
@@ -44,6 +44,8 @@ window.onload = function() {
|
|
|
}, 500)
|
|
|
} else if (json.cmd == 'show') {
|
|
|
indexFn.initPage(json.data)
|
|
|
+ } else if(json.cmd=='print'){
|
|
|
+ console.log('print')
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -133,6 +135,49 @@ const indexFn = {
|
|
|
})
|
|
|
}
|
|
|
if(callback) callback()
|
|
|
+ if(data.type=='print'){
|
|
|
+ const range = luckysheet.getRange()
|
|
|
+ if (range.length > 1) {
|
|
|
+ layer.msg('请选择单个打印区域!', {icon: 2})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let printArea = ''
|
|
|
+ if (!(range[0].row[0] == range[0].row[1] && range[0].column[0] == range[0].column[1])) {
|
|
|
+ printArea = luckysheet.getTxtByRange(range)
|
|
|
+ }
|
|
|
+ if (printArea == 'B1:B2') {
|
|
|
+ printArea = ''
|
|
|
+ }
|
|
|
+ layui.printW.open({
|
|
|
+ printArea,
|
|
|
+ success: (data, index) => {
|
|
|
+ layer.close(index)
|
|
|
+ layui.excelUtil.xlsxToPdf({
|
|
|
+ data,
|
|
|
+ success: (json) => {
|
|
|
+ printJS({
|
|
|
+ printable: localStorage.getItem('url') + '/' + json.data,
|
|
|
+ type: 'pdf',
|
|
|
+ properties: [
|
|
|
+ 'mediaSize',
|
|
|
+ 'landscape',
|
|
|
+ 'margin',
|
|
|
+ 'header',
|
|
|
+ 'footer',
|
|
|
+ 'style'
|
|
|
+ ],
|
|
|
+ header: '',
|
|
|
+ footer: '',
|
|
|
+ style: '', // 不打印页眉和页脚
|
|
|
+ honorColor: true, // 是否打印彩色文本
|
|
|
+ targetStyles: ['*']
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
})
|
|
|
}
|