Files
onboard/resources/js/Components/ReportSelectDate.vue
brusnitsyn 87e21f0e08 * восстановление окна наблюдения
* добавил получение выбывших
* фильтрация выбывших по результатам лечения
* добавил подсказку при наведении на операции
* добавил вывод причины наблюдения
* добавил вкладки для выбывших
* изменил связь и сохранение пациентов на контроле
* добавил возможность редактирования причины контроля
* полное изменение окна с нежелательными событиями
* исправил просмотр причины контроля
* работа над окном редактирования причины контроля в таблице
* визуальное выделение умерших и проведенных операций
* добавил выбор даты для роли врач
* центрирование блоков статистики
* разделение выполненных операций на срочность
* поправил метод определения текущего дня для роли врач
* функция блокировки при выборе другой даты для роли врач
2026-01-29 16:42:42 +09:00

160 lines
4.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script setup>
import {NDatePicker} from 'naive-ui'
import {storeToRefs} from "pinia";
import {useReportStore} from "../Stores/report.js";
import {useAuthStore} from "../Stores/auth.js";
import {computed, ref, onMounted, onUnmounted} from "vue";
const reportStore = useReportStore()
const authStore = useAuthStore()
const {timestampCurrentRange} = storeToRefs(reportStore)
// Текущее время для обновления
const currentTime = ref(Date.now())
// Обновляем время каждую секунду
let intervalId = null
onMounted(() => {
if (authStore.isDoctor) {
intervalId = setInterval(() => {
currentTime.value = Date.now()
}, 1000)
}
})
onUnmounted(() => {
if (intervalId) {
clearInterval(intervalId)
}
})
// Проверяем, является ли дата сегодняшней
const isToday = (timestamp) => {
const date = new Date(timestamp)
const today = new Date()
return date.getDate() === today.getDate() &&
date.getMonth() === today.getMonth() &&
date.getFullYear() === today.getFullYear()
}
// Функция для форматирования с заглавной буквой
const formatDateWithCapital = (timestamp) => {
const date = new Date(timestamp)
// Форматируем дату на русском
const formatted = date.toLocaleDateString('ru-RU', {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric'
})
// Делаем первую букву заглавной
return formatted.charAt(0).toUpperCase() + formatted.slice(1)
}
const themeOverride = computed(() => {
if (authStore.isDoctor) {
return {
peers: {
Input: {
border: '',
borderHover: '',
borderFocus: '',
boxShadowFocus: '',
color: '',
colorFocus: '',
fontSizeMedium: '22px',
fontWeight: '500'
}
}
}
}
})
// Используем кастомную функцию форматирования
const formatComputed = computed(() => {
const baseFormat = "dd.MM.yyyy"
if (authStore.isDoctor) {
// Возвращаем функцию форматирования вместо строки
return formatDateWithCapital(modelComputed.value)
}
return baseFormat
})
const typeComputed = computed(() => authStore.isDoctor ? 'date' : 'daterange')
const modelComputed = computed({
get: () => {
const value = reportStore.timestampCurrentRange
if (authStore.isDoctor) {
if (Array.isArray(value)) {
const doctorTimestamp = value[1]
// Если выбрана сегодняшняя дата - показываем текущее время
if (isToday(doctorTimestamp)) {
return currentTime.value
}
// Иначе показываем выбранную дату (без обновления)
return doctorTimestamp
}
return value
}
if (Array.isArray(value)) {
return value
} else {
return [value, value]
}
},
set: (value) => {
if (Array.isArray(value)) {
reportStore.timestampCurrentRange = value
} else {
reportStore.timestampCurrentRange = [value, value]
}
reportStore.getDataOnReportDate(reportStore.timestampCurrentRange)
}
})
const classComputed = computed(() => {
const baseClasses = []
if (authStore.isDoctor) {
baseClasses.push('w-[400px]')
baseClasses.push('text-end')
} else {
baseClasses.push('max-w-[280px]')
}
return baseClasses
})
</script>
<template>
<NDatePicker
:theme-overrides="themeOverride"
v-model:value="modelComputed"
:class="classComputed"
:format="formatComputed"
:type="typeComputed"
placement="top-end"
input-readonly
bind-calendar-months
update-value-on-close
/>
</template>
<style scoped>
:deep(.n-input__suffix) {
margin-left: 12px;
}
:deep(.n-input),
:deep(.n-input__input-el) {
cursor: pointer !important;
}
</style>