king
2024-08-25 326aa6b3effaccc71cfe0775d47b0f29eb3695a6
src/tabviews/zshare/settingcomponent/index.jsx
@@ -1,12 +1,11 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Button, Modal, notification, Spin, Empty } from 'antd'
import { Button, Modal, notification, Spin, Empty, Tooltip } from 'antd'
import Api from '@/api'
import MKEmitter from '@/utils/events.js'
import { updateSubTable } from '@/utils/utils-update.js'
import options from '@/store/options.js'
import asyncComponent from '@/utils/asyncSpinComponent'
import './index.scss'
@@ -143,29 +142,36 @@
            })
          })
        } else if (item.type === 'table') {
          item.cols && item.cols.forEach(col => {
            if (col.type !== 'action') return
            col.elements && col.elements.forEach(cell => {
              cell.$expanded = false
              if (cell.OpenType === 'funcbutton' && cell.funcType === 'print') {
          let loopCol = (cols) => {
            cols.forEach(col => {
              if (col.type === 'colspan') {
                loopCol(col.subcols)
              } else if (col.type === 'custom') {
                col.elements.forEach(cell => {
                  if (cell.eleType !== 'button') return
                  cell.$expanded = false
                  if (cell.OpenType === 'funcbutton' && cell.funcType === 'print') {
                cell.$port = cell.verify ? cell.verify.linkUrl : ''
                if (cell.verify && cell.verify.printerTypeList && cell.verify.printerTypeList.length > 0) {
                  cell.verify.printerTypeList = cell.verify.printerTypeList.map(_cell => {
                    _cell.uuid = _cell.uuid || _cell.key
                    _cell.parentId = cell.uuid
                    _cell.$port = cell.$port
                    cell.$port = cell.verify ? cell.verify.linkUrl : ''
                    if (cell.verify && cell.verify.printerTypeList && cell.verify.printerTypeList.length > 0) {
                      cell.verify.printerTypeList = cell.verify.printerTypeList.map(_cell => {
                        _cell.uuid = _cell.uuid || _cell.key
                        _cell.parentId = cell.uuid
                        _cell.$port = cell.$port
                    return _cell
                  })
                  cell.$expanded = true
                }
                printbtns.push(cell)
                        return _cell
                      })
                      cell.$expanded = true
                    }
                    printbtns.push(cell)
                  }
                  _comp.action.push({...cell, $line: true, ...(userConfig[cell.uuid] || {})})
                })
              }
              _comp.action.push({...cell, $line: true, ...(userConfig[cell.uuid] || {})})
            })
          })
          }
          loopCol(item.cols)
        } 
        
        if (_comp.action.length > 0) {
@@ -310,9 +316,14 @@
        })
      } else if (!links.includes(item.verify.linkUrl)) {
        links.push(item.verify.linkUrl)
      }
    })
        let socket = null
        socket = new WebSocket('ws://' + item.verify.linkUrl)
    if (links.length === 0) return
    let defers = links.map(link => {
      return new Promise((resolve) => {
        let socket = new WebSocket('ws://' + link)
        // 打开Socket
        socket.onopen = () =>{
          let request  = {
@@ -354,29 +365,39 @@
              })
            }
            window.GLOB.UserCacheMap.set(item.verify.linkUrl, _printers)
          } else if (data && data.cmd === 'getPrinters') {
            notification.warning({
              top: 92,
              message: data.message,
              duration: 5
            })
            resolve({status: true, printers: _printers})
          } else if (data && data.cmd === 'getPrinters' && data.message) {
            resolve({status: false, printers: null, message: data.message})
          }
        }
        socket.onerror = () => {
          let tool = item.verify.linkUrl
          if (item.verify.linkUrl === '127.0.0.1:13529') {
          let tool = link
          if (link === '127.0.0.1:13529') {
            tool = '明科通讯组件'
          } else if (item.verify.linkUrl === '127.0.0.1:13528') {
          } else if (link === '127.0.0.1:13528') {
            tool = 'CAINIAO打印组件'
          }
          notification.warning({
            top: 92,
            message: '无法连接到: ' + tool,
            duration: 5
          })
          resolve({status: false, printers: null, message: '无法连接到: ' + tool})
        }
      })
    })
    Promise.all(defers).then(results => {
      let res = results.filter(item => item.status)[0]
      if (res) {
        links.forEach(link => {
          window.GLOB.UserCacheMap.set(link, res.printers)
        })
      } else {
        notification.warning({
          top: 92,
          message: results[0].message,
          duration: 5
        })
      }
    })
  }
@@ -404,7 +425,9 @@
        return
      }
      Api.deleteMenuStorage(config.MenuID).then(() => {
      Api.deleteMenuStorage(config.MenuID)
      setTimeout(() => {
        this.setState({
          visible: false,
          revertLoading: false
@@ -412,7 +435,7 @@
          window.GLOB.CacheMap = new Map()
          MKEmitter.emit('reloadMenuView', config.MenuID)
        })
      })
      }, 100)
    })
  }
@@ -480,7 +503,9 @@
        return
      }
      Api.deleteMenuStorage(config.MenuID).then(() => {
      Api.deleteMenuStorage(config.MenuID)
      setTimeout(() => {
        this.setState({
          visible: false,
          confirmLoading: false
@@ -488,7 +513,7 @@
          window.GLOB.CacheMap = new Map()
          MKEmitter.emit('reloadMenuView', config.MenuID)
        })
      })
      }, 100)
    })
  }
@@ -508,17 +533,16 @@
  render() {
    const { components, visible } = this.state
    if (window.GLOB.mkHS || window.GLOB.sysType !== 'local') return null
    return (
      <div className="page-setting-wrap">
        {options.sysType === 'local' ? <Button
          icon="setting"
          shape="circle"
          className="page-setting"
          onClick={this.trigger}
        /> : null}
      <div className="tool-wrap">
        <Tooltip placement="left" title="自定义设置">
          <Button icon="setting" shape="circle" onClick={this.trigger}/>
        </Tooltip>
        <Modal
          wrapClassName="custom-setting-modal"
          title={'自定义设置'}
          title="自定义设置"
          maskClosable={false}
          width={950}
          visible={visible}