printOutsource.vue 5.67 KB
<template>
  <div class="container" style=" width:600px;/*height:228px;*/color: #333">

    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
          <a-col :md="12" :sm="8">
            <a-form-item label="生产令号" :labelCol="{span: 6}" :wrapperCol="{span: 14, offset: 1}">
              <a-input placeholder="请输入生产令号" v-model="querySource.orderno"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="12" :sm="8">
            <a-form-item label="项目名称" :labelCol="{span: 6}" :wrapperCol="{span: 14, offset: 1}">
              <a-input placeholder="请输入项目名称" v-model="querySource.projectname"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="12" :sm="8">
            <a-form-item label="物料名称" :labelCol="{span: 6}" :wrapperCol="{span: 14, offset: 1}">
              <a-input placeholder="请输入物料名称" v-model="querySource.partno"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="12" :sm="8">
            <a-form-item label="物料名称" :labelCol="{span: 6}" :wrapperCol="{span: 14, offset: 1}">
              <a-input placeholder="请输入部件名称" v-model="querySource.name"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="18" :lg="11" :md="18" :sm="24">
            <a-form-item label="完成日期">
              <j-date placeholder="请选择开始日期" class="query-group-cust" v-model="querySource.createBy"></j-date>
              <span class="query-group-split-cust"></span>
              <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="querySource.updateBy"></j-date>
            </a-form-item>
          </a-col>
          <a-col :md="12" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="search" icon="search">查询</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <div class="noprint container" style="text-align:right; padding: 20px;float: right">
      <a-button v-print="'#printContent'" ghost type="primary">打印</a-button>
    </div>

    <div class="row" id="printContent" >

      <table width="100%" border="0" cellspacing="0" cellpadding="0"
             v-for="source in  dataSource">
        <caption style="font-size:22px;text-align:center; color:#333; padding-bottom: 3px;"></caption>
        <tbody>
        <tr >
          <td  scope="col" style="font-size:12px;font-weight:bold" >生产令号:{{source.orderno}}</td>
        </tr>
        <tr >
          <td  scope="col"  width="100%" style="font-size:12px;font-weight:bold" >物料图号:{{source.partno}}  </td>
          <td   rowspan="4" style="padding: 1px">
            <!--<img class="" align="center" valign="middle" style="vertical-align:middle; padding:2px;"/>-->
            <!--<span class="qrcode"></span>-->
<!--            <div id="qrcode" ></div>-->
            <vue-qr  :text="source.userDef1" :size="70" :margin="0"></vue-qr>
          </td>
        </tr>
        <tr >
          <td scope="col" style="font-size:12px;font-weight:bold" >部件名称:{{source.name}}</td>
        </tr>
        <tr >
          <td scope="col" style="font-size:12px;font-weight:bold" >数量:{{source.qty}}</td>
        </tr>
        <tr >
          <td scope="col" style="font-size:12px;font-weight:bold">单位:{{source.unit}}</td>
        </tr>
        </tbody>
      </table>
    </div>
  </div>
</template>

<script>
import { getOutsourcingPrintDetail, getOutsourcingPrint } from '../../api/api'
import QRCode from 'qrcodejs2'  // 引入qrcode
// import QrcodeVue from 'qrcode.vue'
import VueQr from 'vue-qr'


export default {
  name: 'printScheduler',
  components: {
    QRCode,
    VueQr,
    // QrcodeVue,
  },
  data() {
    return {
      querySource:{},
      dataSource:[],
      downloadData: {
        url: '扫码访问的链接地址',
        icon: '随便一张图片的地址也行'
      },
      value: '',
      size: 300,
    }
  },
  methods:{
    print(){
      var print= document.getElementById('printContent');
      var newContent = print.innerHTML;
      var oldContent = document.body.innerHTML;
      // this.$nextTick (function () {
      //   this.qrcode();
      // });
      document.body.innerHTML = newContent;
      // 获取要打印的dom内容
      // let  newDomHtml =  this.$refs.printContent.innerHTML;
      // // 将要打印的内容赋值给本页
      // window.document.body.innerHTML= newDomHtml ;
      // 调用window的打印
      window.print();
      // 解决打印之后按钮失效的问题,刷新页面
      window.location.reload();
      return false;
    },
    // qrcode() {
    //   setTimeout(function() {
    //     let qrcode = new QRCode('qrcode', {
    //       width: 25,
    //       height: 25,
    //       text: 'https://www.baidu.com', // 二维码地址
    //     })
    //   },500)
    // },
    loadData(id){
      getOutsourcingPrint(id).then((res) => {

          this.dataSource = res;
          this.querySource.headerId = id;
        // this.qrcode();
      })
    },

    search() {
      getOutsourcingPrintDetail(this.querySource).then((res) => {
        console.log(res);
        this.dataSource = res;
        // this.qrcode();
      })
    }
  },

  mounted:function() {
    console.log("123456");
    let id = this.$route.query.id;
    console.log(id);
    this.loadData(id);
  },


}
</script>

<style type="text/css">
@media print {
  .noprint {
    display: none;
  }
}
</style>

<style scoped>
* {
  color: #000000!important;
  -webkit-tap-highlight-color: #000000!important;
}
</style>