|
@@ -406,6 +406,87 @@ export const jGPrintPdf = function (data, type, taskName, printLogParams, callba
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// printBase64Fun
|
|
|
|
+export const printBase64Fun = function (url, params, type, taskName, callback, printLogParams, hidePrint) {
|
|
|
|
+ url(params).then(res => {
|
|
|
|
+ if (res.type == 'application/json') {
|
|
|
|
+ var reader = new FileReader()
|
|
|
|
+ reader.addEventListener('loadend', function () {
|
|
|
|
+ const obj = JSON.parse(reader.result)
|
|
|
|
+ notification.error({
|
|
|
|
+ message: '提示',
|
|
|
|
+ description: obj.message
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ reader.readAsText(res)
|
|
|
|
+ } else {
|
|
|
|
+ console.log(res, 'printFun')
|
|
|
|
+ // 使用浏览器自带打印功能
|
|
|
|
+ if (type == 'orginPrint' || type == 'orginPreview') {
|
|
|
|
+ winPrintPdf(res, type, callback)
|
|
|
|
+ } else {
|
|
|
|
+ jGPrintBase64Pdf(res.data[0], type, taskName, printLogParams, callback, hidePrint)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+// 打印pdf
|
|
|
|
+export const jGPrintBase64Pdf = function (dataurl, type, taskName, printLogParams, callback, hidePrint) {
|
|
|
|
+ if (!dataurl) {
|
|
|
|
+ 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.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!=0, printLogParams)
|
|
|
|
+ // 已打印
|
|
|
|
+ if (Value!=0) {
|
|
|
|
+ if(printLogParams){
|
|
|
|
+ console.log('已打印,统计打印次数')
|
|
|
|
+ printLog(printLogParams, callback)
|
|
|
|
+ }else{
|
|
|
|
+ callback({status:200,message:'打印已完成'})
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ callback()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', dataurl)
|
|
|
|
+ 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) {
|
|
export const getStatusValue = function (ValueType, ValueIndex, callback) {
|
|
const LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'))
|
|
const LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'))
|