| | |
| | | ] |
| | | |
| | | const searchTypeOptions = { |
| | | text: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced'], |
| | | text: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'inputType', 'advanced'], |
| | | select: ['label', 'field', 'resourceType', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'setAll'], |
| | | multiselect: ['label', 'field', 'resourceType', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced'], |
| | | link: ['label', 'field', 'resourceType', 'initval', 'type', 'linkField', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'setAll'], |
| | |
| | | dateweek: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced'], |
| | | datemonth: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced'], |
| | | daterange: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced'], |
| | | group: ['label', 'type', 'field', 'datefield', 'initval', 'blacklist', 'ratio', 'items', 'required', 'transfer', 'labelShow'] |
| | | group: ['label', 'type', 'field', 'datefield', 'initval', 'blacklist', 'ratio', 'items', 'required', 'labelShow'], |
| | | range: ['label', 'type', 'field', 'initval', 'match', 'blacklist', 'Hide', 'required', 'maxValue', 'minValue', 'step', 'labelShow'] |
| | | } |
| | | |
| | | class MainSearch extends Component { |
| | |
| | | let resourceType = '' |
| | | let display = '' |
| | | let cFields = [] |
| | | let multiple = 'false' |
| | | |
| | | formlist.forEach(cell => { |
| | | if (cell.key === 'type') { |
| | |
| | | resourceType = cell.initVal |
| | | } else if (cell.key === 'fields') { |
| | | cFields = cell.initVal |
| | | } else if (cell.key === 'multiple') { |
| | | multiple = cell.initVal |
| | | } |
| | | }) |
| | | |
| | |
| | | } else if (form.key === 'match') { // 表单为匹配字段时,根据不同的类型,显示对应的匹配规则 |
| | | if (type === 'text') { |
| | | form.options = matchReg.text |
| | | } else if (type === 'multiselect') { |
| | | } else if (type === 'multiselect' || (type === 'checkcard' && multiple === 'true')) { |
| | | form.options = matchReg.multiselect |
| | | } else if (type === 'select' || type === 'link' || type === 'checkcard') { |
| | | form.options = matchReg.select |
| | |
| | | form.options = matchReg.date |
| | | } else if (type === 'datemonth') { |
| | | form.options = matchReg.datemonth |
| | | } else if (type === 'dateweek' || type === 'daterange') { |
| | | } else if (type === 'dateweek' || type === 'daterange' || type === 'range') { |
| | | form.options = matchReg.daterange |
| | | } |
| | | } else if (form.key === 'field' && type === 'text') { |
| | | } else if (form.key === 'field' && (type === 'text' || type === 'select')) { |
| | | form.tooltip = this.state.textTooltip |
| | | } else if (form.key === 'field' && type === 'group') { |
| | | form.tooltip = '查询数据时(自定义脚本或统计数据源),类型字段将用作替换脚本中的 @字段@ ,类型字段对应值为 {"日": "day", "周": "week", "月": "month", "季": "quarter", "年": "year", "自定义": "customized"}。' |
| | | form.label = dict['model.form.type'] + dict['model.form.field'] |
| | | } |
| | | form.hidden = !_options.includes(form.key) |
| | |
| | | try { |
| | | let _form = document.getElementById('label') |
| | | _form.select() |
| | | } catch { |
| | | } catch (e) { |
| | | console.warn('表单focus失败!') |
| | | } |
| | | } |
| | |
| | | form.options = matchReg.date |
| | | } else if (value === 'datemonth') { |
| | | form.options = matchReg.datemonth |
| | | } else if (value === 'dateweek' || value === 'daterange') { |
| | | } else if (value === 'dateweek' || value === 'daterange' || value === 'range') { |
| | | form.options = matchReg.daterange |
| | | } |
| | | matchs = form.options |
| | | } else if (form.key === 'field') { |
| | | form.tooltip = '' |
| | | form.label = dict['model.form.field'] |
| | | if (value === 'text') { |
| | | if (value === 'text' || value === 'select') { |
| | | form.tooltip = this.state.textTooltip |
| | | } else if (value === 'group') { |
| | | form.tooltip = '查询数据时(自定义脚本或统计数据源),类型字段将用作替换脚本中的 @字段@ ,类型字段对应值为 {"日": "day", "周": "week", "月": "month", "季": "quarter", "年": "year", "自定义": "customized"}。' |
| | | form.label = dict['model.form.type'] + dict['model.form.field'] |
| | | } |
| | | } |
| | |
| | | } |
| | | if (this.props.form.getFieldValue('match') !== undefined) { |
| | | this.props.form.setFieldsValue({match: matchs[0].value}) |
| | | } |
| | | if (this.props.form.getFieldValue('multiple') !== undefined) { |
| | | this.props.form.setFieldsValue({multiple: 'false'}) |
| | | } |
| | | }) |
| | | } |
| | |
| | | form.hidden = !_options.includes(form.key) |
| | | return form |
| | | }) |
| | | }) |
| | | } else if (key === 'multiple') { |
| | | let matchs = [] |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(form => { |
| | | if (form.key === 'match') { |
| | | if (value === 'true') { |
| | | form.options = matchReg.multiselect |
| | | } else { |
| | | form.options = matchReg.select |
| | | } |
| | | matchs = form.options |
| | | } |
| | | |
| | | return form |
| | | }) |
| | | }, () => { |
| | | if (this.props.form.getFieldValue('match') !== undefined) { |
| | | this.props.form.setFieldsValue({match: matchs[0].value}) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | |
| | | const { getFieldDecorator } = this.props.form |
| | | const fields = [] |
| | | this.state.formlist.forEach((item, index) => { |
| | | if (item.hidden) return |
| | | if (item.hidden || item.forbid) return |
| | | |
| | | if (item.type === 'text') { // 文本搜索 |
| | | let rules = [] |
| | |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal || 6, |
| | | initialValue: item.initVal, |
| | | rules: [ |
| | | { |
| | | required: item.required, |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | } |
| | | ] |
| | | })(<InputNumber min={item.min} max={item.max} precision={0} onPressEnter={this.handleSubmit}/>)} |
| | | })(item.max ? |
| | | <InputNumber min={item.min} max={item.max} precision={0} onPressEnter={this.handleSubmit}/> : |
| | | <InputNumber onPressEnter={this.handleSubmit}/> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | |
| | | values.options = [] |
| | | } |
| | | |
| | | if (values.type === 'range') { |
| | | let error = '' |
| | | if (values.maxValue <= values.minValue) { |
| | | error = '最大值必须大于最小值' |
| | | } else if (values.step <= 0) { |
| | | error = '步长必须大于0' |
| | | } else { |
| | | let s = (values.maxValue - values.minValue) / values.step |
| | | if (s !== parseInt(s)) { |
| | | error = '步长必须被 (max - min) 整除' |
| | | } |
| | | } |
| | | |
| | | if (!error && values.initval) { |
| | | let vals = values.initval.split(',') |
| | | if (vals.length !== 2) { |
| | | error = '初始值设置错误!' |
| | | } else if (isNaN(parseFloat(vals[0])) || isNaN(parseFloat(vals[1]))) { |
| | | error = '初始值设置错误!' |
| | | } else { |
| | | let start = parseFloat(vals[0]) |
| | | let end = parseFloat(vals[1]) |
| | | let s = (values.maxValue - start) / values.step |
| | | let e = (values.maxValue - end) / values.step |
| | | if (start > end || start < values.minValue || end > values.maxValue) { |
| | | error = '初始值设置错误!' |
| | | } else if (s !== parseInt(s) || e !== parseInt(e)) { |
| | | error = '初始值设置错误!' |
| | | } |
| | | } |
| | | } |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: error, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | } |
| | | |
| | | if (isvalid) { |
| | | ['linkField', 'valueField', 'valueText', 'orderBy'].forEach(item => { |
| | | if (values[item]) { |