<template>
|
<div class="print-container">
|
<!-- 报表显示区域将由JS动态创建 -->
|
</div>
|
</template>
|
|
<script>
|
import '@/utils/print/CreateControl.js'
|
import '@/utils/print/GRInstall.js'
|
import '@/utils/print/GRUtility.js'
|
|
export default {
|
name: 'HBarPlanPrint',
|
data() {
|
return {
|
PrintCount: 0,
|
params: {},
|
value: '',
|
type: '',
|
openTmp: ''
|
}
|
},
|
mounted() {
|
this.params = this.getUrlVars()
|
this.initParams()
|
this.createDisplayViewer()
|
window.addEventListener('load', this.windowOnload)
|
},
|
beforeUnmount() {
|
window.removeEventListener('load', this.windowOnload)
|
},
|
methods: {
|
getUrlVars() {
|
const vars = {}
|
const hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&')
|
for (let i = 0; i < hashes.length; i++) {
|
const hash = hashes[i].split('=')
|
vars[hash[0]] = hash[1]
|
}
|
return vars
|
},
|
initParams() {
|
// 解析参数,根据实际参数结构调整
|
const paramKeys = Object.keys(this.params)
|
this.value = this.params[paramKeys[0]] || ''
|
this.type = this.params[paramKeys[1]] || ''
|
this.openTmp = this.params[paramKeys[2]] || ''
|
},
|
windowOnload() {
|
const ReportViewer = document.getElementById('ReportViewer')
|
if (ReportViewer) {
|
const Report = ReportViewer.Report
|
Report.OnPrintBegin = this.onPrintBegin
|
Report.OnPrintEnd = this.onPrintEnd
|
ReportViewer.Start()
|
}
|
},
|
onPrintBegin() {
|
// 打印开始时的逻辑
|
},
|
onPrintEnd() {
|
// 打印结束时的逻辑
|
if (this.PrintCount === 0) {
|
const LCStatus = sessionStorage.getItem('LCStatus')
|
if (LCStatus === 'Print') {
|
// 调用保存打印记录的方法,此处假设SaveLabelPrint已全局定义
|
if (window.SaveLabelPrint) {
|
window.SaveLabelPrint(sessionStorage.getItem('LabelJson'))
|
}
|
this.PrintCount = 1
|
}
|
}
|
},
|
createDisplayViewer() {
|
switch (this.type) {
|
case 'HProcessReport':
|
window.CreateDisplayViewerEx('100%', '100%', '../../grf/' + this.openTmp + '.grf', 'xmlLBM_ProcessReport.aspx?linterid=' + this.value, true, '')
|
break
|
case 'HDepartMent':
|
window.CreateDisplayViewerEx('100%', '100%', 'grf/' + this.openTmp + '.grf', 'xmlLBM_Gy_Department_Edit.aspx?linterid=' + this.value, true, '')
|
break
|
case 'HMaterial':
|
window.CreateDisplayViewerEx('100%', '100%', '../../grf/' + this.openTmp + '.grf', 'xmlLBM_Gy_Material.aspx?linterid=' + this.value, true, '')
|
break
|
// 其他case省略,保持与原html中switch逻辑一致
|
case 'HCustTag':
|
const listTrue = this.value.split('@')
|
if (listTrue.length > 1) {
|
window.CreateDisplayViewerEx('100%', '100%', '../../grf/' + this.openTmp + '.grf', `xmlLBM_Sc_CustTagBarCodeList.aspx?linterid=${listTrue[0]}&entryid=${listTrue[1]}`, true, '')
|
} else {
|
window.CreateDisplayViewerEx('100%', '100%', '../../grf/' + this.openTmp + '.grf', 'xmlLBM_Sc_CustTagBarCodeList_Select.aspx?linterid=' + listTrue[0], true, '')
|
}
|
break
|
// 更多case请参照原代码补充
|
default:
|
break
|
}
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.print-container {
|
width: 100%;
|
height: 100%;
|
margin: 0;
|
}
|
</style>
|