king
2020-01-22 c54724b0590729c677057736bd2d04715dc0c3fb
src/templates/comtableconfig/index.jsx
@@ -36,12 +36,10 @@
class ComTableConfig extends Component {
  static propTpyes = {
    type: PropTypes.string,
    menu: PropTypes.any,
    supMenuList: PropTypes.array,
    reloadmenu: PropTypes.func,
    handleConfig: PropTypes.func,
    handleSubConfig: PropTypes.func,
    supMenuList: PropTypes.array
    handleView: PropTypes.func
  }
  state = {
@@ -79,7 +77,7 @@
   */
  UNSAFE_componentWillMount () {
    const { menu } = this.props
    console.log(menu)
    let _LongParam = menu.LongParam
    let _config = ''
@@ -91,6 +89,12 @@
    } else {
      _config = _LongParam
    }
    // 配置默认值,兼容
    _config.tabs = _config.tabs || []
    _config.tabgroups = _config.tabgroups || ['tabs']
    _config.setting.subtabs = _config.setting.subtabs || []
    _config.Template = 'CommonTable'
    
    let _oriActions = []
    if (_config.type === 'user') {
@@ -106,14 +110,18 @@
        }
        item.uuid = uuid
        return item
      })
    }
    _config.tabs = _config.tabs || []
    _config.tabgroups = _config.tabgroups || ['tabs']
    _config.setting.subtabs = _config.setting.subtabs || []
      // 重置标签ID
      _config.tabgroups.forEach(group => {
        _config[group] = _config[group].map(tab => {
          tab.uuid = Utils.getuuid()
          return tab
        })
      })
    }
    this.setState({
      config: _config,
@@ -438,7 +446,7 @@
        {
          type: 'select',
          key: 'linkTab',
          label: '关联标签',
          label: this.state.dict['header.form.linkTab'],
          initVal: card.linkTab || '',
          required: false,
          options: []
@@ -469,7 +477,7 @@
        {
          type: 'mutilselect',
          key: 'subtabs',
          label: '下级标签',
          label: this.state.dict['header.form.subTab'],
          initVal: subtabs,
          required: false,
          options: menus
@@ -1271,7 +1279,7 @@
   * @description 三级菜单切换模板
   */
  changeTemplate = () => {
    this.props.handleConfig('template')
    this.props.handleView({tabview: 'template'})
  }
  /**
@@ -1579,7 +1587,7 @@
          duration: 2
        })
        if (this.state.closeVisible) {
          this.props.handleConfig('')
          this.props.handleView()
        } else {
          this.setState({
            menuloading: false,
@@ -1620,7 +1628,7 @@
        okText: this.state.dict['header.confirm'],
        cancelText: this.state.dict['header.cancel'],
        onOk() {
          _this.props.handleConfig('')
          _this.props.handleView()
        },
        onCancel() {}
      })
@@ -1642,7 +1650,7 @@
            closeVisible: true
          })
        } else {
          this.props.handleConfig('')
          this.props.handleView()
        }
      }, () => {
        this.setState({
@@ -1973,25 +1981,14 @@
  /**
   * @description 设置可配置按钮
   */
  setSubConfig = (btn, type) => {
  setSubConfig = (item, type) => {
    const { menu } = this.props
    const { config, originMenu } = this.state
    let isAdd = false
    if (
      (config.search[0] && config.search[0].origin) ||
      (config.action[0] && config.action[0].origin) ||
      (config.columns[0] && config.columns[0].origin) ||
      (config.tabs[0] && config.tabs[0].origin)
    ) {
      isAdd = true
    }
    if (isAdd) {
    if (!originMenu.MenuID) { // menuID不存在时,为新建菜单,提示菜单尚未保存
      notification.warning({
        top: 92,
        message: '菜单尚未保存,请保存菜单配置!',
        message: this.state.dict['header.menu.config.notsave'],
        duration: 10
      })
    } else {
@@ -2007,74 +2004,88 @@
          ParentID: res.parentId
        }
        if (!is(fromJS(originMenu), fromJS(_originMenu))) {
        if (!is(fromJS(originMenu), fromJS(_originMenu))) { // 菜单信息变化时,提示保存
          notification.warning({
            top: 92,
            message: '菜单配置已修改,请保存!',
            message: this.state.dict['header.menu.config.update'],
            duration: 10
          })
        } else {
          this.setState({
            loading: true
          })
          let uuid = ''
          let _type = type
          if (type === 'button' && btn.OpenType === 'popview') {
            _type = 'tab'
          } else if (type === 'button' && (btn.OpenType === 'tab' || btn.OpenType === 'blank')) {
            _type = 'tabview'
          }
          if (_type === 'tab') {
            uuid = btn.linkTab
          } else {
            uuid = btn.uuid
          }
          Api.getSystemConfig({
            func: 'sPC_Get_LongParam',
            MenuID: uuid
          }).then(res => {
            if (res.status) {
              this.setState({
                loading: false
              })
              let _LongParam = ''
              if (res.LongParam) {
                _LongParam = window.decodeURIComponent(window.atob(res.LongParam))
                try {
                  _LongParam = JSON.parse(_LongParam)
                } catch (e) {
                  _LongParam = ''
                }
              }
              if (_type === 'tab' && !_LongParam) {
                _LongParam = {
                  ...btn,
                  uuid: btn.linkTab,
                  create: true
                }
              }
              this.props.handleSubConfig(btn, originMenu, _LongParam, _type)
            } else {
              this.setState({
                loading: false
              })
              notification.warning({
                top: 92,
                message: res.message,
                duration: 10
              })
            }
          })
          return
        }
        console.log(item)
        // 菜单信息验证通过后,跳转子配置页面
        let _view = ''
        let uuid = item.uuid
        let isbutton = true
        if (type === 'button' && item.OpenType === 'pop') {
          _view = 'Modal'             // 表单页面
        } else if (type === 'button' && (item.OpenType === 'tab' || item.OpenType === 'blank')) {
          _view = item.tabTemplate    // 新标签页模板
        } else if (type === 'button' && item.OpenType === 'popview') {
          _view = item.tabType        // 新弹窗标签模板
          uuid = item.linkTab
          isbutton = false
        } else if (type === 'tab') {
          _view = item.type           // 标签模板
          uuid = item.linkTab
          isbutton = false
        }
        let param = {
          editMenu: _originMenu,
          editTab: !isbutton ? item : '',
          editAction: isbutton ? item : '',
          subConfig: '',
          tabview: _view
        }
        this.setState({
          loading: true
        })
        Api.getSystemConfig({
          func: 'sPC_Get_LongParam',
          MenuID: uuid
        }).then(res => {
          if (res.status) {
            this.setState({
              loading: false
            })
            let _LongParam = ''
            if (res.LongParam) {
              _LongParam = window.decodeURIComponent(window.atob(res.LongParam))
              try {
                _LongParam = JSON.parse(_LongParam)
              } catch (e) {
                _LongParam = ''
              }
            }
            if (_LongParam && param.tabview === 'Modal' && _LongParam.type === 'Modal') {
              param.subConfig = _LongParam
            } else if (_LongParam && param.tabview === 'FormTab' && _LongParam.type === 'FormTab') {
              param.subConfig = _LongParam
            } else if (_LongParam && param.tabview === 'SubTable' && _LongParam.Template === 'SubTable') {
              param.subConfig = _LongParam
            }
            this.props.handleView(param)
          } else {
            this.setState({
              loading: false
            })
            notification.warning({
              top: 92,
              message: res.message,
              duration: 10
            })
          }
        })
      }, () => {
        notification.warning({
          top: 92,
          message: '菜单基本信息已修改,请保存!',
          message: this.state.dict['header.menu.config.update'],
          duration: 10
        })
      })
@@ -2186,7 +2197,7 @@
      }
      Api.getSystemConfig(_param)
    })
    this.props.handleConfig('')
    this.props.handleView()
  }
  render () {