From e9c48bd7356462ba9257540b130a47a65ad1861d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 26 八月 2021 17:17:11 +0800
Subject: [PATCH] 2021-08-26

---
 src/tabviews/zshare/actionList/printbutton/index.jsx |  193 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 190 insertions(+), 3 deletions(-)

diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx
index fb45054..ac9fa04 100644
--- a/src/tabviews/zshare/actionList/printbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/printbutton/index.jsx
@@ -3,7 +3,7 @@
 import moment from 'moment'
 import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
-import { Button, Modal, notification, message } from 'antd'
+import { Button, Modal, notification, message, Icon } from 'antd'
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
@@ -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)
 
@@ -1338,6 +1509,22 @@
         {this.getModels()}
       </div>
     } else { // icon銆乼ext銆� all 鍗$墖
+      let label = ''
+      let icon = ''
+
+      if (show === 'button') {
+        label = btn.label
+        icon = btn.icon || ''
+      } else if (show === 'link') {
+        label = <span>{btn.label}{btn.icon ? <Icon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
+        icon = ''
+      } else if (show === 'icon') {
+        icon = btn.icon || ''
+      // } else if (show === 'text') {
+      } else {
+        label = btn.label
+      }
+
       return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
         <Button
           type="link"
@@ -1345,9 +1532,9 @@
           loading={loading}
           disabled={disabled}
           style={btn.style}
-          icon={show === 'text' ? '' : (btn.icon || '')}
+          icon={icon}
           onClick={() => {this.actionTrigger()}}
-        >{show === 'icon' && btn.icon ? '' : btn.label}</Button>
+        >{label}</Button>
         {this.getModels()}
       </div>
     }

--
Gitblit v1.8.0