| | |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon, notification, InputNumber } from 'antd' |
| | | import { formRule } from '@/utils/option.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import './index.scss' |
| | | |
| | | const { TextArea } = Input |
| | |
| | | dict: PropTypes.object, // 字典项 |
| | | menu: PropTypes.object, |
| | | config: PropTypes.object, |
| | | usefulFields: PropTypes.array, |
| | | inputSubmit: PropTypes.any // 回车提交事件 |
| | | } |
| | | |
| | | state = { |
| | | interType: (this.props.config.setting && this.props.config.setting.interType) || 'inner', |
| | | columns: null, |
| | | usefulFields: [], |
| | | interReadonly: false, |
| | | } |
| | | |
| | |
| | | return true |
| | | } |
| | | }) |
| | | } catch { |
| | | } catch (e) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '菜单信息错误!', |
| | | duration: 10 |
| | | duration: 5 |
| | | }) |
| | | } |
| | | |
| | | let usefulFields = sessionStorage.getItem('permFuncField') |
| | | if (usefulFields) { |
| | | try { |
| | | usefulFields = JSON.parse(usefulFields) |
| | | } catch (e) { |
| | | usefulFields = [] |
| | | } |
| | | } else { |
| | | usefulFields = [] |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | setting: _setting, |
| | | interType: _setting.interType || 'inner', |
| | | interReadonly: _setting.sysInterface === 'true', |
| | | datatype: _setting.datatype || 'maintable' |
| | | datatype: _setting.datatype || 'maintable', |
| | | usefulFields |
| | | }) |
| | | } |
| | | |
| | |
| | | return new Promise((resolve, reject) => { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | let error = Utils.verifySql(values.dataresource) |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | resolve(values) |
| | | } else { |
| | | reject(err) |
| | |
| | | onSysChange = (e) => { |
| | | if (e.target.value === 'true') { |
| | | this.props.form.setFieldsValue({ |
| | | interface: window.GLOB.mainSystemApi || window.GLOB.subSystemApi |
| | | interface: window.GLOB.mainSystemApi || '' |
| | | }) |
| | | this.setState({ |
| | | interReadonly: true |
| | |
| | | let _type = this.props.form.getFieldValue('sysInterface') |
| | | if (_type === 'true') { |
| | | this.props.form.setFieldsValue({ |
| | | interface: window.GLOB.mainSystemApi || window.GLOB.subSystemApi |
| | | interface: window.GLOB.mainSystemApi || '' |
| | | }) |
| | | this.setState({ |
| | | interReadonly: true |
| | |
| | | let _type = this.props.form.getFieldValue('sysInterface') |
| | | if (_type === 'true') { |
| | | this.props.form.setFieldsValue({ |
| | | interface: window.GLOB.mainSystemApi || window.GLOB.subSystemApi |
| | | interface: window.GLOB.mainSystemApi || '' |
| | | }) |
| | | this.setState({ |
| | | interReadonly: true |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { dict, usefulFields, menu } = this.props |
| | | const { dict, menu } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { interType, setting, datatype } = this.state |
| | | const { interType, setting, datatype, usefulFields } = this.state |
| | | |
| | | const formItemLayout = { |
| | | labelCol: { |
| | |
| | | message: dict['form.required.input'] + '表名!' |
| | | }, |
| | | { |
| | | max: formRule.input.max, |
| | | message: formRule.input.message |
| | | max: 50, |
| | | message: '表名最长为50个字符!' |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />)} |
| | |
| | | <Select.Option value="1">1列</Select.Option> |
| | | <Select.Option value="2">2列</Select.Option> |
| | | <Select.Option value="3">3列</Select.Option> |
| | | <Select.Option value="4">4列</Select.Option> |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | |
| | | initialValue: interType |
| | | })( |
| | | <Radio.Group onChange={this.onChange}> |
| | | <Radio value="inner">{dict['header.form.interface.inner']}</Radio> |
| | | <Radio value="outer">{dict['header.form.interface.outer']}</Radio> |
| | | <Radio value="inner">{dict['model.interface.inner']}</Radio> |
| | | <Radio value="outer">{dict['model.interface.outer']}</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | |
| | | initialValue: setting.sysInterface || 'false' |
| | | })( |
| | | <Radio.Group onChange={this.onSysChange}> |
| | | <Radio value="true">{dict['header.form.true']}</Radio> |
| | | <Radio value="false">{dict['header.form.false']}</Radio> |
| | | <Radio value="true">{dict['model.true']}</Radio> |
| | | <Radio value="false">{dict['model.false']}</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | |
| | | {datatype === 'query' && interType === 'outer' ? <Col span={12}> |
| | | <Form.Item label={dict['header.form.interface']}> |
| | | {getFieldDecorator('interface', { |
| | | initialValue: setting.sysInterface === 'true' ? (window.GLOB.mainSystemApi || window.GLOB.subSystemApi) : (setting.interface || ''), |
| | | initialValue: setting.sysInterface === 'true' ? (window.GLOB.mainSystemApi || '') : (setting.interface || ''), |
| | | rules: [ |
| | | { |
| | | required: true, |