king
2020-03-02 ba7c54e0029456e6b1bf7f0e0d31af69a3d74db3
src/templates/comtableconfig/index.jsx
@@ -29,6 +29,7 @@
import VerifyCardPrint from '@/templates/tableshare/verifycardprint'
import MenuForm from '@/templates/tableshare/menuform'
import TabDragElement from '@/templates/tableshare/tabdragelement'
import TransferForm from '@/components/transferform'
import SourceElement from '@/templates/tableshare/dragelement/source'
import Source from './source'
import './index.scss'
@@ -73,7 +74,10 @@
    showColumnName: false,   // 显示列字段名控制
    tabviews: [],            // 所有标签页
    profileVisible: false,   // 验证信息模态框
    optionLibs: null         // 自定义下拉选项库
    optionLibs: null,        // 自定义下拉选项库
    thawBtnVisible: false,   // 解冻按钮弹窗
    thawbtnlist: null,       // 解冻按钮列表
    thawButtons: []          // 已选择要解冻的按钮
  }
  /**
@@ -123,6 +127,10 @@
      _config.action = _config.action.map(item => {
        let uuid = Utils.getuuid()
        if (item.linkTab) {
          item.linkTab = ''
        }
        if (item.OpenType === 'pop') { // 含有子配置项的按钮(表单)
          _oriActions.push({
            prebtn: JSON.parse(JSON.stringify(item)),
@@ -146,6 +154,10 @@
        _config[group] = _config[group].map(tab => {
          tab.uuid = Utils.getuuid()
          
          if (tab.linkTab) {
            tab.linkTab = ''
          }
          return tab
        })
      })
@@ -1364,7 +1376,7 @@
  }
  deleteElement = (element) => {
    const { config } = this.state
    const { config, thawButtons } = this.state
    let _this = this
    confirm({
@@ -1403,12 +1415,13 @@
        // 删除按钮元素
        let _delActions = _this.state.delActions
        if (element.type === 'action' || element.type === 'tabs') {
          _delActions.push(element.card.uuid)
          _delActions.push(element)
        }
        _this.setState({
          config: _config,
          delActions: _delActions
          delActions: _delActions,
          thawButtons: thawButtons.filter(key => key !== element.card.uuid)
        })
      },
      onCancel() {}
@@ -1544,7 +1557,7 @@
   */
  submitConfig = () => {
    const { menu } = this.props
    const { originMenu, delActions } = this.state
    const { originMenu, delActions, thawButtons } = this.state
    let config = JSON.parse(JSON.stringify(this.state.config))
@@ -1782,8 +1795,23 @@
            let deffers = delActions.map(item => {
              let _param = {
                func: 'sPC_MainMenu_Del',
                MenuID: item
                MenuID: item.card.uuid
              }
              if (item.type === 'action') {
                let _ParentParam = null
                try {
                  _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card)))
                } catch (e) {
                  _ParentParam = null
                }
                if (_ParentParam) {
                  _param.ParentParam = _ParentParam
                }
              }
              return new Promise(resolve => {
                Api.getSystemConfig(_param).then(response => {
                  resolve(response)
@@ -1818,6 +1846,46 @@
            })
          } else if (delActions.length === 0) {
            resolve(true)
          }
        }).then(resp => {
          if (resp === false) return
          if (thawButtons.length > 0) {
            let defers = thawButtons.map(item => {
              return new Promise((resolve) => {
                Api.getSystemConfig({
                  func: 'sPC_MainMenu_ReDel',
                  MenuID: item
                }).then(res => {
                  if (res.status) {
                    resolve('')
                  } else {
                    resolve(res.message)
                  }
                })
              })
            })
            return Promise.all(defers)
          } else {
            return true
          }
        }).then(res => {
          if (res === true || res === false) return res
          let msg = res.filter(Boolean)[0]
          if (msg) {
            notification.warning({
              top: 92,
              message: msg,
              duration: 10
            })
            return false
          } else {
            this.setState({
              thawButtons: []
            })
            return true
          }
        }).then(resp => {
          if (resp === false) return
@@ -1970,13 +2038,17 @@
                try {
                  _subconfig.action = _subconfig.action.map(_btn => {
                    _btn.uuid = Utils.getuuid()
                    return _btn
                  })
                  _subconfig.tabgroups.forEach(_groupId => {
                    _subconfig[_groupId] = _subconfig[_groupId].map(_tab => {
                      _tab.uuid = Utils.getuuid()
  
                      if (_tab.linkTab) {
                        _tab.linkTab = ''
                      }
                      return _tab
                    })
                  })
@@ -1984,9 +2056,11 @@
                } catch {
                  _subconfig = ''
                }
              }
              _LongParam = _subconfig
                _LongParam = _subconfig
              } else if (_subconfig) {
                _LongParam = result.LongParam
              }
            }
            if (_LongParam) {
@@ -2642,6 +2716,105 @@
  }
  /**
   * @description 解冻按钮
   */
  handleThaw = () => {
    const { menu } = this.props
    this.setState({
      thawBtnVisible: true
    })
    Api.getSystemConfig({
      func: 'sPC_Get_FrozenMenu',
      ParentID: menu.MenuID,
      TYPE: 40
    }).then(res => {
      if (res.status) {
        let _list = []
        res.data.forEach(menu => {
          let _conf = ''
          if (menu.ParentParam) {
            try {
              _conf = JSON.parse(window.decodeURIComponent(window.atob(menu.ParentParam)))
            } catch (e) {
              _conf = ''
            }
          }
          if (_conf) {
            _list.push({
              key: menu.MenuID,
              title: menu.MenuName,
              btnParam: _conf
            })
          }
        })
        this.setState({
          thawbtnlist: _list
        })
      } else {
        notification.warning({
          top: 92,
          message: res.message,
          duration: 10
        })
      }
    })
  }
  /**
   * @description 解冻按钮提交
   */
  thawBtnSubmit = () => {
    const { thawButtons, config, thawbtnlist } = this.state
    // 三级菜单解除冻结
    if (this.refs.trawmenu.state.targetKeys.length === 0) {
      notification.warning({
        top: 92,
        message: this.state.dict['form.required.select'] + this.state.dict['header.form.thawbutton'],
        duration: 10
      })
    } else {
      thawbtnlist.forEach(item => {
        if (this.refs.trawmenu.state.targetKeys.includes(item.key)) {
          config.action.push(item.btnParam)
        }
      })
      this.setState({
        thawButtons: [...thawButtons, ...this.refs.trawmenu.state.targetKeys],
        config: config,
        thawBtnVisible: false
      })
    }
  }
  handleGroup = (index, type) => {
    let config = JSON.parse(JSON.stringify(this.state.config))
    if (type === 'up') {
      config.tabgroups.splice(index, 0, config.tabgroups.splice(index - 1, 1)[0])
    } else {
      config.tabgroups.splice(index, 0, config.tabgroups.splice(index + 1, 1)[0])
    }
    this.setState({
      config: config
    })
    notification.success({
      top: 92,
      message: '调整成功',
      duration: 2
    })
  }
  /**
   * @description 选择不保存时,如有复制按钮,则删除
   */
  notsave = () => {
@@ -2734,14 +2907,19 @@
                    return (<SourceElement key={index} content={item}/>)
                  })}
                </div>
                {configAction.length > 0 ?
                  <p className="config-btn-title">
                    <Tooltip placement="topLeft" title="点击按钮,可完成或查看按钮配置信息。">
                      <Icon type="question-circle" />
                    </Tooltip>
                    {this.state.dict['header.menu.action.configurable']}
                  </p> : null
                }
                <div className="config-btn">
                  {configAction.length > 0 ?
                    <p className="config-btn-title">
                      <Tooltip placement="topLeft" title="点击按钮,可完成或查看按钮配置信息。">
                        <Icon type="question-circle" />
                      </Tooltip>
                      {this.state.dict['header.menu.action.configurable']}
                    </p> : null
                  }
                  <div className="thawbutton" title={this.state.dict['header.form.thawbutton']} onClick={this.handleThaw}>
                    <Icon type="unlock" />
                  </div>
                </div>
                {configAction.map((item, index) => {
                  return (
                    <div key={index}>
@@ -2821,6 +2999,9 @@
                <Tooltip placement="bottomLeft" overlayClassName="middle" title="在左侧工具栏《按钮》中,选择对应类型的按钮拖至此处添加,如选择按钮类型为表单、新标签页等含有配置页面的按钮,可在左侧工具栏-按钮-可配置按钮处,点击按钮完成相关配置。注:当设置按钮显示位置为表格时,显示列会增加操作列。">
                  <Icon type="question-circle" />
                </Tooltip>
                {/* <div className="thawbutton" title={this.state.dict['header.form.thawbutton']} onClick={this.handleThaw}>
                  <Icon type="unlock" />
                </div> */}
                <DragElement
                  type="action"
                  list={this.state.config.action}
@@ -2859,6 +3040,10 @@
                    {index === 0 ? <Tooltip placement="bottomLeft" overlayClassName="middle" title="在左侧工具栏《标签页》中,选择对应类型的标签页拖至此处添加。">
                      <Icon type="question-circle" />
                    </Tooltip> : null}
                    {index !== (this.state.config.tabgroups.length - 1) ?
                      <Icon type="arrow-down" onClick={() => {this.handleGroup(index, 'down')}} /> : null
                    }
                    {index !== 0 ? <Icon type="arrow-up" onClick={() => {this.handleGroup(index, 'up')}} /> : null}
                    {index === 0 ? <Icon type="plus" onClick={this.addTabGroup} /> : null}
                    {index !== 0 ? <Icon type="delete" onClick={() => {this.delTabGroup(groupId)}} /> : null}
                    <TabDragElement
@@ -3097,6 +3282,19 @@
        >
          {this.state.dict['header.menu.config.placeholder']}
        </Modal>
        {/* 解冻按钮模态框 */}
        <Modal
          title={this.state.dict['header.form.thawbutton']}
          okText={this.state.dict['header.confirm']}
          cancelText={this.state.dict['header.cancel']}
          visible={this.state.thawBtnVisible}
          onOk={this.thawBtnSubmit}
          onCancel={() => {this.setState({thawBtnVisible: false, thawbtnlist: null})}}
          destroyOnClose
        >
          {!this.state.thawbtnlist && <Spin style={{marginLeft: 'calc(50% - 22px)', marginTop: '70px', marginBottom: '70px'}} size="large" />}
          {this.state.thawbtnlist && <TransferForm ref="trawmenu" dict={this.state.dict} menulist={this.state.thawbtnlist}/>}
        </Modal>
        {this.state.loading && <Spin size="large" />}
      </div>
    )