king
2023-05-22 43a517b80f2803e0dcf6658113520c4a14c8c17f
src/templates/zshare/verifycard/contrastform/index.jsx
@@ -1,44 +1,18 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Select, Button, Input } from 'antd'
import './index.scss'
// import './index.scss'
class UniqueForm extends Component {
  static propTpyes = {
    dict: PropTypes.object,       // 字典项
    contrastChange: PropTypes.func  // 修改函数
  }
  state = {
    editItem: null // 编辑元素
  }
  edit = (record) => {
    this.setState({
      editItem: record
    })
    this.props.form.setFieldsValue({
      frontfield: record.frontfield,
      operator: record.operator,
      backfield: record.backfield,
      errmsg: record.errmsg,
      errorCode: record.errorCode
    })
  }
  handleConfirm = () => {
    // 表单提交时检查输入值是否正确
    this.props.form.validateFieldsAndScroll((err, values) => {
      if (!err) {
        values.uuid = this.state.editItem ? this.state.editItem.uuid : ''
        this.props.contrastChange(values)
        this.setState({
          editItem: null
        })
        this.props.form.setFieldsValue({
          frontfield: '',
          backfield: '',
@@ -65,26 +39,26 @@
      <Form {...formItemLayout} className="verify-form" id="verifycard1">
        <Row gutter={24}>
          <Col span={7}>
            <Form.Item label={'内容1'}>
            <Form.Item label="内容1">
              {getFieldDecorator('frontfield', {
                initialValue: '',
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.input'] + '内容1!'
                    message: '请输入内容1!'
                  }
                ]
              })(<Input placeholder="" autoComplete="off" />)}
            </Form.Item>
          </Col>
          <Col span={7}>
            <Form.Item label={'运算符'}>
            <Form.Item label="运算符">
              {getFieldDecorator('operator', {
                initialValue: '=',
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.select'] + '运算符!'
                    message: '请选择运算符!'
                  }
                ]
              })(
@@ -102,31 +76,31 @@
            </Form.Item>
          </Col>
          <Col span={7}>
            <Form.Item label={'内容2'}>
            <Form.Item label="内容2">
              {getFieldDecorator('backfield', {
                initialValue: '',
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.input'] + '内容2!'
                    message: '请输入内容2!'
                  }
                ]
              })(<Input placeholder="" autoComplete="off" />)}
            </Form.Item>
          </Col>
          <Col span={3} className="add">
            <Button onClick={this.handleConfirm} type="primary" className="add-row">
              确定
            <Button onClick={this.handleConfirm} type="primary" className="mk-green">
              添加
            </Button>
          </Col>
          <Col span={7}>
            <Form.Item label={'提示信息'}>
            <Form.Item label="提示信息">
              {getFieldDecorator('errmsg', {
                initialValue: '',
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.input'] + '提示信息!'
                    message: '请输入提示信息!'
                  },
                  {
                    pattern: /^[^']*$/ig,
@@ -143,7 +117,7 @@
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.select'] + '报错编码!'
                    message: '请选择报错编码!'
                  }
                ]
              })(