king
2024-08-25 326aa6b3effaccc71cfe0775d47b0f29eb3695a6
src/views/billprint/index.jsx
@@ -1,6 +1,6 @@
import React, { Component } from 'react'
import { is, fromJS } from 'immutable'
import { Col, Row, Spin, notification, Button } from 'antd'
import { Col, Row, Spin, notification, Button, Modal } from 'antd'
import moment from 'moment'
import Api from '@/api'
@@ -44,8 +44,11 @@
    visible: false,
    rePos: false,
    loading: false,
    auto: true
    auto: true,
    ismob: /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(navigator.userAgent)
  }
  reloading = false
  UNSAFE_componentWillMount() {
    const { params } = this.props.match
@@ -87,7 +90,7 @@
  }
  componentDidMount() {
    const _this = this
    const that = this
    if (window.GLOB.sysType !== 'cloud') {
      Object.defineProperty(window, 'debugger', {
@@ -115,7 +118,7 @@
            window.GLOB.breakpoint = value + ''
            sessionStorage.setItem('breakpoint', value)
          }
          _this.debugChange()
          that.debugChange()
        }
      })
    }
@@ -141,7 +144,7 @@
        window.GLOB.breakpoint = false
        sessionStorage.removeItem('breakpoint')
        
        _this.debugChange()
        that.debugChange()
      }
    }
  }
@@ -166,8 +169,6 @@
        sessionStorage.setItem('LoginUID', result.LoginUID || '')
        sessionStorage.setItem('dataM', 'false')
        this.getMenuParam()
        // 获取系统信息
        let _param = {
          func: 's_Get_style',
@@ -184,6 +185,7 @@
          if (res.status) {
            window.GLOB.style = res.CSS
            document.title = res.titleName
            sessionStorage.setItem('appname', res.appname || '')
        
            if (window.GLOB.style && styles[window.GLOB.style]) {
              document.body.className = styles[window.GLOB.style] + ' ' + (res.split_line_show === 'false' ? 'hidden-split-line' : '')
@@ -197,6 +199,8 @@
              document.getElementsByTagName('head')[0].appendChild(link)
            }
          }
          this.getMenuParam()
        })
      } else {
        notification.warning({
@@ -248,6 +252,10 @@
            lostmsg: '抱歉,您访问的页面未启用,请联系管理员。'
          })
          return
        }
        if (config.webTitle) {
          document.title = config.webTitle
        }
        config.style = config.style || {}
@@ -324,7 +332,7 @@
        let initInters = []
        this.formatInterSetting(config.interfaces, regs, initInters, params, BID)
        this.formatInterSetting(config.interfaces, regs, initInters, params, BID, config.MenuName)
        config.components = config.components.map(component => {
          if (component.action) {
@@ -340,6 +348,8 @@
            component.$searches = []
          }
          component.data = [] // 初始化数据为空
          component.$menuname = (config.MenuName || '') + '-' + (component.name || '')
          if (component.subtype === 'tablecard') { // 兼容
            component.type = 'card'
@@ -359,7 +369,9 @@
            let getColumns = (cols) => {
              return cols.filter(item => {
                if (item.Hide === 'true') return false
                item.IsSort = 'false'
                if (item.type === 'number') {
                  if (typeof(item.decimal) === 'number') {
                    item.round = Math.pow(10, item.decimal)
@@ -393,6 +405,10 @@
                  }
                } else {
                  item.IsSort = 'false'
                }
                if (item.marks && item.marks.length === 0) {
                  item.marks = null
                }
          
                return true
@@ -460,6 +476,12 @@
          if (!component.format) return component  // 没有动态数据  数据格式 array 或 object
          component.setting.arr_field = component.columns ? component.columns.map(col => col.field).join(',') : ''
          component.setting.laypage = false   // 是否分页,转为boolean 统一格式
          component.setting.$name = component.$menuname
          if (component.format === 'object') {
            component.setting.$top = true
          }
          if (component.setting.interType !== 'system') { // 不使用系统函数时
            component.setting.sync = 'false'
@@ -483,7 +505,6 @@
          delete component.scripts
    
          component.setting.execute = component.setting.execute !== 'false'  // 默认sql是否执行,转为boolean 统一格式
          component.setting.laypage = false   // 是否分页,转为boolean 统一格式
          component.setting.onload = 'true'   // 默认加载
    
          if (!component.setting.execute) {
@@ -530,7 +551,7 @@
          return component
        })
        _pars = this.getFormatParam(_pars)
        _pars = this.getFormatParam(_pars, config.MenuName)
        if (_pars) {
          _pars.componentId = 'union'
@@ -553,6 +574,16 @@
          auto: config.printPage === 'auto',
          config
        }, () => {
          if (config.normalcss) {
            let node = document.getElementById(config.uuid)
            node && node.remove()
            let ele = document.createElement('style')
            ele.id = config.uuid
            ele.innerHTML = config.normalcss
            document.getElementsByTagName('head')[0].appendChild(ele)
          }
          if (params.length === 0 && initInters.length === 0) {
            this.setState({loadingview: false, pages: [config.components]})
          } else if (initInters.length > 0) {
@@ -599,6 +630,13 @@
    if (cell.style.display === 'inline-block') {
      cell.style.verticalAlign = 'top'
    }
    if (cell.marks && cell.marks.length === 0) {
      cell.marks = null
    }
    if (cell.anchors && cell.anchors.length === 0) {
      cell.anchors = null
    }
    
    if (['text', 'number', 'formula'].includes(cell.eleType)) {
      cell.innerHeight = cell.innerHeight || 'auto'
@@ -617,7 +655,7 @@
    return cell
  }
  formatInterSetting = (inters, regs, initInters, params, BID) => {
  formatInterSetting = (inters, regs, initInters, params, BID, MenuName) => {
    if (!inters) return []
    let delay = 15
@@ -629,6 +667,7 @@
      inter.setting.supModule = ''
      inter.setting.arr_field = inter.columns.map(col => col.field).join(',')
      inter.setting.$name = (MenuName || '') + '-公共数据源-' + inter.setting.name
      if (inter.setting.interType !== 'system') {
        let param = UtilsDM.getQueryDataParams(inter.setting, [], inter.setting.order || '', 1, 1000, BID)
@@ -660,9 +699,9 @@
      })
      delete inter.scripts
      inter.setting.$name = '公共数据源-' + inter.setting.name
      inter.setting.execute = inter.setting.execute !== 'false'
      inter.setting.laypage = true
      inter.setting.laypage = false
      inter.setting.$top = true
      if (!inter.setting.execute) {
        inter.setting.dataresource = ''
@@ -747,7 +786,7 @@
    }
  }
  getFormatParam = (params) => {
  getFormatParam = (params, MenuName) => {
    const { BID } = this.state
    if (!params || params.length === 0) return ''
@@ -774,6 +813,7 @@
      { reg: /@SessionUid@/ig, value: `'${localStorage.getItem('SessionUid') || ''}'`},
      { reg: /@UserID@/ig, value: `'${sessionStorage.getItem('UserID') || ''}'`},
      { reg: /@Appkey@/ig, value: `'${window.GLOB.appkey || ''}'`},
      { reg: /@lang@/ig, value: `'${sessionStorage.getItem('lang')}'`},
      { reg: /@typename@/ig, value: `'admin'`},
    ]
@@ -798,8 +838,8 @@
      // 测试系统打印查询语句
      if (window.GLOB.debugger === true) {
        _script && console.info(`${_sql ? '' : '/*不执行默认sql*/\n'}${_script}`)
        _sql &&  console.info(_sql)
        _script && window.mkInfo(`${_sql ? '' : '/*不执行默认sql*/\n'}${_script}`)
        _sql && window.mkInfo(_sql)
      }
      item.columns.forEach(cell => {
@@ -810,17 +850,21 @@
    let param = {
      func: 'sPC_Get_structured_data',
      LText: LText.join(' union all '),
      LText_field: LText_field.join(' union all '),
      BID: BID || '',
      username: userName,
      fullName: fullName
    }
    param.LText = Utils.formatOptions(param.LText)
    param.LText_field = Utils.formatOptions(param.LText_field)
    if (MenuName) {
      param.menuname = MenuName
    }
    param.exec_type = window.GLOB.execType || 'y'
    param.LText = Utils.formatOptions(LText.join(' union all '), param.exec_type)
    param.custom_script = Utils.formatOptions(LText_field.join(' union all '), param.exec_type)
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
    param.secretkey = Utils.encrypt('', param.timestamp)
    return param
  }
@@ -873,11 +917,18 @@
      return new Promise(resolve => {
        Api.genericInterface(item).then(res => {
          if (!res.status) {
            notification.warning({
              top: 92,
              message: res.message,
              duration: 5
            })
            if (item.func === 'sPC_Get_structured_data' && /将截断字符串或二进制数据/ig.test(res.message)) {
              res.message = res.message + '请检查字段集'
            }
            if (res.ErrCode === 'version_up') {
              this.reloadTabs()
            } else {
              notification.warning({
                top: 92,
                message: res.message,
                duration: 5
              })
            }
            resolve(false)
          } else {
            res.componentId = componentId
@@ -1034,6 +1085,20 @@
      })
      this.setState({loadingview: false, pages, rePos})
    })
  }
  reloadTabs = () => {
    if (this.reloading) return
    this.reloading = true
    Api.getAppVersion(true).then(() => {
      window.location.reload()
    }, (message) => {
      Modal.error({
        title: message || '系统配置更新失败!',
      })
    })
  }
@@ -1288,7 +1353,7 @@
  }
  render() {
    const { loadingview, viewlost, config, pages, auto, rePos, loading } = this.state
    const { loadingview, viewlost, config, pages, auto, rePos, loading, ismob } = this.state
    return (
      <div className="bill-print-wrap" >
@@ -1298,8 +1363,8 @@
        </div> : null}
        {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
        {config && window.GLOB.breakpoint ? <DebugTable /> : null}
        {pages && !loadingview && !viewlost ? <div className="print-button"><Button icon="printer" size="large" shape="circle" onClick={this.print}></Button></div> : null}
        {!loadingview && !viewlost ? <div className="refresh-button"><Button icon="reload" size="large" shape="circle" onClick={this.reload}></Button></div> : null}
        {pages && !loadingview && !viewlost && !ismob ? <div className="print-button"><Button icon="printer" size="large" shape="circle" onClick={this.print}></Button></div> : null}
        {!loadingview && !viewlost && !ismob ? <div className="refresh-button"><Button icon="reload" size="large" shape="circle" onClick={this.reload}></Button></div> : null}
      </div>
    )
  }