From 669d7cc31eb3728ad09bfb7ce6e615f5c571c14e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 08 一月 2020 15:58:39 +0800 Subject: [PATCH] 2020-01-08 --- src/templates/tableshare/verifycard/voucherform/index.jsx | 74 ++++++++++++++++-------------------- 1 files changed, 33 insertions(+), 41 deletions(-) diff --git a/src/templates/tableshare/verifycard/voucherform/index.jsx b/src/templates/tableshare/verifycard/voucherform/index.jsx index a661f56..7acdb92 100644 --- a/src/templates/tableshare/verifycard/voucherform/index.jsx +++ b/src/templates/tableshare/verifycard/voucherform/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Form, Row, Col, Input, Select, Switch } from 'antd' +import { Form, Row, Col, Select, Switch } from 'antd' import './index.scss' @@ -10,33 +10,33 @@ dict: PropTypes.object, // 瀛楀吀椤� voucherobj: PropTypes.object, // 鍑瘉淇℃伅 voucher: PropTypes.array, // 琛ㄥ崟 + columns: PropTypes.array, // 琛ㄥ崟 voucherDetail: PropTypes.array, // 琛ㄥ崟 - voucherChange: PropTypes.func // 琛ㄥ崟 + voucherChange: PropTypes.func // 琛ㄥ崟 } state = { voucher: [], - voucherDetail: [] + voucherDetail: [], + columns: [] } UNSAFE_componentWillMount() { + let _voucher = [] + let _voucherDetail = [] if (this.props.voucherobj.BVoucherType && this.props.voucher.length > 0) { - let _voucher = this.props.voucher.filter(item => item.TypeCharOne === this.props.voucherobj.BVoucherType) - let _voucherDetail = this.props.voucherDetail.filter(item => item.BID === this.props.voucherobj.VoucherType) - - this.setState({ - voucher: _voucher, - voucherDetail: _voucherDetail - }) + _voucher = this.props.voucher.filter(item => item.TypeCharOne === this.props.voucherobj.BVoucherType) + _voucherDetail = this.props.voucherDetail.filter(item => item.BID === this.props.voucherobj.VoucherType) } else if (this.props.voucher.length > 0) { - let _voucher = this.props.voucher.filter(item => item.TypeCharOne === 'MES') - let _voucherDetail = this.props.voucherDetail.filter(item => _voucher[0] && item.BID === _voucher[0].ID) - - this.setState({ - voucher: _voucher, - voucherDetail: _voucherDetail - }) + _voucher = this.props.voucher.filter(item => item.TypeCharOne === 'MES') + _voucherDetail = this.props.voucherDetail.filter(item => _voucher[0] && item.BID === _voucher[0].ID) } + + this.setState({ + voucher: _voucher, + voucherDetail: _voucherDetail, + columns: this.props.columns.filter(col => col.type === 'text') + }) } UNSAFE_componentWillReceiveProps (nextProps) { @@ -137,6 +137,7 @@ render() { const { getFieldDecorator } = this.props.form const { voucherobj } = this.props + const { columns } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -147,6 +148,7 @@ sm: { span: 14 } } } + return ( <Form {...formItemLayout} className="verify-form"> <Row gutter={24}> @@ -221,36 +223,26 @@ </Form.Item> </Col> <Col span={6}> - <Form.Item label={'鎻愮ず淇℃伅'}> - {getFieldDecorator('errmsg', { - initialValue: voucherobj.errmsg ||'', + <Form.Item label={'鍏宠仈瀛楁'}> + {getFieldDecorator('linkField', { + initialValue: voucherobj.linkField || (columns[0] && columns[0].field) || '', rules: [ { required: true, - message: this.props.dict['form.required.input'] + '鎻愮ず淇℃伅!' - } - ] - })(<Input placeholder="" onChange={this.contentChange} autoComplete="off" />)} - </Form.Item> - </Col> - <Col span={6}> - <Form.Item label={'鎶ラ敊缂栫爜'}> - {getFieldDecorator('errorCode', { - initialValue: voucherobj.errmsg || 'E', - rules: [ - { - required: true, - message: this.props.dict['form.required.select'] + '鎶ラ敊缂栫爜!' + message: this.props.dict['form.required.input'] + '鍏宠仈瀛楁!' } ] })( - <Select onChange={this.contentChange}> - <Select.Option value="E"> E </Select.Option> - <Select.Option value="N"> N </Select.Option> - <Select.Option value="F"> F </Select.Option> - <Select.Option value="NM"> NM </Select.Option> - <Select.Option value="S"> S </Select.Option> - <Select.Option value="-1"> -1 </Select.Option> + <Select + showSearch + filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} + onChange={this.contentChange} + > + {columns.map((option, index) => + <Select.Option id={index + option.uuid} key={index + option.uuid} value={option.field}> + {option.label} + </Select.Option> + )} </Select> )} </Form.Item> -- Gitblit v1.8.0