|
@@ -56,7 +56,83 @@ window.onload = function() {
|
|
|
} else if (json.cmd == 'show') {
|
|
|
indexFn.initPage(json.data)
|
|
|
} else if(json.cmd=='print'){
|
|
|
- console.log('print')
|
|
|
+ // console.log('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: ['*']
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if(json.cmd=='download'){
|
|
|
+ //console.log('down');
|
|
|
+ console.log(json.data.dtype);
|
|
|
+ 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 = ''
|
|
|
+ }
|
|
|
+ let data = {
|
|
|
+ bottomMargin: "10",
|
|
|
+ leftMargin: "10",
|
|
|
+ orientation: "2",
|
|
|
+ paperSize: "9",
|
|
|
+ printArea: "",
|
|
|
+ printQuality: "1",
|
|
|
+ printScale: "1",
|
|
|
+ printType: "1",
|
|
|
+ rightMargin: "10",
|
|
|
+ scale: "",
|
|
|
+ topMargin: "10",
|
|
|
+ wordQuality: "600"
|
|
|
+ };
|
|
|
+ layui.excelUtil.xlsxToPdf({
|
|
|
+ data,
|
|
|
+ success: (json) => {
|
|
|
+ let fileName = localStorage.getItem('url') + '/' + json.data;
|
|
|
+ console.log(fileName);
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -155,49 +231,6 @@ const indexFn = {
|
|
|
callback()
|
|
|
return
|
|
|
}
|
|
|
- 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: ['*']
|
|
|
- });
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
})
|
|
|
}
|