From c39ea1f23d21b070188abcf5f4dd5bdd7b47c1f9 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 10 三月 2020 10:32:13 +0800 Subject: [PATCH] 2020-03-10 --- src/tabviews/tableshare/actionList/index.jsx | 143 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 139 insertions(+), 4 deletions(-) diff --git a/src/tabviews/tableshare/actionList/index.jsx b/src/tabviews/tableshare/actionList/index.jsx index dbb9143..31c03eb 100644 --- a/src/tabviews/tableshare/actionList/index.jsx +++ b/src/tabviews/tableshare/actionList/index.jsx @@ -11,6 +11,7 @@ import './index.scss' const { confirm } = Modal +let socket = null class MainAction extends Component { static propTpyes = { @@ -185,7 +186,25 @@ if (item.funcType === 'changeuser') { this.changeUser(item, data) } else if (item.funcType === 'print') { - this.triggerPrint(item, data) + if (item.execMode === 'pop') { + this.setState({ + execAction: item, + tabledata: data, + btnloading: true + }, () => { + this.improveAction(item) + }) + } else if (item.execMode === 'prompt') { + confirm({ + title: this.props.dict['main.action.confirm.tip'], + onOk() { + _this.triggerPrint(item, data) + }, + onCancel() {} + }) + } else { + this.triggerPrint(item, data) + } } } else { notification.warning({ @@ -199,8 +218,10 @@ /** * @description 瑙﹀彂鎵撳嵃 */ - triggerPrint = (item, data) => { + triggerPrint = (item, data, formdata) => { console.log(item) + console.log(data) + console.log(formdata) if (!item.verify || !item.verify.Template || !item.verify.linkUrl) { notification.warning({ top: 92, @@ -224,7 +245,33 @@ Api.getLocalConfig(param).then(res => { if (res.status) { - resolve(res) + + if (!res.ConfigParam) { + notification.warning({ + top: 92, + message: '鏈幏鍙栧埌鎵撳嵃妯℃澘淇℃伅锛�', + duration: 15 + }) + resolve(false) + } else { + let configParam = '' + + try { + configParam = JSON.parse(window.decodeURIComponent(window.atob(res.ConfigParam))) + } catch (e) { + configParam = '' + } + + if (!configParam) { + notification.warning({ + top: 92, + message: '鎵撳嵃妯℃澘瑙f瀽閿欒锛�', + duration: 15 + }) + } else { + resolve(configParam) + } + } } else { this.execError(res, item) resolve(false) @@ -233,7 +280,87 @@ }).then(res => { console.log(res) if (!res) return - + + if (!socket || socket.readyState !== 1 || socket.url !== 'ws://' + item.verify.linkUrl) { + socket = new WebSocket('ws://' + item.verify.linkUrl) + } + // 鎵撳紑Socket + socket.onopen = () =>{ + if (!item.printer) { + let request = { + requestID: '', + version: '', + cmd: 'getPrinters' + } + socket.send(JSON.stringify(request)) + } else { + let printdata = { + cmd: 'print', + requestID: '', + version: '', + task: { + taskID: '1', + preview: false, + printer: item.printer, + documents: [ + { + documentID: '9890000106027', + contents: [ + { + data: { + barcode: '12345' + }, + templateURL: '{"Version":"","Title":"1234","Author":"U000000001","Description":"","PrintTempNO":"","PageSetting":{"Width":210,"Height":297,"Left":"0","Right":"0","Top":"0","Bottom":"0","Landscape":false},"PageHeader":[],"ReportHeader":{"Control":[{"Name":"","Type":"barcode","Value":"","Field":"barcode","Left":71,"Top":32,"Width":52,"Height":26,"Rotate":0,"BorderSize":0.1,"BorderColor":"black","Align":"center","VerticalAlign":"middle","BackColor":"white","ForeColor":"black","BarcodeType":"code128","BarcodeWidth":31,"BarcodeHeight":10,"BarcodeLabel":true,"LabelSize":12}]},"ReportFooter":[],"PageFooter":[]}' + } + ] + } + ] + } + } + + socket.send(JSON.stringify(printdata)) + } + } + // 鐩戝惉娑堟伅 + socket.onmessage = (event) => { + let data = JSON.parse(event.data) + + if (data.defaultPrinter) { + let printdata = { + cmd: 'print', + requestID: '', + version: '', + task: { + taskID: '1', + preview: false, + printer: data.defaultPrinter, + documents: [ + { + documentID: '9890000106027', + contents: [ + { + data: { + barcode: '12345' + }, + templateURL: '{"Version":"","Title":"1234","Author":"U000000001","Description":"","PrintTempNO":"","PageSetting":{"Width":210,"Height":297,"Left":"0","Right":"0","Top":"0","Bottom":"0","Landscape":false},"PageHeader":[],"ReportHeader":{"Control":[{"Name":"","Type":"barcode","Value":"","Field":"barcode","Left":71,"Top":32,"Width":52,"Height":26,"Rotate":0,"BorderSize":0.1,"BorderColor":"black","Align":"center","VerticalAlign":"middle","BackColor":"white","ForeColor":"black","BarcodeType":"code128","BarcodeWidth":31,"BarcodeHeight":10,"BarcodeLabel":true,"LabelSize":12}]},"ReportFooter":[],"PageFooter":[]}' + } + ] + } + ] + } + } + + socket.send(JSON.stringify(printdata)) + } + } + + socket.onerror = () => { + notification.warning({ + top: 92, + message: '鏃犳硶杩炴帴鍒�:' + item.verify.linkUrl, + duration: 10 + }) + } }) @@ -309,6 +436,14 @@ execSubmit = (btn, data, _resolve, formdata) => { const { setting, logcolumns } = this.props + if (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop') { + this.setState({ + confirmLoading: false, + visible: false + }) + this.triggerPrint(btn, data, formdata) + return + } if (btn.intertype === 'inner') { // 浣跨敤鍐呴儴鎺ュ彛鏃讹紝鍐呴儴鍑芥暟鍜屾暟鎹簮涓嶅彲鍚屾椂涓虹┖, 浣跨敤绯荤粺鍑芥暟鏃讹紝绫诲瀷涓嶅彲涓虹┖ if (!btn.innerFunc && (!btn.sql || (btn.sql && !btn.sqlType))) { -- Gitblit v1.8.0