| | |
| | | |
| | | let printlist = [] |
| | | let templates = [] |
| | | let printCount = 1 |
| | | let printCount = +(formdata.printCount || formdata.PrintCount || formdata.printcount || formdata.Printcount || 1) |
| | | |
| | | if (formdata.printCount && typeof(formdata.printCount) === 'number' && formdata.printCount >= 1) { |
| | | printCount = formdata.printCount |
| | | if (isNaN(printCount) || printCount < 1) { |
| | | printCount = 1 |
| | | } |
| | | |
| | | new Promise(resolve => { |
| | | if (btn.intertype === 'system') { // 使用系统时,直接从表格或表单中选取数据 |
| | | let printcell = {} |
| | | |
| | | printcell.printType = formdata.printType || '' |
| | | printcell.printType = formdata.printType || formdata.PrintType || formdata.printtype || formdata.Printtype || '' |
| | | printcell.printCount = printCount |
| | | printcell.templateID = btn.verify.Template || '' |
| | | |
| | |
| | | // 系统打印数据,校验data字段 |
| | | if (btn.verify.printMode !== 'custom' && (!cell.data || cell.data.length === 0)) return |
| | | |
| | | cell.templateID = cell.templateID || btn.verify.Template |
| | | cell.printType = cell.printType || formdata.printType || '' |
| | | cell.templateID = cell.templateID || cell.TemplateID || cell.Templateid || cell.templateid || btn.verify.Template |
| | | cell.printType = cell.printType || cell.PrintType || cell.printtype || cell.Printtype || formdata.printType || formdata.PrintType || formdata.printtype || formdata.Printtype || '' |
| | | |
| | | let _printCount = printCount |
| | | if (cell.printCount && typeof(cell.printCount) === 'number' && cell.printCount >= 1) { |
| | | _printCount = cell.printCount |
| | | let _printCount = +(cell.printCount || cell.PrintCount || cell.printcount || cell.Printcount || 0) |
| | | |
| | | if (isNaN(_printCount) || _printCount < 1) { |
| | | _printCount = printCount |
| | | } |
| | | |
| | | cell.printCount = _printCount |
| | |
| | | task: { |
| | | taskID: Utils.getuuid(), |
| | | preview: false, |
| | | printer: printer, |
| | | printer: printer === 'lackprinter' ? '' : printer, |
| | | documents: [_cell] |
| | | } |
| | | }) |
| | |
| | | return |
| | | } |
| | | |
| | | let lackItems = printerList.filter(cell => cell.task.printer === 'lackprinter')[0] |
| | | // let lackItems = printerList.filter(cell => cell.task.printer === 'lackprinter')[0] |
| | | |
| | | if (!socket || socket.readyState !== 1 || socket.url !== 'ws://' + btn.verify.linkUrl) { |
| | | socket = new WebSocket('ws://' + btn.verify.linkUrl) |
| | | } else { |
| | | if (lackItems) { |
| | | let request = { |
| | | requestID: '', |
| | | version: '', |
| | | cmd: 'getPrinters' |
| | | } |
| | | socket.send(JSON.stringify(request)) |
| | | } else { |
| | | // if (lackItems) { |
| | | // let request = { |
| | | // requestID: '', |
| | | // version: '', |
| | | // cmd: 'getPrinters' |
| | | // } |
| | | // socket.send(JSON.stringify(request)) |
| | | // } else { |
| | | this.syncMessageSend(printerList) |
| | | |
| | | this.execSuccess({ |
| | |
| | | ErrMesg: '打印请求已发出。', |
| | | status: true |
| | | }) |
| | | } |
| | | // } |
| | | } |
| | | |
| | | // 打开Socket |
| | | socket.onopen = () =>{ |
| | | if (lackItems) { |
| | | let request = { |
| | | requestID: '', |
| | | version: '', |
| | | cmd: 'getPrinters' |
| | | } |
| | | socket.send(JSON.stringify(request)) |
| | | } else { |
| | | // if (lackItems) { |
| | | // let request = { |
| | | // requestID: '', |
| | | // version: '', |
| | | // cmd: 'getPrinters' |
| | | // } |
| | | // socket.send(JSON.stringify(request)) |
| | | // } else { |
| | | this.syncMessageSend(printerList) |
| | | |
| | | this.execSuccess({ |
| | |
| | | ErrMesg: '打印请求已发出。', |
| | | status: true |
| | | }) |
| | | } |
| | | // } |
| | | } |
| | | // 监听消息 |
| | | socket.onmessage = (event) => { |
| | |
| | | } |
| | | } |
| | | |
| | | if (data && data.cmd === 'getPrinters' && data.status) { |
| | | printerList = printerList.map(cell => { |
| | | if (cell.task.printer === 'lackprinter') { |
| | | cell.task.printer = data.defaultPrinter |
| | | } |
| | | return cell |
| | | }) |
| | | // if (data && data.cmd === 'getPrinters' && data.status) { |
| | | // printerList = printerList.map(cell => { |
| | | // if (cell.task.printer === 'lackprinter') { |
| | | // cell.task.printer = data.defaultPrinter |
| | | // } |
| | | // return cell |
| | | // }) |
| | | |
| | | this.syncMessageSend(printerList) |
| | | // this.syncMessageSend(printerList) |
| | | |
| | | this.execSuccess({ |
| | | ErrCode: 'S', |
| | | message: '', |
| | | ErrMesg: '打印请求已发出。', |
| | | status: true |
| | | }) |
| | | } else if (data && data.message && !data.status) { |
| | | // this.execSuccess({ |
| | | // ErrCode: 'S', |
| | | // message: '', |
| | | // ErrMesg: '打印请求已发出。', |
| | | // status: true |
| | | // }) |
| | | // } else if (data && data.message && !data.status) { |
| | | if (data && data.message && !data.status) { |
| | | this.execError({ |
| | | ErrCode: 'N', |
| | | message: data.message, |