king
2023-08-15 a94b0a4d15b26ecf8fe99f0a1c3e60d60b97766d
src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.jsx
@@ -2,9 +2,7 @@
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Radio, Tooltip, notification, InputNumber } from 'antd'
import { QuestionCircleOutlined } from '@ant-design/icons'
import moment from 'moment'
import Api from '@/api'
import { formRule } from '@/utils/option.js'
import Utils from '@/utils/utils.js'
import CodeMirror from '@/templates/zshare/codemirror'
@@ -14,7 +12,6 @@
class SettingForm extends Component {
  static propTpyes = {
    dict: PropTypes.object,       // 字典项
    menu: PropTypes.object,       // 菜单信息
    setting: PropTypes.object,    // 数据源配置
    inputSubmit: PropTypes.func   // 触发提交
@@ -62,7 +59,6 @@
  }
  handleConfirm = () => {
    const { setting } = this.props
    // 表单提交时检查输入值是否正确
    return new Promise((resolve, reject) => {
      this.props.form.validateFieldsAndScroll((err, values) => {
@@ -109,6 +105,14 @@
              })
              reject()
              return
            } else if (/,,/ig.test(values.dataresource)) {
              notification.warning({
                top: 92,
                message: '数据源中,不可出现连续的英文逗号(,,)',
                duration: 5
              })
              reject()
              return
            }
            let error = Utils.verifySql(values.dataresource)
@@ -122,24 +126,6 @@
              reject()
              return
            }
          }
          // 数据源保存
          if (
            values.interType === 'system' && values.default !== 'false' &&
            /[^\s]+\s+[^\s]+/ig.test(values.dataresource) && setting.dataresource !== values.dataresource
          ) {
            let param = {
              func: 's_DataSrc_Save',
              LText: values.dataresource,
              MenuID: this.props.menu.MenuID
            }
            param.LText = Utils.formatOptions(param.LText)
            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
            Api.genericInterface(param)
          }
          resolve(values)
@@ -175,7 +161,7 @@
  }
  render() {
    const { setting, dict, menu } = this.props
    const { setting, menu } = this.props
    const { getFieldDecorator } = this.props.form
    const { interType, funcRules, funcTooltip } = this.state
@@ -200,7 +186,7 @@
                rules: [
                  {
                    required: true,
                    message: dict['form.required.input'] + '表名!'
                    message: '请输入表名!'
                  },
                  {
                    max: 50,
@@ -217,7 +203,7 @@
                rules: [
                  {
                    required: true,
                    message: dict['form.required.input'] + '标题!'
                    message: '请输入标题!'
                  },
                  {
                    max: formRule.input.max,
@@ -228,13 +214,13 @@
            </Form.Item>
          </Col>
          <Col span={8}>
            <Form.Item label={dict['header.form.intertype']}>
            <Form.Item label="接口类型">
              {getFieldDecorator('interType', {
                initialValue: interType,
                rules: [
                  {
                    required: true,
                    message: dict['form.required.select'] + dict['header.form.intertype'] + '!'
                    message: '请选择接口类型!'
                  }
                ]
              })(
@@ -246,19 +232,24 @@
            </Form.Item>
          </Col>
          {interType === 'outer' ? <Col span={8}>
            <Form.Item label={dict['header.form.sysInterface']}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="单点登录系统">
                <QuestionCircleOutlined className="mk-form-tip" />
                系统接口
              </Tooltip>
            }>
              {getFieldDecorator('sysInterface', {
                initialValue: setting.sysInterface || 'false',
                rules: [
                  {
                    required: true,
                    message: dict['form.required.select'] + dict['header.form.sysInterface'] + '!'
                    message: '请选择系统接口!'
                  },
                ]
              })(
              <Radio.Group onChange={(e) => {this.onRadioChange(e, 'sysInterface')}}>
                <Radio value="true">{dict['model.true']}</Radio>
                <Radio value="false">{dict['model.false']}</Radio>
                <Radio value="true">是</Radio>
                <Radio value="false">否</Radio>
              </Radio.Group>)}
            </Form.Item>
          </Col> : null}
@@ -274,7 +265,7 @@
                rules: [
                  {
                    required: true,
                    message: dict['form.required.input'] + '内部函数!'
                    message: '请输入内部函数!'
                  },
                  {
                    max: formRule.func.max,
@@ -292,7 +283,7 @@
                rules: [
                  {
                    required: true,
                    message: dict['form.required.input'] + '接口地址!'
                    message: '请输入接口地址!'
                  }
                ]
              })(<TextArea rows={2}/>)}
@@ -328,7 +319,7 @@
          </Col> : null}
          <Col span={8}>
            <Form.Item label={
              <Tooltip placement="topLeft" title={'数据值字段。'}>
              <Tooltip placement="topLeft" title="数据值字段。">
                <QuestionCircleOutlined className="mk-form-tip" />
                Value
              </Tooltip>
@@ -338,7 +329,7 @@
                rules: [
                  {
                    required: true,
                    message: dict['form.required.input'] + 'Value!'
                    message: '请输入Value!'
                  },
                  {
                    pattern: formRule.field.pattern,
@@ -363,7 +354,7 @@
                rules: [
                  {
                    required: true,
                    message: dict['form.required.input'] + 'Label!'
                    message: '请输入Label!'
                  },
                  {
                    pattern: formRule.field.pattern,
@@ -378,7 +369,7 @@
          </Col>
          <Col span={8}>
            <Form.Item label={
              <Tooltip placement="topLeft" title={'父级字段。'}>
              <Tooltip placement="topLeft" title="父级字段。">
                <QuestionCircleOutlined className="mk-form-tip" />
                Parent
              </Tooltip>
@@ -388,7 +379,7 @@
                rules: [
                  {
                    required: true,
                    message: dict['form.required.input'] + 'Label!'
                    message: '请输入Label!'
                  },
                  {
                    pattern: formRule.field.pattern,
@@ -408,7 +399,7 @@
                rules: [
                  {
                    required: true,
                    message: dict['form.required.input'] + '排序!'
                    message: '请输入排序!'
                  },
                  {
                    max: formRule.input.max,
@@ -448,7 +439,7 @@
                rules: [
                  {
                    required: true,
                    message: dict['form.required.input'] + '宽度!'
                    message: '请输入宽度!'
                  }
                ]
              })(<InputNumber min={2} max={12} precision={0} />)}