* добавлены операции и услуги операций
* добавлена выборка и подсчет по датам для роли зав. * переключатель ролей * выбор отделений для роли зав.
This commit is contained in:
@@ -1,13 +1,23 @@
|
||||
import { ref, computed } from 'vue'
|
||||
import {ref, computed, watch} from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import axios from 'axios'
|
||||
import {usePage} from "@inertiajs/vue3";
|
||||
|
||||
export const useAuthStore = defineStore('authStore', () => {
|
||||
const user = usePage().props.user
|
||||
const token = user?.token
|
||||
const permissions = user?.permissions
|
||||
const availableDepartments = ref(user?.available_departments)
|
||||
const page = usePage()
|
||||
const user = ref(page.props.user)
|
||||
const token = computed(() => user.value?.token)
|
||||
const role = computed(() => user.value?.role)
|
||||
const permissions = computed(() => user.value?.permissions)
|
||||
const availableDepartments = computed(() => user.value?.available_departments)
|
||||
const availableRoles = computed(() => user.value?.available_roles)
|
||||
|
||||
watch(
|
||||
() => page.props.user,
|
||||
(newUser) => {
|
||||
user.value = newUser
|
||||
},
|
||||
{ deep: true, immediate: true })
|
||||
|
||||
// Инициализация axios с токеном
|
||||
if (token?.value) {
|
||||
@@ -16,12 +26,10 @@ export const useAuthStore = defineStore('authStore', () => {
|
||||
|
||||
// Вычисляемые свойства
|
||||
const isAuthenticated = computed(() => !!user.value && !!token.value)
|
||||
const isAdmin = computed(() => user.role === 'admin')
|
||||
const isDoctor = computed(() => user.role === 'doctor')
|
||||
const isNurse = computed(() => user.role === 'nurse')
|
||||
const isHeadOfDepartment = computed(() => user.role === 'head_of_department')
|
||||
const isStatistician = computed(() => user.role === 'statistician')
|
||||
const userDepartment = computed(() => user.current_department || '')
|
||||
const isAdmin = computed(() => role.value?.slug === 'admin')
|
||||
const isDoctor = computed(() => role.value?.slug === 'doctor')
|
||||
const isHeadOfDepartment = computed(() => role.value?.slug === 'head_of_department')
|
||||
const userDepartment = computed(() => user.value?.current_department || '')
|
||||
|
||||
const clearAuthData = () => {
|
||||
user.value = null
|
||||
@@ -59,12 +67,11 @@ export const useAuthStore = defineStore('authStore', () => {
|
||||
token,
|
||||
permissions,
|
||||
availableDepartments,
|
||||
availableRoles,
|
||||
isAuthenticated,
|
||||
isAdmin,
|
||||
isDoctor,
|
||||
isNurse,
|
||||
isHeadOfDepartment,
|
||||
isStatistician,
|
||||
userDepartment,
|
||||
|
||||
clearAuthData,
|
||||
|
||||
@@ -19,7 +19,7 @@ export const useReportStore = defineStore('reportStore', () => {
|
||||
}
|
||||
})
|
||||
|
||||
const timestampCurrentRange = ref([timestampNow.value, timestampNow.value])
|
||||
const timestampCurrentRange = ref([null, null])
|
||||
|
||||
const dataOnReport = ref(null)
|
||||
|
||||
@@ -74,6 +74,9 @@ export const useReportStore = defineStore('reportStore', () => {
|
||||
const form = {
|
||||
metrics: reportForm.value,
|
||||
observationPatients: patientsData.value['observation'],
|
||||
unwantedEvent: {
|
||||
comment: reportForm.comment
|
||||
},
|
||||
...assignForm
|
||||
}
|
||||
|
||||
@@ -99,21 +102,40 @@ export const useReportStore = defineStore('reportStore', () => {
|
||||
await axios.get('/api/report')
|
||||
.then((res) => {
|
||||
reportInfo.value = res.data
|
||||
|
||||
reportForm.value.metrika_item_3 = reportInfo.value.department?.recipientCount
|
||||
reportForm.value.metrika_item_7 = reportInfo.value.department?.extractCount
|
||||
reportForm.value.metrika_item_8 = reportInfo.value.department?.currentCount
|
||||
|
||||
timestampCurrentRange.value = [
|
||||
reportInfo.value.dates.startAt,
|
||||
reportInfo.value.dates.endAt,
|
||||
]
|
||||
})
|
||||
.finally(() => {
|
||||
isLoadReportInfo.value = false
|
||||
})
|
||||
}
|
||||
|
||||
const getDataOnReportDate = async () => {
|
||||
await axios.get(`/api/metric-forms/1/report-by-date?sent_at=${timestampCurrentRange.value}`)
|
||||
.then(res => {
|
||||
dataOnReport.value = res.data
|
||||
})
|
||||
.catch(err => {
|
||||
// Отчета на выбранную дату не найдено
|
||||
if (err.code === 404) {}
|
||||
})
|
||||
const getDataOnReportDate = async (dateRange) => {
|
||||
isLoadReportInfo.value = true
|
||||
timestampCurrentRange.value = dateRange
|
||||
await axios.get(`/api/report?startAt=${timestampCurrentRange.value[0]}&endAt=${timestampCurrentRange.value[1]}`)
|
||||
.then((res) => {
|
||||
reportInfo.value = res.data
|
||||
|
||||
reportForm.value.metrika_item_3 = reportInfo.value.department?.recipientCount
|
||||
reportForm.value.metrika_item_7 = reportInfo.value.department?.extractCount
|
||||
reportForm.value.metrika_item_8 = reportInfo.value.department?.currentCount
|
||||
|
||||
timestampCurrentRange.value = [
|
||||
reportInfo.value.dates.startAt,
|
||||
reportInfo.value.dates.endAt,
|
||||
]
|
||||
})
|
||||
.finally(() => {
|
||||
isLoadReportInfo.value = false
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user