king
2022-09-13 3cca19f42bfc1eb99e16e94dc9e89e3f973bc4a6
src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.jsx
@@ -1,6 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Radio, Tooltip, Icon, notification, InputNumber } from 'antd'
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'
@@ -9,11 +10,12 @@
import CodeMirror from '@/templates/zshare/codemirror'
import './index.scss'
const { TextArea } = Input
class SettingForm extends Component {
  static propTpyes = {
    dict: PropTypes.object,       // 字典项
    menu: PropTypes.object,       // 菜单信息
    permFuncField: PropTypes.any, // 存储过程可用开始字符
    setting: PropTypes.object,    // 数据源配置
    inputSubmit: PropTypes.func   // 触发提交
  }
@@ -25,14 +27,25 @@
  }
  UNSAFE_componentWillMount () {
    const { setting, permFuncField } = this.props
    const { setting } = this.props
    let usefulFields = sessionStorage.getItem('permFuncField')
    let tooltip = null
    let rules = []
    if (permFuncField && permFuncField.length > 0) {
      tooltip = '开头可用字符:' + permFuncField.join(', ')
      let str = '^(' + permFuncField.join('|') + ')'
    if (usefulFields) {
      try {
        usefulFields = JSON.parse(usefulFields)
      } catch (e) {
        usefulFields = []
      }
    } else {
      usefulFields = []
    }
    if (usefulFields.length > 0) {
      tooltip = '开头可用字符:' + usefulFields.join(', ')
      let str = '^(' + usefulFields.join('|') + ')'
      let _patten = new RegExp(str + formRule.func.innerPattern + '$', 'g')
      rules.push({
@@ -126,7 +139,7 @@
            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
    
            Api.getLocalConfig(param)
            Api.genericInterface(param)
          }
          resolve(values)
@@ -191,8 +204,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}/>)}
@@ -253,7 +266,7 @@
            {interType === 'inner' ? <Col span={12}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={funcTooltip}>
                  <Icon type="question-circle" />
                  <QuestionCircleOutlined className="mk-form-tip" />
                  内部函数
                </Tooltip>
              }>
@@ -273,7 +286,7 @@
                })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)}
              </Form.Item>
            </Col> : null}
            {interType === 'outer' ? <Col span={12}>
            {interType === 'outer' ? <Col span={24} className="data-source">
              <Form.Item label="接口地址">
                {getFieldDecorator('interface', {
                  initialValue: setting.interface || '',
@@ -283,7 +296,7 @@
                      message: dict['form.required.input'] + '接口地址!'
                    }
                  ]
                })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)}
                })(<TextArea rows={2}/>)}
              </Form.Item>
            </Col> : null}
            {interType === 'outer' ? <Col span={12}>
@@ -305,7 +318,7 @@
            {interType === 'system' ? <Col span={24} className="data-source" style={{paddingLeft: '7px'}}>
              <Form.Item help={'数据ID:' + menu.MenuID} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } label={
                <Tooltip placement="topLeft" title={'使用系统函数时,需填写数据源。注:数据权限替换符 $@ -> /* 或 \'\'、 @$ -> */ 或 \'\''}>
                  <Icon type="question-circle" />
                  <QuestionCircleOutlined className="mk-form-tip" />
                  数据源
                </Tooltip>
              }>
@@ -317,7 +330,7 @@
            <Col span={12}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'数据值字段。'}>
                  <Icon type="question-circle" />
                  <QuestionCircleOutlined className="mk-form-tip" />
                  Value
                </Tooltip>
              }>
@@ -342,7 +355,7 @@
            <Col span={12}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'显示文字字段。'}>
                  <Icon type="question-circle" />
                  <QuestionCircleOutlined className="mk-form-tip" />
                  Label
                </Tooltip>
              }>
@@ -367,7 +380,7 @@
            <Col span={12}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'父级字段。'}>
                  <Icon type="question-circle" />
                  <QuestionCircleOutlined className="mk-form-tip" />
                  Parent
                </Tooltip>
              }>
@@ -392,7 +405,7 @@
            <Col span={12}>
              <Form.Item label="排序">
                {getFieldDecorator('order', {
                  initialValue: setting.order || '',
                  initialValue: setting.order || 'ID desc',
                  rules: [
                    {
                      required: true,
@@ -408,8 +421,8 @@
            </Col>
            <Col span={12}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'父级字段值与顶级标识(默认值为空)相同时,视为顶级节点。'}>
                  <Icon type="question-circle" />
                <Tooltip placement="topLeft" title={'父级字段值与顶级标识相同时,视为顶级节点。'}>
                  <QuestionCircleOutlined className="mk-form-tip" />
                  顶级标识
                </Tooltip>
              }>
@@ -426,8 +439,8 @@
            </Col>
            <Col span={12}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'每行分为24份,树形比例可设置为2-12(最大50%)'}>
                  <Icon type="question-circle" />
                <Tooltip placement="topLeft" title={'栅格布局,每行等分为24列,树形比例可设置为2-12(最大50%)'}>
                  <QuestionCircleOutlined className="mk-form-tip" />
                  宽度
                </Tooltip>
              }>