king
2023-09-28 cd5079f2dbe12eb03fcef2e1898e4f013848d895
src/tabviews/custom/popview/index.jsx
@@ -4,8 +4,6 @@
import { notification, Spin, Row, Col, Modal } from 'antd'
import Api from '@/api'
import zhCN from '@/locales/zh-CN/main.js'
import enUS from '@/locales/en-US/main.js'
import Utils from '@/utils/utils.js'
import { getStructuredParams, getStructDefaultParam } from '@/utils/utils-datamanage.js'
import MKEmitter from '@/utils/events.js'
@@ -52,7 +50,6 @@
  }
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    BID: '',              // 页面跳转时携带ID
    viewlost: false,      // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用
    lostmsg: '',          // 页面丢失时的提示信息
@@ -91,7 +88,7 @@
    if (!config.enabled) {
      this.setState({
        viewlost: true,
        lostmsg: this.state.dict['main.view.unenabled']
        lostmsg: '抱歉,您访问的页面未启用,请联系管理员。'
      })
      return
    }
@@ -114,11 +111,6 @@
    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') || ''
    }
    let regs = [
      { reg: /@userName@/ig, value: `'${userName}'` },
      { reg: /@fullName@/ig, value: `'${fullName}'` }
@@ -129,6 +121,11 @@
        reg: /@db@/ig,
        value: window.GLOB.externalDatabase
      })
    }
    if (Tab.$process && window.GLOB.UserCacheMap.has(Tab.$flowId)) {
      let flow = window.GLOB.UserCacheMap.get(Tab.$flowId)
      regs.push({ reg: /@works_flow_code@/ig, value: `'${flow.flow_code || ''}'` })
    }
    config.components = this.filterComponent(config.components, roleId, balMap, param, Tab, Tab.uuid, Tab.uuid)
@@ -161,7 +158,7 @@
    config.components = this.formatSetting(config.components, params, regs, balMap)
    if ([...balMap.keys()].length > 0) {
    if (balMap.size > 0) {
      config.components = this.filterBalcony(config.components, balMap)
    }
@@ -180,6 +177,11 @@
      item.$pageId = Tab.uuid
      item.$searchId = searchId
      item.$syncId = syncId
      if (Tab.$process) {
        item.$process = true
        item.$flowId = Tab.$flowId
      }
      
      if (item.style && item.style.boxShadow) {
        delete item.style.hShadow
@@ -274,16 +276,22 @@
          let _searchId = searchId
          tab.components.forEach(cell => {
            if (cell.type !== 'search') return
            _searchId = cell.uuid
            window.GLOB.SearchBox.set(cell.uuid, cell.$searches)
            if (cell.$s_req) {
              window.GLOB.SearchBox.set(cell.uuid + 'required', true)
            }
          })
          if (tab.components.findIndex(cell => cell.type === 'search') > -1) {
            _searchId = tab.uuid
          }
          tab.components = this.filterComponent(tab.components, roleId, balMap, urlparam, Tab, _searchId, tab.uuid)
          if (_searchId === tab.uuid) {
            tab.components.forEach(cell => {
              if (cell.type !== 'search') return
              window.GLOB.SearchBox.set(_searchId, cell.$searches)
              if (cell.$s_req) {
                window.GLOB.SearchBox.set(_searchId + 'required', true)
              }
            })
          }
          return tab
        })
@@ -316,9 +324,7 @@
      }
      // 搜索条件初始化
      if (item.type === 'search' && item.search.length === 0) {
        return false
      } else if (item.search) {
      if (item.search) {
        Utils.initSearchVal(item)
        item.$searches = Utils.initMainSearch(item.search)
@@ -348,7 +354,6 @@
      }
      if (item.type === 'table') {
        let statFields = []
        let getCols = (cols) => {
          return cols.filter(col => {
            if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
@@ -360,9 +365,6 @@
            }
            
            if (col.type === 'number') {
              if (col.sum === 'true' && !statFields.includes(col.field)) {
                statFields.push(col)
              }
              if (typeof(col.decimal) === 'number') {
                col.round = Math.pow(10, col.decimal)
                if (col.format === 'percent') {
@@ -398,7 +400,7 @@
      
            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 = ''
            }
@@ -408,7 +410,6 @@
        }
        
        item.cols = getCols(item.cols)
        item.statFields = statFields
        if (item.subtype === 'editable') {
          item.submit.logLabel = item.$menuname + '-提交'
@@ -595,6 +596,11 @@
    cell.$MenuID = Tab.$MenuID
    cell.$tabId = Tab.uuid
    if (Tab.$process) {
      cell.$process = true
      cell.$flowId = Tab.$flowId
    }
    if (cell.btnstyle) { // 兼容
      cell.style = cell.style || {}
      cell.style = {...cell.style, ...cell.btnstyle}
@@ -605,6 +611,20 @@
        cell.controlVals = cell.controlVal.split(',')
      } else {
        cell.controlVals = [(cell.controlVal || '')]
      }
    }
    if (cell.OpenType === 'excelOut') { // 导出
      cell.$menuName = item.name
      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'
        }
      }
    }
@@ -639,6 +659,11 @@
  resetElement = (cell) => {
    cell.style = cell.style || {}
    if (cell.style.display === 'inline-block') {
      cell.style.verticalAlign = 'top'
    }
    if (['text', 'number', 'formula'].includes(cell.eleType)) {
      if (!cell.height) {
        cell.innerHeight = 'auto'
@@ -721,6 +746,7 @@
        return component
      }
      component.setting.arr_field = component.columns ? component.columns.map(col => col.field).join(',') : ''
      component.setting.useMSearch = component.setting.useMSearch === 'true'
      if (component.setting.useMSearch) {
        if (!window.GLOB.SearchBox.has(component.$searchId)) {
@@ -737,9 +763,15 @@
      }
      let _customScript = ''
      let _tailScript = ''
      component.scripts && component.scripts.forEach(script => {
        if (script.status !== 'false') {
        if (script.status === 'false') return
        if (script.position !== 'back') {
          _customScript += `
          ${script.sql}
          `
        } else {
          _tailScript += `
          ${script.sql}
          `
        }
@@ -759,17 +791,27 @@
      if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
        component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
        _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
        _tailScript = _tailScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
      } else {
        component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
        _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
        _tailScript = _tailScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
      }
      regs.forEach(cell => {
        component.setting.dataresource = component.setting.dataresource.replace(cell.reg, cell.value)
        _customScript = _customScript.replace(cell.reg, cell.value)
        _tailScript = _tailScript.replace(cell.reg, cell.value)
      })
      component.setting.customScript = _customScript // 整理后自定义脚本
      component.setting.tailScript = _tailScript     // 后置自定义脚本
      component.setting.custompage = /@pageSize@|@orderBy@/i.test(component.setting.dataresource + component.setting.customScript)
      if (!component.setting.execute || component.setting.custompage) {
        component.forbidLine = true
      }
      if (component.setting.sync === 'true') {
        // pageable 是否分页,组件属性,不分页的组件才可以统一查询