<template>
  <p-modal
    :title="null"
    :visible="isvisible"
    width="95%"
    :maskClosable="false"
    :destroyOnClose="true"
    @cancel="isvisible = false"
    :footer="null"
  >
    <a-spin :spinning="spinning">
      <div>
        <p-card title="出库单详情">
          <a-col :span="24">
            <a-col :span="6">
              <a-col :span="8">
                <div class="leftName">货主编号：</div>
              </a-col>
              <a-col :span="16">
                <span class="rightName">
                  {{ detailData.consignorcode }}
                </span>
              </a-col>
            </a-col>
            <a-col :span="6">
              <a-col :span="8"><div class="leftName">货主名称：</div></a-col>
              <a-col :span="16"
                ><span class="rightName">{{ detailData.consignorname }}</span></a-col
              >
            </a-col>
            <a-col :span="6">
              <a-col :span="8"><div class="leftName">单据编号：</div></a-col>
              <a-col :span="16"
                ><span class="rightName">{{ detailData.billno }}</span></a-col
              >
            </a-col>
            <a-col :span="6">
              <a-col :span="8"><div class="leftName">单位名称：</div></a-col>
              <a-col :span="16"
                ><span class="rightName">{{ detailData.shippername }}</span></a-col
              >
            </a-col>
          </a-col>
          <a-col :span="24">
            <a-col :span="6">
              <a-col :span="8"><div class="leftName">配送方向：</div></a-col>
              <a-col :span="16"
                ><span class="rightName">{{ detailData.lineName }}</span></a-col
              >
            </a-col>
            <a-col :span="6">
              <a-col :span="8"><div class="leftName">药检报告数：</div></a-col>
              <a-col :span="16"
                ><span class="rightName">{{ detailData.drugTestNum }}</span></a-col
              >
            </a-col>
            <a-col :span="6">
              <a-col :span="8"><div class="leftName">冷链数：</div></a-col>
              <a-col :span="16"
                ><span class="rightName">{{ detailData.coldChainNum }}</span></a-col
              >
            </a-col>
            <a-col :span="6">
              <a-col :span="8"><div class="leftName">个人清单数：</div></a-col>
              <a-col :span="16"
                ><span class="rightName">{{ detailData.grshFlag || 0 }}</span></a-col
              >
            </a-col>
          </a-col>
          <a-col :span="24">
            <a-col :span="6">
              <a-col :span="8"><div class="leftName">合同数：</div></a-col>
              <a-col :span="16"
                ><span class="rightName">{{ detailData.contractList || 0 }}</span></a-col
              >
            </a-col>
            <a-col :span="6">
              <a-col :span="8"><div class="leftName">单据日期：</div></a-col>
              <a-col :span="16"
                ><span class="rightName">{{ detailData.billdate }}</span></a-col
              >
            </a-col>
            <a-col :span="6">
              <a-col :span="8"><div class="leftName">是否随货同行：</div></a-col>
              <a-col :span="16"
                ><span class="rightName">{{ detailData.isAccompanyInvoice }}</span></a-col
              >
            </a-col>
            <a-col :span="6">
              <a-col :span="8"><div class="leftName">是否打印：</div></a-col>
              <a-col :span="16"
                ><span class="rightName">{{ detailData.printCount }}</span></a-col
              >
            </a-col>
          </a-col>
          <a-col :span="24">
            <a-col :span="2"><div class="leftName">客户备注：</div></a-col>
            <a-col :span="16"
              ><span class="rightName">{{ detailData.remark }}</span></a-col
            >
          </a-col>
          <p-table
            ref="table"
            :scroll="{ x: true }"
            row-key="lineId"
            style="margin-top: 140px"
            :bordered="true"
            auto-width
            :columns="tableColumns"
            :dataSource="detailDataList"
          >
          </p-table>
        </p-card>
      </div>
    </a-spin>
  </p-modal>
</template>

<script>
import { postline } from '../../../buyQuit/api/api'
const columns = [
  { dataIndex: 'mergenumber', title: '拼箱号', key: 'mergenumber', width: 150 },
  { dataIndex: 'typeName', title: '货品大类', key: 'typeName', width: 180 },
  { dataIndex: 'itemcode', title: '商品编号', key: 'itemcode', width: 100 },
  { dataIndex: 'itemname', title: '商品名称', key: 'itemname', width: 100 },
  { dataIndex: 'packUnits', title: '包装单位', key: 'packUnits', width: 80 },
  { dataIndex: 'categoryId', title: '商品规格', key: 'categoryId', width: 150 },
  { dataIndex: 'packSize', title: '包装数', key: 'packSize', width: 100 },
  { dataIndex: 'manufacturer', title: '生产厂家', key: 'manufacturer', width: 120 },
  { dataIndex: 'lotNo', title: '批号', key: 'lotNo', width: 100 },
  { dataIndex: 'affirmedPcs', title: '实际件数', key: 'affirmedPcs', width: 100 },
  { dataIndex: 'affirmedOdd', title: '实际零散数', key: 'affirmedOdd', width: 100 },
  { dataIndex: 'affirmedQty', title: '实际数量', key: 'affirmedQty', width: 100 },
  { dataIndex: '11', title: '显示货位', key: '111', width: 100 },
  { dataIndex: 'sorter', title: '拣货员', key: 'sorter', width: 80 },
  { dataIndex: 'pdateFrom', title: '生产日期', key: 'pdateFrom', width: 120 },
  { dataIndex: 'validUntil', title: '有效期至', key: 'validUntil', width: 150 },
  { dataIndex: 'storeTemperature', title: '存储条件', key: 'storeTemperature', width: 150 },
]
export default {
  name: 'outBoundPrint',
  data() {
    return {
      remoteParams: {},
      detailData: {},
      spinning: false,
      tableColumns: columns,
      isvisible: false,
      detailDataList: [],
    }
  },
  props: {
    rowData: {
      type: Object,
    },
  },
  watch: {
    rowData(val) {
      this.detailData = val
    },
    isvisible(val) {
      if (val) {
        this.querydetailData()
      }
    },
  },
  created() {
    this.detailData = this.rowData
  },
  methods: {
    querydetailData() {
      // 查询明细
      let params = {
        num: 'outBoundListDetailById',
        pageNum: 1,
        pageSize: 1000,
        params: { billId: this.detailData.billid },
      }
      this.spinning = true
      postline(params).then((res) => {
        this.spinning = false
        if (!res.success) {
          this.$exception(res)
          return
        }
        this.detailDataList = res.data?.list
      })
    },
  },
}
</script>

<style scoped>
.gridClass {
  margin-bottom: 40px;
}
.leftName {
  text-align: right;
  line-height: 30px;
}
.rightName {
  line-height: 30px;
  color: #333;
}
.ant-tabletd {
  white-space: nowrap;
}
</style>
