king
2025-01-10 fec6c24bc3fd902f8ced64bc2600c0b0836f7e52
src/views/billprint/index.jsx
@@ -99,10 +99,22 @@
        configurable: true,
        enumerable: true,
        set(value) {
          if (value + '' === 'false') {
            window.GLOB.debugger = false
          } else {
          if (value === true) {
            window.GLOB.debugger = true
          } else if (value === 0) {
            if (window.backend) {
              sessionStorage.setItem('systemRun', 'front')
              window.location.reload()
            } else {
              window.mkInfo('系统当前未使用后端脚本!')
            }
          } else if (value === false) {
            if (sessionStorage.getItem('systemRun') === 'front') {
              sessionStorage.removeItem('systemRun')
              window.location.reload()
            } else {
              window.GLOB.debugger = false
            }
          }
        }
      })
@@ -176,6 +188,10 @@
          func: 's_Get_style',
          TypeCharOne: 'PC',
          LText: `select '${window.GLOB.appkey}'`,
        }
        if (window.GLOB.style_appkey) {
          _param.style_appkey = window.GLOB.style_appkey
        }
        _param.userid = result.UserID
@@ -598,6 +614,7 @@
          if (data.length > 0) {
            params.push({
              $backend: true,
              $type: 's_Get_TableData',
              componentId: '',
              data
            })
@@ -961,7 +978,6 @@
    let deffers = params.map(item => {
      let componentId = item.componentId
      let ispublic = item.public
      delete item.componentId
      delete item.public
      return new Promise(resolve => {
@@ -983,13 +999,12 @@
          } else {
            res.componentId = componentId
            if (ispublic) {
              let _data = { $$empty: true }
              if (res.data && res.data[0]) {
                _data = res.data[0]
              }
              window.GLOB.CacheData.set(componentId, _data)
            let _data = { $$empty: true }
            if (res.data && res.data[0]) {
              _data = res.data[0]
            }
            window.GLOB.CacheData.set(componentId, _data)
            resolve(res)
          }
        })
@@ -1044,63 +1059,79 @@
        }
      }
      while (!over) {
        let page = []
        let count = 0
        let _pageover = false
        comps.forEach(comp => {
          let item = fromJS(comp).toJS()
          if (item.wrap.printType === 'headerOrfooter') { // 页眉页脚
            item.data = item.dataArray || null
            setData(item)
            page.push(item)
            comp.added = true
          }
          if (_pageover) return
          if (item.$page && comp.dataArray.length > 0) {
            item.data = []
            while (count + 1 <= limit && comp.dataArray.length > 0) {
              item.data.push(comp.dataArray.shift())
              count++
            }
            if (count >= limit || comp.dataArray.length > 0) {
              _pageover = true
            }
            if (comp.dataArray.length === 0) {
      if (this.state.config.printPage === 'custom' && this.state.config.printScripts) {
        try {
          // eslint-disable-next-line
          let func = new Function('components', 'pages', 'notification', this.state.config.printScripts)
          func(comps, pages, notification)
        } catch (e) {
          console.warn(e)
          notification.warning({
            top: 92,
            message: '自定义脚本执行错误!',
            duration: 5
          })
        }
      } else {
        while (!over) {
          let page = []
          let count = 0
          let _pageover = false
          comps.forEach(comp => {
            let item = fromJS(comp).toJS()
            if (item.wrap.printType === 'headerOrfooter') { // 页眉页脚
              item.data = item.dataArray || null
              setData(item)
              page.push(item)
              comp.added = true
            }
            setData(item)
            page.push(item)
          } else if (!comp.added) {
            if (item.wrap.printHeight) {
              count += item.wrap.printHeight
              if (count >= limit) {
                _pageover = true
                return
            if (_pageover) return
            if (item.$page && comp.dataArray.length > 0) {
              item.data = []
              while (count + 1 <= limit && comp.dataArray.length > 0) {
                item.data.push(comp.dataArray.shift())
                count++
              }
              if (count >= limit || comp.dataArray.length > 0) {
                _pageover = true
              }
              if (comp.dataArray.length === 0) {
                comp.added = true
              }
              setData(item)
              page.push(item)
            } else if (!comp.added) {
              if (item.wrap.printHeight) {
                count += item.wrap.printHeight
                if (count >= limit) {
                  _pageover = true
                  return
                }
              }
              item.data = item.dataArray || null
              setData(item)
              page.push(item)
              comp.added = true
            }
            item.data = item.dataArray || null
            setData(item)
            page.push(item)
            comp.added = true
          })
          pages.push(page)
          pageIndex++
          if (pageIndex >= 2000 || comps.findIndex(comp => !comp.added) === -1) {
            over = true
          }
        })
        pages.push(page)
        pageIndex++
        if (pageIndex >= 2000 || comps.findIndex(comp => !comp.added) === -1) {
          over = true
        }
      }