From 07acb5f4dc11e484801ccfcd95eee8845128c62a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 26 十一月 2019 22:41:29 +0800 Subject: [PATCH] 2019-11-26-01 --- src/templates/comtableconfig/searchform/index.jsx | 123 ++++++++++++++++++++++++++++++++--------- 1 files changed, 96 insertions(+), 27 deletions(-) diff --git a/src/templates/comtableconfig/searchform/index.jsx b/src/templates/comtableconfig/searchform/index.jsx index 2ac2445..c151d01 100644 --- a/src/templates/comtableconfig/searchform/index.jsx +++ b/src/templates/comtableconfig/searchform/index.jsx @@ -1,11 +1,52 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { Form, Row, Col, Input, Select, Icon, Radio, notification } from 'antd' -// import moment from 'moment' import EditTable from '../editable' import './index.scss' const { TextArea } = Input +const matchReg = { + text: [{ + value: 'like', + text: 'like' + }, { + value: 'not like', + text: 'not like' + }, { + value: '=', + text: '=' + }], + select: [{ + value: '=', + text: '=' + }, { + value: 'like', + text: 'like' + }, { + value: 'not like', + text: 'not like' + }], + date: [{ + value: '>=', + text: '>=' + }, { + value: '<=', + text: '<=' + }, { + value: '>', + text: '>' + }, { + value: '<', + text: '<' + }, { + value: '=', + text: '=' + }], + daterange: [{ + value: 'between', + text: 'between' + }] +} class MainSearch extends Component { static propTpyes = { @@ -29,18 +70,17 @@ openTypeChange = (key, value) => { if (key === 'type') { let _options = ['label', 'field', 'initval', 'type', 'match'] - if (value === 'select' && this.state.resourceType === '0') { - _options = [..._options, ...['resourceType', 'setAll', 'options', 'display']] - } else if (value === 'select' && this.state.resourceType === '1') { - _options = [..._options, ...['resourceType', 'setAll', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']] - } else if (value === 'link' && this.state.resourceType === '0') { - _options = [..._options, ...['resourceType', 'setAll', 'options', 'linkField', 'display']] - } else if (value === 'link' && this.state.resourceType === '1') { - _options = [..._options, ...['resourceType', 'setAll', 'dataSource', 'linkField', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']] + if (value === 'select' || value === 'link') { // 鍒囨崲绫诲瀷涓洪�夋嫨鎴栧叧鑱旀椂锛屾潵婧愰粯璁や负鑷畾涔� + _options = [..._options, 'resourceType', 'setAll', 'options', 'display'] + } + + if (value === 'link') { + _options = [..._options, 'linkField'] } this.setState({ openType: value, + resourceType: '0', formlist: this.state.formlist.map(form => { form.hidden = !_options.includes(form.key) if (form.key === 'initval') { @@ -53,12 +93,29 @@ form.initVal = '' form.hidden = true } + + if (form.key === 'match') { + if (value === 'text') { + form.options = matchReg.text + } else if (value === 'select' || value === 'link') { + form.options = matchReg.select + } else if (value === 'date' || value === 'datemonth') { + form.options = matchReg.date + } else if (value === 'dateweek' || value === 'daterange') { + form.options = matchReg.daterange + } + form.hidden = true + } return form }) }, () => { this.setState({ formlist: this.state.formlist.map(form => { if (form.key === 'initval') { + form.hidden = false + } + if (form.key === 'match') { + form.initVal = form.options[0].value form.hidden = false } return form @@ -69,17 +126,18 @@ } onChange = (e, key) => { + const { openType } = this.state let value = e.target.value if (key === 'resourceType') { - let _options = ['label', 'field', 'initval', 'type', 'match', 'resourceType', 'setAll'] - if (this.state.openType === 'select' && value === '0') { - _options = [..._options, ...['options', 'display']] - } else if (this.state.openType === 'select' && value === '1') { - _options = [..._options, ...['dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']] - } else if (this.state.openType === 'link' && value === '0') { - _options = [..._options, ...['options', 'linkField', 'display']] - } else if (this.state.openType === 'link' && value === '1') { - _options = [..._options, ...['dataSource', 'linkField', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']] + let _options = ['label', 'field', 'initval', 'type', 'match', 'resourceType', 'setAll', 'display'] + if (value === '0') { + _options = [..._options, 'options'] + } else if (value === '1') { + _options = [..._options, 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType'] + } + + if (openType === 'link') { + _options = [..._options, 'linkField'] } this.setState({ @@ -246,15 +304,15 @@ if (!formlist) return let type = formlist.filter(cell => cell.key === 'type')[0].initVal let resourceType = formlist.filter(cell => cell.key === 'resourceType')[0].initVal - let _options = ['label', 'field', 'initval', 'type', 'match'] - if (type === 'select' && resourceType === '0') { - _options = [..._options, ...['resourceType', 'setAll', 'options', 'display']] - } else if (type === 'select' && resourceType === '1') { - _options = [..._options, ...['resourceType', 'setAll', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']] - } else if (type === 'link' && resourceType === '0') { - _options = [..._options, ...['resourceType', 'setAll', 'options', 'linkField', 'display']] - } else if (type === 'link' && resourceType === '1') { - _options = [..._options, ...['resourceType', 'setAll', 'dataSource', 'linkField', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']] + let _options = ['label', 'field', 'initval', 'type', 'match'] // 榛樿鏄剧ず椤� + if ((type === 'select' || type === 'link') && resourceType === '0') { // 閫夋嫨绫诲瀷銆佽嚜瀹氫箟璧勬簮 + _options = [..._options, 'resourceType', 'setAll', 'options', 'display'] + } else if ((type === 'select' || type === 'link') && resourceType === '1') { // 閫夋嫨绫诲瀷銆佹暟鎹簮 + _options = [..._options, 'resourceType', 'setAll', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display'] + } + + if (type === 'link') { // 鍏宠仈绫诲瀷銆佸鍔犲叧鑱斿瓧娈� + _options = [..._options, 'linkField'] } this.setState({ @@ -265,6 +323,17 @@ form.options = this.state.dateoptions[type] form.type = 'select' } + if (form.key === 'match') { + if (type === 'text') { + form.options = matchReg.text + } else if (type === 'select' || type === 'link') { + form.options = matchReg.select + } else if (type === 'date' || type === 'datemonth') { + form.options = matchReg.date + } else if (type === 'dateweek' || type === 'daterange') { + form.options = matchReg.daterange + } + } form.hidden = !_options.includes(form.key) return form }) -- Gitblit v1.8.0