king
2020-11-24 0f79daefced8980fa571dd3d2c781a0e3646614f
src/templates/sharecomponent/actioncomponent/verifyexcelin/uniqueform/index.jsx
@@ -11,46 +11,25 @@
    uniqueChange: PropTypes.func  // 修改函数
  }
  state = {
    editItem: null // 编辑元素
  }
  edit = (record) => {
    this.setState({
      editItem: record
    })
    this.props.form.setFieldsValue({
      field: record.field.split(','),
      errorCode: record.errorCode,
      verifyType: record.verifyType || 'physical'
    })
  }
  handleConfirm = () => {
    const { fields } = this.props
    let change = {}
    fields.forEach(col => {
      change[col.Column] = col.Text
    })
    // 表单提交时检查输入值是否正确
    this.props.form.validateFieldsAndScroll((err, values) => {
      if (!err) {
        values.uuid = this.state.editItem ? this.state.editItem.uuid : ''
        values.fieldlabel = values.field.map(field => {
          let item = fields.filter(cell => cell.Column === field)[0]
          let label = ''
          if (item) {
            label = item.Text
          }
          return label
          return change[field] || ''
        })
        values.fieldlabel = values.fieldlabel.join(',')
        values.field = values.field.join(',')
        this.setState({
          editItem: null
        }, () => {
          this.props.uniqueChange(values)
        })
        this.props.uniqueChange(values)
        this.props.form.setFieldsValue({
          field: [],
        })
@@ -76,7 +55,7 @@
    return (
      <Form {...formItemLayout} className="verify-form" id="verifycard1">
        <Row gutter={24}>
          <Col span={8}>
          <Col span={7}>
            <Form.Item label={'列名'}>
              {getFieldDecorator('field', {
                initialValue: [],
@@ -98,7 +77,7 @@
              )}
            </Form.Item>
          </Col>
          <Col span={6}>
          <Col span={7}>
            <Form.Item label={'报错编码'}>
              {getFieldDecorator('errorCode', {
                initialValue: 'E',
@@ -118,7 +97,7 @@
              )}
            </Form.Item>
          </Col>
          <Col span={6}>
          <Col span={7}>
            <Form.Item label={'验证类型'}>
              {getFieldDecorator('verifyType', {
                initialValue: 'physical',
@@ -136,9 +115,9 @@
              )}
            </Form.Item>
          </Col>
          <Col span={4} className="add">
          <Col span={3} className="add">
            <Button onClick={this.handleConfirm} className="mk-green">
              保存
              添加
            </Button>
          </Col>
        </Row>