| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon } from 'antd' |
| | | import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon, notification } from 'antd' |
| | | import './index.scss' |
| | | |
| | | const { TextArea } = Input |
| | |
| | | return new Promise((resolve, reject) => { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | |
| | | if (values.interType === 'inner' && !values.innerFunc && !values.dataresource) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请自定义函数或填写数据源!', |
| | | duration: 10 |
| | | }) |
| | | } else { |
| | | resolve(values) |
| | | } |
| | | } else { |
| | | reject(err) |
| | | } |
| | |
| | | } |
| | | |
| | | onChange = (e) => { |
| | | console.log(e.target.value) |
| | | this.setState({ |
| | | interType: e.target.value |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { data, dict } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { interType } = this.state |
| | | |
| | | const formItemLayout = { |
| | | labelCol: { |
| | |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.input'] + '表名!' |
| | | message: dict['form.required.input'] + '表名!' |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | <Form.Item label="接口类型"> |
| | | <Form.Item label={dict['header.form.intertype']}> |
| | | {getFieldDecorator('interType', { |
| | | initialValue: data.interType || 'inner' |
| | | })( |
| | | <Radio.Group onChange={this.onChange}> |
| | | <Radio value="inner">内部</Radio> |
| | | <Radio value="outer">外部</Radio> |
| | | <Radio value="inner">{dict['header.form.interface.inner']}</Radio> |
| | | <Radio value="outer">{dict['header.form.interface.outer']}</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | <Form.Item label="内部函数"> |
| | | {interType === 'outer' ? <Col span={12}> |
| | | <Form.Item label={dict['header.form.interface']}> |
| | | {getFieldDecorator('interface', { |
| | | initialValue: data.interface || '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: dict['form.required.input'] + dict['header.form.interface'] + '!' |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'outer' ? <Col span={12}> |
| | | <Form.Item label={dict['header.form.outerFunc']}> |
| | | {getFieldDecorator('outerFunc', { |
| | | initialValue: data.outerFunc || '' |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType !== 'outer' ? <Col span={12}> |
| | | <Form.Item label={dict['header.form.innerFunc']}> |
| | | {getFieldDecorator('innerFunc', { |
| | | initialValue: data.innerFunc || '' |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> |
| | | </Col> : null} |
| | | <Col span={24}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title=""> |
| | | <Tooltip placement="topLeft" title="使用系统函数时,需填写数据源,自定义函数时,可忽略。"> |
| | | <Icon type="question-circle" /> |
| | | {'数据源'} |
| | | </Tooltip> |
| | |
| | | <Col span={12}> |
| | | <Form.Item label="主键"> |
| | | {getFieldDecorator('primaryKey', { |
| | | initialValue: primaryKey |
| | | initialValue: primaryKey ? primaryKey : (this.props.columns.length === 0 ? 'ID' : '') |
| | | })( |
| | | <Select |
| | | getPopupContainer={() => document.getElementById('commontable-setting-form')} |
| | | > |
| | | <Select.Option value="">不设置</Select.Option> |
| | | {this.props.columns.length === 0 ? |
| | | <Select.Option value="ID">ID</Select.Option> : null |
| | | } |
| | | {this.props.columns.map(option => |
| | | <Select.Option id={option.uuid} title={option.label} key={option.uuid} value={option.field}>{option.label}</Select.Option> |
| | | )} |