king
2022-08-02 8d66ff34fae5b048a6b7923cc75d34f13a08be9d
src/views/billprint/index.jsx
@@ -37,6 +37,7 @@
    data: '',
    tempId: '',
    config: null,
    urlParam: null,
    auto: true
  }
@@ -58,7 +59,8 @@
        sessionStorage.setItem('localDataM', param.dataM || '')
        this.setState({
          BID: param.id || '',
          tempId: param.tempId
          tempId: param.tempId,
          urlParam: param
        }, () => {
          this.getMenuParam()
        })
@@ -135,7 +137,7 @@
  }
  getMenuParam = () => {
    const { tempId, BID } = this.state
    const { tempId, BID, urlParam } = this.state
    let _param = {
      func: 'sPC_Get_LongParam',
@@ -225,7 +227,6 @@
        let userName = sessionStorage.getItem('User_Name') || ''
        let fullName = sessionStorage.getItem('Full_Name') || ''
        let city = sessionStorage.getItem('city') || ''
        if (sessionStorage.getItem('isEditState') === 'true') {
          userName = sessionStorage.getItem('CloudUserName') || ''
@@ -234,14 +235,23 @@
        let regs = [
          { reg: /@userName@/ig, value: `'${userName}'` },
          { reg: /@fullName@/ig, value: `'${fullName}'` },
          { reg: /@login_city@/ig, value: `'${city}'` }
          { reg: /@fullName@/ig, value: `'${fullName}'` }
        ]
        
        if (window.GLOB.externalDatabase !== null) {
          regs.push({
            reg: /@db@/ig,
            value: window.GLOB.externalDatabase
          })
        }
        if (config.urlFields) {
          config.urlFields.forEach(field => {
            let val = `'${urlParam ? (urlParam[field] || '') : ''}'`
            regs.push({
              reg: new RegExp('@' + field + '@', 'ig'),
              value: val
            })
          })
        }
@@ -322,7 +332,7 @@
            _pars.push(param)
          } else {
            let arr_field = component.columns.map(col => col.field).join(',')
            let param = UtilsDM.getQueryDataParams(component.setting, arr_field, [], component.setting.order || '', 1, 1000, BID, '')
            let param = UtilsDM.getQueryDataParams(component.setting, arr_field, [], component.setting.order || '', 1, 1000, BID)
            
            param.componentId = component.uuid
@@ -340,7 +350,20 @@
          params.unshift(_pars)
        }
        if (config.everyPCount && !config.printPage) { // 兼容
          config.printPage = 'page'
        }
        config.printPage = config.printPage || 'auto'
        if (config.printPage === 'auto') {
          config.everyPCount = 99999
        }
        config.limit = config.everyPCount || 15
        this.setState({
          auto: config.printPage === 'auto',
          config
        }, () => {
          if (params.length === 0) {
@@ -417,7 +440,12 @@
    let RoleID = sessionStorage.getItem('role_id') || ''
    let departmentcode = sessionStorage.getItem('departmentcode') || ''
    let organization = sessionStorage.getItem('organization') || ''
    let mk_user_type = sessionStorage.getItem('mk_user_type') || ''
    let nation = sessionStorage.getItem('nation') || ''
    let province = sessionStorage.getItem('province') || ''
    let city = sessionStorage.getItem('city') || ''
    let district = sessionStorage.getItem('district') || ''
    let address = sessionStorage.getItem('address') || ''
  
    if (sessionStorage.getItem('isEditState') === 'true') {
      userName = sessionStorage.getItem('CloudUserName') || ''
@@ -429,8 +457,8 @@
      let _script = item.script
      if (index === 0) {
        _script = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(50),@mk_organization nvarchar(50),@login_city nvarchar(50)
          select @ErrorCode='',@retmsg ='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @login_city='${city}'
        _script = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(50),@mk_organization nvarchar(50),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100)
          select @ErrorCode='',@retmsg ='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}'
          ${_script}
        `
      }
@@ -467,7 +495,7 @@
   * @description 主表数据加载
   */ 
  loadmaindata = (params) => {
    const { components, everyPCount, firstCount, lastCount } = this.state.config
    const { components, limit } = this.state.config
    let deffers = params.map(item => {
      let componentId = item.componentId
@@ -517,19 +545,11 @@
        this.setState({loadingview: false, pages})
      }
      let auto = true
      if (comps[comps.length - 1].wrap && comps[comps.length - 1].wrap.printHeight) {
        auto = false
      }
      while (!over) {
        let page = []
        let count = 0
        let _pageover = false
        let pagesover = false
        let limit = pageIndex === 1 ? (firstCount || 20) : (everyPCount || 20)
        comps.forEach((_item, index) => {
          let item = fromJS(_item).toJS()
@@ -568,7 +588,11 @@
    
                if (count >= limit) {
                  _pageover = true
                } else if (_item.dataArray.length > 0) {
                  _pageover = true
                }
                page.push(item)
              }
              _item.added = true
@@ -600,95 +624,15 @@
          }
        })
        if (pagesover && lastCount && count > lastCount) {
          pagesover = false
          page = []
          count = 0
          _pageover = false
          if (pageIndex === 1) {
            limit = (everyPCount - firstCount) + (everyPCount - lastCount)
            if (limit <= 0) {
              limit = firstCount
            }
          } else {
            limit = lastCount
          }
          comps.forEach((_item, index) => {
            let item = fromJS(_item).toJS()
            if (item.wrap && item.wrap.printType === 'headerOrfooter') { // 页眉页脚
              page.push(item)
            } else if (_pageover) {
              return
            } else if (item.subtype === 'datacard' || item.type === 'table') {
              if (_item.dataArray && _item.dataArray.length > 0) {
                if (item.subtype === 'datacard' && item.wrap.layout === 'flex') {
                  if (!item.added && item.wrap.printHeight) {
                    count += item.wrap.printHeight
                    if (count >= limit) {
                      _pageover = true
                    }
                    if (count <= limit) {
                      _item.added = true
                      page.push(item)
                    }
                  } else if (!item.added) {
                    _item.added = true
                    page.push(item)
                  }
                } else {
                  item.data = []
                  while (count + 1 <= limit && _item.dataArray.length > 0) {
                    item.data.push(_item.dataArray.shift())
                    count++
                  }
                  if (count >= limit) {
                    _pageover = true
                  }
                  page.push(item)
                }
                _item.added = true
              } else if (!item.added) {
                _item.added = true
                page.push(item)
              }
            } else if (!item.added && item.wrap && item.wrap.printHeight) {
              if (item.wrap.empty === 'hidden' && (!item.data || item.data.length === 0)) {
                _item.added = true
                return
              }
              count += item.wrap.printHeight
              if (count >= limit) {
                _pageover = true
              }
              if (count <= limit) {
                _item.added = true
                page.push(item)
              }
            } else if (!item.added) {
              _item.added = true
              page.push(item)
            }
            if (index + 1 === length && !_pageover) {
              pagesover = true
            }
          })
        }
        pages.push(page)
        pageIndex++
        if (pageIndex >= 200 || pagesover) {
        if (pageIndex >= 2000 || pagesover) {
          over = true
        }
      }
      this.setState({loadingview: false, pages, auto})
      this.setState({loadingview: false, pages})
    })
  }
@@ -750,67 +694,67 @@
      if (item.type === 'bar' || item.type === 'line') {
        return (
          <Col span={item.width} key={item.uuid}>
            <AntvBarAndLine config={item} initdata={item.data} mainSearch={[]} menuType="" />
            <AntvBarAndLine config={item} initdata={item.data} mainSearch={[]} />
          </Col>
        )
      } else if (item.type === 'pie') {
        return (
          <Col span={item.width} key={item.uuid}>
            <AntvPie config={item} initdata={item.data} mainSearch={[]} menuType="" />
            <AntvPie config={item} initdata={item.data} mainSearch={[]} />
          </Col>
        )
      } else if (item.type === 'scatter') {
        return (
          <Col span={item.width} key={item.uuid}>
            <AntvScatter config={item} initdata={item.data} mainSearch={[]} menuType="" />
            <AntvScatter config={item} initdata={item.data} mainSearch={[]}/>
          </Col>
        )
      } else if (item.type === 'dashboard') {
        return (
          <Col span={item.width} key={item.uuid}>
            <AntvDashboard config={item} initdata={item.data} mainSearch={[]} menuType="" />
            <AntvDashboard config={item} initdata={item.data} mainSearch={[]}/>
          </Col>
        )
      } else if (item.type === 'card' && item.subtype === 'datacard') {
        return (
          <Col span={item.width} key={item.uuid}>
            <DataCard config={item} initdata={item.data} mainSearch={[]} menuType="" />
            <DataCard config={item} initdata={item.data} mainSearch={[]} />
          </Col>
        )
      } else if (item.type === 'card' && item.subtype === 'propcard') {
        return (
          <Col span={item.width} key={item.uuid}>
            <PropCard config={item} initdata={item.data} mainSearch={[]} menuType="" />
            <PropCard config={item} initdata={item.data} mainSearch={[]} />
          </Col>
        )
      } else if (item.type === 'table' && item.subtype === 'tablecard') {
        return (
          <Col span={item.width} key={item.uuid}>
            <TableCard config={item} initdata={item.data} mainSearch={[]} menuType="" />
            <TableCard config={item} initdata={item.data} mainSearch={[]}/>
          </Col>
        )
      } else if (item.type === 'table' && item.subtype === 'normaltable') {
        return (
          <Col span={item.width} key={item.uuid}>
            <NormalTable config={item} initdata={item.data} mainSearch={[]} menuType="" />
            <NormalTable config={item} initdata={item.data} mainSearch={[]}/>
          </Col>
        )
      } else if (item.type === 'code') {
        return (
          <Col span={item.width} key={item.uuid}>
            <SandBox config={item} initdata={item.data} mainSearch={[]} menuType="" />
            <SandBox config={item} initdata={item.data} mainSearch={[]}/>
          </Col>
        )
      } else if (item.type === 'balcony') {
        return (
          <Col span={item.width} key={item.uuid}>
            <Balcony config={item} initdata={item.data} menuType="" />
            <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} menuType="" />
            <TimeLine config={item} initdata={item.data}/>
          </Col>
        )
      } else {