king
2021-07-28 137fb8ea6af2789b3238b22bac31d80bced41dfe
src/menu/components/share/normalheader/index.jsx
@@ -5,6 +5,7 @@
import asyncComponent from '@/utils/asyncComponent'
import MKEmitter from '@/utils/events.js'
import { resetStyle } from '@/utils/utils-custom.js'
import './index.scss'
const SearchComponent = asyncComponent(() => import('@/menu/components/share/searchcomponent'))
@@ -15,6 +16,10 @@
    hideSearch: PropTypes.any,       // 隐藏搜索条件
    config: PropTypes.object,        // 配置信息
    updateComponent: PropTypes.func  // 配置更新
  }
  state = {
    appType: sessionStorage.getItem('appType')
  }
  componentDidMount () {
@@ -48,22 +53,30 @@
  changeStyle = () => {
    const { config } = this.props
    // MKEmitter.emit('changeStyle', [config.uuid, 'header'], ['font', 'height', 'border'], config.headerStyle)
    MKEmitter.emit('changeStyle', [config.uuid, 'header'], ['font', 'border'], config.headerStyle)
  }
  render() {
    const { config, defaultshow, hideSearch } = this.props
    const { appType } = this.state
    let title = config.plot ? config.plot.title : config.wrap.title
    let show = true
    if (!title && appType === 'mob' && config.type === 'card' && config.subtype === 'datacard' && config.action && config.action.length) {
      title = ' '
    }
    if (defaultshow === 'hidden') {
      if (!title && (!config.search || config.search.length === 0)) {
        show = false
      }
    }
    let _style = resetStyle(config.headerStyle)
    return (
      <div className={'normal-header' + (!show ? ' hidden' : '')} style={config.headerStyle}>
      <div className={'normal-header' + (!show ? ' hidden' : '') + (config.wrap && config.wrap.searchable === 'true' ? ' tree-search' : '')} style={_style}>
        <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
          <div className="mk-popover-control">
            <Icon className="style" title="调整样式" onClick={this.changeStyle} type="font-colors" />
@@ -71,6 +84,7 @@
        } trigger="hover">
          <span className="title">{title}</span>
        </Popover>
        {config.wrap && config.wrap.searchable === 'true' ? <span className="ant-input-search ant-input-affix-wrapper"><span className="ant-input-suffix"><Icon type="search" /></span></span> : null}
        {hideSearch !== 'true' && config.search ? <SearchComponent config={config} updatesearch={this.props.updateComponent}/> : null}
      </div>
    )