<script>
import CheckReportItem from "./checkReportItem.vue";

export default {
  name: "checkDetailReport",
  components: { CheckReportItem },
  props: {
    /**
     * @type {import('index').Obr}
     */
    obr: {
      type: Object,
      required: true,
      default: function () {
        return {
          medTechProCode: "医疗技术单号",
        };
      },
    },
  },
  methods: {
    // generateReportItem() {
    //   // 获取prop报告表单的数据obr的所有键值，同时把形如id, cardId, reportEntryId等键值过滤掉
    //   return Object.keys(this.$props.obr).filter(
    //     (key) => !key.match(/[a-z]Id|id/),
    //   );
    // },
    /**
     * 填充报告单项
     */
    fillReportItem(reportItemLabelList) {
      const filledList = [...reportItemLabelList];

      const remainder =  filledList.length % 3
      const num = 3 - remainder;

      for (let i = num; i >0; i--) {
        filledList.push({key: `filled${i}`, label: "null"})
      }
      return filledList;
    }
  },
  data() {
    return {
      // itemLabels: {
      //   label: "content",
      // },
      reportItemLabelList: [
        { key: "reportNo", label: "报告单号" },
        { key: "medTechProCode", label: "医技号" },
        { key: "medTechProName", label: "医技项目名称" },
        { key: "reportClass", label: "报告单类别名称" },
        { key: "report_complete_time", label: "报告完成时间" },
        { key: "signs", label: "危机标志" },
        { key: "sampleReceivedDate", label: "样本收到日期" },
        { key: "checkpoint", label: "检查部位或样本" },
        { key: "executeDepartmentName", label: "执行科室名称" },
        { key: "applyDoctorName", label: "申请医生" },
        { key: "testingDoctorName", label: "检验医生信息名称" },
        { key: "reviewDoctorName", label: "审核医生" },
        { key: "reportDate", label: "报告单日期" },
      ],
    };
  },
  created() {
    // this.$data.itemLabels = this.generateReportItem();
  },
};
</script>

<template>
  <div id="check-report">
    <check-report-item
      item-width="30%"
      v-for="item in fillReportItem(reportItemLabelList)"
      :key="item.key"
      :report-label="item.label"
      :report-content="obr[item.key] || ''"
      :item-hide = "item.label === 'null'"
    />
  </div>
</template>

<style scoped>
#check-report {
  padding: 1% 5%;
  width: 100%;
  display: flex;
  justify-content: space-evenly;

  flex-wrap: wrap;
}
</style>
