فهرست منبع

定义打印模板默认值,默认隐藏页码

sh4wmoo 2 سال پیش
والد
کامیت
2d6b9f2f87
1فایلهای تغییر یافته به همراه13 افزوده شده و 4 حذف شده
  1. 13 4
      src/view/mst/label-print-layout/layout-setting.vue

+ 13 - 4
src/view/mst/label-print-layout/layout-setting.vue

@@ -528,6 +528,12 @@ export default {
         // }
       })
 
+      //定义模板默认值,默认隐藏页码
+      let template=this.formData?.layoutData
+      if(template&&Object.keys(template).length==0){
+        template={"panels":[{"index":0,"name":1,"paperType":"A4","height":297,"width":210,"paperHeader":0,"paperFooter":841.8897637795277,"printElements":[],"paperNumberLeft":565,"paperNumberTop":819,"paperNumberContinue":false,"paperNumberDisabled":true}]}
+      }
+
       //构建左侧可拖拽元素
       this.$dkprint.PrintElementTypeManager.buildByHtml($('.ep-draggable-item'))
 
@@ -535,7 +541,7 @@ export default {
       $('#hiprint-printTemplate').empty()
       this.hiprintTemplate = new hiprint.PrintTemplate({
         //导入模板
-        template:this.formData?.layoutData,
+        template:template,
         //设置字体
         fontList: [
           { title: '微软雅黑', value: 'Microsoft YaHei' },
@@ -557,9 +563,12 @@ export default {
       this.hiprintTemplate.design('#hiprint-printTemplate', { grid: true })
 
       //重写纸张大小
-      this.paperHeight=this.formData?.layoutData?.panels[0]?.height
-      this.paperWidth=this.formData?.layoutData?.panels[0]?.width
-      this.setPaper('other')
+      this.paperHeight=this.formData?.layoutData?.panels?.[0]?.height
+      this.paperWidth=this.formData?.layoutData?.panels?.[0]?.width
+      if( this.paperHeight&&this.paperWidth){
+        this.setPaper('other')
+      }
+
 
       //模板参数
       console.log('HIPRINT_CONFIG',window.HIPRINT_CONFIG )