king
2020-11-24 0f79daefced8980fa571dd3d2c781a0e3646614f
src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx
@@ -6,45 +6,12 @@
class ExcelInColumn extends Component {
  static propTpyes = {
    dict: PropTypes.object,         // 字典项
    columns: PropTypes.array,       // 列名集合
    columnChange: PropTypes.func    // 修改函数
  }
  state = {
    editItem: null, // 编辑元素
    type: 'Nvarchar(50)',
    locked: false
  }
  edit = (record) => {
    this.setState({
      editItem: record,
      type: record.type || 'Nvarchar(50)'
    }, () => {
      if (!/^Nvarchar/.test(record.type)) {
        this.props.form.setFieldsValue({
          min: record.min,
          max: record.max
        })
      }
    })
    this.props.form.setFieldsValue({
      Column: record.Column,
      Text: record.Text,
      required: record.required || 'true',
      import: record.import || 'true',
      type: record.type
    })
    if (record.type === 'Int' || /^Decimal/ig.test(record.type)) {
      this.setState({
        locked: true
      })
    } else {
      this.setState({
        locked: false
      })
    }
  }
  typeChange = (val) => {
@@ -68,12 +35,9 @@
  handleConfirm = () => {
    // const { columns } = this.props
    // 表单提交时检查输入值是否正确
    this.props.form.validateFieldsAndScroll((err, values) => {
      if (!err) {
        values.uuid = this.state.editItem ? this.state.editItem.uuid : ''
        if (/^Nvarchar/ig.test(values.type)) {
          values.limit = values.type.match(/\d+/) ? values.type.match(/\d+/)[0] : '20000'
        } else if (/^Decimal/ig.test(values.type)) {
@@ -84,7 +48,6 @@
        this.props.columnChange(values)
        this.setState({
          editItem: null,
          locked: false,
          type: 'Nvarchar(50)'
        })
@@ -113,12 +76,10 @@
      }
    }
    let haslimit = !/^Nvarchar/.test(this.state.type)
    return (
      <Form {...formItemLayout} className="verify-form">
        <Row gutter={24}>
          <Col span={7}>
          <Col span={6}>
            <Form.Item label={dict['model.form.field']}>
              {getFieldDecorator('Column', {
                initialValue: '',
@@ -131,7 +92,7 @@
              })(<Input placeholder="" autoComplete="off" />)}
            </Form.Item>
          </Col>
          <Col span={7}>
          <Col span={6}>
            <Form.Item label={dict['model.name']}>
              {getFieldDecorator('Text', {
                initialValue: '',
@@ -144,7 +105,7 @@
              })(<Input placeholder="" autoComplete="off" />)}
            </Form.Item>
          </Col>
          <Col span={7}>
          <Col span={6}>
            <Form.Item label={dict['model.form.type']}>
              {getFieldDecorator('type', {
                initialValue: 'Nvarchar(50)'
@@ -169,12 +130,7 @@
              )}
            </Form.Item>
          </Col>
          <Col span={3} className="add">
            <Button onClick={this.handleConfirm} type="primary" className="mk-green">
              {dict['model.save']}
            </Button>
          </Col>
          <Col span={7}>
          <Col span={6}>
            <Form.Item label={dict['model.required']}>
              {getFieldDecorator('required', {
                initialValue: 'true'
@@ -186,8 +142,8 @@
              )}
            </Form.Item>
          </Col>
          <Col span={7}>
            <Form.Item label={dict['model.import']}>
          <Col span={6}>
            <Form.Item style={{marginBottom: 0}} label={dict['model.import']}>
              {getFieldDecorator('import', {
                initialValue: 'true'
              })(
@@ -198,20 +154,27 @@
              )}
            </Form.Item>
          </Col>
          {haslimit ? <Col span={7}>
            <Form.Item label={'最小值'}>
          <Col span={6}>
            <Form.Item style={{marginBottom: 0}} label={'最小值'}>
              {getFieldDecorator('min', {
                initialValue: ''
              })(<InputNumber />)}
            </Form.Item>
          </Col> : null}
          {haslimit ? <Col span={7}>
            <Form.Item label={'最大值'}>
          </Col>
          <Col span={6}>
            <Form.Item style={{marginBottom: 0}} label={'最大值'}>
              {getFieldDecorator('max', {
                initialValue: ''
              })(<InputNumber />)}
            </Form.Item>
          </Col> : null}
          </Col>
          <Col span={6}>
            <Form.Item style={{marginBottom: 0}} label={' '} colon={false}>
              <Button onClick={this.handleConfirm} type="primary" className="mk-green">
                {dict['model.add']}
              </Button>
            </Form.Item>
          </Col>
        </Row>
      </Form>
    )