* добавлены операции и услуги операций

* добавлена выборка и подсчет по датам для роли зав.
* переключатель ролей
* выбор отделений для роли зав.
This commit is contained in:
brusnitsyn
2026-01-22 17:58:27 +09:00
parent 8a0fdf9470
commit cb43c74a72
28 changed files with 961 additions and 143 deletions

View File

@@ -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,