import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
|
import asyncComponent from '@/utils/asyncComponent'
|
import './index.scss'
|
|
const SearchComponent = asyncComponent(() => import('@/tabviews/zshare/topSearch'))
|
|
class NormalHeader extends Component {
|
static propTpyes = {
|
BID: PropTypes.any, // 上级主键值
|
menuType: PropTypes.any, // 菜单类型
|
config: PropTypes.object, // 配置信息
|
refresh: PropTypes.func // 条件刷新
|
}
|
|
state = {
|
title: '', // 标题
|
show: false, // 是否显示搜索
|
}
|
|
UNSAFE_componentWillMount () {
|
const { config } = this.props
|
|
this.setState({
|
title: config.plot ? config.plot.title : config.wrap.title,
|
show: !['normaltable', 'propcard'].includes(config.subtype) && config.search && config.search.length > 0
|
})
|
}
|
|
shouldComponentUpdate (nextProps, nextState) { return false }
|
|
/**
|
* @description 组件销毁,清除state更新,清除快捷键设置
|
*/
|
componentWillUnmount () {
|
this.setState = () => {
|
return
|
}
|
}
|
|
render() {
|
const { config, menuType, BID } = this.props
|
const { title, show } = this.state
|
|
if (!title && !show) return null
|
|
return (
|
<div className={'normal-header' + (show ? ' header-search' : '')} style={config.headerStyle}>
|
<span className="title">{title}</span>
|
{show ? <SearchComponent config={config} BID={BID} menuType={menuType} refreshdata={this.props.refresh}/> : null}
|
</div>
|
)
|
}
|
}
|
|
export default NormalHeader
|