<template>
  <div class="report-container">
    <div class="report-header">
      <!-- <div class="company-logo">
        <img src="@/assets/logo.png" alt="嘉实医药" />
      </div> -->
      <div class="report-title">检验报告书</div>
    </div>
    
    <div class="report-info">
      <div class="info-item">
        <span class="label">编号:</span>
        <span class="value">{{ templateInfo.code }}</span>
      </div>
      <div class="info-item">
        <span class="label">报告单号:</span>
        <span class="value">{{ templateInfo.reportNumber }}</span>
      </div>
    </div>
    
    <table class="report-table">
      <tbody>
        <tr>
          <td class="td-label">检品名称</td>
          <td class="td-value" colspan="2">{{ templateInfo.productName }}</td>
          <td class="td-label">批号/序列号</td>
          <td class="td-value" colspan="2">{{ templateInfo.batchNo }}</td>
        </tr>
        <tr>
          <td class="td-label">规格型号</td>
          <td class="td-value" colspan="2">{{ templateInfo.specification }}/{{ templateInfo.modelType }}</td>
          <td class="td-label">数量</td>
          <td class="td-value" colspan="2">{{ templateInfo.total }}{{ templateInfo.unit }}</td>
        </tr>
        <tr>
          <td class="td-label">请验日期</td>
          <td class="td-value" colspan="2">{{ templateInfo.pleaseVerifyDate }}</td>
          <td class="td-label">请验部门</td>
          <td class="td-value" colspan="2">{{ templateInfo.pleaseVerifyDepartment }}</td>
        </tr>
        <tr>
          <td class="td-label">报告日期</td>
          <td class="td-value" colspan="2">{{ templateInfo.reportDate }}</td>
          <td class="td-label">有效期</td>
          <td class="td-value" colspan="2">{{ templateInfo.expirationDate }}</td>
        </tr>
        <tr>
          <td class="td-label">来源</td>
          <td class="td-value" colspan="2">{{ templateInfo.source }}</td>
          <td class="td-label">储存条件</td>
          <td class="td-value" colspan="2">{{ templateInfo.storageCondition }}</td>
        </tr>
        <tr>
          <td class="td-label">检验依据</td>
          <td class="td-value" colspan="5">{{ templateInfo.inspectionBasis }}</td>
        </tr>
        <tr>
          <td class="td-label">检验项目</td>
          <td class="td-value" colspan="3">标准规定</td>
          <td class="td-value" colspan="2">检验结果</td>
        </tr>
        <tr v-for="(item, index) in templateInfo.list" :key="index">
          <td class="td-value">{{ item.item }}</td>
          <td class="td-value" colspan="3">{{ item.standardRegulations }}</td>
          <td class="td-value" colspan="2">{{ item.results }}</td>
        </tr>
        <tr>
          <td class="td-label">结论</td>
          <td class="td-value" colspan="5">{{ templateInfo.conclusion }}</td>
        </tr>
        <tr>
          <td class="td-label">备注</td>
          <td class="td-value" colspan="5">{{ templateInfo.remarks }}</td>
        </tr>
      </tbody>
    </table>
    
    <div class="report-footer">
      <div class="footer-item">检验员：{{ templateInfo.inspector }} /日期：{{ templateInfo.inspectionTime }}</div>
      <div class="footer-item">复核人：{{ templateInfo.reviewer }} /日期：{{ templateInfo.reviewTime }}</div>
      <div class="footer-item">审核人：{{ templateInfo.checker }} /日期：{{ templateInfo.approvedDate }}</div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ReportTemplate',
  props: {
    templateInfo: {
      type: Object,
      default: () => ({})
    }
  }
}
</script>

<style scoped>
.report-container {
  /* width: 500px; */
  width: 800px;
  margin: 0 auto;
  /* padding: 20px; */
  /* border: 1px solid #000; */
  /* font-family: Arial, sans-serif; */
  overflow-x: auto;
  white-space: nowrap;
}

.report-container::-webkit-scrollbar {
  height: 8px;
}

.report-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.report-container::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.report-container::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.company-logo {
  width: 80px;
  height: 80px;
}

.company-logo img {
  width: 100%;
  height: 100%;
}

.report-title {
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  flex: 1;
  margin-left: -80px;
}

.report-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.info-item {
  display: flex;
  margin-right: 20px;
  align-items: center;
}

.info-item .label {
  font-weight: bold;
  margin-right: 10px;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.report-table td {
  border: 1px solid #000;
  padding: 8px;
}

.td-label {
  font-weight: bold;
  background-color: #f5f5f5;
  /* width: 90px; */
  word-wrap: break-word;
  white-space: normal;
}

.td-value {
  word-wrap: break-word;
  white-space: normal;
  max-width: 250px;
}

.report-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}

.footer-item {
  flex: 1;
  text-align: center;
  margin-right: 20px;
}
</style>