king
2022-11-21 f6626b05f1275cc2f8ca77f773d4f6a6af1b0a89
src/tabviews/custom/index.jsx
@@ -36,11 +36,12 @@
const NormalTree = asyncComponent(() => import('./components/tree/antd-tree'))
const Balcony = asyncComponent(() => import('./components/card/balcony'))
const SettingComponent = asyncComponent(() => import('@/tabviews/zshare/settingcomponent'))
const PagemsgComponent = asyncComponent(() => import('@/tabviews/zshare/pageMessage'))
const CustomChart = asyncComponent(() => import('./components/chart/custom-chart'))
const TimeLine = asyncComponent(() => import('./components/timeline/normal-timeline'))
const Voucher = asyncComponent(() => import('./components/module/voucher'))
const Iframe = asyncComponent(() => import('./components/iframe'))
const DebugTable = asyncComponent(() => import('@/tabviews/debugtable'))
const TableNodes = asyncComponent(() => import('@/tabviews/zshare/tablenodes'))
const MkInterfaces = asyncComponent(() => import('@/tabviews/custom/components/interfaces'))
class CustomPage extends Component {
@@ -49,7 +50,8 @@
    Tab: PropTypes.string,       // 弹窗标签
    MenuID: PropTypes.string,    // 菜单Id
    MenuNo: PropTypes.string,    // 菜单参数
    MenuName: PropTypes.string   // 菜单名称
    MenuName: PropTypes.string,  // 菜单名称
    changeTemp: PropTypes.func
  }
  state = {
@@ -93,21 +95,6 @@
        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')
        }
      }
      // 页面配置解析错误时提示
      if (!config) {
        this.setState({
@@ -125,6 +112,36 @@
          lostmsg: this.state.dict['main.view.unenabled']
        })
        return
      }
      // 模板错误
      if (config.Template !== 'CustomPage') {
        if (config.Template === 'BaseTable' || 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')
        }
      }
      // 数据缓存设置
@@ -172,9 +189,15 @@
        })
      }
      let popview = 'CustomPage'
      if (config.version === 2.0) {
        popview = 'popview'
      }
      config.interfaces = this.formatInterSetting(config.interfaces, regs)
      config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces)
      config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces, popview)
      
      // 获取主搜索条件
      let mainSearch = []
@@ -282,7 +305,7 @@
    }
  }
  filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces) => {
  filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview) => {
    return components.filter(item => {
      item.$pageId = pageId
      
@@ -368,7 +391,7 @@
        item.subtabs = item.subtabs.map(tab => {
          tab.$pageId = pageId
          tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces)
          tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview)
          return tab
        })
@@ -381,7 +404,7 @@
          return false
        }
        item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces)
        item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview)
        return true
      } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart'].includes(item.type)) {
@@ -409,24 +432,25 @@
        }
      }
      if (item.subtype === 'tablecard') { // 兼容
        item.type = 'card'
      }
      // 搜索条件初始化
      if (item.search && item.search.length > 0) {
        item.search = Utils.initSearchVal(item.search)
      }
      if (item.type === 'table' && (item.subtype === 'normaltable' || item.subtype === 'editable')) {
      if (item.type === 'table') {
        let statFields = []
        let getCols = (cols) => {
          return cols.filter(col => {
            if (item.subtype !== 'editable') {
              if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
                return false
              } else if (col.Hide === 'true') {
                return false
              }
            } else if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
              col.Hide = 'true'
            }
            if (col.type === 'number') {
              if (col.sum === 'true' && !statFields.includes(col.field)) {
                statFields.push(col)
@@ -488,18 +512,16 @@
      }
      // 权限过滤
      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 = 'CustomPage'
          cell.$view = popview
          cell.$toolbtn = true
          if (!mutil && cell.syncComponentId === item.setting.supModule) {
@@ -519,7 +541,7 @@
        })
      }
      if (item.type === 'card') {
      if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') {
        item.subcards && item.subcards.forEach(card => {
          if (card.style.boxShadow) {
            delete card.style.hShadow
@@ -538,8 +560,7 @@
              cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
              cell.$menuId = item.uuid
              cell.$MenuID = this.props.MenuID
              cell.$tabId = tabId
              cell.$view = 'CustomPage'
              cell.$view = popview
              if (!mutil && cell.syncComponentId === item.setting.supModule) {
                cell.syncComponentId = ''
@@ -566,6 +587,9 @@
            return cell.eleType !== 'button' || skip || permAction[cell.uuid]
          })
          if (!card.backElements || card.backElements.length === 0) return
          card.backElements = card.backElements.filter(cell => {
            if (cell.eleType === 'button') {
              if (cell.hidden === 'true') return false
@@ -576,8 +600,7 @@
              cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
              cell.$menuId = item.uuid
              cell.$MenuID = this.props.MenuID
              cell.$tabId = tabId
              cell.$view = 'CustomPage'
              cell.$view = popview
              if (!mutil && cell.syncComponentId === item.setting.supModule) {
                cell.syncComponentId = ''
@@ -622,8 +645,7 @@
            cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
            cell.$menuId = item.uuid
            cell.$MenuID = this.props.MenuID
            cell.$tabId = tabId
            cell.$view = 'CustomPage'
            cell.$view = popview
            if (cell.syncComponentId === item.wrap.supModule) {
              cell.syncComponentId = ''
@@ -646,47 +668,7 @@
          return cell.eleType !== 'button' || skip || permAction[cell.uuid]
        })
      } else if ((item.type === 'table' && item.subtype === 'tablecard') || item.type === 'carousel' || item.type === 'timeline') {
        item.subcards && item.subcards.forEach(card => {
          card.elements = card.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.$tabId = tabId
              cell.$view = 'CustomPage'
              if (cell.syncComponentId === item.setting.supModule) {
                cell.syncComponentId = ''
              }
              if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置
                cell = this.getPrinter(cell, item.uuid)
              }
              if (card.btnstyle) { // 兼容
                card.style = card.style || {}
                card.style = {...card.style, ...card.btnstyle}
              }
            } else if (['text', 'number', 'formula'].includes(cell.eleType)) {
              if (!cell.height) {
                cell.innerHeight = 'auto'
              }
              if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') {
                cell.round = Math.pow(10, cell.decimal)
                if (cell.format === 'percent') {
                  cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0
                }
              }
            }
            return cell.eleType !== 'button' || skip || permAction[cell.uuid]
          })
        })
      } else if (item.type === 'table' && (item.subtype === 'normaltable' || item.subtype === 'editable')) {
      } else if (item.type === 'table') {
        item.cols = item.cols.filter(col => {
          if (col.type !== 'action') return true
          col.elements = col.elements.filter(cell => {
@@ -698,8 +680,7 @@
            cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
            cell.$menuId = item.uuid
            cell.$MenuID = this.props.MenuID
            cell.$tabId = tabId
            cell.$view = 'CustomPage'
            cell.$view = popview
            if (cell.syncComponentId === item.setting.supModule) {
              cell.syncComponentId = ''
@@ -727,6 +708,7 @@
        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'
@@ -841,22 +823,21 @@
        component = {...component, ...inherit}
        return component
      } else if (component.wrap && component.wrap.datatype === 'public') {
        component.setting.useMSearch = false
        return component
      }
      if (component.setting) {
        component.setting.useMSearch = component.setting.useMSearch === 'true'
        component.setting.syncRefresh = (component.setting.useMSearch && component.setting.syncRefresh === 'true')
      }
      if (component.wrap && component.wrap.datatype === 'static') {
      } else if (component.wrap && component.wrap.datatype === 'static') {
        component.format = ''
        component.setting = component.setting || {}
        component.setting.useMSearch = false
        component.setting.syncRefresh = false
        return component
      } else if (!component.setting || !component.format) {
        return component
      }
      if (!component.setting || !component.format) return component  // 1、不使用系统函数时;2、 没有动态数据  数据格式 array 或 object
      component.setting.useMSearch = component.setting.useMSearch === 'true'
      if (component.setting.interType !== 'system') { // 不使用系统函数时
        component.setting.sync = 'false'
        component.setting.laypage = component.setting.laypage === 'true'
@@ -929,9 +910,10 @@
        }
      } else if (params) {
        component.setting.sync = 'false'
      }
        component.setting.delay = delay
        delay += 20
      }
      if (balMap.has(component.uuid)) {
        component.setting.$hasSyncModule = true
@@ -1100,6 +1082,15 @@
  }
  reloadview = () => {
    window.GLOB.CacheData.delete(this.props.MenuID)
    if (this.state.config) {
      this.deleteCache(this.state.config.components)
      this.state.config.interfaces.forEach(m => {
        window.GLOB.CacheData.delete(m.uuid)
      })
    }
    this.setState({
      BID: '',              // 页面跳转时携带ID
      loadingview: true,    // 页面加载中
@@ -1125,148 +1116,160 @@
    if (!config || !config.components) return
    return config.components.map(item => {
      if (item.type === 'bar' || item.type === 'line') {
      let style = null
      if (item.style && item.style.clear === 'left') {
        style = {clear: 'left'}
      }
      if (item.type === 'card' && item.subtype === 'datacard') {
        return (
          <Col span={item.width} key={item.uuid}>
            <AntvBarAndLine config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'pie') {
        return (
          <Col span={item.width} key={item.uuid}>
            <AntvPie config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'scatter') {
        return (
          <Col span={item.width} key={item.uuid}>
            <AntvScatter config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'dashboard') {
        return (
          <Col span={item.width} key={item.uuid}>
            <AntvDashboard config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'form' && item.subtype === 'simpleform') {
        return (
          <Col span={item.width} key={item.uuid}>
            <SimpleForm config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'form' && item.subtype === 'stepform') {
        return (
          <Col span={item.width} key={item.uuid}>
            <StepForm config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'form' && item.subtype === 'tabform') {
        return (
          <Col span={item.width} key={item.uuid}>
            <TabForm config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'search') {
        return (
          <Col span={item.width} key={item.uuid}>
            <MainSearch config={item} BID={BID} refreshdata={this.resetSearch} />
          </Col>
        )
      } else if (item.type === 'tabs') {
        return (
          <Col span={item.width} key={item.uuid}>
            <AntvTabs config={item} mainSearch={mainSearch} />
          </Col>
        )
      } else if (item.type === 'card' && item.subtype === 'datacard') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <DataCard config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'card' && item.subtype === 'propcard') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <PropCard config={item} data={data} mainSearch={mainSearch}/>
          </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}/>
          </Col>
        )
      } 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}/>
          </Col>
        )
      } else if (item.type === 'pie') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvPie config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'scatter') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvScatter config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'dashboard') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvDashboard config={item} data={data} mainSearch={mainSearch}/>
          </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}/>
          </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}/>
          </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}/>
          </Col>
        )
      } else if (item.type === 'search') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <MainSearch config={item} BID={BID} refreshdata={this.resetSearch} />
          </Col>
        )
      } else if (item.type === 'tabs') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvTabs config={item} mainSearch={mainSearch} />
          </Col>
        )
      } else if (item.type === 'balcony') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <Balcony config={item} data={data}/>
          </Col>
        )
      } else if (item.type === 'timeline') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <TimeLine config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'carousel' && item.subtype === 'datacard') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <CarouselDataCard config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'carousel' && item.subtype === 'propcard') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <CarouselPropCard config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'table' && item.subtype === 'tablecard') {
      } else if (item.type === 'card' && item.subtype === 'tablecard') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <TableCard config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'table' && item.subtype === 'normaltable') {
        return (
          <Col span={item.width} key={item.uuid}>
            <NormalTable config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'table' && item.subtype === 'editable') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <EditTable config={item} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'group' && item.subtype === 'normalgroup') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <NormalGroup config={item} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'editor') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <BraftEditor config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'tree') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <NormalTree config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'code') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <SandBox config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'chart') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <CustomChart config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else if (item.type === 'module' && item.subtype === 'voucher') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <Voucher config={item}/>
          </Col>
        )
      } else if (item.type === 'iframe') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <Iframe config={item} data={data} mainSearch={mainSearch}/>
          </Col>
        )
      } else {
@@ -1284,7 +1287,7 @@
        <Row className="component-wrap">{this.getComponents()}</Row>
        {config && config.interfaces.length > 0 ? <MkInterfaces BID={BID} interfaces={config.interfaces}/> : null}
        {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 && 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>