| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | // import { fromJS } from 'immutable' |
| | | import { connect } from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Row, Col, Empty } from 'antd' |
| | | |
| | | import asyncSpinComponent from '@/utils/asyncSpinComponent' |
| | | import Utils from '@/utils/utils.js' |
| | | import './index.scss' |
| | | |
| | | // 通用组件 |
| | | const AntvBarAndLine = asyncSpinComponent(() => import('@/tabviews/custom/components/chart/antv-bar-line')) |
| | | const MainSearch = asyncSpinComponent(() => import('@/tabviews/custom/components/search/main-search')) |
| | | const AntvPie = asyncSpinComponent(() => import('@/tabviews/custom/components/chart/antv-pie')) |
| | | const AntvTabs = asyncSpinComponent(() => import('@/tabviews/custom/components/tabs/antv-tabs')) |
| | | |
| | | class MainSearch extends Component { |
| | | class TabTransfer extends Component { |
| | | static propTpyes = { |
| | | BID: PropTypes.any, // 父级Id |
| | | config: PropTypes.object, // 组件配置信息 |
| | |
| | | dataManager: PropTypes.any, // 数据权限 |
| | | } |
| | | |
| | | state = {} |
| | | state = { |
| | | mainSearch: [], |
| | | self: false |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { config, mainSearch } = this.props |
| | | // 获取主搜索条件 |
| | | let _mainSearch = [] |
| | | let self = false |
| | | config.components.forEach(component => { |
| | | if (component.type === 'search') { |
| | | self = true |
| | | component.search = component.search.map(item => { |
| | | item.oriInitval = item.initval |
| | | |
| | | if (!item.blacklist || item.blacklist.length === 0) return item |
| | | |
| | | let _black = item.blacklist.filter(v => { |
| | | return this.props.permRoles.indexOf(v) !== -1 |
| | | }) |
| | | |
| | | if (_black.length > 0) { |
| | | item.Hide = 'true' |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | _mainSearch = Utils.initMainSearch(component.search) |
| | | } |
| | | }) |
| | | |
| | | this.setState({mainSearch: self ? _mainSearch : fromJS(mainSearch).toJS(), self}) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | const { self } = this.state |
| | | |
| | | if (!self && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({mainSearch: fromJS(nextProps.mainSearch).toJS()}) |
| | | } |
| | | } |
| | | |
| | | resetSearch = (search) => { |
| | | this.setState({mainSearch: search}) |
| | | } |
| | | |
| | | getComponents = () => { |
| | | const { menuType, dataManager, BID, mainSearch, config } = this.props |
| | | const { menuType, dataManager, BID, config } = this.props |
| | | const { mainSearch } = this.state |
| | | |
| | | if (!config || !config.components || config.components.length === 0) return (<Empty description={false} />) |
| | | |
| | |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <AntvPie config={item} BID={BID} mainSearch={mainSearch} menuType={menuType} dataManager={dataManager} /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'search') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <MainSearch config={item} BID={BID} mainSearch={mainSearch} menuType={menuType} dataManager={dataManager} refreshdata={this.resetSearch} /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'tabs') { |
| | |
| | | } |
| | | } |
| | | |
| | | export default MainSearch |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | menuType: state.editLevel, |
| | | permAction: state.permAction, |
| | | permRoles: state.permRoles, |
| | | dataManager: state.dataManager |
| | | } |
| | | } |
| | | |
| | | const mapDispatchToProps = () => { |
| | | return {} |
| | | } |
| | | |
| | | export default connect(mapStateToProps, mapDispatchToProps)(TabTransfer) |