king
2023-04-02 24bfb39e86c7a265803486bc4b546ea2bfaef4a5
src/views/billprint/index.jsx
@@ -21,11 +21,14 @@
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 DebugTable = asyncComponent(() => import('@/tabviews/debugtable'))
class BillPrint extends Component {
@@ -58,13 +61,14 @@
        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,
          urlParam: param
        }, () => {
          this.getMenuParam()
          setTimeout(() => {
            this.getMenuParam()
          }, 200)
        })
      } catch (e) {
        notification.warning({
@@ -199,11 +203,7 @@
    window.GLOB.dataFormat = false // 打印去除水印
    if (window.GLOB.mainSystemApi) { // 从单点登录服务器取打印配置信息
      _param.rduri = window.GLOB.mainSystemApi
    }
    Api.genericInterface(_param).then(result => {
    Api.getCacheConfig(_param).then(result => {
      if (result.status) {
        let config = ''
@@ -310,6 +310,8 @@
          })
        }
        window.GLOB.CacheData.set(tempId, {$BID: BID})
        config.components = config.components.map(component => {
          if (component.action) component.action = []
          if (component.search) component.search = []
@@ -317,6 +319,16 @@
          if (component.subtype === 'tablecard') { // 兼容
            component.type = 'card'
          }
          component.$pageId = tempId
          if (component.setting && component.setting.supModule) {
            let pid = component.setting.supModule.pop()
            if (pid && pid !== 'empty') {
              component.setting.supModule = pid
            } else {
              component.setting.supModule = ''
            }
          }
          if (component.type === 'table') {
@@ -332,9 +344,10 @@
              })
            }
            component.cols = getColumns(component.cols)
            component.statFields = []
          }
          if (component.wrap.datatype === 'static') {
          if (component.wrap && component.wrap.datatype === 'static') {
            component.format = ''
          }
    
@@ -386,7 +399,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 {
@@ -442,13 +455,23 @@
  }
  reload = () => {
    const { tempId } = this.state
    this.setState({
      loadingview: true,
      pages: null,
      data: '',
      config: null
    }, () => {
      this.getMenuParam()
      Api.deleteMenuStorage(tempId)
      setTimeout(() => {
        this.getMenuParam()
      }, 50)
      // Api.getAppVersion(tempId).then(() => {
      //   this.getMenuParam()
      // }, () => {
      //   this.getMenuParam()
      // })
    })
  }
@@ -693,6 +716,13 @@
    return image
  }
  chartToImage(canvas) {
    let image = new Image()
    image.src = canvas.toDataURL('image/jpg')
    image.style = `width:100%;height:${canvas.style.height || '100%'};`
    return image
  }
  print = () => {
    const { config, printing } = this.state
    
@@ -708,6 +738,21 @@
  
        canvas.remove()
        qrcodes[i].append(img)
      }
    }
    let charts = document.getElementsByTagName('canvas')
    if (charts.length) {
      for (let i = 0; i < charts.length; i++) {
        let img = this.chartToImage(charts[i])
        let parentNode = charts[i].parentNode
        parentNode.append(img)
      }
      while (charts[0]) {
        charts[0].remove()
      }
    }
@@ -761,70 +806,94 @@
  getComponents = (components) => {
    return components.map(item => {
      let style = null
      if (item.style && item.style.clear === 'left') {
        style = {clear: 'left'}
      }
      if (item.type === 'bar' || item.type === 'line') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvBarAndLine config={item} initdata={item.data} mainSearch={[]} />
          </Col>
        )
      } else if (item.type === 'pie') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvPie config={item} initdata={item.data} mainSearch={[]} />
          </Col>
        )
      } else if (item.type === 'scatter') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvScatter config={item} initdata={item.data} mainSearch={[]}/>
          </Col>
        )
      } else if (item.type === 'dashboard') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvDashboard config={item} initdata={item.data} 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} initdata={item.data} 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} initdata={item.data} mainSearch={[]} />
          </Col>
        )
      } else if (item.type === 'card' && item.subtype === 'dualdatacard') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <DoubleDataCard config={item} mainSearch={[]}/>
          </Col>
        )
      } 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} initdata={item.data} mainSearch={[]}/>
          </Col>
        )
      } else if (item.type === 'table' && item.subtype === 'normaltable') {
        return (
          <Col span={item.width} key={item.uuid}>
          <Col span={item.width} style={style} key={item.uuid}>
            <NormalTable config={item} initdata={item.data} 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} initdata={item.data} 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} initdata={item.data}/>
          </Col>
        )
      } else if (item.type === 'timeline') {
        return (
          <Col span={item.width} key={item.uuid}>
            <TimeLine config={item} initdata={item.data}/>
          <Col span={item.width} style={style} key={item.uuid}>
            <TimeLine config={item} initdata={item.data} mainSearch={[]}/>
          </Col>
        )
      } else if (item.type === 'editor') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <BraftEditor config={item} initdata={item.data} mainSearch={[]}/>
          </Col>
        )
      } else if (item.type === 'antvG6') {
        return (
          <Col span={item.width} style={style} key={item.uuid}>
            <AntvG6 config={item} initdata={item.data} mainSearch={[]}/>
          </Col>
        )
      } else {
@@ -840,7 +909,7 @@
      <div className="bill-print-wrap" >
        {loadingview && <Spin size="large" />}
        {pages ? <div id="bill-print">
          {pages.map((components, index) => (<div className={'print-page' + (auto ? ' auto' : '')} key={index} style={{...config.style, overflow: 'hidden', boxSizing: 'border-box'}}><Row>{this.getComponents(components)}</Row></div>))}
          {pages.map((components, index) => (<div className={'print-page' + (auto ? ' auto' : '')} key={index} style={{...config.style, overflow: 'hidden', boxSizing: 'border-box'}}><Row className="component-wrap">{this.getComponents(components)}</Row></div>))}
        </div> : null}
        {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
        {config && window.GLOB.breakpoint ? <DebugTable /> : null}