king
2023-08-10 ac1d52c46ff9019fcc93cf3d5e7ab17cf850824e
src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx
@@ -5,46 +5,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 +34,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 +47,6 @@
        this.props.columnChange(values)
        this.setState({
          editItem: null,
          locked: false,
          type: 'Nvarchar(50)'
        })
@@ -100,7 +62,6 @@
  }
  render() {
    const { dict } = this.props
    const { getFieldDecorator } = this.props.form
    const formItemLayout = {
      labelCol: {
@@ -113,39 +74,37 @@
      }
    }
    let haslimit = !/^Nvarchar/.test(this.state.type)
    return (
      <Form {...formItemLayout} className="verify-form">
        <Row gutter={24}>
          <Col span={7}>
            <Form.Item label={dict['model.form.field']}>
          <Col span={6}>
            <Form.Item label="字段">
              {getFieldDecorator('Column', {
                initialValue: '',
                rules: [
                  {
                    required: true,
                    message: dict['form.required.input'] + dict['model.form.field'] + '!'
                    message: '请输入字段!'
                  }
                ]
              })(<Input placeholder="" autoComplete="off" />)}
              })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleConfirm}/>)}
            </Form.Item>
          </Col>
          <Col span={7}>
            <Form.Item label={dict['model.name']}>
          <Col span={6}>
            <Form.Item label="名称">
              {getFieldDecorator('Text', {
                initialValue: '',
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.input'] + dict['model.name'] + '!'
                    message: '请输入名称!'
                  }
                ]
              })(<Input placeholder="" autoComplete="off" />)}
              })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleConfirm}/>)}
            </Form.Item>
          </Col>
          <Col span={7}>
            <Form.Item label={dict['model.form.type']}>
          <Col span={6}>
            <Form.Item label="类型">
              {getFieldDecorator('type', {
                initialValue: 'Nvarchar(50)'
              })(
@@ -169,49 +128,51 @@
              )}
            </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}>
            <Form.Item label={dict['model.required']}>
          <Col span={6}>
            <Form.Item label="必填">
              {getFieldDecorator('required', {
                initialValue: 'true'
              })(
                <Radio.Group disabled={this.state.locked}>
                  <Radio value="true">{dict['model.true']}</Radio>
                  <Radio value="false">{dict['model.false']}</Radio>
                  <Radio value="true">是</Radio>
                  <Radio value="false">否</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col>
          <Col span={7}>
            <Form.Item label={dict['model.import']}>
          <Col span={6}>
            <Form.Item style={{marginBottom: 0}} label="导入">
              {getFieldDecorator('import', {
                initialValue: 'true'
              })(
                <Radio.Group>
                  <Radio value="true">{dict['model.true']}</Radio>
                  <Radio value="false">{dict['model.false']}</Radio>
                  <Radio value="true">是</Radio>
                  <Radio value="false">否</Radio>
                </Radio.Group>
              )}
            </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">
                添加
              </Button>
            </Form.Item>
          </Col>
        </Row>
      </Form>
    )