king
2020-02-03 75623dd039b742dbb44fb4c6b4af563404ed9c7f
src/templates/formtabconfig/index.jsx
@@ -35,10 +35,9 @@
class ComTableConfig extends Component {
  static propTpyes = {
    menu: PropTypes.any,
    editAction: PropTypes.object,
    btnTab: PropTypes.object,
    config: PropTypes.any,
    handleConfig: PropTypes.func,
    handleSubConfig: PropTypes.func
    handleView: PropTypes.func
  }
  state = {
@@ -73,21 +72,20 @@
   * 2、设置操作类型、原始菜单信息(每次保存后重置)、已使用表及基本信息表单
   */
  UNSAFE_componentWillMount () {
    const { menu, editAction, config } = this.props
    const { menu, btnTab, config } = this.props
    let _config = ''
    let _originMenu = ''
    if (!config) {
      _config = JSON.parse(JSON.stringify(Source.baseConfig))
      _config.isAdd = true
    } else {
      _config = config
      _originMenu = JSON.parse(JSON.stringify(_config))
    }
    this.setState({
      config: _config,
      originMenu: _originMenu,
      originMenu: JSON.parse(JSON.stringify(_config)),
      selectedTables: _config.tables,
      menuformlist: [
        {
@@ -101,7 +99,7 @@
          type: 'text',
          key: 'actionName',
          label: '按钮名称',
          initVal: editAction.label,
          initVal: btnTab.label,
          readonly: true
        }
      ]
@@ -231,6 +229,26 @@
    this.setState = () => {
      return
    }
  }
  // 页面返回
  handleViewBack = () => {
    const { menu } = this.props
    let _tabview = menu ? menu.LongParam.Template : ''
    let param = {
      editMenu: menu,
      editTab: null,
      tabConfig: null,
      editSubTab: null,
      subTabConfig: null,
      btnTab: null,
      btnTabConfig: null,
      editAction: null,
      subConfig: null,
      tabview: _tabview
    }
    this.props.handleView(param)
  }
  handleList = (type, list, card, groupId, elementId) => {
@@ -1139,13 +1157,14 @@
   * @description 菜单保存
   */
  submitConfig = () => {
    const { menu, editAction } = this.props
    const { menu, btnTab } = this.props
    const { delActions } = this.state
    let config = JSON.parse(JSON.stringify(this.state.config))
    this.menuformRef.handleConfirm().then(res => {
      if (config.isAdd) {
      if (config.groups[0] && config.groups[0].sublist[0] && config.groups[0].sublist[0].origin) {
        config.groups[0].sublist = config.groups[0].sublist.filter(item => !item.origin)
      }
@@ -1154,6 +1173,7 @@
      }
      if (config.tabs[0] && config.tabs[0].origin) {
        config.tabs = config.tabs.filter(item => !item.origin)
        }
      }
      let _LongParam = ''
@@ -1167,6 +1187,8 @@
          }
        })
      }
      delete _config.isAdd
      try {
        _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config)))
@@ -1199,9 +1221,9 @@
      
      let tabParam = { // 添加菜单tab页
        func: 'sPC_sMenusTab_AddUpt',
        MenuID: editAction.uuid,
        MenuID: btnTab.uuid,
        LText: config.tabs.map((item, index) => {
          return `select '${editAction.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${(index + 1) * 10}' as Sort`
          return `select '${btnTab.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${(index + 1) * 10}' as Sort`
        })
      }
      tabParam.LText = tabParam.LText.join(' union all ')
@@ -1212,10 +1234,10 @@
      let param = {
        func: 'sPC_ButtonParam_AddUpt',
        ParentID: menu.MenuID,
        MenuID: editAction.uuid,
        MenuID: btnTab.uuid,
        MenuNo: menu.MenuNo,
        Template: 'FormTab',
        MenuName: editAction.label,
        MenuName: btnTab.label,
        PageParam: JSON.stringify({Template: 'FormTab'}),
        LongParam: _LongParam
      }
@@ -1363,7 +1385,7 @@
          duration: 2
        })
        if (this.state.closeVisible) {
          this.props.handleConfig('')
          this.handleViewBack()
        } else {
          this.setState({
            menuloading: false,
@@ -1384,13 +1406,13 @@
    let _this = this
    if (!originMenu) {
    if (config.isAdd) {
      confirm({
        content: '按钮配置尚未提交,确定放弃保存吗?',
        okText: this.state.dict['header.confirm'],
        cancelText: this.state.dict['header.cancel'],
        onOk() {
          _this.props.handleConfig('')
          _this.handleViewBack()
        },
        onCancel() {}
      })
@@ -1402,7 +1424,7 @@
          closeVisible: true
        })
      } else {
        this.props.handleConfig('')
        this.handleViewBack()
      }
    }
  }
@@ -1617,19 +1639,10 @@
   * @description 设置可配置标签
   */
  setSubConfig = (btn, type) => {
    const {menu, btnTab} = 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.tabs[0] && config.tabs[0].origin)
    ) {
      isAdd = true
    }
    if (isAdd) {
    if (config.isAdd) {
      notification.warning({
        top: 92,
        message: '菜单尚未保存,请保存菜单配置!',
@@ -1650,21 +1663,22 @@
            loading: true
          })
          let uuid = ''
          let _type = type
          if (type === 'button' && btn.OpenType === 'popview') {
            _type = 'tab'
          }
          if (_type === 'button') {
            uuid = btn.uuid
          } else {
            uuid = btn.linkTab
          let param = {
            editMenu: menu,
            editTab: btn,
            tabConfig: null,
            editSubTab: null,
            subTabConfig: null,
            btnTab: btnTab,
            btnTabConfig: _config,
            editAction: null,
            subConfig: '',
            tabview: btn.type
          }
          Api.getSystemConfig({
            func: 'sPC_Get_LongParam',
            MenuID: uuid
            MenuID: btn.linkTab
          }).then(res => {
            if (res.status) {
              this.setState({
@@ -1680,15 +1694,11 @@
                }
              }
              if (_type === 'tab' && !_LongParam) {
                _LongParam = {
                  ...btn,
                  uuid: btn.linkTab,
                  create: true
                }
              if (_LongParam && param.tabview === 'SubTable' && _LongParam.Template === 'SubTable') {
                param.subConfig = _LongParam
              }
              this.props.handleSubConfig(btn, originMenu, _LongParam, _type)
              this.props.handleView(param)
            } else {
              this.setState({
                loading: false
@@ -2168,7 +2178,7 @@
          onCancel={() => { this.setState({closeVisible: false}) }}
          footer={[
            <Button key="save" className="mk-btn mk-green" loading={this.state.menucloseloading} onClick={this.submitConfig}>{this.state.dict['header.save']}</Button>,
            <Button key="confirm" className="mk-btn mk-yellow" onClick={() => {this.props.handleConfig('')}}>{this.state.dict['header.notsave']}</Button>,
            <Button key="confirm" className="mk-btn mk-yellow" onClick={this.handleViewBack}>{this.state.dict['header.notsave']}</Button>,
            <Button key="cancel" onClick={() => { this.setState({closeVisible: false}) }}>{this.state.dict['header.cancel']}</Button>
          ]}
          destroyOnClose