From 88ca0a326f0101a7713404909041003a512bb7e2 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 08 六月 2022 17:19:41 +0800 Subject: [PATCH] 2022-06-08 --- src/templates/sharecomponent/searchcomponent/searchform/index.jsx | 23 +++++++++++++++++++++-- 1 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx index 2b3e7fd..238c641 100644 --- a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { fromJS } from 'immutable' -import { Form, Row, Col, Input, Select, Radio, notification, Tooltip, InputNumber, Checkbox, Cascader } from 'antd' +import { Form, Row, Col, Input, Select, Radio, notification, Tooltip, InputNumber, Checkbox, Cascader, AutoComplete } from 'antd' import { QuestionCircleOutlined } from '@ant-design/icons' import { dateOptions, matchReg, formRule } from '@/utils/option.js' @@ -419,6 +419,12 @@ this.props.form.setFieldsValue({dataSource: resource}) } + complete = (key, option) => { + let label = option.props.label + + this.props.form.setFieldsValue({label: label}) + } + getFields() { const { getFieldDecorator } = this.props.form const { dict } = this.props @@ -455,7 +461,20 @@ }) } - content = <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} /> + if (item.key === 'field' && item.options && item.options.length > 0) { + content = <AutoComplete + dataSource={item.options.map((cell) => <AutoComplete.Option label={cell.label} key={cell.key}> + {cell.text} + </AutoComplete.Option>)} + filterOption={(input, option) => option.props.children.indexOf(input) > -1} + onSelect={this.complete} + placeholder="" + > + <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} /> + </AutoComplete> + } else { + content = <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} /> + } } else if (item.type === 'number') { rules = [ { required: item.required, message: dict['form.required.input'] + item.label + '!' } -- Gitblit v1.8.0