Browse Source

Finish Hotfix-zh-228

Howie 3 years ago
parent
commit
13991cf437

+ 1 - 1
src/views/deposit_commerce/components/deposit_list-detail.vue

@@ -403,7 +403,7 @@
         <el-row :gutter="0">
           <el-col :xs="12" :sm="12" :lg="12" class="item">
             <div class="label">申请人</div>
-            <div class="value">{{ details.createBy }}</div>
+            <div class="value">{{ details.customerName }}</div>
           </el-col>
           <el-col :xs="12" :sm="12" :lg="12" class="item">
             <div class="label">申请日期</div>

+ 1 - 1
src/views/deposit_home/components/deposit_list-detail.vue

@@ -412,7 +412,7 @@
         <el-row :gutter="0">
           <el-col :xs="12" :sm="12" :lg="12" class="item">
             <div class="label">申请人</div>
-            <div class="value">{{ details.createBy }}</div>
+            <div class="value">{{ details.customerName }}</div>
           </el-col>
           <el-col :xs="12" :sm="12" :lg="12" class="item">
             <div class="label">申请日期</div>

+ 81 - 0
src/views/finance/components/design/index.vue

@@ -0,0 +1,81 @@
+<template>
+  <div>
+      <a-button type="primary" icon="eye" @click="preView">
+        预览
+      </a-button>
+    <print-preview ref="preView"/>
+  </div>
+</template>
+
+<script>
+import {disAutoConnect, hiprint, defaultElementTypeProvider} from 'vue-plugin-hiprint'
+// disAutoConnect();
+
+let hiprintTemplate;
+import panel from './panel'
+import printData from './print-data'
+import printPreview from './preview'
+
+export default {
+  name: "printDesign",
+  components: {},
+  data() {
+    return {
+      
+    }
+  },
+
+  methods: {
+    preView() {
+     
+    },
+   
+  }
+}
+</script>
+
+<style  scoped>
+  td {
+    border:none !important;
+  }
+.drag_item_box {
+  height: 100%;
+  padding: 6px;
+}
+
+.drag_item_box > div {
+  height: 100%;
+  width: 100%;
+  background-color: #fff;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+}
+
+.drag_item_box > div > a {
+  text-align: center;
+  text-decoration-line: none;
+}
+
+.drag_item_box > div > a > span {
+  font-size: 28px;
+}
+
+.drag_item_box > div > a > p {
+  margin: 0;
+}
+
+.drag_item_title {
+  font-size: 16px;
+  padding: 12px 6px 0 6px;
+  font-weight: bold;
+}
+
+
+.card-design {
+  overflow: hidden;
+  overflow-x: auto;
+  overflow-y: auto;
+}
+
+</style>

+ 149 - 0
src/views/finance/components/design/panel.js

@@ -0,0 +1,149 @@
+
+export default {
+  "panels": [{
+    "index": 0,
+    "height": 140,
+    "width": 241,
+    "paperCount": 222,
+    "printElements": [{
+      "options": {
+        "left": 0,
+        "top": 25,
+        "height": 27,
+        "width": 656,
+        "field": "company",
+        "fontSize": 19,
+        "fontWeight": "600",
+        "fontFamily": '黑体',
+        "textAlign": "center",
+        "lineHeight": 26
+      }, "printElementType": { "title": "", "type": "text" }
+    },
+    {
+      "options": {
+        "left": 25,
+        "top": 80,
+        "height": 56,
+        "width": 633,
+        "field": "table",
+        "tableFooterRepeat": "",
+        "tableHeaderRepeat": "none",
+        "rows": [[
+       
+        {
+          "field": "gender",
+          "width": 85.25,
+          "colspan": 1,
+          "rowspan": 1,
+          "checked": false
+        }, {
+
+          "field": "name",
+          "width": 85.25,
+          "align": "center",
+          "colspan": 4,
+          "rowspan": 2,
+         
+        }, {
+
+          "field": "count",
+          "width": 85.25,
+          "align": "center",
+          "colspan": 1,
+          "rowspan": 1,
+       
+        }, {
+          "width": 85.25,
+          "colspan": 1,
+          "rowspan": 1,
+          "checked": true
+        },
+       { "width": 85.25, "colspan": 1, "rowspan": 1, "checked": true }
+      ]]
+      }, "printElementType": {
+        "title": "表格", "type": "table",
+        editable: true,
+            columnDisplayEditable: true,//列显示是否能编辑
+            columnDisplayIndexEditable: true,//列顺序显示是否能编辑
+            columnTitleEditable: true,//列标题是否能编辑
+            columnResizable: true, //列宽是否能调整
+            columnAlignEditable: true,//列对齐是否调整
+            isEnableEditField: true, //编辑字段
+            isEnableContextMenu: true, //开启右键菜单 默认true
+            isEnableInsertRow: true, //插入行
+            isEnableDeleteRow: true, //删除行
+            isEnableInsertColumn: true, //插入列
+            isEnableDeleteColumn: true, //删除列
+            isEnableMergeCell: true, //合并单元格
+      }
+    }
+      , {
+      "options": {
+        "left": 40,
+        "top": 360,
+        "height": 13,
+        "width": 218,
+        "fontSize": 13,
+        "title": "打印",
+        "fontFamily": '黑体',
+        "field": "takerName",
+        "testData": "",
+        "color": "#000",
+        "textAlign": "left"
+      }, "printElementType": { "title": "", "type": "text" }
+    }],
+    "paperNumberDisabled": true
+  }]
+}
+
+
+
+
+// {
+//   "options": {"left": 23, "top": 80, "height": 10, "width": 633},
+//   "printElementType": {"title": "", "type": "hline"}
+// },
+// {
+//   "options": {"left": 23, "top": 80+62.5, "height": 10, "width": 633},
+//   "printElementType": {"title": "", "type": "hline"}
+// },
+// {
+//   "options": {"left": 23, "top": 80+(62.5*2), "height": 10, "width": 633},
+//   "printElementType": {"title": "", "type": "hline"}
+// },
+// {
+//   "options": {"left": 23, "top":80+(62.5*3), "height": 10, "width": 633},
+//   "printElementType": {"title": "", "type": "hline"}
+// },
+// {
+//   "options": {"left": 23, "top": 80, "height": 250, "width": 10},
+//   "printElementType": {"title": "", "type": "vline"}
+// },
+// {
+//   "options": {"left": 23+105.5, "top": 80, "height": 250, "width": 10},
+//   "printElementType": {"title": "", "type": "vline"}
+// },
+// {
+//   "options": {"left": 23+(105.5*2), "top": 80, "height": 250, "width": 10},
+//   "printElementType": {"title": "", "type": "vline"}
+// },
+// {
+//   "options": {"left": 23+(105.5*3), "top": 80, "height": 250, "width": 10},
+//   "printElementType": {"title": "", "type": "vline"}
+// },
+// {
+//   "options": {"left": 23+(105.5*4), "top": 80, "height": 250, "width": 10},
+//   "printElementType": {"title": "", "type": "vline"}
+// },
+// {
+//   "options": {"left": 23+(105.5*5), "top": 80, "height": 250, "width": 10},
+//   "printElementType": {"title": "", "type": "vline"}
+// },
+// {
+//   "options": {"left": 23, "top": 330, "height": 10, "width": 633},
+//   "printElementType": {"title": "", "type": "hline"}
+// },
+// {
+//   "options": {"left": 656, "top": 80, "height": 250, "width": 10},
+//   "printElementType": {"title": "", "type": "vline"}
+// },

+ 219 - 0
src/views/finance/components/design/preview.vue

@@ -0,0 +1,219 @@
+<template>
+  <el-dialog :visible.sync="visible" :show-close="false" :maskClosable="false" :close-on-click-modal="false"
+    @cancel="hideModal" :width="350 + 'mm'">
+    <div :spinning="spinning" style="min-height: 100px">
+      <div id="preview_content" ref="printDom">
+
+      </div>
+    </div>
+    <template slot="title">
+      <div>
+        <!-- <div style="margin-right: 20px">打印预览</div> -->
+        <el-button :loading="waitShowPrinter" type="primary" icon="printer" @click.stop="print">打印</el-button>
+        <!-- <el-button type="primary" icon="printer" @click.stop="toPdf">pdf</el-button> -->
+      </div>
+    </template>
+    <template slot="footer">
+      <el-button key="close" type="info" @click="hideModal">
+        关闭
+      </el-button>
+    </template>
+  </el-dialog>
+</template>
+
+<script>
+// import { downloadPDF } from '@/utils/pdf'
+import { addPrint } from './print-data'
+import { detailArr } from './print-data'
+export default {
+  name: "printPreview",
+  props: {},
+  data() {
+    return {
+      visible: false,
+      spinning: true,
+      waitShowPrinter: false,
+      // 纸张宽 mm
+      width: 0,
+      // 模板
+      hiprintTemplate: {},
+      // 数据
+      printData: {}
+    }
+  },
+  computed: {},
+  watch: {},
+  created() {
+  },
+  mounted() {
+  },
+  methods: {
+    // handleExport() {
+    //   downloadPDF(this.$refs.printDom);
+    // },
+    hideModal() {
+      this.visible = false
+      this.waitShowPrinter = false
+      this.$parent.initPrint()
+      // console.log(this.$parent);
+    },
+    show(hiprintTemplate, printData, width = '210') {
+      this.visible = true
+      this.spinning = true
+      this.width = width
+      this.hiprintTemplate = hiprintTemplate
+      this.printData = printData
+      setTimeout(() => {
+        // eslint-disable-next-line no-undef
+        $('#preview_content').html(hiprintTemplate.getHtml(printData))
+        this.spinning = false
+      }, 500)
+    },
+    print() {
+       
+      this.hiprintTemplate.print(this.printData, {}, {
+        callback: () => {
+          addPrint()
+          this.hiprintTemplate = {}
+          this.$parent.getList()
+          this.$parent.tableSelection =[]
+        }
+      })
+      this.hiprintTemplate.on('printSuccess', function (data) {
+        console.log('打印完成')
+          //  addPrint()
+          this.hiprintTemplate = {}
+          this.$parent.getList()
+          this.$parent.tableSelection =[]
+      })
+      // this.hiprintTemplate.on('printError', function (data) {
+      //   console.log('打印失败')
+      //   this.hiprintTemplate = {}
+      //     this.$parent.getList()
+      //     this.$parent.tableSelection =[]
+      // })
+      setTimeout(()=>{
+        this.hideModal()
+      },2000)
+    },
+    // toPdf() {
+    //   downloadPDF(this.$refs.printDom);
+    //   this.hiprintTemplate.toPdf({}, '打印预览');
+    // },
+  }
+}
+
+</script>
+
+<style scoped>
+::v-deep .el-dialog__body {
+  padding: 0;
+}
+
+
+::v-deep tr {
+  height: 40px !important;
+}
+
+::v-deep .hiprint-printPaper {
+  margin: 0 auto;
+}
+
+/* ::v-deep tr td {
+  border: 0 !important;
+
+} */
+
+::v-deep .hiprint-paperNumber {
+  display: none;
+}
+
+.ant-modal-body {
+  padding: 0px;
+}
+
+.ant-modal-content {
+  margin-bottom: 24px;
+
+}
+
+@media print {
+   
+/*    
+  td {
+    border: none !important;
+  } */
+
+  .drag_item_box {
+    height: 100%;
+    padding: 6px;
+  }
+
+  .drag_item_box>div {
+    height: 100%;
+    width: 100%;
+    background-color: #fff;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+  }
+
+  .drag_item_box>div>a {
+    text-align: center;
+    text-decoration-line: none;
+  }
+
+  .drag_item_box>div>a>span {
+    font-size: 28px;
+  }
+
+  .drag_item_box>div>a>p {
+    margin: 0;
+  }
+
+  .drag_item_title {
+    font-size: 16px;
+    padding: 12px 6px 0 6px;
+    font-weight: bold;
+  }
+
+
+  .card-design {
+    overflow: hidden;
+    overflow-x: auto;
+    overflow-y: auto;
+  }
+
+  ::v-deep .el-dialog__body {
+    padding: 0;
+  }
+
+  ::v-deep table {
+    height: 240px !important;
+  }
+
+  ::v-deep tr {
+    height: 40px !important;
+  }
+
+  ::v-deep .hiprint-printPaper {
+    margin: 0 auto;
+  }
+
+  ::v-deep tr td {
+    border: 0 !important;
+    /* width: 911px !important;
+    height: 529px !important; */
+  }
+
+
+  .ant-modal-body {
+    padding: 0px;
+  }
+
+  .ant-modal-content {
+    margin-bottom: 24px;
+
+  }
+}
+</style>

+ 171 - 0
src/views/finance/components/design/print-data.js

@@ -0,0 +1,171 @@
+import { getK3ReceiptDetail } from "@/api/finance/receipt_list";
+
+import { addPrints } from '@/api/supply/pickup'
+import { getCompanyList } from '@/api/user'
+let detailArr = []
+let detailData = []
+let cids = []
+let company = ''
+// 获取详情
+getCompanyLists()
+function getDetail(ids, nickName) {
+
+  let invoicePickBeans = []
+  let start = 0
+  let end = 5
+  detailArr = []
+  const table = []
+  // detailData = ids 
+  let newIds = []
+  newIds = ids
+  cids = JSON.parse(JSON.stringify(ids))
+  let filterId = []
+  if (newIds instanceof Array) {
+    filterId = newIds.map(k => {
+      return k.id
+    })
+  } else {
+    filterId = [newIds]
+  }
+  filterId = [...new Set(filterId)]
+  for (let i = 0; i < filterId.length; i++) {
+    getK3ReceiptDetail({ id: filterId[i] }).then(res => {
+      const item = res.data
+      console.log(item, '887899');
+
+      table.push({
+        billNo:item.billNo,
+        theTime:item.theTime,
+        walletName:item.walletName,
+        customerName:item.customerName,
+        remark:item.remark,
+        amount:item.amount,
+        nowDate: nowDate(),
+      })
+      detailArr.push({
+        company:`${company}其他收款单`,
+        table: [
+          {id: '1', name: '王小可', gender: '单据编号', count: '120', amount: '9089元'},
+          {id: '2', name: '梦之遥', gender: '付款单位', count: '20', amount: '89元'},
+          {id: '3', name: '梦之遥', gender: '钱包', count: '720', amount: '29089元'},
+          {id: '3', name: '梦之遥', gender: '备注', count: '720', amount: '29089元'},
+        ]
+      })
+
+      return
+      detailData.push(JSON.parse(JSON.stringify(item)))
+      invoicePickBeans = item.invoicePickBeans
+      let len = Math.ceil(invoicePickBeans.length / 5)
+      console.log(len, '长度');
+      for (let index = 0; index < len; index++) {
+        const table = []
+        if (invoicePickBeans.length) {
+          invoicePickBeans.splice(0, 5).forEach(e => {
+            table.push({
+              salesId: e.salesOrderId,
+              invoiceId: e.invoiceId,
+              id: e.id,
+              createTime: e.id ? dateToDayFilter(item.createTime) : '',
+              enginOrderType: e.enginOrderType == 'HOME' || e.enginOrderType == 'TRADE' ? e.enginOrderNo : e.mainOrderId,
+              materialName: e.materialName || '',
+              specification: e.specification || '',
+              refundableQty: e.refundableQty || 0,
+              // headerRemark:e.headerRemark,
+              pjxh1Text: e.pjxh1Text || ''
+            })
+
+          });
+        }
+        detailArr.push({
+          pageNumber: `${len}-${index + 1}`,
+          type: item.type,
+          tiTui: item.type === 2 ? `退货人` : `提货人`,
+          takerPhone: item.takerPhone || '',
+          headerRemark: item.remark,
+          total_num: item.total_num,
+          company: item.type === 2 ? `${company}销售退货单` : `${company}销售发货单`,
+          pickOrderWater: item.pickOrderWater,
+          customerNumber: item.customerNumber,
+          takerDa: '',
+          nowDate: nowDate(),
+          takerName: item.type === 2 ? `退货人:${item.takerName || ''}` : `提货人:${item.takerName || ''}`,
+          customerName: item.customerName || '',
+          correspondName: item.correspondName,
+          correspondNames: '',
+          pickCar: item.pickCar || '',
+          createBy: JSON.parse(
+            localStorage.getItem("supply_user")
+          ).nickName,
+          table
+        })
+      }
+    })
+  }
+}
+
+function nowDate() {
+  var date = new Date();
+  var seperator1 = "-";
+  var year = date.getFullYear();
+  var month = date.getMonth() + 1;
+  var strDate = date.getDate();
+  if (month >= 1 && month <= 9) {
+    month = "0" + month;
+  }
+  if (strDate >= 0 && strDate <= 9) {
+    strDate = "0" + strDate;
+  }
+  var currentdate = year + seperator1 + month + seperator1 + strDate;
+  console.log(currentdate);
+  return currentdate;
+}
+
+function dateToDayFilter(date) {
+  if (!date) { return '' }
+  return date.slice(0, 10)
+}
+
+function getCompanyLists() {
+  getCompanyList().then(res => {
+    company = res.data ? res.data[0].companyName : ''
+  })
+  return company
+}
+
+// 添加次数
+function addPrint() {
+  let ids = []
+  detailData.map(item => {
+    console.log(detailData, '3223');
+    if (item.invoicePickBeans && item.invoicePickBeans.length) {
+      for (let index = 0; index < item.invoicePickBeans.length; index++) {
+        const element = item.invoicePickBeans[index];
+        console.log(element.id, 'element.id ');
+        // return  element.id 
+        ids.push(element.id)
+      }
+    } else {
+      // console.log(item.invoiceOrderId ,'item.invoiceOrderId ');
+      return item.invoiceOrderId || item.id
+    }
+
+  })
+
+  // console.log(document.execCommand('print'),'4545');
+  addPrints({ ids: ids.join(',') }).then(res => {
+    console.log('chenggong ');
+    // this.$successMsg('提交成功');
+    // this.$parent.getList()
+
+  })
+}
+
+
+
+
+
+export {
+  getDetail, getCompanyLists,
+  detailArr,
+  addPrint
+}

+ 135 - 12
src/views/finance/receipt_list.vue

@@ -51,13 +51,15 @@
             </el-col> -->
             <el-col :xs="24" :sm="12" :lg="6">
               <el-form-item label="开始时间" prop="startTime">
-                <el-date-picker class="selectStyle" v-model="searchForm.startTime" type="datetime" placeholder="选择日期时间" default-time="00:00:00" value-format="yyyy-MM-dd HH:mm:ss">
+                <el-date-picker class="selectStyle" v-model="searchForm.startTime" type="datetime" placeholder="选择日期时间"
+                  default-time="00:00:00" value-format="yyyy-MM-dd HH:mm:ss">
                 </el-date-picker>
               </el-form-item>
             </el-col>
             <el-col :xs="24" :sm="12" :lg="6">
               <el-form-item label="结束时间" prop="endTime">
-                <el-date-picker class="selectStyle" v-model="searchForm.endTime" type="datetime" placeholder="选择日期时间" default-time="00:00:00" value-format="yyyy-MM-dd HH:mm:ss">
+                <el-date-picker class="selectStyle" v-model="searchForm.endTime" type="datetime" placeholder="选择日期时间"
+                  default-time="00:00:00" value-format="yyyy-MM-dd HH:mm:ss">
                 </el-date-picker>
               </el-form-item>
             </el-col>
@@ -74,18 +76,20 @@
       <!-- 按钮 -->
       <div class="btn-group clearfix">
         <div class="fl">
-          <!-- <el-button type="primary" size="mini" @click="toPrint" :disabled="tableSelection.length < 1">打印发货单 -->
-          <!-- </el-button> -->
+          <el-button type="primary" size="mini" @click="toPrint" :disabled="tableSelection.length < 1">打印发货单
+          </el-button>
         </div>
         <div class="fr">
 
-          <ExportButton :exUrl="'/k3/receipt/export'" :exParams="exParams" class="exportClass" />
+          <!-- <ExportButton :exUrl="'/k3/receipt/export'" :exParams="exParams" class="exportClass" /> -->
         </div>
       </div>
       <!-- 列表 -->
       <div class="mymain-container">
         <div class="table">
-          <el-table ref="table" v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe show-summary :summary-method="getSummaries" @select="handleSelect" @select-all="handleSelectAll">
+          <el-table ref="table" v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit
+            highlight-current-row stripe show-summary :summary-method="getSummaries" @select="handleSelect"
+            @select-all="handleSelectAll">
             <el-table-column align="center" type="selection" width="55"></el-table-column>
 
             <el-table-column align="left" label="单据类型" prop="billType" min-width="160" show-overflow-tooltip>
@@ -178,25 +182,34 @@
                   scope.row.status == 'C'
                 " @click="NoExamineFn(scope.row.id)">弃审</el-button>
                 <el-button type="text" class="textColor" @click="seeFn(scope.row.id)">查看</el-button>
-                <!-- <el-button type="text" class="textColor" @click="toPrint(scope.row)">打印</el-button> -->
-
+                <!-- <el-button type="text" class="textColor" @click="toPrint(scope.row, 2)">打印</el-button> -->
               </template>
             </el-table-column>
           </el-table>
         </div>
         <!-- 分页 -->
         <div class="fr">
-          <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[10, 20, 30, 50]" :page-size="10" layout="total, sizes, prev, pager, next, jumper" :total="listTotal">
+          <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
+            :current-page="currentPage" :page-sizes="[10, 20, 30, 50]" :page-size="10"
+            layout="total, sizes, prev, pager, next, jumper" :total="listTotal">
           </el-pagination>
         </div>
       </div>
     </div>
+    
     <ReceiptPrint :listItem="queryItem" v-else-if="showDetail == 2" @backListFormDetail="backList" />
     <ReceiptListDetail :detailId="detailId" v-else />
+    <print-preview ref="preView" />
+
   </div>
 </template>
 
 <script>
+import { disAutoConnect, hiprint, defaultElementTypeProvider } from 'vue-plugin-hiprint'
+disAutoConnect();
+import panel from './components/design/panel'
+import { getDetail, detailArr } from './components/design/print-data'
+import printPreview from './components/design/preview.vue'
 import { getCustomerList } from "@/api/finance/wallet";
 import {
   getK3ReceiptList,
@@ -210,6 +223,7 @@ export default {
   components: {
     ReceiptPrint,
     ReceiptListDetail,
+    printPreview
   },
   data() {
     return {
@@ -232,6 +246,41 @@ export default {
       detailId: null,
       queryItem: {},
       tableSelection: [],
+      curPaper: {
+        type: 'A5',
+        width: 500,
+        height: 147.6
+      },
+      paperTypes: {
+        'A3': {
+          width: 420,
+          height: 296.6
+        },
+        'A4': {
+          width: 210,
+          height: 296.6
+        },
+        'A5': {
+          width: 210,
+          height: 147.6
+        },
+        'B3': {
+          width: 500,
+          height: 352.6
+        },
+        'B4': {
+          width: 250,
+          height: 352.6
+        },
+        'B5': {
+          width: 250,
+          height: 175.6
+        }
+      },
+      scaleValue: 1,
+      scaleMax: 5,
+      scaleMin: 0.5,
+      hiprintTemplate: '',
     };
   },
   computed: {
@@ -240,11 +289,26 @@ export default {
         ...this.searchForm,
       };
     },
+    curPaperType() {
+      let type = 'other'
+      let types = this.paperTypes
+      for (const key in types) {
+        let item = types[key]
+        let { width, height } = this.curPaper
+        if (item.width === width && item.height === height) {
+          type = key
+        }
+      }
+      return type
+    }
   },
   created() {
     this.getDataList({ pageSize: this.pageSize, pageNum: this.currentPage });
     this.getCustomerDataList();
   },
+  mounted() {
+    this.initPrint()
+  },
   methods: {
     //获取经销商列表
     async getCustomerDataList() {
@@ -254,6 +318,40 @@ export default {
       });
       this.customerList = res.data.records;
     },
+    initPrint() {
+      hiprint.init({
+        providers: [new defaultElementTypeProvider()]
+      });
+      // 还原配置
+      hiprint.setConfig()
+      // 替换配置
+      hiprint.setConfig({
+        movingDistance: 2.5,
+        text: {
+          supportOptions: [
+            {
+              name: 'styler',
+              hidden: true
+            },
+            {
+              name: 'formatter',
+              hidden: true
+            },
+          ]
+        }
+      })
+      // eslint-disable-next-line no-undef
+      hiprint.PrintElementTypeManager.buildByHtml($('.ep-draggable-item'));
+      this.hiprintTemplate = new hiprint.PrintTemplate({
+        template: panel,
+        settingContainer: '#PrintElementOptionSetting',
+        paginationContainer: '.hiprint-printPagination'
+      });
+      this.hiprintTemplate.design('#hiprint-printTemplate');
+      // 获取当前放大比例, 当zoom时传true 才会有
+      // this.scaleValue = hiprintTemplate.editingPanel.scale || 1;
+    }
+    ,
     //合计
     getSummaries(param) {
       const { columns, data } = param;
@@ -348,11 +446,36 @@ export default {
       this.queryItem = {};
       this.isShowPrint = false;
     },
+    /**
+      * 设置纸张大小
+      * @param type [A3, A4, A5, B3, B4, B5, other]
+      * @param value {width,height} mm
+      */
+    setPaper(type, value) {
+      try {
+        if (Object.keys(this.paperTypes).includes(type)) {
+          this.curPaper = { type: type, width: value.width, height: value.height }
+          this.hiprintTemplate.setPaper(value.width, value.height)
+        } else {
+          this.curPaper = { type: 'other', width: value.width, height: value.height }
+          this.hiprintTemplate.setPaper(value.width, value.height)
 
+        }
+      } catch (error) {
+        this.$message.error(`操作失败: ${error}`)
+      }
+    },
     // 点击打印
-    toPrint(row) {
-      this.queryItem = row;
-      this.showDetail = 2;
+    toPrint(row, type) {
+      // this.tableSelection = this.$refs.table.selection;
+      if (!type) {
+        getDetail(this.tableSelection)
+      } else {
+        this.queryItem = row;
+        getDetail(row.id)
+      }
+      this.$refs.preView.show(this.hiprintTemplate, detailArr)
+
     },
   },
 };