king
2020-06-02 a181fc113d024ed34d6b488c65882961bd1de3f4
src/templates/sharecomponent/tabscomponent/index.jsx
@@ -16,7 +16,6 @@
class TablesComponent extends Component {
  static propTpyes = {
    type: PropTypes.string,       // 菜单类型
    tabs: PropTypes.array,        // 标签组
    config: PropTypes.object,     // 页面配置
    setSubConfig: PropTypes.func, // 子标签配置
@@ -28,6 +27,7 @@
    tabgroups: [],     // 标签组
    card: [],          // 编辑标签
    group: [],         // 编辑组
    levels: null,      // 树形页面的标签级别关联
    visible: false     // 模态框控制
  }
@@ -83,22 +83,28 @@
   * @description 标签编辑,筛选可选的下级标签与已关联的下级标签
   */
  handleTab = (card, _group) => {
    const { config } = this.props
    let tabgroups = fromJS(this.state.tabgroups).toJS()
    let menus = [
      {value: '', text: '空'},
      {value: 'mainTable', text: this.props.type === 'main' ? '主表' : '主数据'}
      {value: 'mainTable', text: '主表'}
    ]
    let equalTabs = []
    let supMenu = card.supMenu || ''
    let equalTab = card.equalTab || []
    let isuptab = true
    let equalTabIds = []
    let levels = {}
    tabgroups.forEach((group, i) => {
    tabgroups.forEach(group => {
      if (group.uuid === _group.uuid) {
        isuptab = false
        group.sublist.forEach(tab => { // 可关联的同级标签
          if (tab.level) {
            levels[tab.uuid] = tab.level
          }
          if (tab.uuid === card.uuid) return
          equalTabIds.push(tab.uuid)
@@ -106,6 +112,10 @@
        })
      } else if (isuptab) {
        group.sublist.forEach(tab => {
          if (tab.level) {
            levels[tab.uuid] = tab.level
          }
          menus.push({
            value: tab.uuid,
            text: tab.label
@@ -122,11 +132,16 @@
      equalTab = equalTab.filter(tabId => equalTabIds.includes(tabId))
    }
    if (config.Template !== 'TreePage') {
      levels = null
    }
    this.setState({
      visible: true,
      card: card,
      levels: levels,
      group: _group,
      formlist: getTabForm(card, supMenu, menus, equalTab, equalTabs, this.props.type)
      formlist: getTabForm(card, supMenu, menus, equalTab, equalTabs, config.Template)
    })
  }
@@ -176,6 +191,20 @@
        return _group
      })
      // 更新与之关联的标签显示级别
      if (config.Template === 'TreePage' && res.level !== card.level) {
        tabgroups = tabgroups.map(_group => {
          _group.sublist = _group.sublist.map(item => {
            if (item.supMenu === res.uuid) {
              item.level = res.level
            }
            return item
          })
          return _group
        })
      }
      this.setState({
        card: null,
        group: null,
@@ -204,6 +233,17 @@
          if (_group.uuid === group.uuid) {
            _group.sublist = _group.sublist.filter(item => item.uuid !== card.uuid)
          }
          return _group
        })
        // 清除与之关联标签的上级标签设置
        tabgroups = tabgroups.map(_group => {
          _group.sublist = _group.sublist.map(item => {
            if (item.supMenu === card.uuid) {
              item.supMenu = ''
            }
            return item
          })
          return _group
        })
@@ -386,6 +426,7 @@
            dict={this.state.dict}
            card={this.state.card}
            tabs={this.props.tabs}
            levels={this.state.levels}
            formlist={this.state.formlist}
            inputSubmit={this.handleSubmit}
            wrappedComponentRef={(inst) => this.tabsFormRef = inst}