king
2024-04-22 fc8c8d714687a22f711d642d192bd4149f3b7e88
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'
@@ -14,10 +13,8 @@
class CustomSetting extends Component {
  static propTpyes = {
    dict: PropTypes.object,           // 字典表
    config: PropTypes.object,         // 页面配置信息
    shortcuts: PropTypes.any,         // 自定义设置
    permAction: PropTypes.object,     // 按钮权限
  }
  state = {
@@ -42,7 +39,7 @@
    if (config.Template === 'CommonTable' || config.Template === 'TreePage') {
      this.getPageConfig()
    } else if (config.Template === 'CustomPage') {
    } else if (config.Template === 'CustomPage' || config.Template === 'BaseTable') {
      this.getCustomPageConfig()
    } else {
      notification.warning({
@@ -83,7 +80,7 @@
          if (cell.OpenType === 'funcbutton' && cell.funcType === 'print') {
            cell.$port = cell.verify ? cell.verify.linkUrl : ''
            if (cell.verify && cell.verify.printerTypeList) {
            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
@@ -99,7 +96,7 @@
          _comp.action.push({...cell, ...(userConfig[cell.uuid] || {})})
        })
        
        if (item.type === 'card' || (item.type === 'table' && item.subtype === 'tablecard')) {
        if (item.type === 'card') {
          item.subcards.forEach(card => {
            card.elements && card.elements.forEach(cell => {
              if (cell.eleType !== 'button') return
@@ -107,7 +104,7 @@
              if (cell.OpenType === 'funcbutton' && cell.funcType === 'print') {
                cell.$port = cell.verify ? cell.verify.linkUrl : ''
                if (cell.verify && cell.verify.printerTypeList) {
                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
@@ -120,7 +117,7 @@
                printbtns.push(cell)
              }
              _comp.action.push({...cell, ...(userConfig[cell.uuid] || {})})
              _comp.action.push({...cell, $line: true, ...(userConfig[cell.uuid] || {})})
            })
            card.backElements && card.backElements.forEach(cell => {
              if (cell.eleType !== 'button') return
@@ -128,7 +125,7 @@
              if (cell.OpenType === 'funcbutton' && cell.funcType === 'print') {
                cell.$port = cell.verify ? cell.verify.linkUrl : ''
                if (cell.verify && cell.verify.printerTypeList) {
                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
@@ -141,33 +138,40 @@
                printbtns.push(cell)
              }
              _comp.action.push({...cell, ...(userConfig[cell.uuid] || {})})
              _comp.action.push({...cell, $line: true, ...(userConfig[cell.uuid] || {})})
            })
          })
        } else if (item.type === 'table' && item.subtype === 'normaltable') {
          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') {
        } else if (item.type === 'table') {
          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 = 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, ...(userConfig[cell.uuid] || {})})
            })
          })
          }
          loopCol(item.cols)
        } 
        
        if (_comp.action.length > 0) {
@@ -183,7 +187,7 @@
  }
  getPageConfig = () => {
    const { shortcuts, permAction } = this.props
    const { shortcuts } = this.props
    let config = fromJS(this.props.config).toJS()
    let userConfig = {}
    let components = []
@@ -262,7 +266,7 @@
          let _comp = {title: res.tab.label, uuid: res.tab.uuid, action: []}
          subconfig.action.forEach(item => {
            if (!permAction[item.uuid]) return
            if (!window.GLOB.mkActions[item.uuid]) return
            item.$expanded = false
            if (item.OpenType === 'funcbutton' && item.funcType === 'print') {
@@ -270,7 +274,7 @@
              item.printer = _item ? (_item.printer || '') : ''
              item.$port = item.verify ? item.verify.linkUrl : ''
              if (item.verify && item.verify.printerTypeList) {
              if (item.verify && item.verify.printerTypeList && item.verify.printerTypeList.length > 0) {
                item.verify.printerTypeList = item.verify.printerTypeList.map(cell => {
                  cell.uuid = cell.uuid || cell.key
                  cell.parentId = item.uuid
@@ -329,7 +333,7 @@
          let data = ''
          try {
            data = JSON.parse(event.data)
          } catch {
          } catch (e) {
            data = ''
          }
@@ -406,7 +410,9 @@
        return
      }
      Api.deleteMenuStorage(config.MenuID).then(() => {
      Api.deleteMenuStorage(config.MenuID)
      setTimeout(() => {
        this.setState({
          visible: false,
          revertLoading: false
@@ -414,7 +420,7 @@
          window.GLOB.CacheMap = new Map()
          MKEmitter.emit('reloadMenuView', config.MenuID)
        })
      })
      }, 100)
    })
  }
@@ -425,7 +431,7 @@
    components.forEach(com => {
      com.action.forEach(item => {
        if (item.shortcut && item.shortcut.length > 0) {
        if (item.shortcut && item.shortcut.length > 0 && !item.$line) {
          _LongParam.action.push({uuid: item.uuid, parentId: com.uuid, shortcut: item.shortcut, $shortcut: item.shortcut.join('+')})
        }
        if (item.funcType === 'print' && (item.printer || item.verify.printerTypeList)) {
@@ -482,7 +488,9 @@
        return
      }
      Api.deleteMenuStorage(config.MenuID).then(() => {
      Api.deleteMenuStorage(config.MenuID)
      setTimeout(() => {
        this.setState({
          visible: false,
          confirmLoading: false
@@ -490,7 +498,7 @@
          window.GLOB.CacheMap = new Map()
          MKEmitter.emit('reloadMenuView', config.MenuID)
        })
      })
      }, 100)
    })
  }
@@ -510,28 +518,28 @@
  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}
          onCancel={() => { this.setState({ visible: false }) }}
          footer={[
            <Button key="revert" type="danger" loading={this.state.revertLoading} onClick={this.settingRevert}>{this.props.dict['main.revert.default']}</Button>,
            <Button key="cancel" onClick={() => { this.setState({ visible: false }) }}>{this.props.dict['main.cancel']}</Button>,
            <Button key="confirm" type="primary" loading={this.state.confirmLoading} onClick={this.settingSubmit}>{this.props.dict['main.submit']}</Button>
            <Button key="revert" type="danger" loading={this.state.revertLoading} onClick={this.settingRevert}>恢复默认设置</Button>,
            <Button key="cancel" onClick={() => { this.setState({ visible: false }) }}>取消</Button>,
            <Button key="confirm" type="primary" loading={this.state.confirmLoading} onClick={this.settingSubmit}>提交</Button>
          ]}
          destroyOnClose
        >
          <div className="tip">注:行级按钮快捷键设置无效。</div>
          {components && components.length > 0 ? components.map(item => (
            <div key={item.uuid}>
              <p className="component-title">{item.title}</p>