| | |
| | | /** |
| | | * @description 搜索条件顺序调整,或拖拽添加 |
| | | */ |
| | | handleList = (list, card) => { |
| | | const { config } = this.props |
| | | handleList = (list, newcell) => { |
| | | const { card } = this.state |
| | | let _card = {...card, search: list} |
| | | |
| | | if (card) { |
| | | this.setState({searchlist: list}) |
| | | this.handleSearch(card) |
| | | if (newcell) { |
| | | this.setState({card: _card}) |
| | | this.handleSearch(newcell) |
| | | } else { |
| | | this.setState({searchlist: list}, ()=> { |
| | | this.props.updatesearch({...config, search: list}) |
| | | this.setState({card: _card}, ()=> { |
| | | this.props.updateConfig(_card) |
| | | }) |
| | | } |
| | | } |
| | |
| | | * @description 取消保存,如果元素为新添元素,则从序列中删除 |
| | | */ |
| | | editModalCancel = () => { |
| | | const { card } = this.state |
| | | const { card, editcard } = this.state |
| | | |
| | | if (card.focus) { |
| | | let searchlist = fromJS(this.state.searchlist).toJS() |
| | | |
| | | searchlist = searchlist.filter(item => item.uuid !== card.uuid) |
| | | if (editcard.focus) { |
| | | card.search = card.search.filter(item => item.uuid !== editcard.uuid) |
| | | |
| | | this.setState({ |
| | | card: null, |
| | | searchlist: searchlist, |
| | | card: card, |
| | | editcard: null, |
| | | visible: false |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | card: null, |
| | | editcard: null, |
| | | visible: false |
| | | }) |
| | | } |
| | |
| | | |
| | | /** |
| | | * @description 搜索修改后提交保存 |
| | | * 1、去除系统默认搜索条件 |
| | | * 2、字段及提示文字重复校验 |
| | | * 3、更新下拉菜单可选集合 |
| | | * 4、下拉菜单数据源语法验证 |
| | | * 1、字段及提示文字重复校验 |
| | | * 2、下拉菜单数据源语法验证 |
| | | */ |
| | | handleSubmit = () => { |
| | | const { config } = this.props |
| | | let _searchlist = fromJS(this.state.searchlist).toJS() |
| | | let card = fromJS(this.state.card).toJS() |
| | | |
| | | this.searchFormRef.handleConfirm().then(res => { |
| | | let fieldrepet = false // 字段重复 |
| | | let labelrepet = false // 提示文字重复 |
| | | |
| | | _searchlist = _searchlist.filter(item => !item.origin || item.uuid === res.uuid) // 去除系统项 |
| | | |
| | | _searchlist = _searchlist.map(item => { // 数据更新及重复检测 |
| | | card.search = card.search.map(item => { // 数据更新及重复检测 |
| | | if (item.uuid !== res.uuid && res.field && item.field) { |
| | | let itemFields = [] |
| | | if (item.type === 'text') { |
| | |
| | | return |
| | | } |
| | | |
| | | if ((res.type === 'select' || res.type === 'multiselect' || res.type === 'link') && res.resourceType === '1' && /\s/.test(res.dataSource)) { |
| | | if (['select', 'multiselect', 'link'].includes(res.type) && res.resourceType === '1' && /\s/.test(res.dataSource)) { |
| | | this.setState({ |
| | | sqlVerifing: true |
| | | }) |
| | |
| | | Api.getLocalConfig(param).then(result => { |
| | | if (result.status) { |
| | | this.setState({ |
| | | card: card, |
| | | sqlVerifing: false, |
| | | searchlist: _searchlist, |
| | | visible: false |
| | | }, ()=> { |
| | | this.props.updatesearch({...config, search: _searchlist}) |
| | | this.props.updateConfig(card) |
| | | }) |
| | | } else { |
| | | this.setState({sqlVerifing: false}) |
| | |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | searchlist: _searchlist, |
| | | card: card, |
| | | visible: false |
| | | }, ()=> { |
| | | this.props.updatesearch({...config, search: _searchlist}) |
| | | this.props.updateConfig(card) |
| | | }) |
| | | } |
| | | }) |
| | |
| | | /** |
| | | * @description 搜索条件删除 |
| | | */ |
| | | deleteElement = (card) => { |
| | | const { config } = this.props |
| | | deleteElement = (cell) => { |
| | | const { dict } = this.state |
| | | let _this = this |
| | | |
| | | confirm({ |
| | | content: dict['model.confirm'] + dict['model.delete'] + ` - ${card.label} ?`, |
| | | content: dict['model.confirm'] + dict['model.delete'] + ` - ${cell.label} ?`, |
| | | onOk() { |
| | | let _searchlist = fromJS(_this.state.searchlist).toJS() |
| | | |
| | | _searchlist = _searchlist.filter(item => item.uuid !== card.uuid) |
| | | let _card = fromJS(_this.state.card).toJS() |
| | | _card.search = _card.search.filter(item => item.uuid !== cell.uuid) |
| | | |
| | | _this.setState({ |
| | | searchlist: _searchlist |
| | | card: _card |
| | | }, () => { |
| | | _this.props.updatesearch({...config, search: _searchlist}) |
| | | _this.props.updateConfig(_card) |
| | | }) |
| | | }, |
| | | onCancel() {} |
| | |
| | | } |
| | | card.search.push(item) |
| | | |
| | | this.setState({card}) |
| | | this.setState({card}, () => { |
| | | this.handleSearch(item) |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | |
| | | > |
| | | <SearchForm |
| | | dict={dict} |
| | | card={this.state.card} |
| | | card={this.state.editcard} |
| | | formlist={this.state.formlist} |
| | | inputSubmit={this.handleSubmit} |
| | | wrappedComponentRef={(inst) => this.searchFormRef = inst} |