<template>
  <!-- 发货打印 -->
  <div id="sendGood-print" style="height:0;overflow: hidden;" v-if="detail">
    <div class="print-box" style="width: 574pt;font-size: 12pt;">
      <div style="display: flex;align-items: center;justify-content: center;">
        <img src="@/assets/logo.png" height="50px"/>
        <h1 style="margin:0;">东莞市箭冠汽车配件制造有限公司</h1>
      </div>
      <div style="text-align: center;padding: 5px 0;position: relative;">
        <h2 style="margin:0;">托运单</h2>
        <span style="position: absolute;top: 10px;right: 0;">No:{{ detail.sendBillNo }}</span>
      </div>
      <div style="display: flex;align-items: center;justify-content:space-between;padding: 5px;">
        <span style="width: 70%;">托运日期：{{ detail.sendDate }}</span>
        <span style="width: 30%;word-break:break-all;">目的地：{{ detail.customerAddress }}</span>
      </div>
      <div>
        <div style="border: 1px solid #000;border-bottom:0;">
          <div style="border-bottom: 1px solid #000;display: flex;align-items: center;justify-content:space-between;">
            <span style="width: 60%;border-right: 1px solid #000;padding: 5px;">收货人：{{ detail.customerCacateName }}</span>
            <span style="width: 40%;padding: 5px;">电话：{{ detail.customerCacatePhone }}</span>
          </div>
          <div style="padding: 5px;word-break:break-all;">
            <span>详细地址：{{ detail.customerAddressDetail }}</span>
          </div>
        </div>
        <table border="1" style="width: 574pt;border-collapse: collapse;text-align: center;border-color:#000;">
          <tr style="padding: 0;">
            <td style="padding: 5px 0;width:70pt;">货物名称</td>
            <td style="padding: 0;width:56pt;">件数</td>
            <td style="padding: 0;width:56pt;">体积（m³）</td>
            <td style="padding: 0;width:56pt;">重量（kg）</td>
            <td style="padding: 0;width:56pt;">计费单价（元）</td>
            <td style="padding: 0;width:55pt;">运费（元）</td>
            <td style="padding: 0;width:55pt;">保价（万）</td>
            <td style="padding: 0;width:55pt;">送货费</td>
            <td style="padding: 0;width:60pt;">其他</td>
            <td style="padding: 0;width:60pt;">合计</td>
          </tr>
          <tr style="padding: 0;" v-for="item in detail.detailList" :key="item.id">
            <td style="padding: 5px 0;width:70pt;">{{ item.goodsName }}</td>
            <td style="padding: 0;width:56pt;">{{ item.goodsQty }}</td>
            <td style="padding: 0;width:56pt;">{{ item.goodsVolume.toFixed(2) }}</td>
            <td style="padding: 0;width:56pt;">{{ item.goodsWeight.toFixed(2) }}</td>
            <td style="padding: 0;width:56pt;">{{ item.unitPrice.toFixed(2) }}</td>
            <td style="padding: 0;width:55pt;">{{ item.transportAmount.toFixed(2) }}</td>
            <td style="padding: 0;width:55pt;">{{ item.supportValue.toFixed(2) }}</td>
            <td style="padding: 0;width:55pt;">{{ item.sendAmount.toFixed(2) }}</td>
            <td style="padding: 0;width:60pt;">{{ item.otherAmount.toFixed(2) }}</td>
            <td style="padding: 0;width:60pt;">{{ item.totalAmount.toFixed(2) }}</td>
          </tr>
        </table>
        <div style="border: 1px solid #000;border-top:0;">
          <div style="border-bottom: 1px solid #000;display: flex;align-items: center;justify-content:space-between;">
            <div style="width: 78%;border-right: 1px solid #000;padding: 4pt;">费用合计(大写)：{{ dealBigMoney(detail.totalSendAmount.toFixed(2)) }}</div>
            <div style="width:22%;padding: 4pt;">￥：{{ detail.totalSendAmount.toFixed(2) }}</div>
          </div>
          <div style="border-bottom: 1px solid #000;display: flex;align-items: center;justify-content:space-between;">
            <div style="border-right: 1px solid #000;flex:1;text-align: center;padding: 5px;">付款方式：</div>
            <div style="border-right: 1px solid #000;flex:2;padding: 5px;text-align:center;">{{ detail.payTypeDictValue }}</div>
            <div style="border-right: 1px solid #000;flex:1;text-align: center;padding: 5px;">交货方式：</div>
            <div style="flex:2;padding: 5px;text-align:center;">{{ detail.handoverTypeDictValue }}</div>
          </div>
          <div style="border-bottom: 1px solid #000;display: flex;align-items: center;justify-content:space-between;">
            <div style="border-right: 1px solid #000;flex:1;padding: 8px 5px;">发货人签字：</div>
            <div style="flex:1;padding: 8px 5px;">承运人签字：</div>
          </div>
          <div style="border-bottom: 1px solid #000;display: flex;align-items: center;justify-content:space-between;">
            <div style="width: 8%;border-right: 1px solid #000;padding: 5px;">备注：</div>
            <div style="width: 92%;padding: 5px;">{{ detail.sendRemark }}</div>
          </div>
          <div style="display: flex;align-items: center;justify-content:space-between;">
            <div style="width: 30px;text-align: center;">注意事项</div>
            <div style="flex: 1;padding: 5px;border-left: 1px solid #000;">
              <ol style="margin: 0;padding-left: 30px;">
                <li>承运人需按合同规定时间内把货物送达客户所在区域(不得超出十公里).</li>
                <li>送货上门的货物,到达目的地后需提前和收货人联系并确定送货时间.</li>
                <li>货物必需完整的交接给收货人,并让收货人在物流单上签字并上传回单.</li>
                <li>如果发生货物丢失以及其它原因损坏需按价赔偿给客户.</li>
              </ol>
            </div>
          </div>
        </div>
        <div style="display: flex;align-items: center;justify-content:space-between;padding: 5px;">
          <div>东莞市箭冠汽车配件制造有限公司</div>
          <div>中国.广东.东莞.茶山工业园</div>
          <div>电话:0769-81860196</div>
          <div>传真:0769-81860108</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { jGPrint } from '@/libs/JGPrint.js'
import { dealBigMoney } from '@/libs/tools.js'
export default {
  props: {
    detail: {
      type: Object,
      default: function () {
        return null
      }
    }
  },
  methods: {
    dealBigMoney: dealBigMoney,
    printDom () {
      const html = document.getElementById('sendGood-print').innerHTML
      jGPrint(html, 'preview', function () {}, null, 3)
    }
  }
}
</script>

<style>
</style>
