<template>
    <el-container>
        <el-aside width="280px">
            <PatientBaseList  @selectPatientInfo="selectPatientInfo"></PatientBaseList>
        </el-aside>
        <el-container>
            <el-header style="height: 100px">
                <PatientInfo :patientInfo="patientInfo"></PatientInfo>

            </el-header>

            <el-main>
               <div style="margin-bottom: 10px">
                   <div style="width: 100%;height: 20px;padding-left: 10px;" >
                       查询日期
                       <el-input :disabled="true" v-model="queryParam.startRecTime" style="width: 80px"></el-input>
                       至
                       <el-input :disabled="true"  v-model="queryParam.endRecTime" style="width: 80px"></el-input>
                       <el-select  filterable v-model="queryParam.week" style="width: 100px;" size="small" @change="selectWeek">
                           <el-option v-for="item in weekList" :key="item.code" :label="item.name" :value="item.code">
                               <span style="color: #8492a6; font-size: 12px">{{ item.code }}</span>
                               <el-divider direction="vertical"></el-divider>
                               <span>{{ item.name }}</span>
                           </el-option>
                       </el-select>
                       <el-button icon="Search" type="primary" @click="queryInfo">查询</el-button>
                       <el-button icon="Printer" type="success" v-print="'#scdPrint'">打印</el-button>&nbsp;
                       <el-checkbox v-model="checkBoxFlag.mbFlag" label="脉搏" size="small" />
                       <el-checkbox v-model="checkBoxFlag.hxFlag" label="呼吸" size="small" />
                       <el-checkbox v-model="checkBoxFlag.xyFlag" label="血压" size="small" />
                       <el-checkbox v-model="checkBoxFlag.wcyRqFlag" label="无出院日期" size="small" />
                   </div>
               </div>
                <el-scrollbar height="600px">
                    <div id="scdPrint" style="background:white;">
                        <Graphics v-if="graphicsFlag"  :patientInfo="patientInfo" :queryParam="queryParam"></Graphics>
                    </div>
                </el-scrollbar>
            </el-main>
        </el-container>
    </el-container>
</template>


<script setup name='PrintThreeTestList'>
import  Graphics from '@/components/medical-advice/temperature/graphics'
import PatientInfo from "@/components/medical-advice/PatientInfo.vue"
import PatientBaseList from "@/components/medical-advice/PatientBaseList.vue"
import {stringNotBlank} from "@/utils/blank-utils"
import { getFormatDatetime } from "@/utils/date"
import {getAllWards} from "@/api/zhu-yuan-yi-sheng/resident-doctor";
import {getWeek} from "@/api/medical-advice/nursing-manage";

import { ref, onMounted,nextTick } from 'vue'

const queryParam = ref(
    {
        startRecTime:'',
        endRecTime:'',
        week:'',
        }
)
//选中第几周
const selectWeek = (val)=>{
    queryParam.value.startRecTime = weekMap.value['ev_'+val].startDate
    queryParam.value.endRecTime = weekMap.value['ev_'+val].endDate
}
//下拉框 周
const weekList = ref([])

const weekMap = ref({})

const checkBoxFlag = ref({
    mbFlag:true,
    hxFlag:true,
    xyFlag:true,
    wcyRqFlag:false
})

onMounted(() => {

})

const graphicsFlag = ref(false)

// 基本信息
const patientInfo = ref({})

const queryInfo = ()=>{
    queryParam.value['checkBoxFlag'] = checkBoxFlag.value
    graphicsFlag.value = false
    nextTick(() => {
        graphicsFlag.value = true
    })
}


const selectPatientInfo=(val)=>{
    patientInfo.value =  val.patientInfo
    patientInfo.value.admissDate =getFormatDatetime(val.patientInfo.admissDate,'YYYY-DD-MM')
    getWeek({inpatientNo:val.patientInfo.inpatientNo,admissTimes:val.patientInfo.admissTimes}).then((res)=>{
        weekMap.value = res
        weekList.value = []
        for (let i = 1; i <= res.totalWeek; i++) {
            let temp = {}
            temp['code'] = i;
            temp['name'] = `第${i}周`;
            weekList.value.push(temp)
        }
        queryParam.value.week = 1
        selectWeek(1)
        queryInfo()
    })
}



</script>

<style  scoped>

    .nav{
        margin: 0 auto;
        width: 100%;
        padding-left: 20px;
    }
    ul{
        list-style: none;
        width: 100%;
    }
    .nav li{
        float: left;
        margin-left: 15px;

    }

</style>