king
2023-07-14 cc87fc060c30597ec2efe38d0c3efe62f4957fd5
src/tabviews/basetable/index.jsx
@@ -16,7 +16,8 @@
const AntvTabs = asyncComponent(() => import('@/tabviews/custom/components/tabs/antv-tabs'))
const MkBaseTable = asyncComponent(() => import('@/tabviews/custom/components/table/base-table'))
const SettingComponent = asyncComponent(() => import('@/tabviews/zshare/settingcomponent'))
const PagemsgComponent = asyncComponent(() => import('@/tabviews/zshare/pageMessage'))
const TableNodes = asyncComponent(() => import('@/tabviews/zshare/tablenodes'))
const AutoMatic = asyncComponent(() => import('@/tabviews/zshare/automatic'))
const DebugTable = asyncComponent(() => import('@/tabviews/debugtable'))
class BasePage extends Component {
@@ -24,8 +25,8 @@
    param: PropTypes.any,        // 其他页面传递的参数
    Tab: PropTypes.string,       // 弹窗标签
    MenuID: PropTypes.string,    // 菜单Id
    MenuNo: PropTypes.string,    // 菜单参数
    MenuName: PropTypes.string   // 菜单名称
    MenuName: PropTypes.string,  // 菜单名称
    changeTemp: PropTypes.func
  }
  state = {
@@ -41,19 +42,25 @@
    data: null,           // 列表数据集
    loading: false,       // 列表数据加载中
    visible: false,       // 标签页控制
    shortcuts: null       // 快捷键
    shortcuts: null,      // 快捷键
    autoMatic: null
  }
  /**
   * @description 获取页面配置信息
   */
  async loadconfig () {
    const { MenuID } = this.props
    const { MenuID, MenuName } = this.props
    let _param = {
      func: 'sPC_Get_LongParam',
      MenuID: MenuID
    }
    if (window.GLOB.mkHS) {
      _param.appkey = '20191106103859640976D6E924E464D029CF0'
    }
    let result = await Api.getCacheConfig(_param)
    if (result.status) {
@@ -62,25 +69,13 @@
      try { // 配置信息解析
        config = window.decodeURIComponent(window.atob(result.LongParam))
        config = config.replace(/@mywebsite@\//ig, window.GLOB.baseurl)
        config = JSON.parse(config)
        config.MenuID = MenuID
        config.MenuName = MenuName || config.MenuName
      } catch (e) {
        console.warn('Parse Failure')
        config = ''
      }
      // HS不使用自定义设置
      if (result.LongParamUser && !window.GLOB.mkHS) {
        try { // 配置信息解析
          let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser)))
          if (userConfig) {
            shortcuts = userConfig.action
            userConfig.printers.forEach(item => {
              window.GLOB.UserCacheMap.set(item.parentId + item.uuid, item)
            })
          }
        } catch (e) {
          console.warn('Parse Failure')
        }
      }
      // 页面配置解析错误时提示
@@ -100,6 +95,35 @@
          lostmsg: this.state.dict['main.view.unenabled']
        })
        return
      }
      // 模板错误
      if (config.Template !== 'BaseTable') {
        if (config.Template === 'CustomPage' || config.Template === 'CommonTable') {
          this.props.changeTemp(MenuID, config.Template)
        } else {
          this.setState({
            viewlost: true,
            loadingview: false,
            lostmsg: '菜单信息错误,可能原因:1、当前用户无权限;2、打开此菜单的按钮需要更新。'
          })
        }
        return
      }
      // HS不使用自定义设置
      if (result.LongParamUser && !window.GLOB.mkHS) {
        try { // 配置信息解析
          let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser)))
          if (userConfig) {
            shortcuts = userConfig.action
            userConfig.printers.forEach(item => {
              window.GLOB.UserCacheMap.set(item.parentId + item.uuid, item)
            })
          }
        } catch (e) {
          console.warn('Parse Failure')
        }
      }
      // 权限过滤
@@ -138,7 +162,21 @@
        })
      }
      config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, skip, param, MenuID)
      config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, skip, param, MenuID, config.MenuName)
      let autoMatic = null
      if (config.autoMatic && config.autoMatic.enable === 'true') {
        config.components[0].action.forEach(item => {
          if (item.uuid === config.autoMatic.action) {
            autoMatic = config.autoMatic
            autoMatic.OpenType = item.execMode || item.OpenType
            config.components[0].wrap.selected = 'false'
            config.components[0].MenuID = config.components[0].uuid
            config.components[0].autoMatic = true
            item.autoMatic = true
          }
        })
      }
      
      // 获取主搜索条件
      let mainSearch = []
@@ -159,12 +197,13 @@
      let BID = param.$BID || ''
      config.components = this.formatSetting(config.components, mainSearch, regs)
      config.components = this.formatSetting(config.components, regs)
      this.setState({
        BID: BID,
        shortcuts: shortcuts.length > 0 ? shortcuts : null,
        config,
        autoMatic,
        mainSearch
      }, () => {
        setTimeout(() => { // 延时加载状态
@@ -230,11 +269,11 @@
    }
  }
  filterComponent = (components, roleId, permAction, skip, urlparam, pageId) => {
  filterComponent = (components, roleId, permAction, skip, urlparam, pageId, MenuName) => {
    return components.filter(item => {
      item.$pageId = pageId
      item.$menuname = (this.props.MenuName || '') + '-' + (item.name || '主表')
      item.$menuname = (MenuName || '') + '-' + (item.name || '主表')
      if (item.type === 'tabs') {
        item.subtabs = item.subtabs.filter(tab => {
@@ -250,11 +289,16 @@
        item.subtabs = item.subtabs.map(tab => {
          tab.components[0].name = tab.label
          tab.components = this.filterComponent(tab.components, roleId, permAction, skip, urlparam, pageId)
          if (tab.permission !== 'true') { // 权限未开启不做权限控制
            skip = true
          }
          tab.components = this.filterComponent(tab.components, roleId, permAction, skip, urlparam, pageId, MenuName)
          return tab
        })
        return true
      } else {
        item.name = (MenuName || '')
      }
      // 搜索条件初始化
@@ -278,6 +322,8 @@
            return false
          } else if (col.Hide === 'true') {
            return false
          } else if (col.type === 'action') {
            col.type = 'custom'
          }
          
          if (col.type === 'number') {
@@ -296,8 +342,58 @@
              return false
            }
          } else if (col.type === 'custom') {
            col.elements = col.elements.map(cell => {
              if (['text', 'number', 'formula'].includes(cell.eleType)) {
            col.elements = col.elements.filter(cell => {
              if (cell.eleType === 'button') {
                if (cell.hidden === 'true') return false
                cell.logLabel = item.$menuname + '-' + cell.label
                cell.Ot = cell.Ot || 'requiredSgl'
                cell.ContainerId = this.state.ContainerId
                cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
                cell.$menuId = item.uuid
                cell.$MenuID = this.props.MenuID
                cell.$view = 'popview'
                if (cell.syncComponentId) {
                  if (cell.syncComponentId === item.setting.supModule) {
                    cell.syncComponentId = ''
                    if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
                      cell.execSuccess = 'mainline'
                    }
                  } else if (cell.syncComponentId === 'multiComponent') {
                    let ids = cell.syncComponents.map(m => {
                      return m.syncComId.pop() || ''
                    })
                    if (item.setting.supModule && ids.includes(item.setting.supModule)) {
                      if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
                        cell.execSuccess = 'mainline'
                      }
                      ids = ids.filter(id => id !== item.setting.supModule)
                    }
                    if (ids.length === 0) {
                      cell.syncComponentId = ''
                    } else {
                      cell.syncComponentIds = ids
                    }
                  }
                }
                if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置
                  cell = this.getPrinter(cell, item.uuid)
                }
                if (cell.controlField) {
                  if (/,/ig.test(cell.controlVal)) {
                    cell.controlVals = cell.controlVal.split(',')
                  } else {
                    cell.controlVals = [(cell.controlVal || '')]
                  }
                }
                return skip || permAction[cell.uuid]
              } else if (['text', 'number', 'formula'].includes(cell.eleType)) {
                if (!cell.height) {
                  cell.innerHeight = 'auto'
                }
@@ -308,8 +404,12 @@
                  }
                }
              }
              return cell
              return true
            })
            if (col.elements.length === 0) {
              return false
            }
          }
    
          if (col.linkmenu && col.linkmenu.length > 0) {
@@ -327,58 +427,59 @@
      item.statFields = Array.from(new Set(statFields))
      // 权限过滤
      let tabId = this.props.Tab ? this.props.Tab.uuid : '' // 弹窗标签按钮Id
      if (item.action && item.action.length > 0) {
        item.action = item.action.filter(cell => {
          if (item.hidden === 'true') return false
          if (cell.hidden === 'true') return false
          cell.logLabel = item.$menuname + '-' + cell.label
          cell.ContainerId = this.state.ContainerId
          cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
          cell.$menuId = item.uuid
          cell.$MenuID = this.props.MenuID
          cell.$tabId = tabId
          cell.$view = 'BasePage'
          cell.$view = 'popview'
          cell.$toolbtn = true
          if (cell.syncComponentId === item.setting.supModule) {
            cell.syncComponentId = ''
          if (cell.syncComponentId) {
            if (cell.syncComponentId === item.setting.supModule) {
              cell.syncComponentId = ''
              if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
                cell.execSuccess = 'mainline'
              }
            } else if (cell.syncComponentId === 'multiComponent') {
              let ids = cell.syncComponents.map(m => {
                return m.syncComId.pop() || ''
              })
              if (item.setting.supModule && ids.includes(item.setting.supModule)) {
                if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
                  cell.execSuccess = 'mainline'
                }
                ids = ids.filter(id => id !== item.setting.supModule)
              }
              if (ids.length === 0) {
                cell.syncComponentId = ''
              } else {
                cell.syncComponentIds = ids
              }
            }
          }
          if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置
            cell = this.getPrinter(cell, item.uuid)
          }
          if (cell.controlField) {
            if (/,/ig.test(cell.controlVal)) {
              cell.controlVals = cell.controlVal.split(',')
            } else {
              cell.controlVals = [(cell.controlVal || '')]
            }
          }
          return skip || permAction[cell.uuid]
        })
      }
      item.cols = item.cols.filter(col => {
        if (col.type !== 'action') return true
        col.elements = col.elements.filter(cell => {
          if (cell.hidden === 'true') return false
          cell.logLabel = item.$menuname + '-' + cell.label
          cell.Ot = cell.Ot || 'requiredSgl'
          cell.ContainerId = this.state.ContainerId
          cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
          cell.$menuId = item.uuid
          cell.$MenuID = this.props.MenuID
          cell.$tabId = tabId
          cell.$view = 'BasePage'
          if (cell.syncComponentId === item.setting.supModule) {
            cell.syncComponentId = ''
          }
          if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置
            cell = this.getPrinter(cell, item.uuid)
          }
          return skip || permAction[cell.uuid]
        })
        return col.elements.length !== 0
      })
      
      return true
    })
@@ -531,6 +632,11 @@
  }
  reloadview = () => {
    window.GLOB.CacheData.delete(this.props.MenuID)
    if (this.state.config) {
      this.deleteCache(this.state.config.components)
    }
    this.setState({
      BID: '',              // 页面跳转时携带ID
      loadingview: true,    // 页面加载中
@@ -573,14 +679,15 @@
  }
  render() {
    const { loadingview, viewlost, config, loading, shortcuts } = this.state
    const { loadingview, viewlost, config, loading, shortcuts, autoMatic } = this.state
    return (
      <div className={'custom-page-wrap ' + (loadingview || loading ? 'loading' : '')} id={this.state.ContainerId} style={config ? config.style : null}>
      <div className={'custom-table-wrap ' + (loadingview || loading ? 'loading' : '')} id={this.state.ContainerId} style={config ? config.style : null}>
        {(loadingview || loading) ? <Spin className="view-spin" size="large" /> : null}
        <Row className="component-wrap">{this.getComponents()}</Row>
        {config && window.GLOB.breakpoint ? <DebugTable /> : null}
        {!window.GLOB.mkHS && window.GLOB.systemType !== 'production' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null}
        {!window.GLOB.mkHS && config && autoMatic ? <AutoMatic autoMatic={autoMatic} config={config.components[0]} /> : null}
        {!window.GLOB.mkHS && window.GLOB.systemType !== 'production' ? <TableNodes config={config} /> : null}
        {!window.GLOB.mkHS && config ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts || []}/> : null}
        {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
      </div>