king
2024-05-16 b69b5f6329ca5f87932436b7a6c1ddfc3377e10f
src/tabviews/custom/index.jsx
@@ -2,6 +2,7 @@
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 Utils from '@/utils/utils.js'
@@ -41,6 +42,7 @@
const AntvX6 = asyncComponent(() => import('./components/chart/antv-X6'))
const Voucher = asyncComponent(() => import('./components/module/voucher'))
const Account = asyncComponent(() => import('./components/module/account'))
const Invoice = asyncComponent(() => import('./components/module/invoice'))
const Iframe = asyncComponent(() => import('./components/iframe'))
const Calendar = asyncComponent(() => import('./components/calendar'))
const DebugTable = asyncComponent(() => import('@/tabviews/debugtable'))
@@ -75,7 +77,7 @@
   * @description 获取页面配置信息
   */
  async loadconfig () {
    const { MenuID, MenuName } = this.props
    const { MenuID, MenuName, param } = this.props
    let _param = {
      func: 'sPC_Get_LongParam',
@@ -181,8 +183,8 @@
        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)
            })
          }
@@ -203,9 +205,18 @@
      let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
      let balMap = new Map()
      let skip = config.permission === 'false' || 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)
      let userName = sessionStorage.getItem('User_Name') || ''
      let fullName = sessionStorage.getItem('Full_Name') || ''
@@ -223,7 +234,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
@@ -249,11 +260,11 @@
      let initInters = []
      config.interfaces = this.formatInterSetting(config.interfaces, regs, MenuID, initInters)
      config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces, config.$cache, config.$time, config.MenuName, MenuID, MenuID, config.process === 'true')
      config.interfaces = this.formatInterSetting(config.interfaces, regs, MenuID, initInters, config.MenuName)
      config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, urlparam, MenuID, config.interfaces, config.$cache, config.$time, config.MenuName, MenuID, MenuID, config.process === 'true')
      let params = []
      let BID = param.$BID || ''
      let BID = urlparam.$BID || ''
      let inherit = {}
      if (config.cacheUseful === 'true') { // 缓存继承
@@ -265,18 +276,6 @@
      // 字段透视
      config.components.forEach(component => {
        if (component.type !== 'search') return
        if (param.$searchkey) {
          component.search = component.search.map(item => {
            if (['text', 'select', 'link', 'checkcard'].includes(item.type) && param.$searchkey === item.field) {
              item.initval = param.$searchval
            }
            return item
          })
          component.$searches = Utils.initMainSearch(component.search)
        }
        window.GLOB.SearchBox.set(MenuID, component.$searches)
@@ -451,6 +450,8 @@
            }
          }
          tab.$menuname = (MenuName || '') + '-' + (tab.label || '')
          return true
        })
@@ -459,12 +460,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
@@ -477,12 +473,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 = ''
@@ -554,6 +545,7 @@
            item.wrap.datatype = 'static'
          } else {
            item.setting = {...inter.setting}
            item.$searchId = inter.$searchId
          }
        }
      }
@@ -562,21 +554,47 @@
        item.type = 'card'
      }
      // 搜索条件初始化
      if (item.search) {
        Utils.initSearchVal(item)
        item.$searches = Utils.initMainSearch(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') {
          item.setting.supModule = pid
        } else {
          item.setting.supModule = ''
        }
      } else if (item.type === 'search') {
        if (item.wrap.supModule) {
          item.wrap.supModule = item.wrap.supModule.pop()
        }
      }
      // 搜索条件初始化
      if (item.search) {
        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)
        if (item.type === 'search' && item.wrap.supModule) {
          if (!item.checkBid) {
            item.wrap.supModule = ''
          } else {
            window.GLOB.SearchBox.set(item.$searchId + 'checkBid', true)
          }
        }
      }
@@ -599,7 +617,7 @@
            cell = this.getPrinter(cell, item.uuid)
          }
          return pass || permAction[cell.uuid]
          return pass || permAction[cell.uuid] || cell.permission === 'false'
        })
      }
@@ -614,7 +632,10 @@
              col.type = 'custom'
            }
            
            if (col.type === 'number') {
            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') {
@@ -641,7 +662,7 @@
                    cell = this.getPrinter(cell, item.uuid)
                  }
                  return pass || permAction[cell.uuid]
                  return pass || permAction[cell.uuid] || cell.permission === 'false'
                } else {
                  cell = this.resetElement(cell)
                }
@@ -660,11 +681,22 @@
              col.linkThdMenu = ''
            }
            if (col.marks && col.marks.length === 0) {
              col.marks = null
            }
            return true
          })
        }
        
        item.cols = getCols(item.cols)
        if (item.hasExtend) {
          item.setting.hasExtend = true
          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 + '-提交'
@@ -700,7 +732,7 @@
              cell = this.resetElement(cell)
            }
            return cell.eleType !== 'button' || pass || permAction[cell.uuid]
            return cell.eleType !== 'button' || pass || permAction[cell.uuid] || cell.permission === 'false'
          })
          if (card.setting.click === 'menus') {
@@ -742,7 +774,7 @@
              cell = this.resetElement(cell)
            }
            return cell.eleType !== 'button' || pass || permAction[cell.uuid]
            return cell.eleType !== 'button' || pass || permAction[cell.uuid] || cell.permission === 'false'
          })
        })
      } else if (item.type === 'balcony') {
@@ -766,51 +798,22 @@
            cell = this.resetElement(cell)
          }
          return cell.eleType !== 'button' || pass || permAction[cell.uuid]
          return cell.eleType !== 'button' || pass || permAction[cell.uuid] || cell.permission === 'false'
        })
      } else if (item.type === 'form') {
        item.subcards = item.subcards.map(group => {
          group.subButton.uuid = group.uuid
          group.subButton.$menuId = group.uuid
          group.subButton.$MenuID = this.props.MenuID
          // group.subButton.$forbid = true // 不声明数据源变量
          group.subButton.OpenType = 'formSubmit'
          group.subButton.execError = 'never'
          group.subButton.logLabel = item.$menuname + '-' + group.subButton.label
          if (!group.subButton.Ot) {
            group.subButton.Ot = item.wrap.datatype === 'static' ? 'notRequired' : 'requiredSgl'
          }
          if (item.$process) {
            group.subButton.$process = true
            group.subButton.$flowId = 'flow' + this.props.MenuID
          }
          group.subButton = this.resetButton(item, group.subButton)
          if (item.$cache && item.$time) {
          if (item.$cache && item.$time) { // 表单缓存
            group.$cache = item.$cache
            group.$time = item.$time
          }
          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'
            }
          }
          if (group.subButton.verify && group.subButton.verify.invalid === 'true') {
            if (item.wrap.datatype === 'static' || item.wrap.datatype === 'public') {
              group.subButton.verify.invalid = 'false'
            } else if (group.subButton.sqlType === 'insert') {
              group.subButton.verify.invalid = 'false'
            } else if (group.subButton.Ot === 'notRequired') {
              group.subButton.verify.invalid = 'false'
            } else if (group.subButton.intertype !== 'system' && group.subButton.procMode !== 'system') {
              group.subButton.verify.invalid = 'false'
            }
          }
          group.fields = group.fields.map(cell => {
@@ -911,7 +914,7 @@
    }
    if (cell.OpenType === 'excelOut') { // 导出
      cell.$menuName = item.name
      cell.$menuName = item.$menuname
      if (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0) {
        cell.errorType = 'error1'
@@ -931,6 +934,8 @@
    if (cell.verify && cell.verify.invalid === 'true') {
      if (item.wrap && (item.wrap.datatype === 'static' || item.wrap.datatype === 'public')) {
        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') {
@@ -940,10 +945,32 @@
      }
    }
    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 (/#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') {
@@ -951,8 +978,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)
@@ -974,6 +1010,21 @@
    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)) {
@@ -1046,9 +1097,6 @@
        component.components = this.formatSetting(component.components, params, null, regs, balMap)
        return component
      } else if (component.wrap && component.wrap.datatype === 'public') {
        component.setting.useMSearch = false
        component.setting.sync = 'false'
        return component
      } else if (component.wrap && component.wrap.datatype === 'static') {
        component.format = ''
@@ -1063,11 +1111,19 @@
      component.setting.arr_field = component.columns ? component.columns.map(col => col.field).join(',') : ''
      component.setting.useMSearch = component.setting.useMSearch === 'true'
      component.setting.laypage = component.setting.laypage === 'true'   // 是否分页,转为boolean 统一格式
      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
        } else {
          if (window.GLOB.SearchBox.has(component.$searchId + 'required')) {
            component.$s_req = true
          }
          if (window.GLOB.SearchBox.has(component.$searchId + 'checkBid')) {
            component.checkBid = true
            component.setting.checkBid = true
          }
        }
      }
@@ -1075,10 +1131,14 @@
        component.setting.sync = 'false'
      }
      if (component.format === 'object') {
        component.setting.laypage = false
        component.setting.$top = true
      }
      if (component.setting.interType !== 'system') { // 不使用系统函数时
        component.setting.sync = 'false'
        component.setting.dataresource = ''
        component.setting.laypage = component.setting.laypage === 'true'
        return component
      }
@@ -1099,8 +1159,7 @@
      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 = ''
      }
@@ -1181,7 +1240,7 @@
  }
  // 格式化默认设置
  formatInterSetting = (inters, regs, MenuID, initInters) => {
  formatInterSetting = (inters, regs, MenuID, initInters, MenuName) => {
    if (!inters) return []
    let initlimit = false
@@ -1216,6 +1275,8 @@
        inter.setting.onload = 'false'
      }
      inter.setting.laypage = false
      inter.setting.$top = true
      inter.setting.useMSearch = inter.setting.useMSearch === 'true'
      inter.setting.arr_field = inter.columns.map(col => col.field).join(',')
@@ -1237,9 +1298,8 @@
      })
      delete inter.scripts
      inter.setting.$name = '公共数据源-' + inter.setting.name
      inter.setting.$name = (MenuName || '') + '-公共数据源-' + inter.setting.name
      inter.setting.execute = inter.setting.execute !== 'false'
      inter.setting.laypage = true
      if (!inter.setting.execute) {
        inter.setting.dataresource = ''
@@ -1331,6 +1391,10 @@
        MKEmitter.emit('transferSyncData', MenuID)
        if (!result.message) return
        if (/将截断字符串或二进制数据/ig.test(result.message)) {
          result.message = result.message + '请检查字段集'
        }
        if (result.ErrCode === 'N') {
          Modal.error({
            title: result.message,
@@ -1600,9 +1664,7 @@
        )
      } else if (item.type === 'group' && item.subtype === 'normalgroup') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <NormalGroup config={item}/>
          </Col>
          <NormalGroup config={item} style={style} key={item.uuid}/>
        )
      } else if (item.type === 'editor') {
        return (
@@ -1658,6 +1720,12 @@
            <Account config={item}/>
          </Col>
        )
      } else if (item.type === 'module' && item.subtype === 'invoice') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <Invoice config={item}/>
          </Col>
        )
      } else if (item.type === 'iframe') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>