1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

переработка админ панели2

This commit is contained in:
MoonTestUse1
2025-01-03 02:10:21 +06:00
parent 258bd376b7
commit 2e65e0868b
2 changed files with 10 additions and 77 deletions

View File

@@ -14,9 +14,9 @@ const router = createRouter({
component: () => import('@/views/LoginView.vue') component: () => import('@/views/LoginView.vue')
}, },
{ {
path: '/admin', path: '/admin/login',
name: 'admin-login', name: 'admin-login',
component: () => import('@/views/AdminLoginView.vue') component: () => import('@/views/admin/AdminLoginView.vue')
}, },
{ {
path: '/requests', path: '/requests',
@@ -27,7 +27,7 @@ const router = createRouter({
{ {
path: '/admin/dashboard', path: '/admin/dashboard',
name: 'admin-dashboard', name: 'admin-dashboard',
component: () => import('@/views/AdminDashboardView.vue'), component: () => import('@/views/admin/AdminDashboardView.vue'),
meta: { requiresAdmin: true } meta: { requiresAdmin: true }
}, },
{ {
@@ -41,6 +41,12 @@ const router = createRouter({
name: 'admin-employees-add', name: 'admin-employees-add',
component: () => import('@/views/admin/AddEmployeeView.vue'), component: () => import('@/views/admin/AddEmployeeView.vue'),
meta: { requiresAdmin: true } meta: { requiresAdmin: true }
},
{
path: '/admin/requests',
name: 'admin-requests',
component: () => import('@/views/admin/RequestsView.vue'),
meta: { requiresAdmin: true }
} }
] ]
}); });
@@ -49,7 +55,7 @@ router.beforeEach((to, from, next) => {
if (to.meta.requiresAdmin) { if (to.meta.requiresAdmin) {
const adminToken = localStorage.getItem('admin_token') const adminToken = localStorage.getItem('admin_token')
if (!adminToken) { if (!adminToken) {
next('/admin') next('/admin/login')
return return
} }
} else if (to.meta.requiresAuth) { } else if (to.meta.requiresAuth) {

View File

@@ -1,73 +0,0 @@
<template>
<div class="space-y-6">
<div class="flex justify-between items-center">
<h1 class="text-2xl font-bold">Панель администратора</h1>
<router-link
to="/admin/employees/add"
class="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 inline-flex items-center gap-2"
>
<PlusCircle class="w-5 h-5" />
Добавить сотрудника7
</router-link>
</div>
<!-- Statistics -->
<div v-if="statisticsCards.length" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
<div v-for="stat in statisticsCards" :key="stat.period" class="bg-white p-4 rounded-lg shadow">
<h3 class="text-lg font-semibold">{{ stat.label }}</h3>
<p class="text-2xl font-bold">{{ stat.value }}</p>
</div>
</div>
<!-- Requests -->
<div v-if="requests.length" class="bg-white rounded-lg shadow">
<div class="p-4">
<h2 class="text-xl font-semibold">Последние заявки</h2>
</div>
<div class="overflow-x-auto">
<table class="w-full">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Сотрудник</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Тип</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Статус</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Дата</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr v-for="request in requests" :key="request.id">
<td class="px-6 py-4 whitespace-nowrap">{{ request.id }}</td>
<td class="px-6 py-4 whitespace-nowrap">{{ request.employee_last_name }}</td>
<td class="px-6 py-4 whitespace-nowrap">{{ getRequestTypeLabel(request.request_type) }}</td>
<td class="px-6 py-4 whitespace-nowrap">{{ getStatusLabel(request.status) }}</td>
<td class="px-6 py-4 whitespace-nowrap">{{ formatDate(request.created_at) }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { onMounted } from 'vue';
import { PlusCircle } from 'lucide-vue-next';
import { useRequests } from '@/composables/useRequests';
import { useStatistics } from '@/composables/useStatistics';
import { getRequestTypeLabel, getStatusLabel } from '@/utils/labels';
const { requests, fetchRequests } = useRequests();
const { statisticsCards, fetchStatistics } = useStatistics();
const formatDate = (date: string) => {
return new Date(date).toLocaleString('ru-RU');
};
onMounted(async () => {
await Promise.all([
fetchStatistics(),
fetchRequests()
]);
});
</script>