king
2023-07-21 71e3da644eca32a5aa40503e903efb0640748093
src/views/billprint/index.jsx
@@ -21,12 +21,15 @@
const AntvScatter = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-scatter'))
const DataCard = asyncComponent(() => import('@/tabviews/custom/components/card/data-card'))
const PropCard = asyncComponent(() => import('@/tabviews/custom/components/card/prop-card'))
const DoubleDataCard = asyncComponent(() => import('@/tabviews/custom/components/card/double-data-card'))
const TableCard = asyncComponent(() => import('@/tabviews/custom/components/card/table-card'))
const NormalTable = asyncComponent(() => import('@/tabviews/custom/components/table/normal-table'))
const SandBox = asyncComponent(() => import('@/tabviews/custom/components/code/sand-box'))
const TimeLine = asyncComponent(() => import('@/tabviews/custom/components/timeline/normal-timeline'))
const BraftEditor = asyncComponent(() => import('@/tabviews/custom/components/editor/braft-editor'))
const Balcony = asyncComponent(() => import('@/tabviews/custom/components/card/balcony'))
const AntvG6 = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-G6'))
const AntvX6 = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-X6'))
const DebugTable = asyncComponent(() => import('@/tabviews/debugtable'))
class BillPrint extends Component {
@@ -59,7 +62,6 @@
        let param = JSON.parse(window.decodeURIComponent(window.atob(params.param)))
  
        sessionStorage.setItem('dataM', param.dataM || '')
        sessionStorage.setItem('localDataM', param.dataM || '')
        this.setState({
          BID: param.id || '',
          tempId: param.tempId,
@@ -313,7 +315,10 @@
        config.components = config.components.map(component => {
          if (component.action) component.action = []
          if (component.search) component.search = []
          if (component.search) {
            component.search = []
            component.$searches = []
          }
          component.data = [] // 初始化数据为空
          if (component.subtype === 'tablecard') { // 兼容
@@ -332,18 +337,66 @@
          if (component.type === 'table') {
            let getColumns = (cols) => {
              return cols.map(item => {
              return cols.filter(item => {
                if (item.type === 'colspan') {
                  item.subcols = getColumns(item.subcols)
                  if (item.subcols.length === 0) {
                    return false
                  }
                } else if (item.type === 'custom') {
                  item.elements = item.elements.filter(cell => {
                    if (cell.eleType === 'button') return false
                    cell = this.resetElement(cell)
                    return cell
                  })
                  if (item.elements.length === 0) {
                    return false
                  }
                } else {
                  item.IsSort = 'false'
                }
          
                return item
                return true
              })
            }
            component.cols = getColumns(component.cols)
            component.statFields = []
          } else if (['card', 'carousel', 'timeline'].includes(component.type)) {
            component.subcards && component.subcards.forEach(card => {
              if (card.style.boxShadow) {
                delete card.style.hShadow
                delete card.style.vShadow
                delete card.style.shadowBlur
                delete card.style.shadowColor
              }
              card.elements = card.elements.filter(cell => {
                if (cell.eleType === 'button') return false
                cell = this.resetElement(cell)
                return true
              })
              if (!card.backElements || card.backElements.length === 0) return
              card.backElements = card.backElements.filter(cell => {
                if (cell.eleType === 'button') return false
                cell = this.resetElement(cell)
                return true
              })
            })
          } else if (component.type === 'balcony') {
            component.elements = component.elements.filter(cell => {
              if (cell.eleType === 'button') return false
              cell = this.resetElement(cell)
              return true
            })
          }
          if (component.wrap && component.wrap.datatype === 'static') {
@@ -379,13 +432,11 @@
          }
      
          if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
            component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*')
            component.setting.dataresource = component.setting.dataresource.replace(/@\$/ig, '*/')
            _customScript = _customScript.replace(/\$@/ig, '/*')
            _customScript = _customScript.replace(/@\$/ig, '*/')
            component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
            _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
          } else {
            component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '')
            _customScript = _customScript.replace(/@\$|\$@/ig, '')
            component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
            _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
          }
          regs.forEach(cell => {
@@ -398,7 +449,7 @@
          // floor    组件的层级
          // pageable 是否分页,组件属性,不分页的组件才可以统一查询
          if (component.setting.sync === 'true') {
            component.dataName = Utils.getdataName()
            component.dataName = 'mk' + component.uuid.slice(-18)
            let param = this.getDefaultParam(component)
            _pars.push(param)
          } else {
@@ -453,14 +504,36 @@
    })
  }
  resetElement = (cell) => {
    cell.style = cell.style || {}
    if (['text', 'number', 'formula'].includes(cell.eleType)) {
      cell.innerHeight = cell.innerHeight || 'auto'
      cell.alignItems = cell.height > 1 ? cell.alignItems : ''
      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
  }
  reload = () => {
    const { tempId } = this.state
    this.setState({
      loadingview: true,
      pages: null,
      data: '',
      config: null
    }, () => {
      this.getMenuParam()
      Api.deleteMenuStorage(tempId)
      setTimeout(() => {
        this.getMenuParam()
      }, 50)
    })
  }
@@ -607,6 +680,13 @@
        this.setState({loadingview: false, pages})
      }
      let setData = (item) => {
        if (item.setting && item.setting.sync === 'true' && item.data) {
          item.dataName = Utils.getuuid()
          window.GLOB.SyncData.set(item.dataName, item.data)
        }
      }
      while (!over) {
        let page = []
        let count = 0
@@ -621,6 +701,7 @@
          }
          if (item.wrap && item.wrap.printType === 'headerOrfooter') { // 页眉页脚
            setData(item)
            page.push(item)
          } else if (_pageover) {
            return
@@ -634,10 +715,12 @@
                  }
                  if (count <= limit) {
                    _item.added = true
                    setData(item)
                    page.push(item)
                  }
                } else if (!item.added) {
                  _item.added = true
                  setData(item)
                  page.push(item)
                }
              } else {
@@ -655,11 +738,13 @@
                }
                setData(item)
                page.push(item)
              }
              _item.added = true
            } else if (!item.added) {
              _item.added = true
              setData(item)
              page.push(item)
            }
          } else if (!item.added && item.wrap && item.wrap.printHeight) {
@@ -674,10 +759,12 @@
            }
            if (count <= limit) {
              _item.added = true
              setData(item)
              page.push(item)
            }
          } else if (!item.added) {
            _item.added = true
            setData(item)
            page.push(item)
          }
          
@@ -799,78 +886,98 @@
      if (item.style && item.style.clear === 'left') {
        style = {clear: 'left'}
      } else if (item.style && item.style.clear === 'right') {
        style = {float: 'right'}
      }
      if (item.type === 'bar' || item.type === 'line') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvBarAndLine config={item} initdata={item.data} mainSearch={[]} />
            <AntvBarAndLine config={item}/>
          </Col>
        )
      } else if (item.type === 'pie') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvPie config={item} initdata={item.data} mainSearch={[]} />
            <AntvPie config={item} />
          </Col>
        )
      } else if (item.type === 'scatter') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvScatter config={item} initdata={item.data} mainSearch={[]}/>
            <AntvScatter config={item}/>
          </Col>
        )
      } else if (item.type === 'dashboard') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvDashboard config={item} initdata={item.data} mainSearch={[]}/>
            <AntvDashboard config={item}/>
          </Col>
        )
      } else if (item.type === 'card' && item.subtype === 'datacard') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <DataCard config={item} initdata={item.data} 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} initdata={item.data} 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}/>
          </Col>
        )
      } else if (item.type === 'card' && item.subtype === 'tablecard') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <TableCard config={item} initdata={item.data} 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} initdata={item.data} mainSearch={[]}/>
            <NormalTable config={item}/>
          </Col>
        )
      } else if (item.type === 'code') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <SandBox config={item} initdata={item.data} mainSearch={[]}/>
            <SandBox config={item}/>
          </Col>
        )
      } else if (item.type === 'balcony') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <Balcony config={item} initdata={item.data}/>
            <Balcony config={item}/>
          </Col>
        )
      } else if (item.type === 'timeline') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <TimeLine config={item} initdata={item.data} mainSearch={[]}/>
            <TimeLine config={item}/>
          </Col>
        )
      } else if (item.type === 'editor') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <BraftEditor config={item}/>
          </Col>
        )
      } else if (item.type === 'antvG6') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvG6 config={item} initdata={item.data} mainSearch={[]}/>
            <AntvG6 config={item}/>
          </Col>
        )
      } else if (item.type === 'antvX6') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvX6 config={item}/>
          </Col>
        )
      } else {