|
@@ -1,7 +1,7 @@
|
|
|
import confirm from 'ant-design-vue/es/modal/confirm'
|
|
|
import notification from 'ant-design-vue/es/notification'
|
|
|
import { getLodop } from '@/libs/LodopFuncs'
|
|
|
-import { printLogSave } from '@/api/data'
|
|
|
+import { printLogSave, printLogSaveBatch } from '@/api/data'
|
|
|
import moment from 'moment'
|
|
|
// 打印页签,支持批量打印
|
|
|
export const JGPrintTag = function (html, width, height, data) {
|
|
@@ -14,29 +14,29 @@ export const JGPrintTag = function (html, width, height, data) {
|
|
|
okType: 'danger',
|
|
|
cancelText: '暂不打印',
|
|
|
onOk () {
|
|
|
- var agent = navigator.userAgent.toLowerCase();
|
|
|
- if (agent.indexOf("win32") >= 0 || agent.indexOf("wow32") >= 0) {
|
|
|
- window.open('http://www.lodop.net/demolist/CLodop_Setup_for_Win32NT.zip')
|
|
|
- }else if (agent.indexOf("win64") >= 0 || agent.indexOf("wow64") >= 0) {
|
|
|
- window.open('http://www.lodop.net/download/CLodop_Setup_for_Win64NT_4.155EN.zip')
|
|
|
+ var agent = navigator.userAgent.toLowerCase()
|
|
|
+ if (agent.indexOf('win32') >= 0 || agent.indexOf('wow32') >= 0) {
|
|
|
+ window.open('http://www.lodop.net/demolist/CLodop_Setup_for_Win32NT.zip')
|
|
|
+ } else if (agent.indexOf('win64') >= 0 || agent.indexOf('wow64') >= 0) {
|
|
|
+ window.open('http://www.lodop.net/download/CLodop_Setup_for_Win64NT_4.155EN.zip')
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
- LODOP.PRINT_INIT("")
|
|
|
+ LODOP.PRINT_INIT('')
|
|
|
LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1) // 隐藏底图上有模拟走纸板的条纹线
|
|
|
LODOP.SET_PRINT_MODE('POS_BASEON_PAPER', true) // 可使输出以纸张边缘为基点
|
|
|
LODOP.ADD_PRINT_HTML(0, 0, '100%', '100%', html)
|
|
|
- LODOP.ADD_PRINT_BARCODE('36%','65%',90,90,"QRCode",data.qrCodeContent)
|
|
|
- LODOP.SET_PRINT_STYLEA(0,"QRCodeVersion",5)
|
|
|
+ LODOP.ADD_PRINT_BARCODE('36%', '65%', 90, 90, 'QRCode', data.qrCodeContent)
|
|
|
+ LODOP.SET_PRINT_STYLEA(0, 'QRCodeVersion', 5)
|
|
|
// LODOP.SET_PRINT_STYLEA(0,"QRCodeErrorLevel",'H')
|
|
|
LODOP.SET_PRINT_COPIES(data.printQty)// 指定份数
|
|
|
LODOP.SET_PRINT_PAGESIZE(1, width, height)
|
|
|
LODOP.PRINT()
|
|
|
}
|
|
|
// 导出文件
|
|
|
-export const exportExcel = function(url,params,fileName,callback,noShowTime){
|
|
|
+export const exportExcel = function (url, params, fileName, callback, noShowTime) {
|
|
|
url(params).then(res => {
|
|
|
if (res.type == 'application/json') {
|
|
|
var reader = new FileReader()
|
|
@@ -49,7 +49,7 @@ export const exportExcel = function(url,params,fileName,callback,noShowTime){
|
|
|
})
|
|
|
reader.readAsText(res)
|
|
|
} else {
|
|
|
- downloadExcel(res,fileName,noShowTime)
|
|
|
+ downloadExcel(res, fileName, noShowTime)
|
|
|
}
|
|
|
callback()
|
|
|
})
|
|
@@ -76,7 +76,7 @@ export const downloadExcel = function (data, fileName, noShowTime) {
|
|
|
}
|
|
|
|
|
|
// pdf blob 转 base64
|
|
|
-export const blobToBaseByPdf = function(data,callback){
|
|
|
+export const blobToBaseByPdf = function (data, callback) {
|
|
|
const reader = new FileReader()
|
|
|
reader.readAsDataURL(new Blob([data], { type: 'application/pdf' }))
|
|
|
reader.addEventListener('load', () => {
|
|
@@ -85,75 +85,75 @@ export const blobToBaseByPdf = function(data,callback){
|
|
|
}
|
|
|
|
|
|
// 打印html
|
|
|
-export const jGPrint = function (data, type, callback, printLogParams,printPageSize) {
|
|
|
- if (!data) {
|
|
|
- return
|
|
|
- }
|
|
|
- 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('http://www.lodop.net/demolist/CLodop_Setup_for_Win32NT.zip')
|
|
|
- }else if (agent.indexOf("win64") >= 0 || agent.indexOf("wow64") >= 0) {
|
|
|
- window.open('http://www.lodop.net/download/CLodop_Setup_for_Win64NT_4.155EN.zip')
|
|
|
- }
|
|
|
+export const jGPrint = function (data, type, callback, printLogParams, printPageSize) {
|
|
|
+ if (!data) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ 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('http://www.lodop.net/demolist/CLodop_Setup_for_Win32NT.zip')
|
|
|
+ } else if (agent.indexOf('win64') >= 0 || agent.indexOf('wow64') >= 0) {
|
|
|
+ window.open('http://www.lodop.net/download/CLodop_Setup_for_Win64NT_4.155EN.zip')
|
|
|
}
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1) // 隐藏底图上有模拟走纸板的条纹线
|
|
|
- //执行该语句之后,PRINT指令不再返回那个所谓“打印成功”,才能获取到打印状态
|
|
|
- LODOP.SET_PRINT_MODE("CATCH_PRINT_STATUS",true);
|
|
|
- //TaskID:任务id,Value:job代码
|
|
|
- LODOP.On_Return=function(TaskID,Value){
|
|
|
- console.log(TaskID,Value)
|
|
|
- // 已打印
|
|
|
- if(Value&&printLogParams){
|
|
|
- console.log('已打印,统计打印次数')
|
|
|
- printLog(printLogParams,callback)
|
|
|
- }else{
|
|
|
- callback()
|
|
|
- }
|
|
|
- };
|
|
|
- if(printPageSize){
|
|
|
- LODOP.ADD_PRINT_HTM(0,0,'100%','99%',data);
|
|
|
- LODOP.SET_PRINT_PAGESIZE(3,'210mm',100,"")
|
|
|
- }else{
|
|
|
- LODOP.ADD_PRINT_HTM('1cm',0,'100%','99%',data);
|
|
|
- LODOP.SET_SHOW_MODE("BKIMG_PRINT",0);
|
|
|
- }
|
|
|
- if (type == 'preview') { // 预览
|
|
|
- LODOP.PREVIEW()
|
|
|
- } else if (type == 'print') { // 打印
|
|
|
- LODOP.PRINTA()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1) // 隐藏底图上有模拟走纸板的条纹线
|
|
|
+ // 执行该语句之后,PRINT指令不再返回那个所谓“打印成功”,才能获取到打印状态
|
|
|
+ LODOP.SET_PRINT_MODE('CATCH_PRINT_STATUS', true)
|
|
|
+ // TaskID:任务id,Value:job代码
|
|
|
+ LODOP.On_Return = function (TaskID, Value) {
|
|
|
+ console.log(TaskID, Value)
|
|
|
+ // 已打印
|
|
|
+ if (Value && printLogParams) {
|
|
|
+ console.log('已打印,统计打印次数')
|
|
|
+ printLog(printLogParams, callback)
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
}
|
|
|
+ }
|
|
|
+ if (printPageSize) {
|
|
|
+ LODOP.ADD_PRINT_HTM(0, 0, '100%', '99%', data)
|
|
|
+ LODOP.SET_PRINT_PAGESIZE(3, '210mm', 100, '')
|
|
|
+ } else {
|
|
|
+ LODOP.ADD_PRINT_HTM('1cm', 0, '100%', '99%', data)
|
|
|
+ LODOP.SET_SHOW_MODE('BKIMG_PRINT', 0)
|
|
|
+ }
|
|
|
+ if (type == 'preview') { // 预览
|
|
|
+ LODOP.PREVIEW()
|
|
|
+ } else if (type == 'print') { // 打印
|
|
|
+ LODOP.PRINTA()
|
|
|
+ }
|
|
|
}
|
|
|
// 浏览器打印pdf功能
|
|
|
-export const winPrintPdf = function(data,type,callback){
|
|
|
+export const winPrintPdf = function (data, type, callback) {
|
|
|
if (!data) {
|
|
|
return
|
|
|
}
|
|
|
const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
|
|
|
document.getElementById('print').innerHTML = '<iframe id="printfbod" name="printfbod" src="' + url + '" hidden></iframe>'
|
|
|
- window.frames['printfbod'].onload = function(){
|
|
|
+ window.frames['printfbod'].onload = function () {
|
|
|
callback()
|
|
|
}
|
|
|
- if(type == 'orginPrint'){
|
|
|
+ if (type == 'orginPrint') {
|
|
|
window.frames['printfbod'].focus()
|
|
|
window.frames['printfbod'].print()
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
window.open(url)
|
|
|
}
|
|
|
}
|
|
|
// 打印
|
|
|
-export const printFun = function(url,params,type,taskName,callback,printLogParams,hidePrint){
|
|
|
+export const printFun = function (url, params, type, taskName, callback, printLogParams, hidePrint) {
|
|
|
url(params).then(res => {
|
|
|
if (res.type == 'application/json') {
|
|
|
var reader = new FileReader()
|
|
@@ -166,95 +166,104 @@ export const printFun = function(url,params,type,taskName,callback,printLogParam
|
|
|
})
|
|
|
reader.readAsText(res)
|
|
|
} else {
|
|
|
- console.log(res,'printFun')
|
|
|
- // 使用浏览器自带打印功能
|
|
|
- if(type == 'orginPrint'||type=='orginPreview'){
|
|
|
- winPrintPdf(res,type,callback)
|
|
|
- }else{
|
|
|
- jGPrintPdf(res,type,taskName,printLogParams,callback,hidePrint)
|
|
|
- }
|
|
|
+ console.log(res, 'printFun')
|
|
|
+ // 使用浏览器自带打印功能
|
|
|
+ if (type == 'orginPrint' || type == 'orginPreview') {
|
|
|
+ winPrintPdf(res, type, callback)
|
|
|
+ } else {
|
|
|
+ jGPrintPdf(res, type, taskName, printLogParams, callback, hidePrint)
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
// 获取系统信息
|
|
|
-export const getSystemInfo = function (strINFOType,callback){
|
|
|
- LODOP=getLodop();
|
|
|
- if (LODOP.CVERSION) CLODOP.On_Return=function(TaskID,Value){callback(Value)};
|
|
|
- var strResult=LODOP.GET_SYSTEM_INFO(strINFOType);
|
|
|
- if (!LODOP.CVERSION) return strResult; else return "";
|
|
|
- }
|
|
|
+export const getSystemInfo = function (strINFOType, callback) {
|
|
|
+ LODOP = getLodop()
|
|
|
+ if (LODOP.CVERSION) CLODOP.On_Return = function (TaskID, Value) { callback(Value) }
|
|
|
+ var strResult = LODOP.GET_SYSTEM_INFO(strINFOType)
|
|
|
+ if (!LODOP.CVERSION) return strResult; else return ''
|
|
|
+}
|
|
|
// 打印记录保存
|
|
|
-export const printLog = function(data,callback){
|
|
|
- getSystemInfo('NetworkAdapter.1.IPAddress',function(ret){
|
|
|
- data.printIp = ret
|
|
|
- printLogSave(data).then(res => {
|
|
|
- callback(res)
|
|
|
- })
|
|
|
+export const printLog = function (data, callback) {
|
|
|
+ getSystemInfo('NetworkAdapter.1.IPAddress', function (ret) {
|
|
|
+ // 批量处理
|
|
|
+ if (data instanceof Array) {
|
|
|
+ data.map(item => { item.printIp = ret })
|
|
|
+ printLogSaveBatch(data).then(res => {
|
|
|
+ callback(res)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 单条处理
|
|
|
+ data.printIp = ret
|
|
|
+ printLogSave(data).then(res => {
|
|
|
+ callback(res)
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
// 打印pdf
|
|
|
-export const jGPrintPdf = function (data, type, taskName, printLogParams,callback,hidePrint) {
|
|
|
- if (!data) {
|
|
|
- return
|
|
|
- }
|
|
|
- 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('http://www.lodop.net/demolist/CLodop_Setup_for_Win32NT.zip')
|
|
|
- }else if (agent.indexOf("win64") >= 0 || agent.indexOf("wow64") >= 0) {
|
|
|
- window.open('http://www.lodop.net/download/CLodop_Setup_for_Win64NT_4.155EN.zip')
|
|
|
- }
|
|
|
+export const jGPrintPdf = function (data, type, taskName, printLogParams, callback, hidePrint) {
|
|
|
+ if (!data) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ 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('http://www.lodop.net/demolist/CLodop_Setup_for_Win32NT.zip')
|
|
|
+ } else if (agent.indexOf('win64') >= 0 || agent.indexOf('wow64') >= 0) {
|
|
|
+ window.open('http://www.lodop.net/download/CLodop_Setup_for_Win64NT_4.155EN.zip')
|
|
|
}
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- blobToBaseByPdf(data, function (dataurl) {
|
|
|
- // console.log(dataurl)
|
|
|
- LODOP.PRINT_INIT(taskName)
|
|
|
- LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1) // 隐藏底图上有模拟走纸板的条纹线
|
|
|
- //执行该语句之后,PRINT指令不再返回那个所谓“打印成功”,才能获取到打印状态
|
|
|
- LODOP.SET_PRINT_MODE("CATCH_PRINT_STATUS",true);
|
|
|
- // 隐藏打印按钮
|
|
|
- if(hidePrint){
|
|
|
- LODOP.SET_SHOW_MODE("HIDE_PBUTTIN_PREVIEW",true);
|
|
|
- }
|
|
|
- //TaskID:任务id,Value:job代码
|
|
|
- LODOP.On_Return=function(TaskID,Value){
|
|
|
- console.log(TaskID,Value)
|
|
|
- // 已打印
|
|
|
- if(Value&&printLogParams){
|
|
|
- console.log('已打印,统计打印次数')
|
|
|
- printLog(printLogParams,callback)
|
|
|
- }else{
|
|
|
- callback()
|
|
|
- }
|
|
|
- };
|
|
|
- LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', dataurl.replace('data:application/pdf;base64,', ''))
|
|
|
- LODOP.SET_PRINT_PAGESIZE(3,2090,30,"");
|
|
|
- if (type == 'preview') { // 预览
|
|
|
- LODOP.PREVIEW()
|
|
|
- } else if (type == 'print') { // 打印
|
|
|
- LODOP.PRINTA()
|
|
|
}
|
|
|
})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ blobToBaseByPdf(data, function (dataurl) {
|
|
|
+ // console.log(dataurl)
|
|
|
+ LODOP.PRINT_INIT(taskName)
|
|
|
+ LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1) // 隐藏底图上有模拟走纸板的条纹线
|
|
|
+ // 执行该语句之后,PRINT指令不再返回那个所谓“打印成功”,才能获取到打印状态
|
|
|
+ LODOP.SET_PRINT_MODE('CATCH_PRINT_STATUS', true)
|
|
|
+ // 隐藏打印按钮
|
|
|
+ if (hidePrint) {
|
|
|
+ LODOP.SET_SHOW_MODE('HIDE_PBUTTIN_PREVIEW', true)
|
|
|
+ }
|
|
|
+ // TaskID:任务id,Value:job代码
|
|
|
+ LODOP.On_Return = function (TaskID, Value) {
|
|
|
+ console.log(TaskID, Value)
|
|
|
+ // 已打印
|
|
|
+ if (Value && printLogParams) {
|
|
|
+ console.log('已打印,统计打印次数')
|
|
|
+ printLog(printLogParams, callback)
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', dataurl.replace('data:application/pdf;base64,', ''))
|
|
|
+ LODOP.SET_PRINT_PAGESIZE(3, 2090, 30, '')
|
|
|
+ if (type == 'preview') { // 预览
|
|
|
+ LODOP.PREVIEW()
|
|
|
+ } else if (type == 'print') { // 打印
|
|
|
+ LODOP.PRINTA()
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// 获取打印机状态
|
|
|
-export const getStatusValue = function (ValueType,ValueIndex,callback){
|
|
|
- const LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'))
|
|
|
- if (LODOP.CVERSION) {
|
|
|
- LODOP.On_Return=function(TaskID,Value){
|
|
|
- callback(Value)
|
|
|
- };
|
|
|
+export const getStatusValue = function (ValueType, ValueIndex, callback) {
|
|
|
+ const LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'))
|
|
|
+ if (LODOP.CVERSION) {
|
|
|
+ LODOP.On_Return = function (TaskID, Value) {
|
|
|
+ callback(Value)
|
|
|
}
|
|
|
- var strResult=LODOP.GET_VALUE(ValueType,ValueIndex);
|
|
|
- if (!LODOP.CVERSION) return callback(strResult); else return callback('');
|
|
|
- }
|
|
|
+ }
|
|
|
+ var strResult = LODOP.GET_VALUE(ValueType, ValueIndex)
|
|
|
+ if (!LODOP.CVERSION) return callback(strResult); else return callback('')
|
|
|
+}
|