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.

84 lines
1.6 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
  1. import { MessageBox } from 'element-ui'
  2. import {getPrinterUrl} from '../api/label/printer'
  3. // ====页面动态加载C-Lodop云打印必须的文件CLodopfuncs.js====
  4. var head = document.head || document.getElementsByTagName('head')[0] || document.documentElement
  5. var oscript = document.createElement('script')
  6. // 让本机的浏览器打印(更优先一点):
  7. oscript = document.createElement('script')
  8. oscript.src = 'http://localhost:8000/CLodopfuncs.js?priority=2'
  9. head.insertBefore(oscript, head.firstChild)
  10. // 加载双端口(8000和18000)避免其中某个端口被占用:
  11. oscript = document.createElement('script')
  12. oscript.src = 'http://localhost:18000/CLodopfuncs.js?priority=1'
  13. head.insertBefore(oscript, head.firstChild)
  14. // 下载loadLodop
  15. function loadLodop() {
  16. window.open( window.SITE_CONFIG['baseUrl']+'/printer/download')
  17. }
  18. // ====获取LODOP对象的主过程:====
  19. function getLodop() {
  20. var LODOP
  21. try {
  22. LODOP = getCLodop()
  23. if (!LODOP && document.readyState !== 'complete') {
  24. MessageBox.alert('C-Lodop print control is not ready, please try again later!')
  25. return
  26. }
  27. return LODOP
  28. } catch (err) {
  29. MessageBox({
  30. title: 'Information',
  31. type: 'warning',
  32. confirmButtonText: 'Confirm',
  33. cancelButtonText: 'Cancel',
  34. zIndex: 3000,
  35. 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',
  36. callback: res => {
  37. if (res === 'confirm') {
  38. loadLodop()
  39. }
  40. }
  41. })
  42. }
  43. }
  44. export default getLodop