king
2025-05-13 1a176e4bdba485301385caac1a29102e598d25cc
src/views/billprint/index.jsx
@@ -66,11 +66,22 @@
        let param = JSON.parse(window.decodeURIComponent(window.atob(params.param)))
  
        sessionStorage.setItem('dataM', param.dataM || '')
        let urlParam = {...param}
        delete urlParam.tempId
        delete urlParam.pageId
        delete urlParam.dataM
        Object.keys(urlParam).forEach(key => {
          if (key === key.toLowerCase()) return
          urlParam[key.toLowerCase()] = urlParam[key]
          delete urlParam[key]
        })
        this.setState({
          BID: param.id || '',
          tempId: param.tempId,
          urlParam: param,
          urlParam: urlParam,
          pageId: param.pageId || ''
        }, () => {
          setTimeout(() => {
@@ -99,10 +110,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 +199,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
@@ -305,12 +332,20 @@
        config.components = config.components.filter(item => !['tabs', 'search'].includes(item.type))
        let urlparam = urlParam ? {...urlParam} : {}
        if (config.urlFields && config.urlFields.length) {
          config.urlFields.forEach(field => {
            let key = field.toLowerCase()
            if (urlparam[key] !== undefined) return
            urlparam[key] = ''
          })
        }
        if (window.backend && config.allSqls) {
          let urlparam = urlParam || {}
          let keys = Object.keys(urlparam)
          config.allSqls.forEach(item => {
            item.id = md5(window.GLOB.appkey + item.v_id)
            if (item.type === 'datasource' || item.type === 'excelOut') {
            if (['datasource', 'interface', 'excelOut'].includes(item.type)) {
              item.urlkeys = keys
              item.urlparam = urlparam
              if (config.flow_code) {
@@ -338,7 +373,7 @@
        if (config.urlFields) {
          config.urlFields.forEach(field => {
            let val = `'${urlParam ? (urlParam[field] || '') : ''}'`
            let val = `'${urlparam[field.toLowerCase()]}'`
            regs.push({
              reg: new RegExp('@' + field + '@', 'ig'),
              value: val
@@ -584,9 +619,10 @@
          params.unshift(_pars)
        } else if (window.backend && config.allSqls && params.length > 0) {
          let data = []
          let ids = []
          params = params.filter(item => {
            if (!item.$backend || item.public) return true
            ids.push(item.componentId)
            item.data[0].exps.forEach(cell => {
              if (cell.key === 'mk_obj_name') {
                cell.value = 'mk' + item.componentId.slice(-18)
@@ -598,7 +634,9 @@
          if (data.length > 0) {
            params.push({
              $backend: true,
              $type: 's_Get_TableData',
              componentId: '',
              componentIds: ids,
              data
            })
          }
@@ -632,6 +670,8 @@
          
          if (params.length === 0 && initInters.length === 0) {
            this.setState({loadingview: false, pages: [config.components]})
            this.autoExec()
          } else if (initInters.length > 0) {
            this.loadinit(initInters, params)
          } else {
@@ -947,6 +987,8 @@
    Promise.all(deffers).then(() => {
      if (params.length === 0) {
        this.setState({loadingview: false, pages: [this.state.config.components]})
        this.autoExec()
      } else {
        this.loadmaindata(params)
      }
@@ -961,8 +1003,9 @@
    let deffers = params.map(item => {
      let componentId = item.componentId
      let ispublic = item.public
      let ids = item.componentIds
      delete item.componentId
      delete item.componentIds
      delete item.public
      return new Promise(resolve => {
        Api.genericInterface(item).then(res => {
@@ -980,16 +1023,29 @@
              })
            }
            resolve(false)
          } else if (ids) {
            ids.forEach(id => {
              let _id = 'mk' + id.slice(-18)
              if (res[_id]) {
                let _data = { $$empty: true }
                if (res[_id][0]) {
                  _data = res[_id][0]
                }
                window.GLOB.CacheData.set(id, _data)
              }
            })
            resolve(res)
          } 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 +1100,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
        }
      }
@@ -1135,9 +1207,21 @@
      })
      this.setState({loadingview: false, pages, rePos})
      this.autoExec()
    })
  }
  autoExec = () => {
    const { config } = this.state
    if (config.autoExec !== 'true') return
    setTimeout(() => {
      this.print()
    }, config.autoExecSplit || 500)
  }
  reloadTabs = () => {
    if (this.reloading) return