king
2020-09-26 ab60d53b67f802878662aaa5a5b52580cca421b8
src/menu/searchcomponent/index.jsx
@@ -5,6 +5,7 @@
import { Modal, notification } from 'antd'
import moment from 'moment'
import MKEmitter from '@/utils/events.js'
import Api from '@/api'
import Utils from '@/utils/utils.js'
import zhCN from '@/locales/zh-CN/model.js'
@@ -41,6 +42,10 @@
    })
  }
  componentDidMount () {
    MKEmitter.addListener('addSearch', this.addSearch)
  }
  /**
   * @description 监听到搜索条件复制时,触发搜索条件编辑
   */
@@ -50,6 +55,29 @@
    if (!is(fromJS(nextProps.config.search), fromJS(this.props.config.search)) && !is(fromJS(nextProps.config.search), fromJS(searchlist))) {
      this.setState({searchlist: fromJS(nextProps.config.search).toJS()})
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState))
  }
  /**
   * @description 组件销毁,清除state更新,清除快捷键设置
   */
  componentWillUnmount () {
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('addSearch', this.addSearch)
  }
  addSearch = (cardId, element) => {
    if (cardId !== this.props.config.uuid) return
    const { searchlist } = this.state
    this.setState({searchlist: [...searchlist, element]})
    this.handleSearch(element)
  }
  /**
@@ -255,19 +283,6 @@
      },
      onCancel() {}
    })
  }
  /**
   * @description 组件销毁,清除state更新
   */
  componentWillUnmount () {
    this.setState = () => {
      return
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState))
  }
  render() {