| | |
| | | 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' |
| | |
| | | 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}) |
| | | }) |
| | | } |
| | | } |
| | | |
| | |
| | | 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 ( |
| | |
| | | <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} |