<template>
    <div style="width: 841.5pt;height: 594.75pt" ref="printDiv">
        <table style="width: 100%;max-height:  594.75pt; ">
            <thead>
            <tr>
                <th colspan="23">长沙泰和医院</th>
            </tr>
            <tr>
                <th colspan="3">
                    姓名: {{ patientInfo?.name }}
                </th>
                <th colspan="3">
                    性别: {{ patientInfo?.sexName }}
                </th>
                <th colspan="3">
                    年龄: {{ patientInfo?.age }}
                </th>
                <th colspan="3">
                    科室: {{ patientInfo?.zkWardName }}
                </th>
                <th colspan="3">
                    床号: {{ patientInfo?.bedNo }}
                </th>
                <th colspan="3">
                    住院号： {{ patientInfo?.inpatientNo }}
                </th>
                <th colspan="3">
                    单位： mmol/L
                </th>
            </tr>

            <tr class="tr">
                <th style="min-width:82.5pt " rowspan="2" colspan="1">日期</th>
                <th v-for="item in thead" colspan="2" width="75pt">
                    {{ item }}
                </th>
            </tr>

            <tr class="tr">
                <template v-for="item in thead">
                    <th>时间</th>
                    <th>签名</th>
                </template>
            </tr>

            </thead>
            <tbody>
            <tr v-for="item in data" style="height:47.25pt">
                <td style="padding: 7.5pt; ">
                    {{ item.date }}
                </td>
                <blood-sugar-td v-for="index in 11"
                                :data="htmlTd(index - 1,item.data)"/>
            </tr>
            </tbody>
            <tfoot>
            <tr>
                <td colspan="23">
                    共&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ page.total }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;条&nbsp;&nbsp;&nbsp;&nbsp;
                    当前第 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <select v-model="page.currentPage">
                        <option v-for="item in page.totalPage" :value="item">{{ item }}</option>
                    </select>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    页/共&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {{ page.totalPage }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 页
                </td>
            </tr>
            </tfoot>
        </table>
    </div>
</template>

<script setup name='BloodSugarTable'>
import BloodSugarTd from "@/views/examination/BloodSugarQuery/components/BloodSugarTd.vue";

const props = defineProps({
    patientInfo: Object,
    page: Object,
    data: Array
})

let thead = ["空腹", "早餐后", "中餐前", "中餐后", "晚餐前", "晚餐后", "零点", "三点", "随机血糖1", "随机血糖2", "随机血糖3"]

const htmlTd = (index, data) => {
    return data[thead[index]]
}

const printDiv = ref(null)

const returnHtml = () => {
    return printDiv.value.innerHTML
}


defineExpose({
    returnHtml
})

</script>

<style scoped lang="scss">
td {
  border: 0.75pt solid #000;
  text-align: center;
  padding: 7.5pt 0;
  word-break: break-all;
}

.tr th {
  border: 0.75pt solid #000;
  text-align: center;
}

table, tr, td {
  border-collapse: collapse;
}
</style>
