From 063b983daaf51a7f1e8677bde1e9c0e618866c91 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 21 二月 2020 10:30:19 +0800 Subject: [PATCH] 2020-02-21 --- src/tabviews/tableshare/mutilform/index.jsx | 54 ++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/tabviews/tableshare/mutilform/index.jsx b/src/tabviews/tableshare/mutilform/index.jsx index aec1414..ea7f0d8 100644 --- a/src/tabviews/tableshare/mutilform/index.jsx +++ b/src/tabviews/tableshare/mutilform/index.jsx @@ -21,12 +21,27 @@ } 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 () { @@ -129,7 +144,7 @@ if (error) { notification.warning({ top: 92, - message: '鍏宠仈鑿滃崟璁剧疆閿欒锛�', + message: this.props.dict['main.form.link.error'], duration: 10 }) } @@ -151,7 +166,7 @@ input.select() }) } catch { - console.warn('琛ㄥ崟鑾峰彇澶辫触锛�') + console.warn('focus error锛�') } } }) @@ -243,15 +258,9 @@ 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 @@ -263,6 +272,26 @@ </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}> @@ -274,9 +303,10 @@ 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> -- Gitblit v1.8.0