king
2020-02-28 888095418c902cc94693cba8b45f31bb79cdf818
src/templates/formtabconfig/settingform/index.jsx
@@ -1,6 +1,6 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon, notification } from 'antd'
import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon, notification, InputNumber } from 'antd'
import { formRule } from '@/utils/option.js'
import './index.scss'
@@ -18,7 +18,6 @@
    interType: (this.props.config.setting && this.props.config.setting.interType) || 'inner',
    columns: null,
    interReadonly: false,
    primaryKey: ''
  }
  UNSAFE_componentWillMount() {
@@ -50,28 +49,12 @@
      })
    }
    let primaryKey = _setting.primaryKey
    if (primaryKey) {
      let field = _columns.filter(column => column.field === primaryKey)
      if (field.length !== 1) {
        primaryKey = ''
      }
    }
    if (!primaryKey) {
      _columns.forEach(col => {
        if (col.field.toLowerCase() === 'id') {
          primaryKey = col.field
        }
      })
    }
    this.setState({
      columns: _columns,
      setting: _setting,
      interType: _setting.interType || 'inner',
      interReadonly: _setting.sysInterface === 'true',
      datatype: _setting.datatype || 'maintable',
      primaryKey: primaryKey
      datatype: _setting.datatype || 'maintable'
    })
  }
@@ -152,7 +135,7 @@
  render() {
    const { dict, usefulFields, menu } = this.props
    const { getFieldDecorator } = this.props.form
    const { interType, columns, setting, datatype, primaryKey } = this.state
    const { interType, setting, datatype } = this.state
    const formItemLayout = {
      labelCol: {
@@ -213,22 +196,13 @@
              )}
            </Form.Item>
          </Col>
          {datatype === 'query' ? <Col span={12}>
          <Col span={12}>
            <Form.Item label="主键">
              {getFieldDecorator('primaryKey', {
                initialValue: primaryKey || ''
              })(
                <Select
                  getPopupContainer={() => document.getElementById('commontable-setting-form')}
                >
                  <Select.Option key='unset' value="">未设置</Select.Option>
                  {columns.map((option, index) =>
                    <Select.Option id={option.uuid} title={option.label} key={index} value={option.field}>{option.label}</Select.Option>
                  )}
                </Select>
              )}
                initialValue: setting.primaryKey
              })(<Input placeholder="" autoComplete="off" disabled/>)}
            </Form.Item>
          </Col> : null}
          </Col>
          {datatype === 'query' ? <Col span={12}>
            <Form.Item label={dict['header.form.intertype']}>
              {getFieldDecorator('interType', {
@@ -319,6 +293,13 @@
              })(<Input placeholder="" autoComplete="off" />)}
            </Form.Item>
          </Col> : null}
          <Col span={12}>
            <Form.Item label="宽度">
              {getFieldDecorator('width', {
                initialValue: setting.width || 100
              })(<InputNumber min={10} max={100} precision={0} />)}
            </Form.Item>
          </Col>
        </Row>
      </Form>
    )