| | |
| | | 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' |
| | | |
| | |
| | | interType: (this.props.config.setting && this.props.config.setting.interType) || 'inner', |
| | | columns: null, |
| | | interReadonly: false, |
| | | primaryKey: '' |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | |
| | | }) |
| | | } |
| | | |
| | | 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' |
| | | }) |
| | | } |
| | | |
| | |
| | | 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: { |
| | |
| | | )} |
| | | </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', { |
| | |
| | | })(<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> |
| | | ) |