* добавлена выборка и подсчет по датам для роли зав. * переключатель ролей * выбор отделений для роли зав.
66 lines
1.5 KiB
Vue
66 lines
1.5 KiB
Vue
<script setup>
|
|
import {computed, onMounted, ref, watch} from "vue";
|
|
import {NSkeleton, NText} from 'naive-ui'
|
|
import {useReportStore} from "../../../Stores/report.js";
|
|
|
|
const props = defineProps({
|
|
title: {
|
|
type: String,
|
|
default: null
|
|
},
|
|
status: {
|
|
type: String,
|
|
default: null
|
|
}
|
|
})
|
|
|
|
const reportStore = useReportStore()
|
|
|
|
const isLoading = ref(true)
|
|
const countPatient = ref(null)
|
|
const fetchPatientCount = async () => {
|
|
if (props.status === 'plan' || props.status === 'emergency') {
|
|
isLoading.value = true
|
|
const data = {
|
|
status: props.status,
|
|
startAt: reportStore.timestampCurrentRange[0],
|
|
endAt: reportStore.timestampCurrentRange[1]
|
|
}
|
|
await axios.post('/api/mis/patients/count', data).then((res) => {
|
|
countPatient.value = res.data
|
|
}).finally(() => {
|
|
isLoading.value = false
|
|
})
|
|
} else {
|
|
isLoading.value = false
|
|
}
|
|
}
|
|
|
|
const computedHeader = computed(() => {
|
|
if (countPatient.value !== null) {
|
|
return `${props.title} (${countPatient.value})`
|
|
} else {
|
|
return props.title
|
|
}
|
|
})
|
|
|
|
onMounted(async () => {
|
|
await fetchPatientCount()
|
|
})
|
|
|
|
watch(() => reportStore.timestampCurrentRange, (newRange) => {
|
|
if (newRange) fetchPatientCount()
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<NSkeleton text style="width: 128px; height: 22px" round v-if="isLoading" />
|
|
<NText v-else>
|
|
{{ computedHeader }}
|
|
</NText>
|
|
</template>
|
|
|
|
<style scoped>
|
|
|
|
</style>
|