king
2024-08-28 c10fc10d5fd307a7b334bcde6af5c1175aaa0410
src/tabviews/basetable/index.jsx
@@ -45,7 +45,7 @@
   * @description 获取页面配置信息
   */
  async loadconfig () {
    const { MenuID, MenuName } = this.props
    const { MenuID, MenuName, param } = this.props
    let _param = {
      func: 'sPC_Get_LongParam',
@@ -112,7 +112,6 @@
            config.flow_code = result.works_flow_code
            config.flow_name = result.works_flow_name
            unset = false
            window.GLOB.UserCacheMap.set('flow' + MenuID, flowConfig)
          } catch (e) {
            unset = true
@@ -145,12 +144,12 @@
      }
      // HS不使用自定义设置
      if (result.LongParamUser && !window.GLOB.mkHS) {
      if (result.LongParamUser) {
        try { // 配置信息解析
          let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser)))
          if (userConfig) {
            shortcuts = userConfig.action
            userConfig.printers.forEach(item => {
            shortcuts = userConfig.action || []
            userConfig.printers && userConfig.printers.forEach(item => {
              window.GLOB.UserCacheMap.set(item.parentId + item.uuid, item)
            })
          }
@@ -162,9 +161,32 @@
      // 权限过滤
      let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
      let skip = window.GLOB.mkHS
      let param = this.props.param || {} // url参数
      let urlparam = {} // url参数
      if (param) {
        Object.keys(param).forEach(key => {
          if (/^\$/.test(key)) {
            urlparam[key] = param[key]
          } else {
            urlparam[key.toLowerCase()] = param[key]
          }
        })
      }
      window.GLOB.CacheData.set(MenuID, param)
      window.GLOB.CacheData.set(MenuID, urlparam)
      if (window.backend && config.allSqls) {
        let keys = Object.keys(urlparam)
        config.allSqls.forEach(item => {
          if (item.type === 'datasource') {
            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') || ''
@@ -182,7 +204,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
@@ -190,7 +212,11 @@
        })
      }
      config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, skip, param, MenuID, config.MenuName, config.process === 'true')
      if (config.flow_code) {
        regs.push({ reg: /@works_flow_code@/ig, value: `'${config.flow_code}'` })
      }
      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') {
@@ -205,22 +231,10 @@
          }
        })
      }
      // 获取主搜索条件
      config.components.forEach(component => {
        if (component.type === 'tabs') return
        if (param.$searchkey) {
          component.search = component.search.map(item => {
            if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) {
              item.initval = param.$searchval
            }
            return item
          })
          component.$searches = Utils.initMainSearch(component.search)
        }
        if (component.$searches.length) {
          component.$main = true
@@ -233,7 +247,7 @@
        }
      })
      let BID = param.$BID || ''
      let BID = urlparam.$BID || ''
      config.components = this.formatSetting(config.components, regs)
@@ -343,11 +357,6 @@
        item.name = (MenuName || '')
      }
      // 搜索条件初始化
      Utils.initSearchVal(item)
      item.$searches = Utils.initMainSearch(item.search)
      if (item.setting.supModule) {
        let pid = item.setting.supModule.pop()
        if (pid && pid !== 'empty') {
@@ -356,6 +365,19 @@
          item.setting.supModule = ''
        }
      }
      // 搜索条件初始化
      Utils.initSearchVal(item)
      if (urlparam.$searchkey) {
        item.search.forEach(cell => {
          if (urlparam.$searchkey === cell.field.toLowerCase() && ['text', 'select', 'link', 'checkcard'].includes(cell.type)) {
            cell.initval = urlparam.$searchval
          }
        })
      }
      item.$searches = Utils.initMainSearch(item.search)
      let statFields = []
      let getCols = (cols) => {
@@ -368,7 +390,10 @@
            col.type = 'custom'
          }
          
          if (col.type === 'number') {
          if (col.type === 'index') {
            col.field = '$Index'
            col.type = 'text'
          } else if (col.type === 'number') {
            if (col.sum === 'true') {
              statFields.push(col)
            }
@@ -394,7 +419,7 @@
                  cell = this.getPrinter(cell, item.uuid)
                }
                return skip || permAction[cell.uuid]
                return skip || permAction[cell.uuid] || cell.permission === 'false'
              } else if (['text', 'number', 'formula'].includes(cell.eleType)) {
                if (!cell.height) {
                  cell.innerHeight = 'auto'
@@ -406,6 +431,22 @@
                  }
                }
              }
              if (cell.linkmenu && cell.linkmenu.length > 0) {
                let menu_id = cell.linkmenu.pop()
                cell.linkThdMenu = window.GLOB.mkThdMenus.get(menu_id) || ''
                if (!cell.linkThdMenu) {
                  cell.link = ''
                }
              }
              if (cell.marks && cell.marks.length === 0) {
                cell.marks = null
              }
              if (cell.anchors && cell.anchors.length === 0) {
                cell.anchors = null
              }
              return true
            })
@@ -416,9 +457,13 @@
    
          if (col.linkmenu && col.linkmenu.length > 0) {
            let menu_id = col.linkmenu.pop()
            col.linkThdMenu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menu_id)[0] || ''
            col.linkThdMenu = window.GLOB.mkThdMenus.get(menu_id) || ''
          } else {
            col.linkThdMenu = ''
          }
          if (col.marks && col.marks.length === 0) {
            col.marks = null
          }
          return true
@@ -441,7 +486,7 @@
            cell = this.getPrinter(cell, item.uuid)
          }
          return skip || permAction[cell.uuid]
          return skip || permAction[cell.uuid] || cell.permission === 'false'
        })
      }
      
@@ -472,12 +517,48 @@
    }
    if (cell.OpenType === 'excelOut') { // 导出
      cell.$menuName = item.name
      cell.$menuName = item.$menuname
    } else if (cell.OpenType === 'pop' && cell.modal) {
      cell.modal.uuid = cell.uuid + 'pop'
    }
      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'
    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 (cell.verify.linkEnable === 'true' && /@/.test(cell.verify.linkUrl)) {
        cell.returnValue = 'true'
      }
      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 (/#position-outer/.test(script)) {
          cell.$outerScript = script
        }
        if (/#position-callback/.test(script)) {
          cell.$callbackScript = script
        }
      }
    }
@@ -513,6 +594,8 @@
  getPrinter = (item, parentId) => {
    let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid)
    item.verify.logLabel = item.logLabel
    if (_item) {
      item.printer = _item.printer || ''
      item.verify.defaultPrinter = _item.printer || ''
@@ -552,9 +635,12 @@
      if (component.setting.interType !== 'system') { // 不使用系统函数时
        component.setting.sync = 'false'
        component.setting.dataresource = ''
        component.setting.laypage = component.setting.laypage === 'true'
        return component
      }
      component.setting.uuid = component.uuid
      let _customScript = ''
      let _tailScript = ''
@@ -601,13 +687,13 @@
      component.setting.customScript = _customScript // 整理后自定义脚本
      component.setting.tailScript = _tailScript     // 后置自定义脚本
      component.setting.custompage = /@pageSize@|@orderBy@/i.test(component.setting.dataresource + component.setting.customScript)
      component.setting.custompage = /@pageSize@|@orderBy@|@mk_total/i.test(component.setting.dataresource + component.setting.customScript)
      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