king
2021-09-01 31ec63f0419895876cbaba99637a884a32d33d0d
src/views/billprint/index.jsx
@@ -26,7 +26,7 @@
class BillPrint extends Component {
  state = {
    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    loadingview: true,
    printing: false,
    pages: null,
@@ -48,7 +48,7 @@
      }, () => {
        this.getMenuParam()
      })
    } catch {
    } catch (e) {
      notification.warning({
        top: 92,
        message: '菜单信息解析错误!',
@@ -121,42 +121,70 @@
          A4: {
            vertical: 980,
            horizontal: 1200,
            verticaldefault: 1.45789,
            verticalwithout: 1.41428,
            horizontaldefault: 0.683,
            horizontalwithout: 0.705,
            verticaldefault: 1.455,
            verticalwithout: 1.411,
            horizontaldefault: 0.679,
            horizontalwithout: 0.701,
          },
          A3: {
            vertical: 1200,
            horizontal: 1600,
            verticaldefault: 1.44404,
            verticalwithout: 1.41414,
            horizontaldefault: 0.6923,
            horizontalwithout: 0.707,
            verticaldefault: 1.441,
            verticalwithout: 1.410,
            horizontaldefault: 0.688,
            horizontalwithout: 0.703,
          },
          A5: {
            vertical: 700,
            horizontal: 1000,
            verticaldefault: 1.482,
            verticalwithout: 1.417,
            horizontaldefault: 0.6736,
            horizontalwithout: 0.7047,
            verticaldefault: 1.478,
            verticalwithout: 1.413,
            horizontaldefault: 0.669,
            horizontalwithout: 0.700,
          }
        }
        config.width = pageParam[config.pageSize][config.pageLayout]
        config.style.height = Math.floor(config.width * pageParam[config.pageSize][config.pageLayout + config.pagePadding])
        if (config.printCustom === 'true' && config.printWidth && config.printHeight) {
          config.width = config.printWidth
          config.style.height = config.printHeight
        }
        let params = []
        let _pars = []
        config.components = config.components.filter(item => !['tabs', 'search'].includes(item.type))
        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') || ''
          fullName = sessionStorage.getItem('CloudFullName') || ''
        }
        let regs = [
          { reg: /@userName@/ig, value: `'${userName}'` },
          { reg: /@fullName@/ig, value: `'${fullName}'` },
          { reg: /@login_city@/ig, value: `'${city}'` }
        ]
        if (window.GLOB.externalDatabase !== null) {
          regs.push({
            reg: /@db@/ig,
            value: window.GLOB.externalDatabase
          })
        }
        config.components = config.components.map(component => {
          if (component.action) component.action = []
          if (component.search) component.search = []
          component.data = [] // 初始化数据为空
          if (['propcard', 'brafteditor', 'sandbox'].includes(component.subtype) && component.wrap.datatype === 'static') {
          if (component.wrap.datatype === 'static') {
            component.format = ''
          }
    
@@ -197,6 +225,11 @@
            component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '')
            _customScript = _customScript.replace(/@\$|\$@/ig, '')
          }
          regs.forEach(cell => {
            component.setting.dataresource = component.setting.dataresource.replace(cell.reg, cell.value)
            _customScript = _customScript.replace(cell.reg, cell.value)
          })
    
          component.setting.customScript = _customScript // 整理后自定义脚本
    
@@ -496,6 +529,7 @@
      let linkList = document.getElementsByTagName('link')     // 获取父窗口link标签对象列表
      let styleList = document.getElementsByTagName('style')   // 获取父窗口style标签对象列表
      iframe.style.marginTop = '600px'
      document.body.appendChild(iframe)
      let doc = iframe.contentWindow.document