|
@@ -1,5 +1,6 @@
|
|
|
import confirm from 'ant-design-vue/es/modal/confirm'
|
|
|
import notification from 'ant-design-vue/es/notification'
|
|
|
+import store from '@/store'
|
|
|
import { getLodop } from '@/libs/LodopFuncs'
|
|
|
import moment from 'moment'
|
|
|
// 打印页签,支持批量打印
|
|
@@ -121,6 +122,75 @@ export const blobToBaseByPdf = function(data,callback){
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+// pdf 直接打印
|
|
|
+export const pdfPrint = function (data){
|
|
|
+ const LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'))
|
|
|
+ if (!LODOP) {
|
|
|
+ confirm({
|
|
|
+ title: '提示?',
|
|
|
+ content: h => <div>打印控件未安装,请先下载并安装。安装完成后,刷新页面即可打印。</div>,
|
|
|
+ okText: '立即下载',
|
|
|
+ okType: 'danger',
|
|
|
+ cancelText: '暂不打印',
|
|
|
+ onOk () {
|
|
|
+ var agent = navigator.userAgent.toLowerCase();
|
|
|
+ if (agent.indexOf("win32") >= 0 || agent.indexOf("wow32") >= 0) {
|
|
|
+ window.open('https://iscm.360arrow.com/electron/CLodop.exe')
|
|
|
+ }else if (agent.indexOf("win64") >= 0 || agent.indexOf("wow64") >= 0) {
|
|
|
+ window.open('https://iscm.360arrow.com/electron/CLodop.exe')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1) // 隐藏底图上有模拟走纸板的条纹线
|
|
|
+ // LODOP.SET_PRINT_MODE('POS_BASEON_PAPER', true) // 可使输出以纸张边缘为基点
|
|
|
+ // 开始打印
|
|
|
+ const dlen = data.length
|
|
|
+ for(let i=0;i<dlen;i++){
|
|
|
+ LODOP.PRINT_INIT("")
|
|
|
+ LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', data[i])
|
|
|
+ LODOP.SET_PRINT_PAGESIZE(3, 2090, (i==dlen-1)?50:0, '')
|
|
|
+ LODOP.PRINT()
|
|
|
+ }
|
|
|
+}
|
|
|
+// pdf 打印预览
|
|
|
+export const pdfPrintView = function(data){
|
|
|
+ store.commit('SET_pdfPrintList', data)
|
|
|
+}
|
|
|
+// lodop 打印预览
|
|
|
+export const lodopPrintView = function(data){
|
|
|
+ const LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'))
|
|
|
+ if (!LODOP) {
|
|
|
+ confirm({
|
|
|
+ title: '提示?',
|
|
|
+ content: h => <div>打印控件未安装,请先下载并安装。安装完成后,刷新页面即可打印。</div>,
|
|
|
+ okText: '立即下载',
|
|
|
+ okType: 'danger',
|
|
|
+ cancelText: '暂不打印',
|
|
|
+ onOk () {
|
|
|
+ var agent = navigator.userAgent.toLowerCase();
|
|
|
+ if (agent.indexOf("win32") >= 0 || agent.indexOf("wow32") >= 0) {
|
|
|
+ window.open('https://iscm.360arrow.com/electron/CLodop.exe')
|
|
|
+ }else if (agent.indexOf("win64") >= 0 || agent.indexOf("wow64") >= 0) {
|
|
|
+ window.open('https://iscm.360arrow.com/electron/CLodop.exe')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1) // 隐藏底图上有模拟走纸板的条纹线
|
|
|
+ // LODOP.SET_PRINT_MODE('POS_BASEON_PAPER', true) // 可使输出以纸张边缘为基点
|
|
|
+ // 预览
|
|
|
+ const dlen = data.length
|
|
|
+ if(dlen > 1){
|
|
|
+ LODOP.SET_SHOW_MODE("HIDE_PBUTTIN_PREVIEW",1);//隐藏打印按钮
|
|
|
+ }
|
|
|
+ LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', data[0])
|
|
|
+ LODOP.SET_PRINT_PAGESIZE(3,2090,dlen>1?0:50,"");
|
|
|
+ LODOP.PREVIEW()
|
|
|
+}
|
|
|
+
|
|
|
// 打印控件
|
|
|
export const jGPrint = function (data, type, printerType) {
|
|
|
if (!data) {
|
|
@@ -128,46 +198,12 @@ export const jGPrint = function (data, type, printerType) {
|
|
|
}
|
|
|
// 针式打印
|
|
|
if (printerType == 'NEEDLE') {
|
|
|
- const LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'))
|
|
|
- if (!LODOP) {
|
|
|
- confirm({
|
|
|
- title: '提示?',
|
|
|
- content: h => <div>打印控件未安装,请先下载并安装。安装完成后,刷新页面即可打印。</div>,
|
|
|
- okText: '立即下载',
|
|
|
- okType: 'danger',
|
|
|
- cancelText: '暂不打印',
|
|
|
- onOk () {
|
|
|
- var agent = navigator.userAgent.toLowerCase();
|
|
|
- if (agent.indexOf("win32") >= 0 || agent.indexOf("wow32") >= 0) {
|
|
|
- window.open('https://iscm.360arrow.com/electron/CLodop.exe')
|
|
|
- }else if (agent.indexOf("win64") >= 0 || agent.indexOf("wow64") >= 0) {
|
|
|
- window.open('https://iscm.360arrow.com/electron/CLodop.exe')
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1) // 隐藏底图上有模拟走纸板的条纹线
|
|
|
- // LODOP.SET_PRINT_MODE('POS_BASEON_PAPER', true) // 可使输出以纸张边缘为基点
|
|
|
if (type == 'preview') { // 预览
|
|
|
- const dlen = data.data.length
|
|
|
- if(dlen > 1){
|
|
|
- LODOP.SET_SHOW_MODE("HIDE_PBUTTIN_PREVIEW",1);//隐藏打印按钮
|
|
|
- }
|
|
|
- LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', data.data[0])
|
|
|
- LODOP.SET_PRINT_PAGESIZE(3,2090,dlen>1?0:50,"");
|
|
|
- LODOP.PREVIEW()
|
|
|
+ // lodopPrintView(data.data)
|
|
|
+ pdfPrintView(data.data)
|
|
|
} else if (type == 'print') { // 打印
|
|
|
- const dlen = data.data.length
|
|
|
- for(let i=0;i<dlen;i++){
|
|
|
- LODOP.PRINT_INIT("")
|
|
|
- LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', data.data[i])
|
|
|
- LODOP.SET_PRINT_PAGESIZE(3, 2090, (i==dlen-1)?50:0, '')
|
|
|
- LODOP.PRINT()
|
|
|
- }
|
|
|
+ pdfPrint(data.data)
|
|
|
}
|
|
|
-
|
|
|
} else {
|
|
|
// 喷墨打印
|
|
|
const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
|