king
2024-09-25 c46e208fc65742bf02d43235a28143abbf3eb7ea
src/tabviews/custom/popview/index.jsx
@@ -2,12 +2,12 @@
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { notification, Spin, Row, Col, Modal } from 'antd'
import moment from 'moment'
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'
import asyncComponent from '@/utils/asyncComponent'
import NotFount from '@/components/404'
import './index.scss'
@@ -51,13 +51,10 @@
  }
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    BID: '',              // 页面跳转时携带ID
    viewlost: false,      // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用
    lostmsg: '',          // 页面丢失时的提示信息
    config: null,         // 页面配置信息,包括组件等
    mainSearch: null,     // 主搜索
    data: null,           // 列表数据集
    loading: false,       // 列表数据加载中
  }
@@ -65,7 +62,7 @@
   * @description 获取页面配置信息
   */
  async loadconfig () {
    const { Tab } = this.props
    const { Tab, param } = this.props
    let config = Tab.config || ''
@@ -74,6 +71,7 @@
        config = JSON.stringify(config)
        config = config.replace(/@mywebsite@\//ig, window.GLOB.baseurl)
        config = JSON.parse(config)
        config.MenuName = Tab.logLabel || Tab.label || ''
      } catch (e) {
        console.warn('Parse Failure')
        config = ''
@@ -92,7 +90,7 @@
    if (!config.enabled) {
      this.setState({
        viewlost: true,
        lostmsg: this.state.dict['main.view.unenabled']
        lostmsg: '抱歉,您访问的页面未启用,请联系管理员。'
      })
      return
    }
@@ -108,17 +106,22 @@
    // 权限过滤
    let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
    let balMap = new Map()
    let param = this.props.param || {} // url参数
    let tbMap = new Map()
    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(Tab.uuid, param)
    window.GLOB.CacheData.set(Tab.uuid, urlparam)
    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}'` },
@@ -132,47 +135,32 @@
      })
    }
    config.$cache = config.cacheLocal === 'true'
    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, config.$cache)
    config.components = this.filterComponent(config.components, roleId, balMap, tbMap, urlparam, Tab, Tab.uuid, Tab.uuid, regs)
    
    // 获取主搜索条件
    let mainSearch = []
    config.components.forEach(component => {
      if (component.type !== 'search') return
      component.search = component.search.map(item => {
        item.oriInitval = item.initval
        if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) {
          item.initval = param.$searchval
        }
      window.GLOB.SearchBox.set(Tab.uuid, component.$searches)
        return item
      })
      mainSearch = Utils.initMainSearch(component.search)
      if (component.$s_req) {
        window.GLOB.SearchBox.set(Tab.uuid + 'required', true)
      }
    })
    let params = []
    let BID = param.$BID || ''
    let inherit = {}
    let BID = urlparam.$BID || ''
    if (config.cacheUseful === 'true') { // 缓存继承
      inherit.cacheUseful = config.cacheUseful
      inherit.timeUnit = config.timeUnit
      inherit.cacheTime = config.cacheTime
    }
    config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs, balMap)
    if ([...balMap.keys()].length > 0) {
      config.components = this.filterBalcony(config.components, balMap)
    }
    config.components = this.formatSetting(config.components, params, balMap, tbMap, BID)
    this.setState({
      BID: BID,
      config,
      mainSearch
      config
    }, () => {
      if (params.length > 0) {
        this.loadmaindata(params)
@@ -180,10 +168,16 @@
    })
  }
  filterComponent = (components, roleId, balMap, urlparam, Tab, cache) => {
  filterComponent = (components, roleId, balMap, tbMap, urlparam, Tab, searchId, syncId, regs) => {
    return components.filter(item => {
      item.$pageId = Tab.uuid
      item.$cache = cache
      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
@@ -192,7 +186,7 @@
        delete item.style.shadowColor
      }
      item.$menuname = (Tab.label || '') + '-' + (item.name || '')
      item.$menuname = (Tab.logLabel || Tab.label || '') + '-' + (item.name || '')
      if (item.type === 'tabs') {
        if (
@@ -229,6 +223,8 @@
            }
          }
          tab.$menuname = (Tab.logLabel || Tab.label || '') + '-' + (tab.label || '')
          return true
        })
@@ -237,12 +233,7 @@
          if (item.setting.supModule === 'preview') {
            item.setting.supModule = ''
            let val = ''
            Object.keys(urlparam).forEach(key => {
              if (key.toLowerCase() === item.setting.controlField) {
                val = urlparam[key]
              }
            })
            let val = urlparam[item.setting.controlField] || ''
            item.subtabs = item.subtabs.filter(tab => {
              if (tab.$pass) return true
@@ -255,12 +246,7 @@
        if (item.setting.selectField) {
          item.setting.selectField = item.setting.selectField.toLowerCase()
          let val = ''
          Object.keys(urlparam).forEach(key => {
            if (key.toLowerCase() === item.setting.selectField) {
              val = urlparam[key]
            }
          })
          let val = urlparam[item.setting.selectField] || ''
          let activeKey = ''
@@ -276,7 +262,24 @@
        item.subtabs = item.subtabs.map(tab => {
          tab.$pageId = Tab.uuid
          tab.components = this.filterComponent(tab.components, roleId, balMap, urlparam, Tab, cache)
          let _searchId = searchId
          if (tab.components.findIndex(cell => cell.type === 'search') > -1) {
            _searchId = tab.uuid
          }
          tab.components = this.filterComponent(tab.components, roleId, balMap, tbMap, urlparam, Tab, _searchId, tab.uuid, regs)
          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
        })
@@ -289,7 +292,7 @@
          return false
        }
        item.components = this.filterComponent(item.components, roleId, balMap, urlparam, Tab, cache)
        item.components = this.filterComponent(item.components, roleId, balMap, tbMap, urlparam, Tab, searchId, syncId, regs)
        return true
      } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart'].includes(item.type)) {
@@ -308,13 +311,14 @@
        }
      }
      // 搜索条件初始化
      if (item.search && item.search.length > 0) {
        item.search = Utils.initSearchVal(item.search)
      }
      if (item.wrap && item.wrap.supType === 'multi') { // 数据卡多上级组件
        item.setting.supModule = item.supNodes[0].componentId
      if (item.wrap && item.wrap.supType === 'multi') { // 数据卡、table多上级组件
        item.supNodes = item.supNodes.map(node => node.componentId)
        if (item.supNodes[0]) {
          item.setting.supModule = item.supNodes[0]
        } else {
          item.supNodes = null
          item.setting.supModule = ''
        }
      } else if (item.setting && item.setting.supModule && typeof(item.setting.supModule) !== 'string') {
        let pid = item.setting.supModule.pop()
        if (pid && pid !== 'empty') {
@@ -322,6 +326,13 @@
        } else {
          item.setting.supModule = ''
        }
      }
      // 搜索条件初始化
      if (item.search) {
        Utils.initSearchVal(item)
        item.$searches = Utils.initMainSearch(item.search)
      }
      // 权限过滤
@@ -337,7 +348,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) {
@@ -348,10 +358,10 @@
              col.type = 'custom'
            }
            
            if (col.type === 'number') {
              if (col.sum === 'true' && !statFields.includes(col.field)) {
                statFields.push(col)
              }
            if (col.type === 'index') {
              col.field = '$Index'
              col.type = 'text'
            } else if (col.type === 'number') {
              if (typeof(col.decimal) === 'number') {
                col.round = Math.pow(10, col.decimal)
                if (col.format === 'percent') {
@@ -387,9 +397,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
@@ -397,7 +411,14 @@
        }
        
        item.cols = getCols(item.cols)
        item.statFields = statFields
        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.subtype === 'editable') {
          item.submit.logLabel = item.$menuname + '-提交'
@@ -412,6 +433,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
@@ -478,6 +502,9 @@
          item.wrap.supModule = item.wrap.supModule.pop()
          item.setting.supModule = item.wrap.supModule
        }
        if (item.wrap.datatype === 'public') {
          balMap.set(item.wrap.publicId + 'public', true)
        }
        item.elements = item.elements.filter(cell => {
          if (cell.eleType === 'button') {
            if (cell.hidden === 'true' || cell.OpenType === 'popview') return false
@@ -490,27 +517,19 @@
          return true
        })
      } else if (item.type === 'form') {
        if (item.wrap.datatype === 'public') {
          balMap.set(item.wrap.publicId + 'public', true)
        }
        item.subcards = item.subcards.map(group => {
          group.subButton.uuid = group.uuid
          group.subButton.$menuId = group.uuid
          group.subButton.$MenuID = Tab.$MenuID
          group.subButton.OpenType = 'formSubmit'
          group.subButton.execError = 'never'
          group.subButton.logLabel = item.$menuname + '-' + group.subButton.label
          group.subButton.$tabId = Tab.uuid
          if (!group.subButton.Ot) {
            group.subButton.Ot = item.wrap.datatype === 'static' ? 'notRequired' : 'requiredSgl'
          }
          group.subButton.syncComponentId = group.subButton.syncComponent ? (group.subButton.syncComponent.pop() || '') : ''
          if (group.subButton.syncComponentId && group.subButton.syncComponentId === item.setting.supModule) {
            group.subButton.syncComponentId = ''
            if (group.subButton.execSuccess === 'grid') {
              group.subButton.execSuccess = 'mainline'
            }
          }
          group.subButton = this.resetButton(item, group.subButton, Tab)
          group.fields = group.fields.map(cell => {
            // 数据源sql语句,预处理,权限黑名单字段设置为隐藏表单
@@ -533,43 +552,91 @@
          return group
        })
      }
      // 整理数据源
      if (item.setting && item.format && (!item.wrap || !['public', 'static'].includes(item.wrap.datatype))) {
        item.setting.arr_field = item.columns ? item.columns.map(col => col.field).join(',') : ''
        item.setting.useMSearch = item.setting.useMSearch === 'true'
        item.setting.laypage = item.setting.laypage === 'true'   // 是否分页,转为boolean 统一格式
        if (item.wrap && item.wrap.goback === 'true') {
          item.setting.sync = 'false'
        }
        if (item.format === 'object') {
          item.setting.laypage = false
          item.setting.$top = true
        }
        if (item.setting.interType !== 'system') { // 不使用系统函数时
          item.setting.sync = 'false'
          item.setting.dataresource = ''
        } else {
          let _customScript = ''
          let _tailScript = ''
          item.scripts && item.scripts.forEach(script => {
            if (script.status === 'false') return
            if (script.position !== 'back') {
              _customScript += `
              ${script.sql}
              `
            } else {
              _tailScript += `
              ${script.sql}
              `
            }
          })
          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'
          }
      
      return true
    })
  }
          if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
            item.setting.dataresource = item.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 {
            item.setting.dataresource = item.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
            _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
            _tailScript = _tailScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
          }
  filterBalcony = (components, balMap) => {
    return components.filter(item => {
      if (item.type === 'tabs') {
        item.subtabs = item.subtabs.map(tab => {
          tab.components = this.filterBalcony(tab.components, balMap)
          return tab
        })
      } else if (item.type === 'group') {
        item.components = this.filterBalcony(item.components, balMap)
      }
          regs.forEach(cell => {
            item.setting.dataresource = item.setting.dataresource.replace(cell.reg, cell.value)
            _customScript = _customScript.replace(cell.reg, cell.value)
            _tailScript = _tailScript.replace(cell.reg, cell.value)
          })
      if (item.type === 'balcony' && item.wrap.linkType === 'sync') {
        let conf = balMap.get(item.wrap.syncModuleId)
          item.setting.customScript = _customScript // 整理后自定义脚本
          item.setting.tailScript = _tailScript     // 后置自定义脚本
        if (!conf || conf === true) {
          return false
        }
        item.syncConfig = {
          uuid: conf.uuid,
          wrap: conf.wrap,
          setting: conf.setting,
          columns: conf.columns
        }
          item.setting.custompage = /@pageSize@|@orderBy@|@mk_total/i.test(item.setting.dataresource + item.setting.customScript)
        if (item.wrap.checkAll === 'show') {
          if (conf.subtype === 'datacard' && conf.wrap.cardType !== 'checkbox') {
            item.wrap.checkAll = 'hidden'
          } else if (conf.subtype === 'normaltable' && conf.wrap.tableType !== 'checkbox') {
            item.wrap.checkAll = 'hidden'
          if (!item.setting.execute || item.setting.custompage) {
            item.forbidLine = true
          }
          if (item.setting.sync === 'true') {
            // pageable 是否分页,组件属性,不分页的组件才可以统一查询
            if ((!item.pageable || (item.pageable && !item.setting.laypage)) && item.setting.onload === 'true' && !_tailScript) {
            } else {
              item.setting.sync = 'false'
            }
          }
        }
      }
      if (item.type === 'card' && item.subtype === 'datacard') {
        tbMap.set(item.uuid, item)
      } else if (item.type === 'table' && item.subtype !== 'editable') {
        tbMap.set(item.uuid, item)
      }
      
      return true
@@ -584,6 +651,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}
@@ -597,10 +669,63 @@
      }
    }
    if (cell.OpenType === 'excelOut') { // 导出
      cell.$menuName = item.$menuname
    } else if (cell.OpenType === 'pop' && cell.modal) {
      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 (isStatic) {
          cell.verify.invalid = 'false'
        } else 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.uniques && cell.verify.uniques.length > 0 && cell.Ot === 'requiredOnce' && isStatic) {
        cell.verify.uniques = []
      }
      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
        }
      }
    }
    if (cell.syncComponentId) {
      if (cell.syncComponentId === item.setting.supModule) {
        cell.syncComponentId = ''
        if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
        if (['line', 'grid', 'line_grid'].includes(cell.execSuccess)) {
          cell.execSuccess = 'mainline'
        }
      } else if (cell.syncComponentId === 'multiComponent') {
@@ -608,8 +733,17 @@
          return m.syncComId.pop() || ''
        })
        if (item.setting.supModule && ids.includes(item.setting.supModule)) {
          if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
        if (item.supNodes) {
          item.supNodes.forEach(node => {
            if (!ids.includes(node)) return
            if (['line', 'grid', 'line_grid'].includes(cell.execSuccess)) {
              cell.execSuccess = 'mainline'
            }
            ids = ids.filter(id => id !== node)
          })
        } else if (item.setting.supModule && ids.includes(item.setting.supModule)) {
          if (['line', 'grid', 'line_grid'].includes(cell.execSuccess)) {
            cell.execSuccess = 'mainline'
          }
          ids = ids.filter(id => id !== item.setting.supModule)
@@ -628,6 +762,26 @@
  resetElement = (cell) => {
    cell.style = cell.style || {}
    if (cell.style.display === 'inline-block') {
      cell.style.verticalAlign = 'top'
    }
    if (cell.marks && cell.marks.length === 0) {
      cell.marks = null
    }
    if (cell.anchors && cell.anchors.length === 0) {
      cell.anchors = null
    }
    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 (['text', 'number', 'formula'].includes(cell.eleType)) {
      if (!cell.height) {
        cell.innerHeight = 'auto'
@@ -663,136 +817,125 @@
    return cell
  }
  getPrinter = (item, parentId) => {
    let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid)
    if (_item) {
      item.printer = _item.printer || ''
      item.verify.defaultPrinter = _item.printer || ''
      if (item.verify.printerTypeList && _item.printerList) {
        item.verify.printerTypeList = item.verify.printerTypeList.map(cell => {
          cell.printer = _item.printerList[cell.Value] || ''
          return cell
        })
      }
    }
    return item
  }
  // 格式化默认设置
  formatSetting = (components, params, mainSearch, inherit, regs, balMap) => {
  formatSetting = (components, params, 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, null, inherit, regs, balMap)
          tab = {...tab, ...inherit}
          tab.components = this.formatSetting(tab.components, null, balMap, tbMap, BID)
          return tab
        })
        return component
      } else if (component.type === 'group') {
        component.components = this.formatSetting(component.components, null, null, inherit, regs, balMap)
        component = {...component, ...inherit}
        component.components = this.formatSetting(component.components, params, balMap, tbMap, BID)
        return component
      } else if (component.wrap && component.wrap.datatype === 'public') {
        component.setting.useMSearch = false
      }
      if (component.type === 'balcony') {
        if (component.wrap.linkType === 'sync') {
          let conf = tbMap.get(component.wrap.syncModuleId)
          if (conf) {
            component.syncConfig = {
              uuid: conf.uuid,
              wrap: conf.wrap,
              setting: conf.setting,
              columns: conf.columns
            }
            if (component.wrap.checkAll === 'show') {
              if (conf.subtype === 'datacard' && conf.wrap.cardType !== 'checkbox') {
                component.wrap.checkAll = 'hidden'
              } else if (conf.subtype === 'normaltable' && conf.wrap.tableType !== 'checkbox') {
                component.wrap.checkAll = 'hidden'
              }
            }
          }
        }
      } else if (balMap.has(component.uuid)) {
        component.setting.$hasSyncModule = true
      }
      if (balMap.has(component.uuid + 'public')) {
        component.$hasTopModule = true
      }
      if (component.wrap && component.wrap.datatype === 'public') {
        if (tbMap.has(component.wrap.publicId)) {
          let tb = tbMap.get(component.wrap.publicId)
          component.setting = {...tb.setting}
          component.$searchId = tb.$searchId
          component.wrap.publicId = component.wrap.publicId + 'tb'
        } else {
          component.wrap.datatype = 'static'
          component.setting = component.setting || {}
          component.setting.useMSearch = false
          component.setting.sync = 'false'
        }
        return component
      } else if (component.wrap && component.wrap.datatype === 'static') {
        component.format = ''
        component.setting = component.setting || {}
        component.setting.useMSearch = false
        component.setting.sync = 'false'
        return component
      } else if (!component.setting || !component.format) {
        return component
      }
      component.setting.useMSearch = component.setting.useMSearch === 'true'
      if (component.setting.interType !== 'system') { // 不使用系统函数时
        component.setting.sync = 'false'
        component.setting.laypage = component.setting.laypage === 'true'
        return component
      }
      let _customScript = ''
      component.scripts && component.scripts.forEach(script => {
        if (script.status !== 'false') {
          _customScript += `
          ${script.sql}
          `
      if (component.setting.useMSearch) {
        if (!window.GLOB.SearchBox.has(component.$searchId)) {
          component.setting.useMSearch = false
        } else if (window.GLOB.SearchBox.has(component.$searchId + 'required')) {
          component.$s_req = true
        }
      })
      delete component.scripts
      component.setting.$name = component.$menuname || ''
      component.setting.execute = component.setting.execute !== 'false'  // 默认sql是否执行,转为boolean 统一格式
      component.setting.laypage = component.setting.laypage === 'true'   // 是否分页,转为boolean 统一格式
      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(/@datam@/ig, '\'Y\'')
        component.setting.dataresource = component.setting.dataresource.replace(/@\$/ig, '*/')
        _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'')
        _customScript = _customScript.replace(/@\$/ig, '*/')
      } else {
        component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
        _customScript = _customScript.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)
      })
      if (component.setting.interType !== 'system') return component
      component.setting.customScript = _customScript // 整理后自定义脚本
      component.setting.uuid = component.uuid
      // dataName 系统生成的数据源名称
      if (component.setting.sync === 'true') {
        component.dataName = 'mk' + component.uuid.slice(-18)
      }
      // floor    组件的层级
      // pageable 是否分页,组件属性,不分页的组件才可以统一查询
      if (params && (!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true' && component.setting.sync === 'true') {
        let searchlist = []
        if (component.search && component.search.length > 0) {
          searchlist = Utils.initMainSearch(component.search)
        }
        if (component.setting.useMSearch) {
          let keys = searchlist.map(item => item.key)
          mainSearch.forEach(item => {
            if (!keys.includes(item.key)) {
        if (params) {
          let searchlist = component.$searches || []
          if (component.setting.useMSearch) {
            let mainSearch = window.GLOB.SearchBox.get(component.$searchId)
            let keys = component.$s_keys || []
            mainSearch.forEach(item => {
              if (keys.includes(item.key.toLowerCase())) return
              searchlist.push(item)
            })
          }
          if (component.$s_req && searchlist.filter(item => item.required && item.value === '').length > 0) {
            component.setting.sync = 'false'
            component.setting.onload = 'false'
          } else {
            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 (searchlist.filter(item => item.required && item.value === '').length > 0) {
          component.setting.sync = 'false'
          component.setting.onload = 'false'
        } else {
          params.push(getStructDefaultParam(component, searchlist, params.length === 0))
            if (backend && !window.GLOB.CacheData.has('sql_' + component.uuid)) {
              component.setting.sync = 'false'
            } else {
              params.push(getStructDefaultParam(component, searchlist, params.length === 0, BID))
            }
          }
        }
      } else if (params) {
        component.setting.sync = 'false'
      }
      component.setting.delay = delay
      component.setting.delay = delay + (component.setting.delay || 0)
      delay += 20
      if (balMap.has(component.uuid)) {
        component.setting.$hasSyncModule = true
        balMap.set(component.uuid, component)
      }
      return component
    })
@@ -802,12 +945,17 @@
   * @description 主表数据加载
   */ 
  loadmaindata = (params) => {
    const { Tab } = this.props
    const { config } = this.state
    let param = getStructuredParams(params, config, this.state.BID || '')
    this.setState({loading: true})
    Api.genericInterface(param).then(result => {
      this.setState({
        loading: false
      })
      if (result.status) {
        if (result.message) {
          if (result.ErrCode === 'Y') {
@@ -823,32 +971,23 @@
          }
        }
        delete result.status
        delete result.message
        delete result.ErrMesg
        delete result.ErrCode
        if (config.$cache) {
          params.forEach((item) => {
            let _data = result[item.name] || ''
            if (_data && !Array.isArray(_data)) {
              _data = [_data]
            }
            Api.writeCacheConfig(item.uuid, _data)
          })
        }
        this.setState({
          data: result,
          loading: false
        params.forEach((item) => {
          let _data = result[item.dataName] || ''
          if (_data && !Array.isArray(_data)) {
            _data = [_data]
          }
          window.GLOB.SyncData.set(item.dataName, _data)
        })
        MKEmitter.emit('transferSyncData', Tab.uuid)
      } else {
        this.setState({
          data: '',
          loading: false
        })
        MKEmitter.emit('transferSyncData', Tab.uuid)
        if (!result.message) return
        if (/将截断字符串或二进制数据/ig.test(result.message)) {
          result.message = result.message + '请检查字段集'
        }
        if (result.ErrCode === 'N') {
          Modal.error({
            title: result.message,
@@ -895,20 +1034,20 @@
        })
      } else if (item.type === 'group') {
        this.deleteCache(item.components)
      } else if (item.type === 'search') {
        window.GLOB.SearchBox.delete(item.$searchId)
      } else {
        window.GLOB.CacheData.delete(item.uuid)
      }
      if (item.dataName) {
        window.GLOB.SyncData.delete(item.dataName)
      }
    })
  }
  resetSearch = (search) => {
    this.setState({mainSearch: null}, () => {
      this.setState({mainSearch: search})
    })
  }
  getComponents = () => {
    const { config, BID, data, mainSearch } = this.state
    const { config, BID } = this.state
    if (!config) return
@@ -924,19 +1063,19 @@
      if (item.type === 'card' && item.subtype === 'datacard') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <DataCard config={item} data={data} mainSearch={mainSearch}/>
            <DataCard config={item}/>
          </Col>
        )
      } else if (item.type === 'card' && item.subtype === 'propcard') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <PropCard config={item} data={data} mainSearch={mainSearch}/>
            <PropCard config={item}/>
          </Col>
        )
      } else if (item.type === 'card' && item.subtype === 'dualdatacard') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <DoubleDataCard config={item} mainSearch={mainSearch}/>
            <DoubleDataCard config={item}/>
          </Col>
        )
      } else if (item.type === 'table' && item.subtype === 'basetable') {
@@ -948,133 +1087,131 @@
      } else if (item.type === 'bar' || item.type === 'line') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvBarAndLine config={item} data={data} mainSearch={mainSearch}/>
            <AntvBarAndLine config={item}/>
          </Col>
        )
      } else if (item.type === 'pie') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvPie config={item} data={data} mainSearch={mainSearch}/>
            <AntvPie config={item}/>
          </Col>
        )
      } else if (item.type === 'scatter') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvScatter config={item} data={data} mainSearch={mainSearch}/>
            <AntvScatter config={item}/>
          </Col>
        )
      } else if (item.type === 'dashboard') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvDashboard config={item} data={data} mainSearch={mainSearch}/>
            <AntvDashboard config={item}/>
          </Col>
        )
      } else if (item.type === 'form' && item.subtype === 'simpleform') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <SimpleForm config={item} data={data} mainSearch={mainSearch}/>
            <SimpleForm config={item}/>
          </Col>
        )
      } else if (item.type === 'form' && item.subtype === 'stepform') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <StepForm config={item} data={data} mainSearch={mainSearch}/>
            <StepForm config={item}/>
          </Col>
        )
      } else if (item.type === 'form' && item.subtype === 'tabform') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <TabForm config={item} data={data} mainSearch={mainSearch}/>
            <TabForm config={item}/>
          </Col>
        )
      } else if (item.type === 'search') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <MainSearch config={item} BID={BID} refreshdata={this.resetSearch} />
            <MainSearch config={item} BID={BID} />
          </Col>
        )
      } else if (item.type === 'tabs') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvTabs config={item} mainSearch={mainSearch} />
            <AntvTabs config={item}/>
          </Col>
        )
      } else if (item.type === 'balcony') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <Balcony config={item} data={data}/>
            <Balcony config={item}/>
          </Col>
        )
      } else if (item.type === 'timeline') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <TimeLine config={item} data={data} mainSearch={mainSearch}/>
            <TimeLine config={item}/>
          </Col>
        )
      } else if (item.type === 'carousel' && item.subtype === 'datacard') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <CarouselDataCard config={item} data={data} mainSearch={mainSearch}/>
            <CarouselDataCard config={item}/>
          </Col>
        )
      } else if (item.type === 'carousel' && item.subtype === 'propcard') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <CarouselPropCard config={item} data={data} mainSearch={mainSearch}/>
            <CarouselPropCard config={item}/>
          </Col>
        )
      } else if (item.type === 'card' && item.subtype === 'tablecard') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <TableCard config={item} data={data} mainSearch={mainSearch}/>
            <TableCard config={item}/>
          </Col>
        )
      } else if (item.type === 'table' && item.subtype === 'normaltable') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <NormalTable config={item} data={data} mainSearch={mainSearch}/>
            <NormalTable config={item}/>
          </Col>
        )
      } else if (item.type === 'table' && item.subtype === 'editable') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <EditTable config={item} mainSearch={mainSearch}/>
            <EditTable config={item}/>
          </Col>
        )
      } else if (item.type === 'group' && item.subtype === 'normalgroup') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <NormalGroup config={item} mainSearch={mainSearch}/>
          </Col>
          <NormalGroup config={item} style={style} key={item.uuid}/>
        )
      } else if (item.type === 'editor') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <BraftEditor config={item} data={data} mainSearch={mainSearch}/>
            <BraftEditor config={item}/>
          </Col>
        )
      } else if (item.type === 'tree') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <NormalTree config={item} data={data} mainSearch={mainSearch}/>
            <NormalTree config={item}/>
          </Col>
        )
      } else if (item.type === 'calendar') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <Calendar config={item} mainSearch={mainSearch}/>
            <Calendar config={item}/>
          </Col>
        )
      } else if (item.type === 'code') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <SandBox config={item} data={data} mainSearch={mainSearch}/>
            <SandBox config={item}/>
          </Col>
        )
      } else if (item.type === 'chart') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <CustomChart config={item} data={data} mainSearch={mainSearch}/>
            <CustomChart config={item}/>
          </Col>
        )
      } else if (item.type === 'module' && item.subtype === 'voucher') {
@@ -1086,13 +1223,13 @@
      } else if (item.type === 'iframe') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <Iframe config={item} data={data} mainSearch={mainSearch}/>
            <Iframe config={item}/>
          </Col>
        )
      } else if (item.type === 'antvG6') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvG6 config={item} data={data} mainSearch={mainSearch}/>
            <AntvG6 config={item}/>
          </Col>
        )
      } else if (item.type === 'antvX6') {
@@ -1112,7 +1249,7 @@
    return (
      <div className={'pop-page-wrap ' + (loading ? 'loading' : '')} style={config ? config.style : null}>
        {loading && !config.$cache ? <Spin className="view-spin" size="large" /> : null}
        {loading ? <Spin className="view-spin" size="large" /> : null}
        <Row className="component-wrap">{this.getComponents()}</Row>
        {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
      </div>