king
2020-09-16 2e5908bf05c200e12aa0fdfe5db5e21cbe7d014a
src/menu/components/tabs/antv-tabs/index.jsx
@@ -12,13 +12,14 @@
const SettingComponent = asyncComponent(() => import('../tabsetting'))
const TabLabelComponent = asyncComponent(() => import('../tablabelform'))
const TabComponents = asyncComponent(() => import('../tabcomponents'))
const { TabPane } = Tabs
const { confirm } = Modal
class antvBarLineChart extends Component {
  static propTpyes = {
    config: PropTypes.object,
    menu: PropTypes.object,
    tabs: PropTypes.object,
    updateConfig: PropTypes.func,
  }
@@ -31,41 +32,30 @@
  }
  UNSAFE_componentWillMount () {
    const { tabs, config } = this.props
    const { tabs } = this.props
    if (tabs.isNew) {
      let name = ''
      let i = 1
      while (!name) {
        let _name = '标签页' + i
        if (config.components.filter(com => com.setting && com.setting.name === _name).length === 0) {
          name = _name
        }
        i++
      }
      let _tabs = {
        uuid: tabs.uuid,
        type: tabs.type,
        floor: tabs.floor,
        subtype: tabs.subtype,
        setting: {span: 12, position: 'top', tabStyle: 'line', name},
        setting: {span: 12, position: 'top', tabStyle: 'line', name: tabs.name},
        subtabs: [{
          uuid: Utils.getuuid(),
          label: 'Tab 1',
          icon: '',
          subcomponents: [],
          components: [],
        }, {
          uuid: Utils.getuuid(),
          label: 'Tab 2',
          icon: '',
          subcomponents: [],
          components: [],
        }, {
          uuid: Utils.getuuid(),
          label: 'Tab 3',
          icon: '',
          subcomponents: [],
          components: [],
        }]
      }
      this.setState({
@@ -79,24 +69,30 @@
    }
  }
  componentDidMount () { }
  UNSAFE_componentWillReceiveProps (nextProps) {
    if (!is(fromJS(this.props.plot), fromJS(nextProps.plot))) {
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
    return !is(fromJS(this.state), fromJS(nextState))
  }
  updateComponent = (component) => {
    this.setState({
      tabs: component
    })
    this.props.updateConfig(component)
  }
  updateTabComponent = (tab) => {
    let tabs = fromJS(this.state.tabs).toJS()
    tabs.subtabs = tabs.subtabs.map(t => {
      if (t.uuid === tab.uuid) {
        return tab
      } else {
        return t
      }
    })
    this.setState({tabs})
    this.props.updateConfig(tabs)
  }
  tabAdd = (e) => {
@@ -106,7 +102,7 @@
        uuid: '',
        label: '',
        icon: '',
        subcomponents: []
        components: []
      },
      labelvisible: true
    })
@@ -175,6 +171,7 @@
  }
  render() {
    const { menu } = this.props
    const { tabs, dict, labelvisible, editab } = this.state
    return (
@@ -194,7 +191,8 @@
                <span>{tab.icon ? <Icon type={tab.icon} /> : null}{tab.label}</span>
              </Popover>
            } key={tab.uuid}>
              Content of Tab Pane {tab.label}
              {/* Content of Tab Pane {tab.label} */}
              <TabComponents menu={menu} config={tab} handleList={this.updateTabComponent} deleteCard={this.deleteCard} />
            </TabPane>
          ))}
          <TabPane className="tab-add" disabled tab={<Icon onClick={this.tabAdd} type="plus" />} key="add"></TabPane>