king
2021-09-27 54d01e6ef9ac31f10de4a0e92824eba50b77eda6
src/templates/sharecomponent/searchcomponent/index.jsx
@@ -10,6 +10,7 @@
import enUS from '@/locales/en-US/model.js'
import { getSearchForm } from '@/templates/zshare/formconfig'
import MKEmitter from '@/utils/events.js'
import SearchForm from './searchform'
import DragElement from './dragsearch'
import './index.scss'
@@ -53,6 +54,32 @@
        this.handleSearch(item)
      }
      this.setState({searchlist: fromJS(nextProps.config.search).toJS()})
    }
  }
  componentDidMount () {
    MKEmitter.addListener('plusSearch', this.plusSearch)
  }
  plusSearch = (MenuId, item, type) => {
    const { config } = this.props
    const { searchlist } = this.state
    if (MenuId !== config.uuid) return
    if (type === 'simple') {
      this.setState({
        searchlist: [...searchlist, item],
      }, () => {
        this.handleSearch(item)
      })
    } else if (type === 'multil') {
      let list = [...searchlist, ...item]
      this.setState({
        searchlist: list
      }, () => {
        this.props.updatesearch({...config, search: list})
      })
    }
  }
@@ -280,13 +307,15 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('plusSearch', this.plusSearch)
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState))
    return !is(fromJS(this.state), fromJS(nextState)) || this.props.config.setting.show !== nextProps.config.setting.show
  }
  render() {
    const { config } = this.props
    const { dict, searchlist, visible, sqlVerifing, card, showField } = this.state
    return (
@@ -297,6 +326,7 @@
        <Switch checkedChildren={dict['model.switch.open']} unCheckedChildren={dict['model.switch.close']} defaultChecked={showField} onChange={this.onFieldChange} />
        <DragElement
          list={searchlist}
          show={config.setting.show}
          showField={showField}
          handleList={this.handleList}
          handleMenu={this.handleSearch}