| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Input, Radio, Select } from 'antd' |
| | | import './index.scss' |
| | | import { Form, Row, Col, Input, Radio, Select, Tooltip } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | // import './index.scss' |
| | | |
| | | class MainSearch extends Component { |
| | | static propTpyes = { |
| | | formlist: PropTypes.array, // 按钮信息、表单列表 |
| | | dict: PropTypes.object // 字典项 |
| | | } |
| | | |
| | | state = { |
| | | |
| | | requireArr: true |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | |
| | | onChange = (value, key) => { |
| | | if (key === 'TryType' && value === 'N') { |
| | | this.setState({requireArr: false}) |
| | | } else if (key === 'TryType' && value === 'Y') { |
| | | this.setState({requireArr: true}) |
| | | } |
| | | } |
| | | |
| | | getFields() { |
| | | const { getFieldDecorator } = this.props.form |
| | | |
| | | const { requireArr } = this.state |
| | | const fields = [] |
| | | |
| | | this.props.formlist.forEach((item, index) => { |
| | | if (!requireArr && item.key === 'array_name') return |
| | | |
| | | if (item.type === 'text') { |
| | | fields.push( |
| | | <Col span={24} key={index}> |
| | | <Form.Item label={item.label}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initval, |
| | | rules: [ |
| | | { |
| | | required: item.required, |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | message: '请输入' + item.label + '!' |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off"/>)} |
| | |
| | | rules: [ |
| | | { |
| | | required: item.required, |
| | | message: this.props.dict['form.required.select'] + item.label + '!' |
| | | message: '请选择' + item.label + '!' |
| | | } |
| | | ] |
| | | })( |
| | |
| | | } else if (item.type === 'radio') { |
| | | fields.push( |
| | | <Col span={24} key={index}> |
| | | <Form.Item label={item.label}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initval, |
| | | rules: [ |
| | | { |
| | | required: item.required, |
| | | message: this.props.dict['form.required.select'] + item.label + '!' |
| | | message: '请选择' + item.label + '!' |
| | | } |
| | | ] |
| | | })( |
| | | <Radio.Group> |
| | | <Radio.Group onChange={(e) => this.onChange(e.target.value, item.key)}> |
| | | {item.options.map(op => { |
| | | return <Radio key={op.value} value={op.value}>{op.text}</Radio> |
| | | })} |
| | |
| | | } |
| | | } |
| | | return ( |
| | | <Form {...formItemLayout} className="create-Interface-setting-form"> |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}>{this.getFields()}</Row> |
| | | </Form> |
| | | ) |