mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
Починка adm5
This commit is contained in:
@@ -55,14 +55,43 @@ import { ref, onMounted } from 'vue';
|
|||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { PlusCircle } from 'lucide-vue-next';
|
import { PlusCircle } from 'lucide-vue-next';
|
||||||
|
|
||||||
|
interface Statistic {
|
||||||
|
period: string;
|
||||||
|
label: string;
|
||||||
|
value: number | string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Request {
|
||||||
|
id: number;
|
||||||
|
employee_last_name: string;
|
||||||
|
request_type: string;
|
||||||
|
status: string;
|
||||||
|
created_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const statistics = ref([]);
|
const statistics = ref<Statistic[]>([]);
|
||||||
const requests = ref([]);
|
const requests = ref<Request[]>([]);
|
||||||
|
|
||||||
const formatDate = (date: string) => {
|
const formatDate = (date: string) => {
|
||||||
return new Date(date).toLocaleString('ru-RU');
|
return new Date(date).toLocaleString('ru-RU');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const fetchStatistics = async () => {
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/admin/statistics?period=week');
|
||||||
|
if (!response.ok) throw new Error('Failed to fetch statistics');
|
||||||
|
const data = await response.json();
|
||||||
|
statistics.value = [
|
||||||
|
{ period: 'total', label: 'Всего заявок', value: data.totalRequests },
|
||||||
|
{ period: 'resolved', label: 'Решено', value: data.resolvedRequests },
|
||||||
|
{ period: 'avgTime', label: 'Среднее время', value: data.averageResolutionTime }
|
||||||
|
];
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching statistics:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const fetchRequests = async () => {
|
const fetchRequests = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/admin/requests');
|
const response = await fetch('/api/admin/requests');
|
||||||
@@ -74,6 +103,7 @@ const fetchRequests = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
fetchStatistics();
|
||||||
fetchRequests();
|
fetchRequests();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
Reference in New Issue
Block a user