import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
// import { fromJS } from 'immutable'
|
import { Row, Col, Empty } from 'antd'
|
|
import asyncSpinComponent from '@/utils/asyncSpinComponent'
|
import './index.scss'
|
|
// 通用组件
|
const AntvBarAndLine = asyncSpinComponent(() => import('@/tabviews/custom/components/chart/antv-bar-line'))
|
const AntvPie = asyncSpinComponent(() => import('@/tabviews/custom/components/chart/antv-pie'))
|
const AntvTabs = asyncSpinComponent(() => import('@/tabviews/custom/components/tabs/antv-tabs'))
|
|
class MainSearch extends Component {
|
static propTpyes = {
|
BID: PropTypes.any, // 父级Id
|
config: PropTypes.object, // 组件配置信息
|
mainSearch: PropTypes.any, // 全局搜索条件
|
menuType: PropTypes.any, // 菜单类型
|
dataManager: PropTypes.any, // 数据权限
|
}
|
|
state = {}
|
|
UNSAFE_componentWillMount () {
|
|
}
|
|
getComponents = () => {
|
const { menuType, dataManager, BID, mainSearch, config } = this.props
|
|
if (!config || !config.components || config.components.length === 0) return (<Empty description={false} />)
|
|
return config.components.map(item => {
|
if (item.type === 'bar' || item.type === 'line') {
|
return (
|
<Col span={item.width} key={item.uuid}>
|
<AntvBarAndLine config={item} BID={BID} mainSearch={mainSearch} menuType={menuType} dataManager={dataManager} />
|
</Col>
|
)
|
} else if (item.type === 'pie') {
|
return (
|
<Col span={item.width} key={item.uuid}>
|
<AntvPie config={item} BID={BID} mainSearch={mainSearch} menuType={menuType} dataManager={dataManager} />
|
</Col>
|
)
|
} else if (item.type === 'tabs') {
|
return (
|
<Col span={item.width} key={item.uuid}>
|
<AntvTabs config={item} BID={BID} mainSearch={mainSearch} menuType={menuType} dataManager={dataManager} />
|
</Col>
|
)
|
} else {
|
return null
|
}
|
})
|
}
|
|
render() {
|
return (
|
<Row gutter={8}>{this.getComponents()}</Row>
|
)
|
}
|
}
|
|
export default MainSearch
|