From 76766991b5e2fd5c7e85fdb1c8323f4dbacb4eb3 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 17 八月 2021 17:15:05 +0800 Subject: [PATCH] 2021-08-17 --- src/tabviews/zshare/actionList/printbutton/index.jsx | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 171 insertions(+), 0 deletions(-) diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index d22fe81..d90e50b 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -380,6 +380,177 @@ // eslint-disable-next-line let func = new Function('data', 'form', 'printer', 'notification', btn.verify.printFunc) func(printlist, formdata, btn.verify, notification) + + // 鑷畾涔夋墦鍗扮ず渚� + // let defaultPrinter = printer.defaultPrinter || 'lackprinter' + // let printers = {} + // if (printer.printerTypeList && printer.printerTypeList.length > 0) { + // printer.printerTypeList.forEach(cell => { + // if (cell.printer) { + // printers[cell.Value] = cell.printer + // } + // }) + // } + + // let jdList = [] + // let otherList = [] + // data.forEach(item => { + // if (item.CustomData) { + // item.CustomData = JSON.parse(item.CustomData.replace(/\n/g,"\\n").replace(/\r/g,"\\r")) + // } + // if (item.PrintData) { + // item.PrintData = JSON.parse(item.PrintData.replace(/\n/g,"\\n").replace(/\r/g,"\\r")) + // item.PrintData.data = {...form, ...item.PrintData.data} + // } + + // if (!item.PrintData) { + // return + // } + + // if (item.PrintData.ectype === 'jdpop') { + // jdList.push(item) + // } else { + // otherList.push(item) + // } + // }) + + // if (jdList.length === 0 && otherList.length === 0) { + // notification.warning({ + // top: 92, + // message: '鏃犳墦鍗版暟鎹紒', + // duration: 5 + // }) + // return + // } + + // let execPrint = (list, linkUrl) => { + // let printdata = {} + + // list.forEach(res => { + // let _printer = defaultPrinter + + // if (res.printType && printers[res.printType]) { + // _printer = printers[res.printType] + // } + + // printdata[_printer] = printdata[_printer] || [] + + // printdata[_printer].push(res) + // }) + + // let printerList = [] + + // Object.keys(printdata).forEach(printer => { + // let _documents = [] + // printdata[printer].forEach(item => { + // let _cell = { + // documentID: new Date().getTime().toString(), + // contents: [] + // } + + // if (item.PrintData) { + // _cell.contents.push(item.PrintData) + // } + // if (item.CustomData) { + // _cell.contents.push(item.CustomData) + // } + + // for (let i = 0; i < item.printCount; i++) { + // _documents.push(_cell) + // } + // }) + // printerList.push({ + // cmd: 'print', + // requestID: '', + // version: '', + // task: { + // taskID: new Date().getTime().toString(), + // preview: false, + // printer: printer, + // documents: _documents + // } + // }) + // }) + + // let lackItems = printerList.filter(cell => cell.task.printer === 'lackprinter')[0] + + // let socket = new WebSocket('ws://' + linkUrl) + + // // 鎵撳紑Socket + // socket.onopen = () =>{ + // if (lackItems) { + // let request = { + // requestID: '', + // version: '', + // cmd: 'getPrinters' + // } + // socket.send(JSON.stringify(request)) + // } else { + // printerList.forEach(cell => { + // socket.send(JSON.stringify(cell).replace(/\\r/g,"\r").replace(/\\n/g,"\n")) + // }) + + // notification.success({ + // top: 92, + // message: '鎵撳嵃璇锋眰宸插彂鍑恒��', + // duration: 2 + // }) + // } + // } + // // 鐩戝惉娑堟伅 + // socket.onmessage = (event) => { + // let data = '' + + // if (event.data) { + // try { + // data = JSON.parse(event.data) + // } catch { + // notification.warning({ + // top: 92, + // message: event.data, + // duration: 10 + // }) + // data = '' + // } + // } + + // if (data && data.cmd === 'getPrinters' && data.status) { + // printerList.forEach(cell => { + // if (cell.task.printer === 'lackprinter') { + // cell.task.printer = data.defaultPrinter + // } + // socket.send(JSON.stringify(cell).replace(/\\r/g,"\r").replace(/\\n/g,"\n")) + // }) + + // notification.success({ + // top: 92, + // message: '鎵撳嵃璇锋眰宸插彂鍑恒��', + // duration: 2 + // }) + // } else if (data && data.message && !data.status) { + // notification.warning({ + // top: 92, + // message: data.message, + // duration: 10 + // }) + // } + // } + + // socket.onerror = () => { + // notification.warning({ + // top: 92, + // message: '鏃犳硶杩炴帴鍒�:' + linkUrl, + // duration: 10 + // }) + // } + // } + + // if (jdList.length > 0) { + // execPrint(jdList, '127.0.0.1:13529') + // } + // if (otherList.length > 0) { + // execPrint(otherList, '127.0.0.1:13528') + // } } catch (e) { console.warn(e) -- Gitblit v1.8.0