headerprintDialog.vue 4.69 KB
<template>
  <el-dialog
    title="出库单打印"
    :visible.sync="visible"
    :showheaderprint="showheaderprint"
    width="800px"
    append-to-body
    @close="$emit('update:showheaderprint', false)">
    <div ref="print">
        <el-header style="height:40px;line-height: 30px">
          发货单
        </el-header>
        <el-aside style="padding-bottom: 5px">发货单号:{{code}}</el-aside>
        <el-main>
          <el-header>
            <el-row :gutter="24" class="dyBHeader">
              <el-col :span="8" style="text-align: left;font-size: 13px">{{ parseTime(printDate) }}</el-col>
              <el-col :span="8" style="font-size: 24px">出库单</el-col>
              <el-col :span="8" style="text-align: right;">
                <qrcode-vue :value="code" size="60" level="H" renderAs="svg"></qrcode-vue>
              </el-col>
            </el-row>
            <el-row :gutter="24">
              <el-col :span="12" style="text-align: left;font-size: 13px">客户名称:{{customerCode}}</el-col>
              <el-col :span="12" style="text-align: right;font-size: 13px;">
                <span>明细条数:{{DetailList.length}}</span>
                <span style="padding-left: 20px">明细总数:{{billTotal}}</span>
                <el-button size="mini"
                           type="info" plain
                           icon="el-icon-printer"
                           @click="print"
                           class="no-print">打印</el-button>
              </el-col>
            </el-row>
          </el-header>
          <el-table :data="DetailList" border :cell-style="tableCellStyle" :header-cell-style="tableHeaderCellStyle">
            <el-table-column prop="materialCode" align="center" label="物料编码" width="110"></el-table-column>
            <el-table-column prop="materialName" align="center" label="物料名称" width="200"></el-table-column>
            <el-table-column prop="batch" align="center" label="批次"></el-table-column>
            <el-table-column prop="lot" align="center" label="批号"></el-table-column>
            <el-table-column prop="projectNo" align="center" label="项目号"></el-table-column>
            <el-table-column prop="shipQty" align="center" label="数量" width="55"></el-table-column>
            <el-table-column prop="materialCodeUnit" align="left" label="条码">
              <template slot-scope="scope">
                <qrcode-vue :value="scope.row.materialCode" size="60" level="H" renderAs="svg" style="margin-top:5px;"></qrcode-vue>
              </template>
            </el-table-column>
          </el-table>
        </el-main>
    </div>
  </el-dialog>
</template>

<script>
  import QrcodeVue from 'qrcode.vue'
  export default {
    components: {
      QrcodeVue,
    },
    props: {
      showheaderprint: {
        type: Boolean,
        default: false
      },
      printlist: {
        type: Array,
      },
      code: {
        type: String
      },
      customerCode: {
        type: String
      },
    },
    data() {
      return {
        printDate: new Date(),
        visible: this.showheaderprint,
        /*code: this.code,
        customerCode: this.customerCode,*/
        DetailList: this.printlist,
      };
    },
    //计算右上角总单据数量、已出库数量
    computed:{
      billTotal:function () {
        let result = 0
        for(let i=0;i<this.DetailList.length;i++){
          result +=this.DetailList[i].shipQty
        }
        return result
      }
    },
    watch: {
      showheaderprint() {
        this.visible = this.showheaderprint;
      },
      printlist() {
        this.DetailList = this.printlist;
      }
    },
    methods: {
      print() {
        this.$print(this.$refs.print);
      },
      // 修改 table cell边框的背景色...
      tableCellStyle () {
        return 'border-color: #868686;'
      },
      // 修改 table header cell的背景色、边框背景色...
      tableHeaderCellStyle () {
        return 'border-color: #868686; color: #606266; background:#fff;font-size:14px'
      },

    },
  };
</script>

<style lang="scss" scoped>
  .el-header {
    color: #333;
    text-align: center;
    line-height: 40px;
    font-size: 16px;
  }
  .dyBHeader{
    border-bottom: 1px solid #333;padding: 10px 0
  }
  .el-main{
    padding: 0;
    border: 1px solid #333;
  }
  aside{padding:5px 0px;line-height:21px;background: none;margin-bottom: 0px; font-size: 13px}
  .el-table--border, .el-table--group {
     border-top: 1px solid #333;
  }

  .no-print {
    margin-top: 5px;
    margin-left: 10px
  }
  .ad-sheet {
    font-size: 22px;
  }
  @media print{
    .el-table{ width: 99.9%}
    .dys{
      padding: 10px 0;
    }
    .dyBHeader{
      padding: 20px 0;
    }
  }
</style>