king
2025-04-23 b48528b1a1a88e289fc0b7ad52f2da213a3f9dfe
src/tabviews/custom/index.jsx
@@ -3,6 +3,7 @@
import { is, fromJS } from 'immutable'
import { notification, Spin, Row, Col, Modal } from 'antd'
import moment from 'moment'
import md5 from 'md5'
import Api from '@/api'
import Utils from '@/utils/utils.js'
@@ -48,6 +49,7 @@
const DebugTable = asyncComponent(() => import('@/tabviews/debugtable'))
const FlowFloat = asyncComponent(() => import('@/tabviews/zshare/flowFloat'))
const TableNodes = asyncComponent(() => import('@/tabviews/zshare/tablenodes'))
const DeepSeek = asyncComponent(() => import('@/tabviews/zshare/deepseek'))
const MkInterfaces = asyncComponent(() => import('@/tabviews/custom/components/interfaces'))
class CustomPage extends Component {
@@ -68,7 +70,8 @@
    loading: false,       // 列表数据加载中
    visible: false,       // 标签页控制
    shortcuts: null,      // 快捷键
    loadinginter: false
    loadinginter: false,
    noParam: false
  }
  stepInter = null
@@ -78,6 +81,7 @@
   */
  async loadconfig () {
    const { MenuID, MenuName, param } = this.props
    const { noParam } = this.state
    let _param = {
      func: 'sPC_Get_LongParam',
@@ -208,16 +212,44 @@
      let skip = config.permission === 'false' || window.GLOB.mkHS
      let urlparam = {} // url参数
      if (param) {
        Object.keys(param).forEach(key => {
          if (/^\$/.test(key)) {
            urlparam[key] = param[key]
          } else {
            urlparam[key.toLowerCase()] = param[key]
          }
        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
        }
      }
      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') || ''
@@ -235,7 +267,7 @@
      }
      if (config.urlFields) {
        config.urlFields.forEach(field => {
          let val = `'${urlparam[field.toLowerCase()] || ''}'`
          let val = `'${urlparam[field.toLowerCase()]}'`
          regs.push({
            reg: new RegExp('@' + field + '@', 'ig'),
            value: val
@@ -285,7 +317,7 @@
        }
      })
      config.components = this.formatSetting(config.components, params, inherit, config.interfaces, balMap, tbMap)
      config.components = this.formatSetting(config.components, params, inherit, config.interfaces, balMap, tbMap, BID)
      if (initInters.length > 0) {
        this.stepInter = {
@@ -567,8 +599,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
            }
          })
@@ -680,9 +713,16 @@
        if (item.hasExtend) {
          item.setting.hasExtend = true
          item.setting.sync = 'false'
          item.setting.tableMode = 'compatible'
          item.setting.extendTime = moment().format('YYYY-MM-DD HH:mm:ss')
          item.colsCtrls = null
        }
        if (item.wrap.tree === 'true') {
          item.setting.sync = 'false'
          item.$cache = false
          item.setting.$tree = true
        }
        if (item.subtype === 'editable') {
@@ -698,6 +738,9 @@
          }
        }
      } else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') {
        if (item.wrap.datatype === 'public') {
          balMap.set(item.wrap.publicId + 'public', true)
        }
        item.subcards && item.subcards.forEach(card => {
          if (card.style.boxShadow) {
            delete card.style.hShadow
@@ -804,6 +847,13 @@
          group.subButton = this.resetButton(item, group.subButton)
          if (group.subButton.linkmenu) {
            if (Array.isArray(group.subButton.linkmenu) && group.subButton.linkmenu.length > 0) {
              group.subButton.openmenu = group.subButton.linkmenu
            }
            delete group.subButton.linkmenu
          }
          if (item.$cache && item.$time) { // 表单缓存
            group.$cache = item.$cache
            group.$time = item.$time
@@ -873,12 +923,9 @@
          delete item.scripts
          item.setting.$name = item.$menuname || ''
          item.setting.execute = item.setting.execute !== 'false'  // 默认sql是否执行,转为boolean 统一格式
          if (!item.setting.execute) {
            item.setting.dataresource = ''
          }
          if (/\s/.test(item.setting.dataresource)) {
            item.setting.dataresource = '(' + item.setting.dataresource + ') tb'
          }
      
          if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
@@ -900,7 +947,17 @@
          item.setting.customScript = _customScript // 整理后自定义脚本
          item.setting.tailScript = _tailScript     // 后置自定义脚本
          item.setting.custompage = /@pageSize@|@orderBy@/i.test(item.setting.dataresource + item.setting.customScript)
          item.setting.custompage = false
          if (/order\s+by\s+sort_id\s*$/i.test(item.setting.dataresource)) {
            item.setting.custompage = true
          } else if (item.setting.$tree || /@pageSize@|@orderBy@|@mk_total/i.test(item.setting.dataresource + item.setting.customScript)) {
            item.setting.custompage = true
          }
          if (/\s/.test(item.setting.dataresource)) {
            item.setting.dataresource = '(' + item.setting.dataresource + ') tb'
          }
          if (!item.setting.execute || item.setting.custompage) {
            item.forbidLine = true
@@ -908,7 +965,7 @@
          if (item.setting.sync === 'true') {
            // pageable 是否分页,组件属性,不分页的组件才可以统一查询
            if ((!item.pageable || (item.pageable && !item.setting.laypage)) && item.setting.onload === 'true') {
            if ((!item.pageable || (item.pageable && !item.setting.laypage)) && item.setting.onload === 'true' && !_tailScript) {
            } else {
              item.setting.sync = 'false'
@@ -956,25 +1013,18 @@
    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') {
        if (item.setting.interType !== 'system') {
          cell.errorType = 'error2'
        } else if (item.type === 'balcony' || item.subtype === 'propcard') {
          cell.errorType = 'error2'
        }
    } else if (cell.OpenType === 'pop' && cell.modal) {
      if (item.$cache && item.$time) {
        cell.modal.$cache = item.$cache
        cell.modal.$time = item.$time
      }
    } else if (cell.OpenType === 'pop' && item.$cache && item.$time && cell.modal) {
      cell.modal.$cache = item.$cache
      cell.modal.$time = item.$time
      cell.modal.uuid = cell.uuid + 'pop'
      cell.modal.uuid = cell.uuid + '_pop'
    }
    if (cell.verify) {
      let isStatic = item.wrap && (item.wrap.datatype === 'static' || item.wrap.datatype === 'public')
      if (cell.verify.invalid === 'true') {
        if (item.wrap && (item.wrap.datatype === 'static' || item.wrap.datatype === 'public')) {
        if (isStatic) {
          cell.verify.invalid = 'false'
        } else if (item.setting && item.setting.maxScript && item.setting.maxScript >= 300) {
          cell.verify.invalid = 'false'
@@ -985,6 +1035,9 @@
        } else if (cell.Ot === 'notRequired') {
          cell.verify.invalid = 'false'
        }
      }
      if (cell.verify.uniques && cell.verify.uniques.length > 0 && cell.Ot === 'requiredOnce' && isStatic) {
        cell.verify.uniques = []
      }
      if (cell.verify.linkEnable === 'true' && /@/.test(cell.verify.linkUrl)) {
@@ -1004,12 +1057,20 @@
        }
        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)
          }
        }
      }
    }
@@ -1022,6 +1083,7 @@
        }
      } else if (cell.syncComponentId === 'multiComponent') {
        let ids = cell.syncComponents.map(m => {
          if (Array.isArray(m)) return m.pop() || ''
          return m.syncComId.pop() || ''
        })
@@ -1130,18 +1192,18 @@
  }
  // 格式化默认设置
  formatSetting = (components, params, inherit, interfaces, balMap, tbMap) => {
  formatSetting = (components, params, inherit, interfaces, balMap, tbMap, BID) => {
    let delay = 20
    return components.map(component => {
      if (component.type === 'tabs') {
        component.subtabs = component.subtabs.map(tab => {
          tab.components = this.formatSetting(tab.components, null, inherit, interfaces, balMap, tbMap)
          tab.components = this.formatSetting(tab.components, null, inherit, interfaces, balMap, tbMap, BID)
          tab = {...tab, ...inherit}
          return tab
        })
        return component
      } else if (component.type === 'group') {
        component.components = this.formatSetting(component.components, params, null, interfaces, balMap, tbMap)
        component.components = this.formatSetting(component.components, params, null, interfaces, balMap, tbMap, BID)
        return component
      }
@@ -1216,6 +1278,8 @@
      if (component.setting.interType !== 'system') return component
      component.setting.uuid = component.uuid
      // dataName 系统生成的数据源名称
      if (component.setting.sync === 'true') {
        component.dataName = 'mk' + component.uuid.slice(-18)
@@ -1237,12 +1301,22 @@
            component.setting.sync = 'false'
            component.setting.onload = 'false'
          } else {
            params.push(getStructDefaultParam(component, searchlist, params.length === 0))
            let backend = false
            if (window.backend && params.length === 0 && window.GLOB.CacheData.has('sql_' + component.uuid)) {
              backend = true
            } else if (window.backend && params[0] && params[0].exps) {
              backend = true
            }
            if (backend && !window.GLOB.CacheData.has('sql_' + component.uuid)) {
              component.setting.sync = 'false'
            } else {
              params.push(getStructDefaultParam(component, searchlist, params.length === 0, BID))
            }
          }
        }
      }
      
      component.setting.delay = delay
      component.setting.delay = delay + (component.setting.delay || 0)
      delay += 20
      return component
@@ -1268,7 +1342,7 @@
    let delay = 15
    return interfaces.map(inter => {
      inter.MenuID = MenuID
      inter.setting.delay = delay
      inter.setting.delay = delay + (inter.setting.delay || 0)
      inter.$searchId = MenuID
      delay += 15
@@ -1292,6 +1366,8 @@
      if (inter.setting.interType !== 'system') return inter
      inter.setting.uuid = inter.uuid
      let _customScript = ''
      let _tailScript = ''
      inter.scripts.forEach(script => {
@@ -1314,9 +1390,6 @@
      if (!inter.setting.execute) {
        inter.setting.dataresource = ''
      }
      if (/\s/.test(inter.setting.dataresource)) {
        inter.setting.dataresource = '(' + inter.setting.dataresource + ') tb'
      }
  
      if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
        inter.setting.dataresource = inter.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
@@ -1336,8 +1409,17 @@
      inter.setting.customScript = _customScript // 整理后自定义脚本
      inter.setting.tailScript = _tailScript     // 后置自定义脚本
      inter.setting.custompage = false
      inter.setting.custompage = /@pageSize@|@orderBy@/i.test(inter.setting.dataresource + inter.setting.customScript)
      if (/order\s+by\s+sort_id\s*$/i.test(inter.setting.dataresource)) {
        inter.setting.custompage = true
      } else if (/@pageSize@|@orderBy@|@mk_total/i.test(inter.setting.dataresource + inter.setting.customScript)) {
        inter.setting.custompage = true
      }
      if (/\s/.test(inter.setting.dataresource)) {
        inter.setting.dataresource = '(' + inter.setting.dataresource + ') tb'
      }
      return inter
    })
@@ -1353,7 +1435,11 @@
    this.setState({loading: true, loadingview: false})
    if (config.$cache && config.$time) {
      Api.getLCacheConfig(params[0].uuid, config.$time, BID).then(res => {
      let uuid = params[0].uuid || ''
      if (params[0].id) {
        uuid = window.GLOB.CacheData.get('first_' + params[0].id) || ''
      }
      Api.getLCacheConfig(uuid, config.$time, BID).then(res => {
        if (!res.valid) {
          this.getMainData(param, params, config.MenuID)
        } else {
@@ -1389,11 +1475,11 @@
        }
        params.forEach((item) => {
          let _data = result[item.name] || ''
          let _data = result[item.dataName] || ''
          if (_data && !Array.isArray(_data)) {
            _data = [_data]
          }
          window.GLOB.SyncData.set(item.name, _data)
          window.GLOB.SyncData.set(item.dataName, _data)
        })
        MKEmitter.emit('transferSyncData', MenuID)
@@ -1420,12 +1506,12 @@
    })
  }
  reloadMenuView = (menuId) => {
  reloadMenuView = (menuId, clear) => {
    const { MenuID } = this.props
    if (MenuID !== menuId) return
    this.reloadview()
    this.reloadview(clear)
  }
  resetActiveMenu = (menuId) => {
@@ -1520,7 +1606,7 @@
    })
  }
  reloadview = () => {
  reloadview = (clear) => {
    window.GLOB.CacheData.delete(this.props.MenuID)
    
    if (this.state.config) {
@@ -1538,7 +1624,8 @@
      viewlost: false,      // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用
      config: null,         // 页面配置信息,包括组件等
      loading: false,       // 列表数据加载中
      shortcuts: null
      shortcuts: null,
      noParam: clear === true
    }, () => {
      this.loadconfig()
    })
@@ -1773,6 +1860,7 @@
          {config.process === 'true' ? <FlowFloat config={config}/> : null}
          <SettingComponent config={config} shortcuts={shortcuts || []}/>
          <TableNodes config={config} />
          <DeepSeek/>
        </div>
      </div>
    )