<template>
  <window-size>
    <van-empty v-if="showEmpty" van-empty description="未找到您的在院信息"></van-empty>
    <div v-else>
      <van-notice-bar left-icon="warning-o" text="医保报销费用仅供参考，实际报销金额以出院结算单为准。" />
      <van-cell title="姓名" :value="data.name"></van-cell>
      <van-cell title="住院号" :value="data.inpatientNo"></van-cell>
      <van-cell title="住院科室" :value="data.deptName"></van-cell>
      <van-cell title="病床医生" :value="data.doctorName"></van-cell>
      <van-cell title="住院总费用">
        <template #default>
          <span style="color: orangered">￥ {{ data.totalCharge }}</span>
        </template>
      </van-cell>
      <van-cell title="医保报销费用">
        <template #default>
          <span style="color: orangered">￥ {{ data.fundPay }}</span>
        </template>
      </van-cell>
      <van-cell title="可用余额">
        <template #default>
          <span style="color: orangered">￥ {{ data.lastBalance }}</span>
        </template>
      </van-cell>
      <div style="height: 5px"></div>
      <van-cell title="住院费用清单" is-link @click="toZyFeeDetail"></van-cell>
      <van-cell title="住院预交金" is-link @click="toPrepaid"></van-cell>
    </div>
  </window-size>
</template>

<script setup>
import { computed, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { getInpatientInfo } from '@/api/inpatient-service'

const router = useRouter()
const patientId = router.currentRoute.value.params.patientId
const data = ref({})
const showEmpty = computed(() => {
  return !data.value.inpatientNo
})
const toZyFeeDetail = () => {
  router.push({
    name: 'zyFeeDetail',
    params: {
      inpatientNo: data.value.inpatientNo,
      admissTimes: data.value.admissTimes,
      admissDate: data.value.admissDate,
    },
  })
}
const toPrepaid = () => {
  router.push({
    name: 'displayPrepaid',
    params: {
      patientId: patientId,
      name: data.value.name,
      inpatientNo: data.value.inpatientNo,
      admissTimes: data.value.admissTimes,
      deptName: data.value.deptName,
      lastBalance: data.value.lastBalance,
    },
  })
}
onMounted(() => {
  getInpatientInfo(patientId).then((res) => {
    data.value = res
  })
})
</script>