Исправил передачу дат умерших, нежелательных и наблюдений

This commit is contained in:
brusnitsyn
2026-06-10 10:47:08 +09:00
parent bd8b4fe81b
commit 9954501437
4 changed files with 52 additions and 32 deletions

View File

@@ -7,11 +7,7 @@ import { format, formatDistanceStrict } from 'date-fns'
import { ru } from 'date-fns/locale' import { ru } from 'date-fns/locale'
import { computed, h, ref, watch } from 'vue' import { computed, h, ref, watch } from 'vue'
import TooltipColumn from '../../Report/Components/DataTableColumns/TooltipColumn.vue' import TooltipColumn from '../../Report/Components/DataTableColumns/TooltipColumn.vue'
import {usePage} from "@inertiajs/vue3";
const props = defineProps({
startAt: { required: true },
endAt: { required: true },
})
const open = defineModel('open') const open = defineModel('open')
const loading = ref(true) const loading = ref(true)
@@ -19,6 +15,16 @@ const deadPatients = ref([])
const currentPatient = ref(null) const currentPatient = ref(null)
const showDrawer = ref(false) const showDrawer = ref(false)
const startAt = computed(() => {
const urlParams = new URLSearchParams(window.location.search)
return urlParams.get('startAt')
})
const endAt = computed(() => {
const urlParams = new URLSearchParams(window.location.search)
return urlParams.get('endAt')
})
// Получаем уникальные отделения для фильтра // Получаем уникальные отделения для фильтра
const departmentOptions = computed(() => { const departmentOptions = computed(() => {
const departments = new Set() const departments = new Set()
@@ -31,6 +37,7 @@ const departmentOptions = computed(() => {
label: dept, label: dept,
value: dept value: dept
})) }))
.sort((a, b) => a.label.localeCompare(b.label))
}) })
// Состояние для выбранных фильтров // Состояние для выбранных фильтров
@@ -92,10 +99,10 @@ const columns = computed(() => [
}, },
]) ])
const fetch = () => { const fetch = (startAt, endAt) => {
loading.value = true loading.value = true
axios.get('/api/statistics/reports/dead-patients', { axios.get('/api/statistics/reports/dead-patients', {
params: { startAt: props.startAt, endAt: props.endAt } params: { startAt, endAt }
}).then((res) => { }).then((res) => {
deadPatients.value = res.data ?? [] deadPatients.value = res.data ?? []
@@ -106,9 +113,9 @@ const fetch = () => {
}) })
} }
watch(open, (isOpen) => { watch(open, (open) => {
if (isOpen && props.endAt && props.startAt) { if (open) {
fetch() fetch(startAt.value, endAt.value)
} }
}) })
</script> </script>

View File

@@ -10,8 +10,6 @@ import TooltipColumn from '../../Report/Components/DataTableColumns/TooltipColum
const props = defineProps({ const props = defineProps({
departmentId: { required: true }, departmentId: { required: true },
startAt: { required: true },
endAt: { required: true },
}) })
const open = defineModel('open') const open = defineModel('open')
@@ -84,10 +82,20 @@ const columns = [
}, },
] ]
const fetch = () => { const startAt = computed(() => {
const urlParams = new URLSearchParams(window.location.search)
return urlParams.get('startAt')
})
const endAt = computed(() => {
const urlParams = new URLSearchParams(window.location.search)
return urlParams.get('endAt')
})
const fetch = (startAt, endAt) => {
loading.value = true loading.value = true
axios.get('/api/statistics/reports/observable-patients', { axios.get('/api/statistics/reports/observable-patients', {
params: { startAt: props.startAt, endAt: props.endAt, departmentId: props.departmentId } params: { startAt, endAt, departmentId: props.departmentId }
}).then((res) => { }).then((res) => {
observablePatients.value = res.data ?? [] observablePatients.value = res.data ?? []
}).finally(() => { }).finally(() => {
@@ -95,8 +103,8 @@ const fetch = () => {
}) })
} }
watch(() => [props.departmentId, props.endAt, props.startAt], () => { watch([open, () => props.departmentId], ([open, departmentId]) => {
if (props.departmentId && props.endAt && props.startAt) fetch() if (open && departmentId) fetch(startAt.value, endAt.value)
}, { immediate: true, deep: true }) }, { immediate: true, deep: true })
</script> </script>

View File

@@ -5,31 +5,36 @@ import {
} from 'naive-ui' } from 'naive-ui'
import {useReportStore} from "../../../Stores/report.js"; import {useReportStore} from "../../../Stores/report.js";
import { TbAlertCircle, TbPencil, TbTrashX } from 'vue-icons-plus/tb' import { TbAlertCircle, TbPencil, TbTrashX } from 'vue-icons-plus/tb'
import {ref, watch} from "vue"; import {computed, ref, watch} from "vue";
const props = defineProps({ const props = defineProps({
departmentId: { departmentId: {
required: true required: true
}, },
startAt: {
required: true
},
endAt: {
required: true
}
}) })
const open = defineModel('open') const open = defineModel('open')
const loading = ref(true) const loading = ref(true)
const unwantedEvents = ref([]) const unwantedEvents = ref([])
const fetchUnwantedEvents = () => {
const startAt = computed(() => {
const urlParams = new URLSearchParams(window.location.search)
return urlParams.get('startAt')
})
const endAt = computed(() => {
const urlParams = new URLSearchParams(window.location.search)
return urlParams.get('endAt')
})
const fetchUnwantedEvents = (startAt, endAt) => {
loading.value = true loading.value = true
axios.get('/api/statistics/reports/unwanted-events', { axios.get('/api/statistics/reports/unwanted-events', {
params: { params: {
departmentId: props.departmentId, departmentId: props.departmentId,
startAt: props.startAt, startAt,
endAt: props.endAt endAt
} }
}) })
.then(res => { .then(res => {
@@ -40,9 +45,9 @@ const fetchUnwantedEvents = () => {
}) })
} }
watch(() => [props.departmentId, props.endAt, props.startAt], () => { watch([open, () => props.departmentId], ([open, departmentId]) => {
if (props.departmentId && props.endAt && props.startAt) { if (open && departmentId) {
fetchUnwantedEvents() fetchUnwantedEvents(startAt.value, endAt.value)
} }
}, { }, {
immediate: true, immediate: true,

View File

@@ -388,9 +388,9 @@ const buildReportHref = (departmentId, startAt, endAt) => {
> >
</NDataTable> </NDataTable>
<ModalUnwantedEvents v-model:open="showUnwantedEventsModal" :start-at="date[0]" :end-at="date[1]" :department-id="currentDepartmentId" /> <ModalUnwantedEvents v-model:open="showUnwantedEventsModal" :department-id="currentDepartmentId" />
<ModalObservablePatients v-model:open="showObservablePatientsModal" :start-at="date[0]" :end-at="date[1]" :department-id="currentDepartmentId" /> <ModalObservablePatients v-model:open="showObservablePatientsModal" :department-id="currentDepartmentId" />
<ModalDeathPatients v-model:open="showDeathPatientsModal" :start-at="date[0]" :end-at="date[1]" /> <ModalDeathPatients v-model:open="showDeathPatientsModal" />
</AppLayout> </AppLayout>
</template> </template>