king
2021-01-25 d33d00cafeea2c4f980ea3af268d9260269edcc1
2021-01-25
16个文件已修改
655 ■■■■ 已修改文件
src/api/index.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/components/code/sandbox/editorcode/index.jsx 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/commontable/index.jsx 285 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/subtable/index.jsx 45 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/subtabtable/index.jsx 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/actionList/normalbutton/index.jsx 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/mutilform/index.jsx 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/index.jsx 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/sharecomponent/settingcomponent/settingform/index.jsx 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/sharecomponent/settingcomponent/settingform/utils.jsx 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/subtableconfig/index.jsx 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/formconfig.jsx 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/verifycard/callbackcustomscript/index.jsx 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/utils-datamanage.js 167 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/utils.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/index.js
@@ -119,7 +119,7 @@
   * @description 直接请求
   * @param {Object} param 查询及提交参数
   */
  directRequest (url, method, param) {
  directRequest (url, method = 'post', param) {
    let params = { method: 'post' }
    let _url = url
src/menu/components/code/sandbox/editorcode/index.jsx
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Icon, Modal, Tabs } from 'antd'
import { Icon, Modal, Tabs, message } from 'antd'
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
@@ -63,6 +63,11 @@
  }
  onJsChange = (val) => {
    if (/document\.getElementsByTagName/g.test(val)) {
      message.warning('为防止代码冲突,js中不可使用document.getElementsByTagName方法!')
      return
    }
    this.setState({
      js: val
    })
src/tabviews/commontable/index.jsx
@@ -8,6 +8,7 @@
import zhCN from '@/locales/zh-CN/main.js'
import enUS from '@/locales/en-US/main.js'
import Utils from '@/utils/utils.js'
import options from '@/store/options.js'
import UtilsDM from '@/utils/utils-datamanage.js'
import UtilsUpdate from '@/utils/utils-update.js'
import asyncComponent from '@/utils/asyncComponent'
@@ -64,6 +65,7 @@
    statFields: [],       // 合计字段
    statFValue: [],       // 合计值
    absFields: [],        // 绝对值字段
    loadCustomApi: true   // 加载外部资源
  }
  /**
@@ -86,6 +88,7 @@
        config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
        config.MenuID = this.props.MenuID
        config.MenuName = MenuName
        config.setting.MenuName = MenuName
      } catch (e) {
        console.warn('Parse Failure')
        config = ''
@@ -210,7 +213,7 @@
      config.setting.execute = config.setting.default !== 'false'     // 默认sql是否执行,转为boolean 统一格式
      config.setting.customScript = ''                                // 自定义脚本
      if (config.setting.interType === 'system') {
      if (config.setting.interType === 'system' || (config.setting.interType === 'custom' && config.setting.requestMode === 'system')) {
        if (config.setting.scripts && config.setting.scripts.length > 0) {
          let _customScript = ''
          config.setting.scripts.forEach(item => {
@@ -363,8 +366,7 @@
        search: Utils.initMainSearch(initSearch) // 搜索条件初始化(含有时间格式,需要转化)
      }, () => {
        if (config.setting.onload !== 'false' && valid) { // 初始化可加载
          this.loadmaindata()
          this.getStatFieldsValue()
          this.loadData()
        }
        this.setShortcut()
      })
@@ -422,11 +424,8 @@
    }
  }
  /**
   * @description 主表数据加载
   */
  async loadmaindata () {
    const { setting, arr_field, BIDs, search, orderBy, BID, pageIndex, pageSize, absFields } = this.state
  loadData = () => {
    const { setting, search, BIDs, loadCustomApi } = this.state
    let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0))
    this.setState({
@@ -448,7 +447,253 @@
        duration: 3
      })
      return
    } else if (window.GLOB.systemType === 'production' && !setting.proInterface) {
      notification.warning({
        top: 92,
        message: '未设置正式系统地址!',
        duration: 3
      })
      return
    }
    if (setting.interType === 'custom' && loadCustomApi) {
      if (setting.execTime === 'once') {
        this.setState({loadCustomApi: false})
      }
      this.loadOutResource()
      if (setting.execType === 'async') {
        this.loadmaindata()
      }
    } else {
      this.loadmaindata()
    }
  }
  loadOutResource = () => {
    const { setting, search, BID } = this.state
    let param = UtilsDM.getPrevQueryParams(setting, search, BID, this.props.menuType)
    if (setting.execType === 'sync') {
      this.setState({
        loading: true
      })
    }
    Api.genericInterface(param).then(res => {
      if (res.status) {
        if (res.mk_ex_invoke === 'false') {
          this.loadmaindata()
        } else {
          this.customOuterRequest(res)
        }
      } else {
        this.setState({
          loading: false
        })
        notification.error({
          top: 92,
          message: res.message,
          duration: 10
        })
      }
    }, () => {
      this.setState({
        loading: false
      })
    })
  }
  customOuterRequest = (result) => {
    const { setting } = this.state
    let url = ''
    if (window.GLOB.systemType === 'production') {
      url = setting.proInterface
    } else {
      url = setting.interface
    }
    let mkey = result.mk_api_key || ''
    delete result.mk_ex_invoke
    delete result.status
    delete result.message
    delete result.ErrCode
    delete result.ErrMesg
    delete result.mk_api_key
    let param = {}
    Object.keys(result).forEach(key => {
      key = key.replace(/^mk_/ig, '')
      param[key] = result[key]
    })
    Api.directRequest(url, setting.method, param).then(res => {
      if (typeof(res) !== 'object' || Array.isArray(res)) {
        let error = '未知的返回结果!'
        if (typeof(res) === 'string') {
          error = res
        }
        let _result = {
          mk_api_key: mkey,
          $ErrCode: 'E',
          $ErrMesg: error
        }
        this.customCallbackRequest(_result)
      } else {
        res.mk_api_key = mkey
        this.customCallbackRequest(res)
      }
    }, () => {
      this.setState({
        loading: false
      })
    })
  }
  customCallbackRequest = (result) => {
    const { setting } = this.state
    let lines = []
    let pre = setting.callbackType === 'script' ? '@' : ''
    let errSql = ''
    if (result.$ErrCode === 'E') {
      errSql = `
        set @ErrorCode='E'
        set @retmsg='${result.$ErrMesg}'
      `
      delete result.$ErrCode
      delete result.$ErrMesg
    }
    let getDefaultSql = (obj, tb, bid, level) => {
      let keys = []
      let vals = []
      let subObjs = []
      let id = Utils.getuuid()
      delete obj.$$key
      Object.keys(obj).forEach(key => {
        let val = obj[key]
        if (typeof(val) === 'object') {
          if (Array.isArray(val)) {
            val.forEach(item => {
              if (typeof(item) !== 'object' || Array.isArray(item)) return
              if (Object.keys(item).length > 0) {
                item.$$key = tb + '_' + key
                subObjs.push(item)
              }
            })
          } else if (Object.keys(val).length > 0) {
            val.$$key = tb + '_' + key
            subObjs.push(val)
          }
        } else if (val !== null && val !== undefined) {
          keys.push(key)
          vals.push(`'${val}'`)
        }
      })
      lines.push({
        table: tb,
        insert: `Insert into ${pre}${tb} (${keys.join(',')},mk_level,mk_id,mk_bid)`,
        select: `Select ${vals.join(',')},'${level}','${id}','${bid}'`
      })
      subObjs.forEach(item => {
        getDefaultSql(item, item.$$key, id, level + 1)
      })
    }
    getDefaultSql(result, setting.cbTable, '', 1)
    let lineMap = new Map()
    lines.forEach(line => {
      if (lineMap.has(line.table)) {
        let _line = lineMap.get(line.table)
        _line.selects.push(line.select)
        lineMap.set(line.table, _line)
      } else {
        lineMap.set(line.table, {
          table: line.table,
          insert: line.insert,
          selects: [line.select]
        })
      }
    })
    let param = {}
    if (setting.callbackType === 'script') { // 使用自定义脚本
      let sql = [...lineMap.values()].map(item => (`
        ${item.insert}
        ${item.selects.join(` union all
        `)}
      `))
      sql = sql.join('')
      param = UtilsDM.getCallBackQueryParams(setting, sql, errSql)
      if (this.state.BID) {
        param.BID = this.state.BID
      }
      if (this.props.menuType === 'HS') { // 函数 sPC_TableData_InUpDe 云端验证
        param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
      }
    } else {
      param.func = 's_ex_result_back'
      param.s_ex_result = [...lineMap.values()].map((item, index) => ({
        MenuID: this.state.config.MenuID,
        MenuName: this.state.config.MenuName,
        TableName: item.table,
        LongText: window.btoa(window.encodeURIComponent(`${item.insert}  ${item.selects.join(` union all `)}`)),
        Sort: index + 1
      }))
      if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) {
        let sql = [...lineMap.values()].map(item => (`
          ${item.insert}
          ${item.selects.join(` union all
          `)}
        `))
        sql = sql.join('')
        console.info(sql.replace(/\n\s{10}/ig, '\n'))
      }
    }
    Api.genericInterface(param).then(res => {
      if (res.status) {
        this.loadmaindata()
      } else {
        this.setState({
          loading: false
        })
        notification.error({
          top: 92,
          message: res.message,
          duration: 10
        })
      }
    }, () => {
      this.setState({
        loading: false
      })
    })
  }
  /**
   * @description 主表数据加载
   */
  async loadmaindata () {
    const { setting, arr_field, search, orderBy, BID, pageIndex, pageSize, absFields } = this.state
    this.setState({
      loading: true
@@ -462,6 +707,9 @@
    }
    let result = await Api.genericInterface(param)
    this.getStatFieldsValue()
    if (result.status) {
      this.setState({
        data: result.data.map((item, index) => {
@@ -567,12 +815,7 @@
  getStatFieldsValue = () => {
    const { setting, search, BID, orderBy, statFields } = this.state
    if (statFields.length === 0 || setting.interType !== 'system' || !setting.dataresource) return
    let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0))
    if (requireFields.length > 0) {
      return
    }
    if (statFields.length === 0 || !(setting.interType === 'system' || (setting.interType === 'custom' && setting.requestMode === 'system')) || !setting.dataresource) return
    let _orderBy = orderBy || setting.order
    let param = UtilsDM.getStatQueryDataParams(setting, statFields, search, _orderBy, BID, this.props.menuType)
@@ -627,8 +870,7 @@
        search: searches,
        setting: {...setting, onload: 'true'}
      }, () => {
        this.loadmaindata()
        this.getStatFieldsValue()
        this.loadData()
      })
    } else {
      MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 列表重置
@@ -636,8 +878,7 @@
        pageIndex: 1,
        search: searches
      }, () => {
        this.loadmaindata()
        this.getStatFieldsValue()
        this.loadData()
      })
    }
  }
@@ -659,7 +900,7 @@
      pageSize: pagination.pageSize,
      orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : ''
    }, () => {
      this.loadmaindata()
      this.loadData()
    })
  }
@@ -672,13 +913,11 @@
      this.setState({
        pageIndex: 1
      }, () => {
        this.loadmaindata()
        this.getStatFieldsValue()
        this.loadData()
      })
    } else {
      MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable', 'false') // 列表重置
      this.loadmaindata()
      this.getStatFieldsValue()
      this.loadData()
    }
  }
src/tabviews/subtable/index.jsx
@@ -74,14 +74,12 @@
      }, () => {
        if (this.state.setting) {
          this.loadmaindata(nextProps.BID, 'refresh')
          this.getStatFieldsValue(nextProps.BID, 'refresh')
        }
      })
    } else if (!this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
      if (this.state.setting) {
        this.setState({}, () => {
          this.loadmaindata()
          this.getStatFieldsValue()
        })
      }
    }
@@ -103,6 +101,7 @@
      try { // 配置信息解析
        config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
        config.setting.MenuName = Tab.label
      } catch (e) {
        console.warn('Parse Failure')
        config = ''
@@ -274,7 +273,7 @@
      config.setting.execute = config.setting.default !== 'false'     // 默认sql是否执行,转为boolean 统一格式
      config.setting.customScript = ''                                // 自定义脚本
      if (config.setting.interType === 'system') {
      if (config.setting.interType === 'system' || (config.setting.interType === 'custom' && config.setting.requestMode === 'system')) {
        if (config.setting.scripts && config.setting.scripts.length > 0) {
          let _customScript = ''
          config.setting.scripts.forEach(item => {
@@ -321,7 +320,6 @@
      }, () => {
        if (config.setting.onload !== 'false' && (!Tab.supMenu || BID || Tab.isTreeNode) && valid) { // 初始化可加载
          this.loadmaindata()
          this.getStatFieldsValue()
        }
      })
    } else {
@@ -371,6 +369,7 @@
      if (!bid) { // 主表ID不存在时,不查询子表
        this.setState({
          data: [],
          statFValue: [],
          total: 0
        })
        return
@@ -378,6 +377,7 @@
        _BID = bid
      }
    }
    this.setState({
      selectedData: [],
      loading: true
@@ -393,6 +393,9 @@
    }
    let result = await Api.genericInterface(param)
    this.getStatFieldsValue(_BID, searches)
    if (result.status) {
      this.setState({
        data: result.data.map((item, index) => {
@@ -501,36 +504,13 @@
  /**
   * @description 获取合计字段值
   */
  getStatFieldsValue = (bid, type) => {
    const { mainSearch } = this.props
    const { setting, search, orderBy, statFields } = this.state
  getStatFieldsValue = (bid, searches) => {
    const { setting, orderBy, statFields } = this.state
    let _BID = this.props.BID
    let searches = fromJS(search).toJS()
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
      searches = [...mainSearch, ...searches]
    }
    if (statFields.length === 0 || setting.interType !== 'system' || !setting.dataresource) return
    let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0))
    if (requireFields.length > 0) {
      return
    }
    if (type === 'refresh') {
      if (!bid) { // 主表ID不存在时,不查询子表合计值
        this.setState({
          statFValue: []
        })
        return
      } else {
        _BID = bid
      }
    }
    if (statFields.length === 0 || !(setting.interType === 'system' || (setting.interType === 'custom' && setting.requestMode === 'system')) || !setting.dataresource) return
    let _orderBy = orderBy || setting.order
    let param = UtilsDM.getStatQueryDataParams(setting, statFields, searches, _orderBy, _BID, this.props.menuType)
    let param = UtilsDM.getStatQueryDataParams(setting, statFields, searches, _orderBy, bid, this.props.menuType)
    if (param.func === 'sPC_Get_TableData') {
      param.menuname = this.props.Tab.label || ''
@@ -580,7 +560,6 @@
      search: searches,
    }, () => {
      this.loadmaindata()
      this.getStatFieldsValue()
    })
  }
@@ -615,12 +594,10 @@
        pageIndex: 1
      }, () => {
        this.loadmaindata()
        this.getStatFieldsValue()
      })
    } else {
      MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid, 'false') // 列表重置
      this.loadmaindata()
      this.getStatFieldsValue()
    }
  }
src/tabviews/subtabtable/index.jsx
@@ -75,6 +75,7 @@
      try { // 配置信息解析
        config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
        config.setting.MenuName = Tab.label
      } catch (e) {
        console.warn('Parse Failure')
        config = ''
@@ -244,7 +245,7 @@
      config.setting.execute = config.setting.default !== 'false'     // 默认sql是否执行,转为boolean 统一格式
      config.setting.customScript = ''                                // 自定义脚本
      if (config.setting.interType === 'system') {
      if (config.setting.interType === 'system' || (config.setting.interType === 'custom' && config.setting.requestMode === 'system')) {
        if (config.setting.scripts && config.setting.scripts.length > 0) {
          let _customScript = ''
          config.setting.scripts.forEach(item => {
@@ -291,7 +292,6 @@
      }, () => {
        if (config.setting.onload !== 'false' && valid) { // 初始化可加载
          this.loadmaindata()
          this.getStatFieldsValue()
        }
      })
    } else {
@@ -346,6 +346,9 @@
    }
    let result = await Api.genericInterface(param)
    this.getStatFieldsValue(searches)
    if (result.status) {
      this.setState({
        data: result.data.map((item, index) => {
@@ -381,21 +384,11 @@
  /**
   * @description 获取合计字段值
   */
  getStatFieldsValue = () => {
    const { mainSearch, BID } = this.props
    const { setting, search, orderBy, statFields } = this.state
  getStatFieldsValue = (searches) => {
    const { BID } = this.props
    const { setting, orderBy, statFields } = this.state
    let searches = fromJS(search).toJS()
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
      searches = [...mainSearch, ...searches]
    }
    if (statFields.length === 0 || setting.interType !== 'system' || !setting.dataresource) return
    let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0))
    if (requireFields.length > 0) {
      return
    }
    if (statFields.length === 0 || !(setting.interType === 'system' || (setting.interType === 'custom' && setting.requestMode === 'system')) || !setting.dataresource) return
    let _orderBy = orderBy || setting.order
    let param = UtilsDM.getStatQueryDataParams(setting, statFields, searches, _orderBy, BID, this.props.menuType)
@@ -448,7 +441,6 @@
      search: searches
    }, () => {
      this.loadmaindata()
      this.getStatFieldsValue()
    })
  }
@@ -483,12 +475,10 @@
        pageIndex: 1
      }, () => {
        this.loadmaindata()
        this.getStatFieldsValue()
      })
    } else {
      MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid, 'false') // 列表重置
      this.loadmaindata()
      this.getStatFieldsValue()
    }
    
  }
src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -724,8 +724,19 @@
    Api.directRequest(url, btn.method, param).then(res => {
      if (typeof(res) !== 'object' || Array.isArray(res)) {
        this.execError({ErrCode: 'E', message: '未知的返回结果!'})
        _resolve()
        let error = '未知的返回结果!'
        if (typeof(res) === 'string') {
          error = res.replace(/'/ig, '"')
        }
        let result = {
          mk_api_key: mkey,
          $ErrCode: 'E',
          $ErrMesg: error
        }
        this.customCallbackRequest(params, result, _resolve)
      } else {
        res.mk_api_key = mkey
        this.customCallbackRequest(params, res, _resolve)
@@ -743,6 +754,16 @@
    const { btn } = this.props
    let lines = []
    let pre = btn.callbackType === 'script' ? '@' : ''
    let errSql = ''
    if (result.$ErrCode === 'E') {
      errSql = `
        set @ErrorCode='E'
        set @retmsg='${result.$ErrMesg}'
      `
      delete result.$ErrCode
      delete result.$ErrMesg
    }
    let getDefaultSql = (obj, tb, bid, level) => {
      let keys = []
@@ -810,8 +831,11 @@
        param.BID = this.props.BID
      }
      let _prevCustomScript = '' // 默认sql前执行脚本
      let _backCustomScript = '' // 默认sql后执行脚本
      let _prevCustomScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000)
        Select @ErrorCode='',@retmsg=''
        ${errSql}
      `
      let _backCustomScript = ''
      btn.verify.cbScripts.forEach(script => {
        if (script.status === 'false') return
src/tabviews/zshare/mutilform/index.jsx
@@ -229,7 +229,7 @@
      if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type) && item.resourceType === '1') {
        deForms.push(item)
      } else if (['select', 'link', 'radio'].includes(item.type) && item.resourceType !== '1') { // 选中第一项
        if (item.initval.indexOf('$first') > -1) {
        if (item.initval && item.initval.indexOf('$first') > -1) {
          item.initval = item.options[0] ? item.options[0].Value : ''
        }
      }
@@ -462,7 +462,7 @@
          } else if (['select', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type)) {
            item.options = item.oriOptions
          }
          if (['select', 'link', 'radio'].includes(item.type) && item.initval.indexOf('$first') > -1) { // 选中第一项
          if (['select', 'link', 'radio'].includes(item.type) && item.initval && item.initval.indexOf('$first') > -1) { // 选中第一项
            item.initval = item.options[0] ? item.options[0].Value : ''
            values.push({field: item.field, value: item.initval})
          }
@@ -569,7 +569,7 @@
          } else if (['select', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type)) {
            item.options = item.oriOptions
          }
          if (['select', 'link', 'radio'].includes(item.type) && item.initval.indexOf('$first') > -1) { // 选中第一项
          if (['select', 'link', 'radio'].includes(item.type) && item.initval && item.initval.indexOf('$first') > -1) { // 选中第一项
            item.initval = item.options[0] ? item.options[0].Value : ''
            values.push({field: item.field, value: item.initval})
          }
@@ -1292,6 +1292,10 @@
              }
            }
            if (_item.value === undefined) {
              _item.value = ''
            }
            search.push(_item)
          })
@@ -1346,7 +1350,10 @@
              }
            } else {
              _value = values[key]
            }
            if (_value === undefined) {
              _value = ''
            }
            search.push({
src/templates/comtableconfig/index.jsx
@@ -1000,8 +1000,12 @@
      }
    })
    if (config.setting.interType === 'system' && config.setting.default !== 'false' && !config.setting.dataresource) {
      return '菜单尚未设置数据源,不可启用!'
    if ((config.setting.interType === 'system' || config.setting.requestMode === 'system') && config.setting.default === 'false' && config.setting.scripts && config.setting.scripts.filter(item => item.status !== 'false').length === 0) {
      return '数据源中不执行默认sql,且未添加自定义脚本,不可启用!'
    } else if (config.setting.interType === 'custom' && config.setting.procMode !== 'inner' && config.setting.preScripts && config.setting.preScripts.filter(item => item.status !== 'false').length === 0) {
      return '数据源未设置前置脚本,不可启用!'
    } else if (config.setting.interType === 'custom' && config.setting.callbackType === 'script' && config.setting.cbScripts && config.setting.cbScripts.filter(item => item.status !== 'false').length === 0) {
      return '数据源未设置回调脚本,不可启用!'
    } else if (!config.setting.primaryKey) {
      return '菜单尚未设置主键,不可启用!'
    } else if (config.columns.length === 0) {
src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx
@@ -293,8 +293,8 @@
                  前置函数
                </Tooltip>
              }>
                {getFieldDecorator('innerFunc', {
                  initialValue: setting.innerFunc || '',
                {getFieldDecorator('prevFunc', {
                  initialValue: setting.prevFunc || '',
                  rules: [
                    {
                      required: true,
@@ -335,6 +335,23 @@
              </Form.Item>
            </Col> : null}
            {interType === 'custom' ? <Col span={12}>
              <Form.Item label="请求方式">
                {getFieldDecorator('method', {
                  initialValue: setting.method || 'post',
                  rules: [
                    {
                      required: true,
                      message: dict['form.required.select'] + '请求方式!'
                    },
                  ]
                })(
                <Radio.Group>
                  <Radio value="get">GET</Radio>
                  <Radio value="post">POST</Radio>
                </Radio.Group>)}
              </Form.Item>
            </Col> : null}
            {interType === 'custom' ? <Col span={12}>
              <Form.Item label="数据请求">
                {getFieldDecorator('requestMode', {
                  initialValue: requestMode,
src/templates/sharecomponent/settingcomponent/settingform/index.jsx
@@ -178,8 +178,6 @@
      this.setState({loading: true})
    }
    let _scripts = scripts.filter(script => script.status !== 'false')
    // 表单提交时检查输入值是否正确
    if (activeKey === 'setting') {
      return new Promise((resolve, reject) => {
@@ -200,14 +198,6 @@
              duration: 5
            })
            this.setState({loading: false})
            reject()
            return
          } else if ((res.interType === 'system' || res.requestMode === 'system') && res.default === 'false' && _scripts.length === 0) {
            notification.warning({
              top: 92,
              message: '不执行默认sql时,请添加自定义脚本!',
              duration: 5
            })
            reject()
            return
          }
@@ -234,14 +224,6 @@
          notification.warning({
            top: 92,
            message: '使用内部接口,才可以创建存储过程!',
            duration: 5
          })
          this.setState({loading: false})
          reject()
        } else if ((setting.interType === 'system' || setting.requestMode === 'system') && setting.default === 'false' && _scripts.length === 0) {
          notification.warning({
            top: 92,
            message: '不执行默认sql时,请添加自定义脚本!',
            duration: 5
          })
          this.setState({loading: false})
src/templates/sharecomponent/settingcomponent/settingform/utils.jsx
@@ -117,13 +117,18 @@
      `
    })
    if (_customScript) {
    if (_customScript && regoptions) {
      _customScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50) select @ErrorCode='',@retmsg =''
        ${_customScript}
      `
    } else if (_customScript) {
      _customScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000) select @ErrorCode='',@retmsg =''
        ${_customScript}
      `
    }
    _customScript = _customScript.replace(/@\$|\$@/ig, '')
    _customScript = _customScript.replace(/@userName@|@fullName@/ig, `''`)
    // 外联数据库替换
    if (window.GLOB.externalDatabase !== null) {
      _customScript = _customScript.replace(/@db@/ig, window.GLOB.externalDatabase)
src/templates/subtableconfig/index.jsx
@@ -836,8 +836,12 @@
      }
    })
    if (config.setting.interType === 'system' && config.setting.default !== 'false' && !config.setting.dataresource) {
      return '尚未设置数据源,不可启用!'
    if ((config.setting.interType === 'system' || config.setting.requestMode === 'system') && config.setting.default === 'false' && config.setting.scripts && config.setting.scripts.filter(item => item.status !== 'false').length === 0) {
      return '数据源中不执行默认sql,且未添加自定义脚本,不可启用!'
    } else if (config.setting.interType === 'custom' && config.setting.procMode !== 'inner' && config.setting.preScripts && config.setting.preScripts.filter(item => item.status !== 'false').length === 0) {
      return '数据源未设置前置脚本,不可启用!'
    } else if (config.setting.interType === 'custom' && config.setting.callbackType === 'script' && config.setting.cbScripts && config.setting.cbScripts.filter(item => item.status !== 'false').length === 0) {
      return '数据源未设置回调脚本,不可启用!'
    } else if (!config.setting.primaryKey) {
      return '尚未设置主键,不可启用!'
    }  else if (config.columns.length === 0) {
src/templates/zshare/formconfig.jsx
@@ -890,11 +890,11 @@
      tooltip: '使用默认方式执行时,需要配合计划任务。',
      required: true,
      options: [{
        value: 'default',
        text: '默认脚本'
      }, {
        value: 'script',
        text: '自定义脚本'
      }, {
        value: 'default',
        text: '后台脚本'
      }]
    },
    {
src/templates/zshare/verifycard/callbackcustomscript/index.jsx
@@ -82,6 +82,8 @@
          return
        }
        let prev = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000)
        `
        let tail = `
          aaa:
        `
@@ -108,7 +110,7 @@
        let param = {
          func: 's_debug_sql',
          exec_type: 'y',
          LText: _prevCustomScript + _backCustomScript + tail
          LText: prev +  _prevCustomScript + _backCustomScript + tail
        }
        // 数据权限
src/utils/utils-datamanage.js
@@ -18,7 +18,7 @@
  static getQueryDataParams (setting, arrFields, search = [], orderBy = '', pageIndex = 1, pageSize = 10, BID, menuType, id) {
    let param = null
    if (setting.interType === 'system' || (setting.interType === 'inner' && !setting.innerFunc)) {
    if (setting.interType === 'system' || (setting.interType === 'custom' && setting.requestMode === 'system')) {
      param = this.getDefaultQueryParam(setting, arrFields, search, orderBy, pageIndex, pageSize, menuType, id)
    } else {
      param = this.getCustomQueryParam(setting, search, orderBy, pageIndex, pageSize, menuType, id)
@@ -52,7 +52,7 @@
      param.PageSize = pageSize
    }
    if (setting.interType === 'inner') {
    if (setting.interType === 'inner' || (setting.interType === 'custom' && setting.requestMode === 'inner')) {
      param.func = setting.innerFunc
    } else {
      if (menuType === 'HS') {
@@ -323,4 +323,167 @@
    return param
  }
  /**
   * @description 数据源名称,用于统一查询
   * @param {Object}   setting      数据源设置
   * @param {String}   arrFields    查询字段
   * @param {Array}    search       搜索条件
   * @param {String}   orderBy      排序方式
   * @param {Number}   pageIndex    页码
   * @param {Number}   pageSize     每页数量
   * @param {String}   BID          上级ID
   * @param {String}   menuType     菜单类型,普通菜单与HS
   * @return {Object}  param
   */
  static getPrevQueryParams (setting, search = [], BID, menuType) {
    let param = null
    if (setting.procMode !== 'inner') {
      param = this.getDefaultPrevQueryParam(setting, search, menuType)
    } else {
      param = Utils.formatCustomMainSearch(search)
      param.func = setting.prevFunc || ''
    }
    if (BID) {
      param.BID = BID
    }
    return param
  }
  /**
   * @description 获取系统存储过程 sPC_Get_TableData 的参数
   */
  static getDefaultPrevQueryParam (setting, search, menuType) {
    let param = {
      func: 'sPC_TableData_InUpDe',
      exec_type: 'y',
      script_type: 'Y'
    }
    let sql = ''
    let userName = sessionStorage.getItem('User_Name') || ''
    let fullName = sessionStorage.getItem('Full_Name') || ''
    if (sessionStorage.getItem('isEditState') === 'true') {
      userName = sessionStorage.getItem('CloudUserName') || ''
      fullName = sessionStorage.getItem('CloudFullName') || ''
    }
    setting.preScripts.forEach(item => {
      if (item.status === 'false') return
      sql += `${item.sql}
      `
    })
    if (sql) {
      sql = `/*前置脚本*/
        declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50)
        Select @ErrorCode='',@retmsg ='',@UserName='${userName}', @FullName='${fullName}'
        ${sql}
        aaa:
          if @ErrorCode!=''
            insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@
      `
      let allSearch = Utils.getAllSearchOptions(search)
      let regoptions = allSearch.map(item => {
        return {
          reg: new RegExp('@' + item.key + '@', 'ig'),
          value: `'${item.value}'`
        }
      })
      regoptions.push({
        reg: new RegExp('@userName@', 'ig'),
        value: userName
      }, {
        reg: new RegExp('@fullName@', 'ig'),
        value: fullName
      })
      regoptions.forEach(item => {
        sql = sql.replace(item.reg, item.value)
      })
      // 测试系统打印查询语句
      if ((options.sysType === 'local' && !window.GLOB.systemType) || window.debugger === true) {
        console.info(sql)
      }
    }
    if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
      sql = sql.replace(/\$@/ig, '/*')
      sql = sql.replace(/@\$/ig, '*/')
    } else {
      sql = sql.replace(/@\$|\$@/ig, '')
    }
    param.LText = Utils.formatOptions(sql)
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
    param.secretkey = Utils.encrypt('', param.timestamp)
    if (menuType === 'HS') { // 函数 sPC_TableData_InUpDe 云端验证
      param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
    }
    param.menuname = setting.MenuName || ''
    return param
  }
  /**
   * @description 获取系统存储过程 sPC_Get_TableData 的参数
   */
  static getCallBackQueryParams (setting, sql, errSql) {
    let param = {
      func: 'sPC_TableData_InUpDe',
      exec_type: 'y',
    }
    let _prevCustomScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000)
      Select @ErrorCode='',@retmsg=''
      ${errSql}
    `
    let _backCustomScript = ''
    setting.cbScripts.forEach(script => {
      if (script.status === 'false') return
      if (script.position === 'front') {
        _prevCustomScript += `
      /* 自定义脚本 */
      ${script.sql}
      `
      } else {
        _backCustomScript += `
      /* 自定义脚本 */
      ${script.sql}
      `
      }
    })
    sql = _prevCustomScript + sql
    sql = sql + _backCustomScript
    if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) {
      console.info(sql.replace(/\n\s{8}/ig, '\n'))
    }
    param.LText = sql
    if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
      param.LText = param.LText.replace(/\$@/ig, '/*')
      param.LText = param.LText.replace(/@\$/ig, '*/')
    } else {
      param.LText = param.LText.replace(/@\$|\$@/ig, '')
    }
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
    param.secretkey = Utils.encrypt('', param.timestamp)
    param.LText = Utils.formatOptions(param.LText)
    param.menuname = setting.MenuName || ''
    return param
  }
}
src/utils/utils.js
@@ -1070,7 +1070,7 @@
    // 获取字段键值对
    formdata && formdata.forEach(form => {
      if (form.type === 'text') { // 特殊字段替换
      if (form.type === 'text' && form.value) { // 特殊字段替换
        form.value = form.value.replace(/^(\s*)@appkey@(\s*)$/ig, appkey)
        form.value = form.value.replace(/^(\s*)@SessionUid@(\s*)$/ig, sessionUid)
        form.value = form.value.replace(/^(\s*)@bid@(\s*)$/ig, BID)