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/templates/tableshare/verifycardexcelin/columnform/index.jsx | 70 +++++++++++++++++++++++++--------- 1 files changed, 51 insertions(+), 19 deletions(-) diff --git a/src/templates/tableshare/verifycardexcelin/columnform/index.jsx b/src/templates/tableshare/verifycardexcelin/columnform/index.jsx index 3470733..3fc28f9 100644 --- a/src/templates/tableshare/verifycardexcelin/columnform/index.jsx +++ b/src/templates/tableshare/verifycardexcelin/columnform/index.jsx @@ -13,7 +13,8 @@ state = { editItem: null, // 缂栬緫鍏冪礌 - type: 'Nvarchar(50)' + type: 'Nvarchar(50)', + locked: false } edit = (record) => { @@ -35,11 +36,33 @@ required: record.required, type: record.type }) + if (record.type === 'Int' || /^Decimal/ig.test(record.type)) { + this.setState({ + locked: true + }) + } else { + this.setState({ + locked: false + }) + } } typeChange = (val) => { this.setState({ type: val + }, () => { + if (val === 'Int' || /^Decimal/ig.test(val)) { + this.props.form.setFieldsValue({ + required: 'true', + }) + this.setState({ + locked: true + }) + } else { + this.setState({ + locked: false + }) + } }) } @@ -50,9 +73,18 @@ if (!err) { values.uuid = this.state.editItem ? this.state.editItem.uuid : '' + if (/^Nvarchar/ig.test(values.type)) { + values.limit = values.type.match(/\d+/)[0] + } else if (/^Decimal/ig.test(values.type)) { + values.limit = values.type.match(/\d+/ig)[1] + } else { + values.limit = '' + } + this.props.columnChange(values) this.setState({ - editItem: null + editItem: null, + locked: false }) this.props.form.setFieldsValue({ Column: '', @@ -109,23 +141,6 @@ </Form.Item> </Col> <Col span={7}> - <Form.Item label={'鏄惁蹇呭~'}> - {getFieldDecorator('required', { - initialValue: 'true' - })( - <Select> - <Select.Option value="false"> 鍚� </Select.Option> - <Select.Option value="true"> 鏄� </Select.Option> - </Select> - )} - </Form.Item> - </Col> - <Col span={3} className="add"> - <Button onClick={this.handleConfirm} type="primary" className="add-row"> - 纭畾 - </Button> - </Col> - <Col span={7}> <Form.Item label={'绫诲瀷'}> {getFieldDecorator('type', { initialValue: 'Nvarchar(50)' @@ -145,6 +160,23 @@ )} </Form.Item> </Col> + <Col span={3} className="add"> + <Button onClick={this.handleConfirm} type="primary" className="add-row"> + 纭畾 + </Button> + </Col> + <Col span={7}> + <Form.Item label={'鏄惁蹇呭~'}> + {getFieldDecorator('required', { + initialValue: 'true' + })( + <Select disabled={this.state.locked}> + <Select.Option value="false"> 鍚� </Select.Option> + <Select.Option value="true"> 鏄� </Select.Option> + </Select> + )} + </Form.Item> + </Col> {haslimit ? <Col span={7}> <Form.Item label={'鏈�灏忓��'}> {getFieldDecorator('min', { -- Gitblit v1.8.0