king
2022-07-22 0c439ced2c97905cb2b02f5f689a37b19369fb8a
src/tabviews/custom/components/tabs/antv-tabs/index.jsx
@@ -17,7 +17,6 @@
    bids: PropTypes.any,             // 父级Id集
    config: PropTypes.object,        // 组件配置信息
    mainSearch: PropTypes.any,       // 外层搜索条件
    menuType: PropTypes.any,         // 菜单类型
  }
  state = {
@@ -29,8 +28,15 @@
  UNSAFE_componentWillMount () {
    const { config, bids } = this.props
    let _tabs = fromJS(config).toJS()
    if (_tabs.setting.supModule) {
      _tabs.subtabs = []
    }
    this.setState({
      tabs: config,
      tabs: _tabs,
      parentIds: config.parentIds || [],
      bids: bids ? bids : {}
    })
@@ -61,13 +67,33 @@
  }
  resetParentParam = (MenuID, id, data) => {
    const { parentIds, bids } = this.state
    const { parentIds, bids, tabs } = this.state
    if (!parentIds.includes(MenuID)) return
    if (parentIds.includes(MenuID)) {
      this.setState({
        bids: {...bids, [MenuID]: id, [MenuID + '_data']: data}
      })
    }
    this.setState({
      bids: {...bids, [MenuID]: id, [MenuID + '_data']: data}
    })
    if (tabs.setting.supModule === MenuID) {
      if (!data) {
        this.setState({
          tabs: {...tabs, subtabs: []}
        })
      } else {
        let val = data[tabs.setting.controlField] === undefined ? '' : data[tabs.setting.controlField] + ''
        this.setState({
          tabs: {...tabs, subtabs: this.props.config.subtabs.filter(tab => {
            if (tab.controlVal === val) {
              return false
            } else if (/,/ig.test(tab.controlVal)) {
              return tab.controlVal.split(',').includes(val)
            }
            return true
          })}
        })
      }
    }
  }
  autoSwitch = (interval) => {
@@ -98,11 +124,13 @@
    const { mainSearch, BID } = this.props
    const { tabs, bids } = this.state
    if (!tabs.subtabs.length) return null
    return (
      <div className={'menu-antv-tabs-wrap ' + tabs.setting.tabLabel} style={tabs.style}>
        <Tabs defaultActiveKey="1" tabPosition={tabs.setting.position} type={tabs.setting.tabStyle}>
        <Tabs defaultActiveKey="1" tabBarStyle={{background: tabs.setting.backgroundColor || 'transparent'}} tabPosition={tabs.setting.position} type={tabs.setting.tabStyle}>
          {tabs.subtabs.map(tab => (
            <TabPane tab={<span id={'tab' + tab.uuid}>{tab.icon ? <MkIcon type={tab.icon} /> : null}{tab.label}</span>} key={tab.uuid}>
            <TabPane tab={<span id={'tab' + tab.uuid}>{tab.icon ? <MkIcon type={tab.icon} /> : null}{tab.label}</span>} style={{backgroundColor: tab.backgroundColor || 'transparent'}} key={tab.uuid}>
              <TabTransfer BID={BID} config={tab} bids={bids} mainSearch={mainSearch}/>
            </TabPane>
          ))}