king
2020-10-26 1b89aa4493d1c9768447f2f480d594cdb8077fdc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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