| | |
| | | |
| | | const { confirm } = Modal |
| | | |
| | | // **悲观者往往正确,乐观者往往成功 |
| | | class SearchComponent extends Component { |
| | | static propTpyes = { |
| | | menu: PropTypes.object, // 当前菜单信息 |
| | |
| | | } |
| | | |
| | | state = { |
| | | dict: (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS, |
| | | dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | searchlist: null, // 搜索条件集 |
| | | sqlVerifing: false, // sql验证中 |
| | | visible: false, // 模态框控制 |
| | |
| | | this.setState({searchlist: [...searchlist, nextProps.pasteContent]}) |
| | | this.handleSearch(nextProps.pasteContent) |
| | | } else if (!is(fromJS(nextProps.config.search), fromJS(this.props.config.search)) && !is(fromJS(nextProps.config.search), fromJS(searchlist))) { |
| | | this.setState({searchlist: nextProps.config.search}) |
| | | this.setState({searchlist: fromJS(nextProps.config.search).toJS()}) |
| | | } |
| | | } |
| | | |
| | |
| | | this.setState({searchlist: list}) |
| | | this.handleSearch(card) |
| | | } else { |
| | | this.setState({searchlist: list}) |
| | | this.props.updatesearch({...config, search: list}) |
| | | this.setState({searchlist: list}, ()=> { |
| | | this.props.updatesearch({...config, search: list}) |
| | | }) |
| | | } |
| | | } |
| | | |
| | |
| | | * @description 搜索条件编辑,获取搜索条件表单信息 |
| | | */ |
| | | handleSearch = (card) => { |
| | | const { searchlist } = this.state |
| | | let linkableFields = [] |
| | | |
| | | searchlist.forEach(item => { |
| | | if (item.uuid !== card.uuid && (item.type === 'select' || item.type === 'link')) { |
| | | linkableFields.push({ |
| | | value: item.field, |
| | | text: item.label |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | this.setState({ |
| | | visible: true, |
| | | card: card, |
| | | formlist: getSearchForm(card, this.props.sysRoles) |
| | | formlist: getSearchForm(card, this.props.sysRoles, linkableFields) |
| | | }) |
| | | } |
| | | |
| | |
| | | |
| | | _searchlist = _searchlist.map(item => { // 数据更新及重复检测 |
| | | if (item.uuid !== res.uuid && res.field && item.field) { |
| | | if (item.field === res.field) { |
| | | let itemFields = [] |
| | | if (item.type === 'text') { |
| | | itemFields = item.field.split(',') |
| | | } else if (item.type === 'group') { |
| | | itemFields = [item.field, item.datefield] |
| | | } else { |
| | | itemFields = [item.field] |
| | | } |
| | | |
| | | let resFields = [] |
| | | if (res.type === 'text') { |
| | | resFields = res.field.split(',') |
| | | } else if (res.type === 'group') { |
| | | resFields = [res.field, res.datefield] |
| | | } else { |
| | | resFields = [res.field] |
| | | } |
| | | |
| | | let setFields = Array.from(new Set([...itemFields, ...resFields])) |
| | | |
| | | if (setFields.length < itemFields.length + resFields.length && (res.type !== 'date' || item.type !== 'date')) { |
| | | fieldrepet = true |
| | | } else if (item.label === res.label) { |
| | | labelrepet = true |
| | |
| | | func: 's_debug_sql', |
| | | LText: res.dataSource |
| | | } |
| | | |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '') |
| | | |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | |
| | | sqlVerifing: false, |
| | | searchlist: _searchlist, |
| | | visible: false |
| | | }, ()=> { |
| | | this.props.updatesearch({...config, search: _searchlist}, optionLibs) |
| | | }) |
| | | this.props.updatesearch({...config, search: _searchlist}, optionLibs) |
| | | } else { |
| | | this.setState({sqlVerifing: false}) |
| | | |
| | |
| | | this.setState({ |
| | | searchlist: _searchlist, |
| | | visible: false |
| | | }, ()=> { |
| | | this.props.updatesearch({...config, search: _searchlist}, optionLibs) |
| | | }) |
| | | this.props.updatesearch({...config, search: _searchlist}, optionLibs) |
| | | } |
| | | }) |
| | | } |
| | |
| | | confirm({ |
| | | content: dict['model.confirm'] + dict['model.delete'] + ` - ${card.label} ?`, |
| | | okText: dict['model.confirm'], |
| | | cancelText: this.state.dict['header.cancel'], |
| | | cancelText: this.state.dict['model.cancel'], |
| | | onOk() { |
| | | let _searchlist = fromJS(_this.state.searchlist).toJS() |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | render() { |
| | | const { dict, searchlist, visible, sqlVerifing, card } = this.state |
| | | |
| | |
| | | <Modal |
| | | title={dict['model.searchCriteria'] + '-' + (card && card.copyType === 'search' ? dict['model.copy'] : dict['model.edit'])} |
| | | visible={visible} |
| | | width={750} |
| | | width={850} |
| | | maskClosable={false} |
| | | onOk={this.handleSubmit} |
| | | confirmLoading={sqlVerifing} |