king
2021-10-14 e41a64966b7832baffe96c21d1ea77ef6adb2905
src/tabviews/custom/index.jsx
@@ -24,11 +24,13 @@
const DataCard = asyncComponent(() => import('./components/card/data-card'))
const PropCard = asyncComponent(() => import('./components/card/prop-card'))
const NormalForm = asyncComponent(() => import('./components/form/normal-form'))
const TabForm = asyncComponent(() => import('./components/form/tab-form'))
const CarouselDataCard = asyncComponent(() => import('./components/carousel/data-card'))
const CarouselPropCard = asyncComponent(() => import('./components/carousel/prop-card'))
const TableCard = asyncComponent(() => import('./components/card/table-card'))
const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch'))
const NormalTable = asyncComponent(() => import('./components/table/normal-table'))
const EditTable = asyncComponent(() => import('./components/table/edit-table'))
const NormalGroup = asyncComponent(() => import('./components/group/normal-group'))
const BraftEditor = asyncComponent(() => import('./components/editor/braft-editor'))
const SandBox = asyncComponent(() => import('./components/code/sand-box'))
@@ -36,6 +38,7 @@
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'))
class CustomPage extends Component {
  static propTpyes = {
@@ -131,7 +134,8 @@
      // 权限过滤
      let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
      let balMap = new Map()
      config.components = this.filterComponent(config.components, roleId, permAction, permMenus, balMap)
      let skip = config.permission === 'false' || this.props.menuType === 'HS'
      config.components = this.filterComponent(config.components, roleId, permAction, permMenus, balMap, skip)
      
      // 获取主搜索条件
      let mainSearch = []
@@ -444,7 +448,7 @@
    })
  }
  filterComponent = (components, roleId, permAction, permMenus, balMap) => {
  filterComponent = (components, roleId, permAction, permMenus, balMap, skip) => {
    return components.filter(item => {
      
      if (item.style && item.style.boxShadow) {
@@ -475,7 +479,7 @@
        })
        item.subtabs = item.subtabs.map(tab => {
          tab.components = this.filterComponent(tab.components, roleId, permAction, permMenus, balMap)
          tab.components = this.filterComponent(tab.components, roleId, permAction, permMenus, balMap, skip)
          return tab
        })
@@ -498,8 +502,8 @@
          return false
        }
        item.components = this.filterComponent(item.components, roleId, permAction, permMenus, balMap)
      } else if (['pie', 'bar', 'line', 'dashboard', 'scatter'].includes(item.type)) {
        item.components = this.filterComponent(item.components, roleId, permAction, permMenus, balMap, skip)
      } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart'].includes(item.type)) {
        if (
          item.plot.blacklist && item.plot.blacklist.length > 0 &&
          item.plot.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0
@@ -520,14 +524,18 @@
        item.search = Utils.initSearchVal(item.search)
      }
      if (item.type === 'table' && item.subtype === 'normaltable') {
      if (item.type === 'table' && (item.subtype === 'normaltable' || item.subtype === 'editable')) {
        let statFields = []
        let getCols = (cols) => {
          return cols.filter(col => {
            if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
              return false
            } else if (col.Hide === 'true') {
              return false
            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' && col.sum === 'true' && !statFields.includes(col.field)) {
              statFields.push(col)
@@ -561,7 +569,6 @@
      }
      // 权限过滤
      let isHS = this.props.menuType === 'HS'
      let tabId = this.props.Tab ? this.props.Tab.uuid : '' // 弹窗标签按钮Id
      if (item.action && item.action.length > 0) {
        item.action = item.action.filter(cell => {
@@ -569,6 +576,7 @@
          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'
@@ -581,7 +589,7 @@
            cell.style = {...cell.style, ...cell.btnstyle}
          }
          return isHS || permAction[cell.uuid]
          return skip || permAction[cell.uuid]
        })
      }
@@ -603,6 +611,7 @@
              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'
@@ -617,7 +626,7 @@
              cell.innerHeight = 'auto'
            }
            return cell.eleType !== 'button' || isHS || permAction[cell.uuid]
            return cell.eleType !== 'button' || skip || permAction[cell.uuid]
          })
          card.backElements = card.backElements.filter(cell => {
            if (cell.eleType === 'button') {
@@ -626,6 +635,7 @@
              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'
@@ -639,7 +649,7 @@
            } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) {
              cell.innerHeight = 'auto'
            }
            return cell.eleType !== 'button' || isHS || permAction[cell.uuid]
            return cell.eleType !== 'button' || skip || permAction[cell.uuid]
          })
        })
      } else if (item.type === 'balcony') {
@@ -653,6 +663,7 @@
            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'
@@ -663,7 +674,7 @@
            cell.innerHeight = 'auto'
          }
          return cell.eleType !== 'button' || isHS || permAction[cell.uuid]
          return cell.eleType !== 'button' || skip || permAction[cell.uuid]
        })
      } else if ((item.type === 'table' && item.subtype === 'tablecard') || item.type === 'carousel') {
        item.subcards && item.subcards.forEach(card => {
@@ -675,13 +686,13 @@
              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.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}
@@ -689,10 +700,10 @@
            } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) {
              cell.innerHeight = 'auto'
            }
            return cell.eleType !== 'button' || isHS || permAction[cell.uuid]
            return cell.eleType !== 'button' || skip || permAction[cell.uuid]
          })
        })
      } else if (item.type === 'table' && item.subtype === 'normaltable') {
      } else if (item.type === 'table' && (item.subtype === 'normaltable' || item.subtype === 'editable')) {
        item.cols = item.cols.filter(col => {
          if (col.type !== 'action') return true
          col.elements = col.elements.filter(cell => {
@@ -701,6 +712,7 @@
            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'
@@ -713,10 +725,15 @@
              cell.style = {...cell.style, ...cell.btnstyle}
            }
            return isHS || permAction[cell.uuid]
            return skip || permAction[cell.uuid]
          })
          return col.elements.length !== 0
        })
        if (item.subtype === 'editable') {
          item.submit.logLabel = item.$menuname + '-提交'
          item.submit.$menuId = item.uuid
        }
      } 
      if (item.setting && item.setting.supModule) {
@@ -799,13 +816,13 @@
    return components.map(component => {
      if (component.type === 'tabs') {
        component.subtabs = component.subtabs.map(tab => {
          tab.components = this.formatSetting(tab.components, [], [], inherit, regs, balMap)
          tab.components = this.formatSetting(tab.components, null, null, inherit, regs, balMap)
          tab = {...tab, ...inherit}
          return tab
        })
        return component
      } else if (component.type === 'group') {
        component.components = this.formatSetting(component.components, [], [], inherit, regs, balMap)
        component.components = this.formatSetting(component.components, null, null, inherit, regs, balMap)
        component = {...component, ...inherit}
        return component
      }
@@ -869,7 +886,7 @@
      // floor    组件的层级
      // dataName 系统生成的数据源名称
      // pageable 是否分页,组件属性,不分页的组件才可以统一查询
      if (component.floor === 1 && component.dataName && (!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true' && component.setting.sync === 'true') {
      if (params && component.dataName && (!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)
@@ -887,7 +904,7 @@
          component.setting.sync = 'false'
          component.setting.onload = 'false'
        } else {
          params.push(getStructDefaultParam(component, searchlist))
          params.push(getStructDefaultParam(component, searchlist, params.length === 0))
        }
      } else if (component.floor === 1) {
        component.setting.sync = 'false'
@@ -983,7 +1000,8 @@
      viewlost: false,      // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用
      config: null,         // 页面配置信息,包括组件等
      loading: false,       // 列表数据加载中
      shortcuts: null
      shortcuts: null,
      data: ''
    }, () => {
      this.loadconfig()
    })
@@ -1031,10 +1049,16 @@
            <AntvDashboard config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} />
          </Col>
        )
      } else if (item.type === 'form') {
      } else if (item.type === 'form' && item.subtype === 'stepform') {
        return (
          <Col span={item.width} key={item.uuid}>
            <NormalForm config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} />
          </Col>
        )
      } else if (item.type === 'form' && item.subtype === 'tabform') {
        return (
          <Col span={item.width} key={item.uuid}>
            <TabForm config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} />
          </Col>
        )
      } else if (item.type === 'search') {
@@ -1046,7 +1070,7 @@
      } else if (item.type === 'tabs') {
        return (
          <Col span={item.width} key={item.uuid}>
            <AntvTabs config={item} mainSearch={mainSearch} />
            <AntvTabs config={item} BID={BID} mainSearch={mainSearch} />
          </Col>
        )
      } else if (item.type === 'card' && item.subtype === 'datacard') {
@@ -1091,6 +1115,12 @@
            <NormalTable config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} />
          </Col>
        )
      } else if (item.type === 'table' && item.subtype === 'editable') {
        return (
          <Col span={item.width} key={item.uuid}>
            <EditTable config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} />
          </Col>
        )
      } else if (item.type === 'group' && item.subtype === 'normalgroup') {
        return (
          <Col span={item.width} key={item.uuid}>
@@ -1115,6 +1145,12 @@
            <SandBox config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} />
          </Col>
        )
      } else if (item.type === 'chart') {
        return (
          <Col span={item.width} key={item.uuid}>
            <CustomChart config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} />
          </Col>
        )
      } else {
        return null
      }
@@ -1129,7 +1165,7 @@
      <div className={'custom-page-wrap ' + (loadingview || loading ? 'loading' : '')} id={this.state.ContainerId} style={config ? config.style : null}>
        {(loadingview || loading) ? <Spin className="view-spin" size="large" /> : null}
        <Row>{this.getComponents()}</Row>
        {menuType !== 'HS' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null}
        {menuType !== 'HS' && window.GLOB.systemType !== 'production' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null}
        {menuType !== 'HS' && shortcuts ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts} permAction={this.props.permAction}/> : null}
        {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
      </div>