You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
import { MessageBox } from 'element-ui'import {getPrinterUrl} from '../api/label/printer'
// ====页面动态加载C-Lodop云打印必须的文件CLodopfuncs.js====
var head = document.head || document.getElementsByTagName('head')[0] || document.documentElement
var oscript = document.createElement('script')
// 让本机的浏览器打印(更优先一点):
oscript = document.createElement('script')
oscript.src = 'http://localhost:8000/CLodopfuncs.js?priority=2'
head.insertBefore(oscript, head.firstChild)
// 加载双端口(8000和18000)避免其中某个端口被占用:
oscript = document.createElement('script')
oscript.src = 'http://localhost:18000/CLodopfuncs.js?priority=1'
head.insertBefore(oscript, head.firstChild)
// 下载loadLodop
function loadLodop() {
window.open( window.SITE_CONFIG['baseUrl']+'/printer/download')
}
// ====获取LODOP对象的主过程:====
function getLodop() {
var LODOP
try {
LODOP = getCLodop()
if (!LODOP && document.readyState !== 'complete') {
MessageBox.alert('C-Lodop print control is not ready, please try again later!')
return
}
return LODOP
} catch (err) {
MessageBox({
title: 'Information',
type: 'warning',
confirmButtonText: 'Confirm', cancelButtonText: 'Cancel', zIndex: 3000,
message: 'You haven’t install the printing component, you can follow the steps in Manual to complete the installation, then close and reopen the window again, it should be fixed',
callback: res => {
if (res === 'confirm') {
loadLodop()
}
}
})
}
}
export default getLodop
|