king
2020-01-08 669d7cc31eb3728ad09bfb7ce6e615f5c571c14e
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>