From ab949bb71eadda3ec1736ccdcfaa1b12b04cce6a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 05 十一月 2023 10:35:56 +0800 Subject: [PATCH] Merge branch 'develop' --- src/tabviews/zshare/actionList/printbutton/index.jsx | 98 +++++++++++++++++++++++++++++++------------------ 1 files changed, 62 insertions(+), 36 deletions(-) diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index b55792d..a6a037c 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -270,6 +270,9 @@ Object.keys(cell).forEach(key => { let _key = key.toLowerCase() + + if (/^\$/.test(_key)) return + _cell[_key] = cell[key] }) @@ -564,16 +567,28 @@ execCustomPrint = (printlist, formdata) => { const { btn } = this.props - this.execSuccess({ - ErrCode: '-1', - message: '', - status: true - }) + let callback = null + + if (/callback\(\)/.test(btn.verify.printFunc)) { + callback = () => { + this.execSuccess({ + ErrCode: '-1', + message: '', + status: true + }) + } + } else { + this.execSuccess({ + ErrCode: '-1', + message: '', + status: true + }) + } try { // eslint-disable-next-line - let func = new Function('data', 'form', 'printer', 'notification', 'Api', 'systemType', btn.verify.printFunc) - func(printlist, formdata, btn.verify, notification, Api, window.GLOB.systemType) + let func = new Function('data', 'form', 'printer', 'notification', 'Api', 'systemType', 'callback', btn.verify.printFunc) + func(printlist, formdata, btn.verify, notification, Api, window.GLOB.systemType, callback) // 鑷畾涔夋墦鍗扮ず渚� // let defaultPrinter = printer.defaultPrinter || 'lackprinter' @@ -769,18 +784,11 @@ } catch (e) { console.warn(e) - try { - // eslint-disable-next-line - let evalfunc = eval('(true && function (data, form, printer, notification, Api, systemType) {' + btn.verify.printFunc + '})') - evalfunc(printlist, formdata, btn.verify, notification, Api, window.GLOB.systemType) - } catch (error) { - console.warn(error) - notification.warning({ - top: 92, - message: '鑷畾涔夊嚱鏁版墽琛岄敊璇紒', - duration: 5 - }) - } + notification.warning({ + top: 92, + message: '鑷畾涔夊嚱鏁版墽琛岄敊璇紒', + duration: 5 + }) } } @@ -1761,26 +1769,35 @@ return } + if (printerList.length === 0) { + this.execSuccess({ + ErrCode: '-1', + message: '鏈幏鍙栧埌鎵撳嵃淇℃伅锛�', + status: true + }) + return + } + if (!socket || socket.readyState !== 1 || socket.url !== 'ws://' + btn.verify.linkUrl) { socket = new WebSocket('ws://' + btn.verify.linkUrl) } else { - this.syncMessageSend(printerList) - - this.execSuccess({ - ErrCode: 'S', - message: '鎵撳嵃璇锋眰宸插彂鍑恒��', - status: true + this.syncMessageSend(printerList, () => { + this.execSuccess({ + ErrCode: 'S', + message: '鎵撳嵃璇锋眰宸插彂鍑恒��', + status: true + }) }) } // 鎵撳紑Socket socket.onopen = () =>{ - this.syncMessageSend(printerList) - - this.execSuccess({ - ErrCode: 'S', - message: '鎵撳嵃璇锋眰宸插彂鍑恒��', - status: true + this.syncMessageSend(printerList, () => { + this.execSuccess({ + ErrCode: 'S', + message: '鎵撳嵃璇锋眰宸插彂鍑恒��', + status: true + }) }) } // 鐩戝惉娑堟伅 @@ -1835,17 +1852,26 @@ } } - syncMessageSend = (list) => { + syncMessageSend = (list, callback) => { let param = list.shift() - if (socket && param) { - socket.send(JSON.stringify(param)) + if (socket) { + try { + socket.send(JSON.stringify(param)) + } catch(e) { + console.warn('鎵撳嵃璇锋眰鍙戦�佸け璐ワ紒') + } } - if (list && list.length > 0) { - setTimeout(() => {this.syncMessageSend(list)}, 3000) + if (list.length > 0) { + setTimeout(() => { + this.syncMessageSend(list, callback) + }, 3000) + } else { + callback() } } + /** * @description 鎿嶄綔鎴愬姛鍚庡鐞� * 1銆乪xcel瀵煎嚭锛屾垚鍔熷悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬� -- Gitblit v1.8.0