| | |
| | | class antvTabs extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object, // 组件配置信息 |
| | | mainSearch: PropTypes.any, // 外层搜索条件 |
| | | } |
| | | |
| | | state = { |
| | |
| | | let val = '' |
| | | Object.keys(data).forEach(key => { |
| | | if (key.toLowerCase() === _tabs.setting.controlField) { |
| | | val = data[key] |
| | | val = data[key] + '' |
| | | } |
| | | }) |
| | | _tabs.subtabs = config.subtabs.filter(tab => { |
| | | if (tab.controlVal === val) { |
| | | return false |
| | | } else if (/,/ig.test(tab.controlVal)) { |
| | | return !tab.controlVal.split(',').includes(val) |
| | | } |
| | | return true |
| | | if (tab.$pass) return true |
| | | |
| | | return !tab.controlVals.includes(val) |
| | | }) |
| | | } else { |
| | | _tabs.subtabs = config.subtabs.filter(tab => { |
| | | if (tab.$pass) return true |
| | | |
| | | return tab.controlVals.includes('@pass_empty@') |
| | | }) |
| | | } |
| | | } |
| | |
| | | if (tabs.setting.supModule === MenuID) { |
| | | if (!data) { |
| | | this.setState({ |
| | | tabs: {...tabs, subtabs: []} |
| | | tabs: {...tabs, subtabs: this.props.config.subtabs.filter(tab => { |
| | | if (tab.$pass) return true |
| | | |
| | | return tab.controlVals.includes('@pass_empty@') |
| | | })} |
| | | }) |
| | | } else { |
| | | let val = '' |
| | | Object.keys(data).forEach(key => { |
| | | if (key.toLowerCase() === tabs.setting.controlField) { |
| | | val = data[key] |
| | | val = data[key] + '' |
| | | } |
| | | }) |
| | | 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 |
| | | if (tab.$pass) return true |
| | | |
| | | return !tab.controlVals.includes(val) |
| | | })} |
| | | }) |
| | | } |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { mainSearch } = this.props |
| | | const { tabs } = this.state |
| | | |
| | | if (!tabs.subtabs.length) return null |
| | |
| | | <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>} style={{backgroundColor: tab.backgroundColor || 'transparent'}} key={tab.uuid}> |
| | | <TabTransfer config={tab} mainSearch={mainSearch}/> |
| | | <TabTransfer config={tab}/> |
| | | </TabPane> |
| | | ))} |
| | | </Tabs> |