<template>
  <div class="tableAllDate">
      <div id="pdfDom">
      <div class="blank">
      </div>
      <div class="title">
        <h1 align="center">{{consigeeName}}</h1>
        <h1 align="center">物资签收单</h1>
      </div>
      <div>
      <!-- tablePart0 -->
        <table border="0" cellpadding="10" cellspacing="0" style="margin: auto;font-size:20px;" width="1000px" class="tablePart0">
        <tr>
          <th style="width :14.5%">销售订单号：</th>
          <td style="width :85.5%">{{saleNo}}</td>
        </tr>
        </table>
      </div>
      <div class="tableBody">
        <!-- tablePart1 -->
        <table border="1" cellpadding="10" cellspacing="0" style="margin-top: 10px;" width="1000px" class="tablePart1">
        <tr>
          <th style="width :5%">序号</th>
          <th style="width :21.5%">物资名称</th>
          <th style="width :21.5%">规格型号</th>
          <th style="width :5%">单位</th>
          <th style="width :14%">件数</th>
          <th style="width :14%">理论重量</th>
          <th style="width :19%">计量重量</th>
        </tr>

        <tr v-for="(item,index) in deliveryOrderMaterialList" :key="index">
          <td>{{index+1}}</td>
          <td>{{item.materialName}}</td>
          <td>{{item.materialSpe}}{{item.materialModel}}</td>
          <td>{{item.measureName}}</td>
          <td>{{item.materialNumber}}</td>
          <td>{{item.materialWeight}}</td>
          <td>{{item.resultWeight}}</td>
        </tr>
        </table>
        <!-- tablePart2 -->
        <table border="1" cellpadding="10" cellspacing="0" style="border-top: 0px" width="1000px" class="tablePart2">
        <tr>
          <th style="width :14%">发货时间</th>
          <td style="width :22%">{{sendDate}}</td>
          <th style="width :14%">收货地点</th>
          <td style="width :50%">{{province}}{{district}}{{town}}{{deliveryAddress}}</td>
        </tr>
        </table>
        <!-- tablePart3 -->
        <table border="1" cellpadding="10" cellspacing="0" style="border-top: 0px" width="1000px" class="tablePart3">
        <tr>
          <th style="width :10.5%">收货人</th>
          <td style="width :20%">{{consignee}}</td>
          <th style="width :10.5%">电话</th>
          <td style="width :26%">{{consigneeTel}}</td>
          <th style="width :14%">收货日期</th>
          <td style="width :19%">{{receiptDate}}</td>
        </tr>
        </table>
        <!-- tablePart4 -->
        <table border="1" cellpadding="10" cellspacing="0" style="border-top: 0px" width="1000px" class="tablePart4">
        <tr>
          <th style="width :10.5%">承运商</th>
          <td style="width :36.5%">{{carrierName}}</td>
          <th style="width :13%">车牌号</th>
          <td style="width :40%">{{capacityNumber}}</td>
        </tr>
        </table>
      </div>
      <div>
        <!-- tablePart6 -->
        <table border="0" cellpadding="10" cellspacing="0" style="margin: auto;font-size:20px;margin-top: 10px;" width="1000px" class="tablePart6">
        <tr>
          <th style="width :14.5%">发货单位：</th>
          <td style="width :48.5%">{{shippername}}</td>
          <th style="width :15.5%">日期：</th>
          <td style="width :5%">{{year}}</td>
          <th style="width :8%">年</th>
          <td style="width :3%">{{month}}</td>
          <th style="width :8%">月</th>
          <td style="width :3%">{{date}}</td>
          <th style="width :5%">日</th>
        </tr>
        </table>
      </div>
      </div>
      <el-button style="margin-left: 45%;" type="primary" @click="getPdf()">
        <i class="el-icon-download"></i>导出(pdf)
      </el-button>
      <el-button style="margin-left: 45%;margin-top: 0.2%;" type="primary" v-print="'#pdfDom'" @click="backScan()">
        <i class="el-icon-printer"></i>打印
      </el-button>
  </div>
</template>

<script>
import table from '@/components/DilCommonUI/packages/table/src/table.vue';
export default {
  components: { table },
  name: "Login",
  data() {
    return {
    orderNumber: "",
    consignee: "",
    town: "",
    consigneeTel: "",
    sendDate: "",
    receiptDate: "",
    consigeeName: "",
    saleNo: "",
    deliveryOrderMaterialList: [
        {
            materialName: "",
            materialSpe: "",
            materialModel: "",
            materialNumber: 0,
            materialWeight: 0,
            measureName:"",
            resultWeight:""
        }
    ],
    carrierName: "",
    province: "",
    deliveryAddress: "",
    district: "",
    capacityNumber: "",
    shippername: "",
    year: new Date().getFullYear(),
    month: new Date().getMonth()+1,
    date: new Date().getDate(),
    htmlTitle: '客户换票签收单'
    };
  },
  created(){
      this.getDeliveryOrder();
  },
  methods: {
      getDeliveryOrder(){
        let orderNumber = this.$route.query.orderNumber;
       this.axios.post("/api/v1/tms/getDeliveryOrder?orderNumber="+orderNumber).then((res) => {
         this.orderNumber = res.data.orderNumber;
         this.carrierName = res.data.carrierName;
         this.capacityNumber = res.data.capacityNumber;
         this.consigeeName = res.data.consigeeName;
         this.consignee = res.data.consignee;
         this.consigneeTel = res.data.consigneeTel;
         this.sendDate = res.data.sendDate;
         this.receiptDate = res.data.receiptDate.slice(0,10);
         this.saleNo = res.data.saleNo;
         this.shippername = res.data.shippername;
         this.province = res.data.province;
         this.district = res.data.district;
         this.town = res.data.town;
         this.deliveryAddress = res.data.deliveryAddress;
         this.deliveryOrderMaterialList = res.data.deliveryOrderMaterialList;
        });
      },
      backScan(){
        this.$router.go(-2);
      }
  },
};
</script>

<style lang="scss" scoped>
.title{
  font-size:25px;
}
.tableBody{
  table, th, td
  {
      border: 1px solid black;
      font-size:20px;
      margin: auto;
  }
  .tablePart1 th{
      border-top: 1px solid black;
  }
  .tablePart2 td,th{
    border-top: 0px
  }
  .tablePart3 td,th{
    border-top: 0px
  }
  .tablePart4 td,th{
    border-top: 0px
  }
}
.blank{
  width: 100%;
  height: 50px;
}
</style>
