king
2021-09-01 31ec63f0419895876cbaba99637a884a32d33d0d
src/templates/formtabconfig/settingform/index.jsx
@@ -2,6 +2,7 @@
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
@@ -11,13 +12,13 @@
    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,
  }
@@ -42,12 +43,23 @@
          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({
@@ -55,7 +67,8 @@
      setting: _setting,
      interType: _setting.interType || 'inner',
      interReadonly: _setting.sysInterface === 'true',
      datatype: _setting.datatype || 'maintable'
      datatype: _setting.datatype || 'maintable',
      usefulFields
    })
  }
@@ -64,6 +77,17 @@
    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)
@@ -75,7 +99,7 @@
  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
@@ -96,7 +120,7 @@
      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
@@ -120,7 +144,7 @@
      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
@@ -142,9 +166,9 @@
  }
  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: {
@@ -173,8 +197,8 @@
                    message: dict['form.required.input'] + '表名!'
                  },
                  {
                    max: formRule.input.max,
                    message: formRule.input.message
                    max: 50,
                    message: '表名最长为50个字符!'
                  }
                ]
              })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />)}
@@ -189,6 +213,7 @@
                  <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>
@@ -218,8 +243,8 @@
                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>
@@ -230,8 +255,8 @@
                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>
@@ -239,7 +264,7 @@
          {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,