headerprintDialog.vue 2.9 KB
<template>
  <el-dialog
    title="入库单打印"
    :visible.sync="visible"
    :showheaderprint="showheaderprint"
    width="800px"
    append-to-body
    @close="$emit('update:showheaderprint', false)">
    <div ref="print">
     <el-row>
      <el-col :span="10"><div>{{parseTime(printDate)}}</div></el-col>
      <el-col :span="4" style="font-size: 24px"><div class="ad-sheet">入库单</div></el-col>
      <el-col :span="10">
        <div class="qrcode" ref="qrCodeUrl"></div>
        入库二维码
      </el-col>
     </el-row>
     <el-row :gutter="24">
      <el-col :span="20" style="text-align: right;font-size: 17px;">
       <span>明细条数:<span></span></span>
       <span style="padding-left: 20px">明细总数:<span></span></span>
      </el-col>
      <el-col class="no-print" :span="4">
       <el-button
         size="mini"
         type="primary"
         icon="el-icon-printer"
         @click="print"
         class="pull-right"
         >打印</el-button>
      </el-col>
     </el-row>
     <el-table :data="DetailList" border :cell-style="tableCellStyle" :header-cell-style="tableHeaderCellStyle">
       <el-table-column prop="materialCode" label="物料编码" align="center"></el-table-column>
       <el-table-column prop="materialName" label="物料名称" align="center"></el-table-column>
       <el-table-column prop="batch" label="批次" align="center"></el-table-column>
       <el-table-column prop="lot" label="批号" align="center"></el-table-column>
       <el-table-column prop="projectNo" label="工程号" align="center"></el-table-column>
       <el-table-column prop="totalQty" label="数量" align="center"></el-table-column>
       <el-table-column prop="materialCode" label="条码" align="center">
       </el-table-column>
     </el-table>
    </div>
  </el-dialog>
</template>

<script>
  import html2canvas from "html2canvas";
  import QRCode from 'qrcodejs2'
  export default {
    props: {
      showheaderprint: {
        type: Boolean,
        default: false
      },
      printlist: {
        type: Array,
      },
    },
    data() {
      return {
        printDate: new Date(),
        visible: this.showheaderprint,
        DetailList: this.printlist,
        isHide:false,
      };
    },
    watch: {
      showheaderprint() {
        this.visible = this.showheaderprint;
      },
      printlist() {
        this.DetailList = this.printlist;
      },
    },
    methods: {
     print() {
       this.$print(this.$refs.print);
     },
     creatQrCode() {
             var qrcode = new QRCode(this.$refs.qrCodeUrl, {
                 text: 'xxxx', // 需要转换为二维码的内容
                 width: 100,
                 height: 100,
                 colorDark: '#000000',
                 colorLight: '#ffffff',
                 correctLevel: QRCode.CorrectLevel.H
             })
         },
    },
    mounted() {
        this.creatQrCode();
    },
  };
</script>

<style>
</style>