| | |
| | | } |
| | | |
| | | state = { |
| | | cols: 2, |
| | | datatype: null, |
| | | readtype: null, |
| | | readin: null, |
| | | fieldlen: null, |
| | | formlist: [], |
| | | record: {} |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | let cols = 2 |
| | | if (this.props.action.setting && this.props.action.setting.cols) { |
| | | cols = parseInt(this.props.action.setting.cols) |
| | | if (cols > 3 || cols < 1) { |
| | | cols = 2 |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | cols: cols |
| | | }) |
| | | } |
| | | |
| | | componentDidMount () { |
| | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '关联菜单设置错误!', |
| | | message: this.props.dict['main.form.link.error'], |
| | | duration: 10 |
| | | }) |
| | | } |
| | |
| | | input.select() |
| | | }) |
| | | } catch { |
| | | console.warn('表单获取失败!') |
| | | console.warn('focus error!') |
| | | } |
| | | } |
| | | }) |
| | |
| | | |
| | | getFields() { |
| | | const { getFieldDecorator } = this.props.form |
| | | const { cols } = this.state |
| | | |
| | | const fields = [] |
| | | let cols = 2 |
| | | if (this.props.action.setting && this.props.action.setting.cols) { |
| | | cols = parseInt(this.props.action.setting.cols) |
| | | if (cols > 3 || cols < 1) { |
| | | cols = 2 |
| | | } |
| | | } |
| | | |
| | | this.state.formlist.forEach((item, index) => { |
| | | if ((!item.field && item.type !== 'title') || item.hidden === 'true') return |
| | |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'text') { |
| | | let _max = item.fieldlength || 50 |
| | | let _rules = [] |
| | | if (item.regular) { |
| | | if (item.regular === 'number') { |
| | | _rules = [{ |
| | | pattern: /^[0-9]*$/ig, |
| | | message: formRule.input.numbermsg |
| | | }] |
| | | } else if (item.regular === 'letter') { |
| | | _rules = [{ |
| | | pattern: /^[a-zA-Z]*$/ig, |
| | | message: formRule.input.lettermsg |
| | | }] |
| | | } else if (item.regular === 'letter&number') { |
| | | _rules = [{ |
| | | pattern: /^[a-zA-Z0-9]*$/ig, |
| | | message: formRule.input.letternummsg |
| | | }] |
| | | } |
| | | } |
| | | fields.push( |
| | | <Col span={24 / cols} key={index}> |
| | | <Form.Item label={item.label}> |
| | |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | }, |
| | | { |
| | | max: formRule.input.max, |
| | | message: formRule.input.message |
| | | } |
| | | max: _max, |
| | | message: formRule.input.formMessage.replace('@max', _max) |
| | | }, |
| | | ..._rules |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} />)} |
| | | </Form.Item> |