king
2025-04-23 b48528b1a1a88e289fc0b7ad52f2da213a3f9dfe
src/tabviews/basetable/index.jsx
@@ -2,6 +2,7 @@
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { notification, Spin, Row, Col } from 'antd'
import md5 from 'md5'
import Api from '@/api'
import Utils from '@/utils/utils.js'
@@ -16,6 +17,7 @@
const FlowFloat = asyncComponent(() => import('@/tabviews/zshare/flowFloat'))
const SettingComponent = asyncComponent(() => import('@/tabviews/zshare/settingcomponent'))
const TableNodes = asyncComponent(() => import('@/tabviews/zshare/tablenodes'))
const DeepSeek = asyncComponent(() => import('@/tabviews/zshare/deepseek'))
const AutoMatic = asyncComponent(() => import('@/tabviews/zshare/automatic'))
const DebugTable = asyncComponent(() => import('@/tabviews/debugtable'))
@@ -38,14 +40,16 @@
    userConfig: null,     // 用户自定义设置
    visible: false,       // 标签页控制
    shortcuts: null,      // 快捷键
    autoMatic: null
    autoMatic: null,
    noParam: false
  }
  /**
   * @description 获取页面配置信息
   */
  async loadconfig () {
    const { MenuID, MenuName } = this.props
    const { MenuID, MenuName, param } = this.props
    const { noParam } = this.state
    let _param = {
      func: 'sPC_Get_LongParam',
@@ -161,9 +165,46 @@
      // 权限过滤
      let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
      let skip = window.GLOB.mkHS
      let param = this.props.param || {} // url参数
      let urlparam = {} // url参数
      if (param) {
        if (!noParam) {
          Object.keys(param).forEach(key => {
            if (/^\$/.test(key)) {
              urlparam[key] = param[key]
            } else {
              urlparam[key.toLowerCase()] = param[key]
            }
          })
        } else {
          urlparam.$BID = param.$BID
        }
      }
      window.GLOB.CacheData.set(MenuID, param)
      if (config.urlFields && config.urlFields.length) {
        config.urlFields.forEach(field => {
          let key = field.toLowerCase()
          if (urlparam[key] !== undefined) return
          urlparam[key] = ''
        })
      }
      window.GLOB.CacheData.set(MenuID, urlparam)
      if (window.backend && config.allSqls) {
        let keys = Object.keys(urlparam)
        config.allSqls.forEach(item => {
          item.id = md5(window.GLOB.appkey + item.v_id)
          if (['datasource', 'interface', 'excelOut'].includes(item.type)) {
            item.urlkeys = keys
            item.urlparam = urlparam
            if (config.flow_code) {
              item.works_flow_code = config.flow_code
            }
          }
          window.GLOB.CacheData.set('sql_' + item.uuid, item)
        })
      }
      let userName = sessionStorage.getItem('User_Name') || ''
      let fullName = sessionStorage.getItem('Full_Name') || ''
@@ -181,7 +222,7 @@
      }
      if (config.urlFields) {
        config.urlFields.forEach(field => {
          let val = `'${param[field] || ''}'`
          let val = `'${urlparam[field.toLowerCase()]}'`
          regs.push({
            reg: new RegExp('@' + field + '@', 'ig'),
            value: val
@@ -193,7 +234,7 @@
        regs.push({ reg: /@works_flow_code@/ig, value: `'${config.flow_code}'` })
      }
      config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, skip, param, MenuID, config.MenuName, config.process === 'true')
      config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, skip, urlparam, MenuID, config.MenuName, config.process === 'true')
      let autoMatic = null
      if (config.autoMatic && config.autoMatic.enable === 'true') {
@@ -224,7 +265,7 @@
        }
      })
      let BID = param.$BID || ''
      let BID = urlparam.$BID || ''
      config.components = this.formatSetting(config.components, regs)
@@ -347,8 +388,9 @@
      Utils.initSearchVal(item)
      if (urlparam.$searchkey) {
        let reg = new RegExp('(^|,)' + urlparam.$searchkey + '($|,)', 'ig')
        item.search.forEach(cell => {
          if (urlparam.$searchkey === cell.field.toLowerCase() && ['text', 'select', 'link', 'checkcard'].includes(cell.type)) {
          if (reg.test(cell.field) && ['text', 'select', 'link', 'checkcard'].includes(cell.type)) {
            cell.initval = urlparam.$searchval
          }
        })
@@ -495,45 +537,55 @@
    if (cell.OpenType === 'excelOut') { // 导出
      cell.$menuName = item.$menuname
      if (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0) {
        cell.errorType = 'error1'
      } else if (cell.intertype === 'system' && cell.verify.dataType !== 'custom' && item.setting.interType !== 'system') {
        cell.errorType = 'error2'
      }
    } else if (cell.OpenType === 'pop' && cell.modal) {
      cell.modal.uuid = cell.uuid + '_pop'
    }
    if (cell.verify && cell.verify.invalid === 'true') {
      if (item.setting.maxScript && item.setting.maxScript >= 300) {
        cell.verify.invalid = 'false'
      } else if (cell.intertype !== 'system' && cell.procMode !== 'system') {
        cell.verify.invalid = 'false'
      } else if (cell.sqlType === 'insert') {
        cell.verify.invalid = 'false'
      } else if (cell.Ot === 'notRequired') {
        cell.verify.invalid = 'false'
      }
    }
    if (cell.verify && cell.verify.preHandle === 'true') {
      let script = cell.verify.pre_func
      if (!/#position-/.test(script) || /#position-init/.test(script)) {
        try {
          // eslint-disable-next-line
          let func = new Function('btn', 'position', 'systemType', script)
          func(cell, 'init', window.GLOB.systemType)
        } catch (e) {
          console.warn(e)
    if (cell.verify) {
      if (cell.verify.invalid === 'true') {
        if (item.setting && item.setting.maxScript && item.setting.maxScript >= 300) {
          cell.verify.invalid = 'false'
        } else if (cell.intertype !== 'system' && cell.procMode !== 'system') {
          cell.verify.invalid = 'false'
        } else if (cell.sqlType === 'insert') {
          cell.verify.invalid = 'false'
        } else if (cell.Ot === 'notRequired') {
          cell.verify.invalid = 'false'
        }
      }
      if (/#position-inner/.test(script)) {
        cell.$innerScript = script
      if (cell.verify.linkEnable === 'true' && /@/.test(cell.verify.linkUrl)) {
        cell.returnValue = 'true'
      }
      if (/#position-outer/.test(script)) {
        cell.$outerScript = script
      }
      if (/#position-callback/.test(script)) {
        cell.$callbackScript = script
      if (cell.verify.preHandle === 'true') {
        let script = cell.verify.pre_func
        if (!/#position-/.test(script) || /#position-init/.test(script)) {
          try {
            // eslint-disable-next-line
            let func = new Function('btn', 'position', 'systemType', script)
            func(cell, 'init', window.GLOB.systemType)
          } catch (e) {
            console.warn(e)
          }
        }
        if (/#position-inner/.test(script)) {
          cell.$innerScript = script
          if (window.backend && window.GLOB.CacheData.has('sql_' + cell.uuid) && !/\$backend/.test(script)) {
            window.GLOB.CacheData.delete('sql_' + cell.uuid)
          }
        }
        if (/#position-outer/.test(script)) {
          cell.$outerScript = script
        }
        if (/#position-callback/.test(script)) {
          cell.$callbackScript = script
          if (window.backend && window.GLOB.CacheData.has('sql_back_' + cell.uuid) && !/\$backend/.test(script)) {
            window.GLOB.CacheData.delete('sql_back_' + cell.uuid)
          }
        }
      }
    }
@@ -545,6 +597,7 @@
        }
      } else if (cell.syncComponentId === 'multiComponent') {
        let ids = cell.syncComponents.map(m => {
          if (Array.isArray(m)) return m.pop() || ''
          return m.syncComId.pop() || ''
        })
@@ -615,6 +668,8 @@
        return component
      }
      component.setting.uuid = component.uuid
      let _customScript = ''
      let _tailScript = ''
      component.scripts && component.scripts.forEach(script => {
@@ -637,9 +692,6 @@
      if (!component.setting.execute) {
        component.setting.dataresource = ''
      }
      if (/\s/.test(component.setting.dataresource)) {
        component.setting.dataresource = '(' + component.setting.dataresource + ') tb'
      }
  
      if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
        component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
@@ -659,26 +711,35 @@
      component.setting.customScript = _customScript // 整理后自定义脚本
      component.setting.tailScript = _tailScript     // 后置自定义脚本
      component.setting.custompage = false
      component.setting.custompage = /@pageSize@|@orderBy@/i.test(component.setting.dataresource + component.setting.customScript)
      if (/order\s+by\s+sort_id\s*$/i.test(component.setting.dataresource)) {
        component.setting.custompage = true
      } else if (/@pageSize@|@orderBy@|@mk_total/i.test(component.setting.dataresource + component.setting.customScript)) {
        component.setting.custompage = true
      }
      if (/\s/.test(component.setting.dataresource)) {
        component.setting.dataresource = '(' + component.setting.dataresource + ') tb'
      }
      if (!component.setting.execute || component.setting.custompage) {
        component.forbidLine = true
      }
      
      component.setting.delay = delay
      component.setting.delay = delay + (component.setting.delay || 0)
      delay += 20
      return component
    })
  }
  reloadMenuView = (menuId) => {
  reloadMenuView = (menuId, clear) => {
    const { MenuID } = this.props
    if (MenuID !== menuId) return
    this.reloadview()
    this.reloadview(clear)
  }
  resetActiveMenu = (menuId) => {
@@ -740,7 +801,7 @@
    })
  }
  reloadview = () => {
  reloadview = (clear) => {
    window.GLOB.CacheData.delete(this.props.MenuID)
    if (this.state.config) {
      this.deleteCache(this.state.config.components)
@@ -752,6 +813,7 @@
      viewlost: false,      // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用
      config: null,         // 页面配置信息,包括组件等
      shortcuts: null,
      noParam: clear === true
    }, () => {
      this.loadconfig()
    })
@@ -803,6 +865,7 @@
          {config.process === 'true' ? <FlowFloat config={config}/> : null}
          <SettingComponent config={config} shortcuts={shortcuts || []}/>
          <TableNodes config={config} />
          <DeepSeek/>
        </div>
      </div>
    )