| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Input, Radio, Select } from 'antd' |
| | | import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon } from 'antd' |
| | | import { formRule } from '@/utils/option.js' |
| | | import './index.scss' |
| | | |
| | |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { group } = this.props |
| | | const { appType } = this.state |
| | | let fields = [] |
| | | |
| | | group.fields.forEach(f => { |
| | | if (f.field && ['select', 'link', 'text', 'number'].includes(f.type) && f.hidden !== 'true' && f.readonly !== 'true') { |
| | | fields.push(f) |
| | | } |
| | | }) |
| | | if (appType === 'mob') { |
| | | group.fields.forEach(f => { |
| | | if (f.field && ['text', 'number'].includes(f.type) && f.hidden !== 'true' && f.readonly !== 'true') { |
| | | fields.push(f) |
| | | } |
| | | }) |
| | | } else { |
| | | group.fields.forEach(f => { |
| | | if (f.field && ['select', 'link', 'text', 'number'].includes(f.type) && f.hidden !== 'true' && f.readonly !== 'true') { |
| | | fields.push(f) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | fields: fields |
| | |
| | | render() { |
| | | const { group, dict } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { fields } = this.state |
| | | const { fields, appType } = this.state |
| | | |
| | | const formItemLayout = { |
| | | labelCol: { |
| | |
| | | <Form.Item label="标题"> |
| | | {getFieldDecorator('title', { |
| | | initialValue: group.setting.title, |
| | | rules: [ |
| | | { |
| | | max: formRule.input.max, |
| | | message: formRule.input.message |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="用于表单加载时的状态控制。"> |
| | | <Icon type="question-circle" /> |
| | | 状态值 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('status', { |
| | | initialValue: group.setting.status || '', |
| | | rules: [ |
| | | { |
| | | max: formRule.input.max, |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | {appType !== 'mob' ? <Col span={12}> |
| | | <Form.Item label="表单排列"> |
| | | {getFieldDecorator('align', { |
| | | initialValue: group.setting.align || 'left_right' |
| | |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | </Col> : null} |
| | | </Row> |
| | | </Form> |
| | | ) |