king
2024-08-20 58826d6f4eab9f8c9acf9fa8696f60039c645cfe
src/templates/sharecomponent/treesettingcomponent/settingform/index.jsx
@@ -2,10 +2,8 @@
import PropTypes from 'prop-types'
import { fromJS } from 'immutable'
import { Form, notification, Modal, Spin, Tabs } from 'antd'
import moment from 'moment'
import Api from '@/api'
import Utils from '@/utils/utils.js'
import SettingUtils from './utils.jsx'
import DataSource from './datasource'
import asyncComponent from '@/utils/asyncComponent'
@@ -34,17 +32,17 @@
    let _setting = fromJS(config.setting).toJS()
    let _scripts = _setting.scripts || []
    if (window.GLOB.funcs && window.GLOB.funcs.length > 0) {
      window.GLOB.funcs.forEach(m => {
        let reg = new RegExp(`\\/\\*\\$ex@${m.func_code}-begin\\*\\/[\\s\\S]+\\/\\*@ex\\$-end\\*\\/`, 'ig')
        _scripts.forEach(item => {
          item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`)
        })
        if (_setting.dataresource) {
          _setting.dataresource = _setting.dataresource.replace(reg, `$ex@${m.func_code}@ex$`)
        }
      })
    }
    // if (window.GLOB.funcs && window.GLOB.funcs.length > 0) {
    //   window.GLOB.funcs.forEach(m => {
    //     let reg = new RegExp(`\\/\\*\\$ex@${m.func_code}-begin\\*\\/[\\s\\S]+\\/\\*@ex\\$-end\\*\\/`, 'ig')
    //     _scripts.forEach(item => {
    //       item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`)
    //     })
    //     if (_setting.dataresource) {
    //       _setting.dataresource = _setting.dataresource.replace(reg, `$ex@${m.func_code}@ex$`)
    //     }
    //   })
    // }
    this.setState({
      setting: _setting,
@@ -134,18 +132,10 @@
    } else if (type === 'scripts' && _scripts.length === 0) {
      _resolve()
    } else { // type 为 submit 、 verify ,以及其他需要验证的场景
      let timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
      let param = {
        func: 's_debug_sql',
        exec_type: 'y',
        LText: SettingUtils.getDebugSql(setting, _scripts, timestamp)
      }
      param.LText = Utils.formatOptions(param.LText)
      param.timestamp = timestamp
      param.secretkey = Utils.encrypt('', timestamp)
      let sql = SettingUtils.getDebugSql(setting, _scripts)
      
      Api.genericInterface(param).then(result => {
        if (result.status) {
      Api.sDebug(sql).then(result => {
        if (result.status || result.ErrCode === '-2') {
          _resolve()
        } else {
          _reject()
@@ -211,10 +201,9 @@
      if (_loading) {
        notification.warning({
          top: 92,
          message: '存在未保存脚本,请点击确定保存,或点击取消放弃修改!',
          message: '存在未保存脚本!',
          duration: 5
        })
        return
      }
      this.setState({loading: true})
      this.sqlverify(() => { // 验证成功