ایجاد سامانه جدید حضور غیاب
This commit is contained in:
@@ -0,0 +1,859 @@
|
||||
<template>
|
||||
<div class="space-y-8 pb-16">
|
||||
<!-- Top Bar: Title & Role Switcher -->
|
||||
<div class="flex flex-col lg:flex-row lg:items-center justify-between gap-4 bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-800 rounded-3xl p-5 sm:p-6 shadow-sm">
|
||||
<div class="space-y-1">
|
||||
<div class="inline-flex items-center gap-2 px-3 py-1 rounded-full text-xs font-bold bg-primary-100/80 dark:bg-primary-950/60 text-primary-800 dark:text-primary-300">
|
||||
<UIcon name="i-lucide-bar-chart-2" class="w-3.5 h-3.5 text-primary-600" />
|
||||
<span>مرکز تحلیل و آمار حضور و غیاب</span>
|
||||
</div>
|
||||
<h1 class="text-2xl sm:text-3xl font-black text-stone-900 dark:text-white tracking-tight">
|
||||
داشبورد گزارشات آموزشی و انضباطی
|
||||
</h1>
|
||||
<p class="text-xs sm:text-sm text-stone-500 dark:text-stone-400">
|
||||
مشاهده وضعیت جلسات درسی، بررسی غیبتهای غیرمجاز و مدیریت دورههای حوزوی
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-3">
|
||||
<RoleSwitcher />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Navigation Tab between Pages -->
|
||||
<div class="flex items-center justify-between border-b border-stone-200 dark:border-stone-800 pb-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<NuxtLink
|
||||
to="/attendance"
|
||||
class="px-4 py-2 rounded-xl text-sm font-bold text-stone-600 dark:text-stone-300 hover:bg-stone-100 dark:hover:bg-stone-800 transition flex items-center gap-2"
|
||||
>
|
||||
<UIcon name="i-lucide-clipboard-check" class="w-4 h-4" />
|
||||
<span>حضور و غیاب امروز</span>
|
||||
</NuxtLink>
|
||||
<NuxtLink
|
||||
to="/dashboard"
|
||||
class="px-4 py-2 rounded-xl text-sm font-bold bg-primary-500 text-white shadow-md shadow-primary-500/20 flex items-center gap-2"
|
||||
>
|
||||
<UIcon name="i-lucide-layout-dashboard" class="w-4 h-4" />
|
||||
<span>داشبورد و گزارشات</span>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
<div class="text-xs text-stone-400 font-medium hidden sm:block">
|
||||
کاربر: <strong class="text-stone-700 dark:text-stone-200">{{ currentUser.name }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ============================================================= -->
|
||||
<!-- ۱. داشبورد طلبه (STUDENT DASHBOARD) -->
|
||||
<!-- ============================================================= -->
|
||||
<div v-if="currentRole === 'student'" class="space-y-8">
|
||||
<!-- Stat Cards -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 sm:gap-6">
|
||||
<UiStatCard
|
||||
title="درصد حضور کل"
|
||||
:value="`${studentTotalStats.presentRate}%`"
|
||||
icon="i-lucide-check-circle"
|
||||
color="emerald"
|
||||
subText="از مجموع کل جلسات درسی"
|
||||
/>
|
||||
<UiStatCard
|
||||
title="کل غیبتهای غیرموجه"
|
||||
:value="studentTotalStats.totalAbsents"
|
||||
unit="جلسه"
|
||||
icon="i-lucide-x-circle"
|
||||
color="rose"
|
||||
:isPositive="false"
|
||||
subText="سقف مجاز: ۳ جلسه در هر درس"
|
||||
/>
|
||||
<UiStatCard
|
||||
title="تعداد تاخیرها"
|
||||
:value="studentTotalStats.totalLates"
|
||||
unit="بار"
|
||||
icon="i-lucide-clock"
|
||||
color="amber"
|
||||
subText="ثبتشده در نیمسال جاری"
|
||||
/>
|
||||
<UiStatCard
|
||||
title="غیبتهای موجه و مجاز"
|
||||
:value="studentTotalStats.totalExcused"
|
||||
unit="جلسه"
|
||||
icon="i-lucide-file-text"
|
||||
color="blue"
|
||||
subText="دارای تاییدیه آموزش"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Warning if any class is dropped or near danger -->
|
||||
<div
|
||||
v-if="studentTotalStats.droppedClassesCount > 0"
|
||||
class="p-4 rounded-2xl bg-rose-50 dark:bg-rose-950/40 border border-rose-300 dark:border-rose-800 flex items-center gap-3 text-xs text-rose-800 dark:text-rose-200"
|
||||
>
|
||||
<UIcon name="i-lucide-alert-octagon" class="w-6 h-6 text-rose-600 flex-shrink-0" />
|
||||
<div>
|
||||
<strong class="font-bold text-sm block">هشدار آموزشی: حذف به علت غیبت بیش از حد!</strong>
|
||||
<span>شما در {{ studentTotalStats.droppedClassesCount }} درس به دلیل رسیدن به ۴ جلسه غیبت، از آزمون پایان ترم محروم شدهاید. جهت بررسی به آموزش مراجعه نمایید.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Classes Summary Table -->
|
||||
<div class="bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-800 rounded-3xl p-6 shadow-sm space-y-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h2 class="text-base font-bold text-stone-900 dark:text-white">گزارش وضعیت غیبت دروس</h2>
|
||||
<p class="text-xs text-stone-500">برای مشاهده ریز تاریخچه غیبتها و تاخیرها روی هر ردیف کلیک کنید</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-right text-xs">
|
||||
<thead class="bg-stone-50 dark:bg-stone-800/60 text-stone-500 font-bold border-b border-stone-200 dark:border-stone-800">
|
||||
<tr>
|
||||
<th class="py-3 px-4">نام درس</th>
|
||||
<th class="py-3 px-4">استاد مربوطه</th>
|
||||
<th class="py-3 px-4 text-center">جلسات برگزار شده</th>
|
||||
<th class="py-3 px-4 text-center">حاضر</th>
|
||||
<th class="py-3 px-4 text-center">تاخیر</th>
|
||||
<th class="py-3 px-4 text-center">غیبت غیرموجه</th>
|
||||
<th class="py-3 px-4 text-center">وضعیت انضباطی</th>
|
||||
<th class="py-3 px-4 text-center">عملیات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-stone-100 dark:divide-stone-800/80">
|
||||
<tr
|
||||
v-for="item in studentReports"
|
||||
:key="item.classId"
|
||||
class="hover:bg-stone-50/70 dark:hover:bg-stone-800/40 cursor-pointer transition"
|
||||
:class="item.isDropped ? 'bg-rose-50/30 dark:bg-rose-950/15' : ''"
|
||||
@click="openStudentClassDetails(item)"
|
||||
>
|
||||
<td class="py-3 px-4 font-bold text-stone-900 dark:text-white">{{ item.className }}</td>
|
||||
<td class="py-3 px-4 text-stone-600 dark:text-stone-300">{{ item.teacherName }}</td>
|
||||
<td class="py-3 px-4 text-center font-mono">{{ item.totalSessions }}</td>
|
||||
<td class="py-3 px-4 text-center font-mono text-emerald-600 font-bold">{{ item.presentCount }}</td>
|
||||
<td class="py-3 px-4 text-center font-mono text-amber-600 font-bold">{{ item.lateCount }}</td>
|
||||
<td class="py-3 px-4 text-center font-mono text-rose-600 font-bold">{{ item.absentCount }}</td>
|
||||
<td class="py-3 px-4 text-center">
|
||||
<UiBadge
|
||||
:status="item.isDropped ? 'dropped' : (item.absentCount >= 2 ? 'warning' : 'normal')"
|
||||
:label="item.isDropped ? 'حذف به علت غیبت' : (item.absentCount >= 2 ? 'در معرض خطر' : 'عادی')"
|
||||
/>
|
||||
</td>
|
||||
<td class="py-3 px-4 text-center">
|
||||
<UButton size="xs" color="primary" variant="ghost" label="ریز جلسات" icon="i-lucide-eye" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal: Student Detailed Sessions History -->
|
||||
<AppModal
|
||||
v-model="isStudentClassModalOpen"
|
||||
:title="selectedStudentReport ? `ریز جلسات و غیبتهای ${selectedStudentReport.className}` : 'ریز جلسات'"
|
||||
description="سوابق حضور، تاخیرها و دلایل ثبتشده در سامانه"
|
||||
size="lg"
|
||||
>
|
||||
<div v-if="selectedStudentReport" class="space-y-4 text-xs">
|
||||
<!-- Summary pills -->
|
||||
<div class="grid grid-cols-3 gap-3 text-center">
|
||||
<div class="p-3 rounded-xl bg-stone-50 dark:bg-stone-800">
|
||||
<span class="text-stone-400">تعداد جلسات:</span>
|
||||
<div class="text-base font-bold">{{ selectedStudentReport.totalSessions }}</div>
|
||||
</div>
|
||||
<div class="p-3 rounded-xl bg-amber-50 dark:bg-amber-950/60">
|
||||
<span class="text-amber-700">تاخیرها:</span>
|
||||
<div class="text-base font-bold text-amber-800 dark:text-amber-300">{{ selectedStudentReport.lateCount }}</div>
|
||||
</div>
|
||||
<div class="p-3 rounded-xl bg-rose-50 dark:bg-rose-950/60">
|
||||
<span class="text-rose-700">غیبتها:</span>
|
||||
<div class="text-base font-bold text-rose-800 dark:text-rose-300">{{ selectedStudentReport.absentCount }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sessions List -->
|
||||
<div class="overflow-x-auto max-h-64">
|
||||
<table class="w-full text-right text-xs">
|
||||
<thead class="bg-stone-100 dark:bg-stone-800 text-stone-500 font-bold sticky top-0">
|
||||
<tr>
|
||||
<th class="p-2">شماره جلسه</th>
|
||||
<th class="p-2">تاریخ جلسه</th>
|
||||
<th class="p-2">وضعیت</th>
|
||||
<th class="p-2">علت و توضیحات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-stone-100 dark:divide-stone-800">
|
||||
<tr v-for="s in selectedStudentReport.sessions" :key="s.sessionNumber">
|
||||
<td class="p-2 font-mono">جلسه {{ s.sessionNumber }}</td>
|
||||
<td class="p-2 font-mono text-stone-500">{{ s.date }}</td>
|
||||
<td class="p-2">
|
||||
<UiBadge :status="s.status" :label="getStatusLabel(s.status)" />
|
||||
</td>
|
||||
<td class="p-2 text-stone-600 dark:text-stone-300">
|
||||
<span v-if="s.status === 'late'">{{ s.delayMinutes }} دقیقه تاخیر — {{ s.reason || 'بدون ثبت علت' }}</span>
|
||||
<span v-else-if="s.reason">{{ s.reason }}</span>
|
||||
<span v-else class="text-stone-400">-</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer="{ close }">
|
||||
<UButton color="neutral" variant="outline" label="بستن پنجره" @click="close" />
|
||||
</template>
|
||||
</AppModal>
|
||||
</div>
|
||||
|
||||
<!-- ============================================================= -->
|
||||
<!-- ۲. داشبورد استاد (TEACHER DASHBOARD) -->
|
||||
<!-- ============================================================= -->
|
||||
<div v-else-if="currentRole === 'teacher'" class="space-y-8">
|
||||
<!-- Teacher Classes Overview Cards -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<div
|
||||
v-for="c in teacherClasses"
|
||||
:key="c.id"
|
||||
class="p-6 rounded-3xl bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-800 shadow-sm space-y-4"
|
||||
>
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-xs font-mono font-bold text-primary-600 bg-primary-50 dark:bg-primary-950 px-2.5 py-1 rounded-lg">
|
||||
{{ c.code }}
|
||||
</span>
|
||||
<span class="text-xs text-stone-400">{{ c.time }}</span>
|
||||
</div>
|
||||
|
||||
<h3 class="text-base font-bold text-stone-900 dark:text-white leading-snug">
|
||||
{{ c.title }}
|
||||
</h3>
|
||||
|
||||
<div class="grid grid-cols-2 gap-3 pt-2 text-center text-xs">
|
||||
<div class="p-3 rounded-2xl bg-stone-50 dark:bg-stone-800">
|
||||
<div class="text-stone-400">جلسات برگزار شده</div>
|
||||
<div class="text-xl font-bold text-stone-800 dark:text-stone-100 font-mono mt-1">۱۶ جلسه</div>
|
||||
</div>
|
||||
<div class="p-3 rounded-2xl bg-emerald-50 dark:bg-emerald-950/60 text-emerald-800 dark:text-emerald-300">
|
||||
<div class="text-[11px]">میانگین حضور</div>
|
||||
<div class="text-xl font-bold font-mono mt-1">۸۸٪</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Warning: Students with High Absences for Teacher's Classes -->
|
||||
<div class="bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-800 rounded-3xl p-6 shadow-sm space-y-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-2 text-rose-600">
|
||||
<UIcon name="i-lucide-alert-triangle" class="w-5 h-5" />
|
||||
<h3 class="text-base font-bold">طلاب دارای غیبت بالا و در معرض خطر حذف</h3>
|
||||
</div>
|
||||
<span class="text-xs text-stone-400">نیازمند تذکر انضباطی و بررسی استاد</span>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-right text-xs">
|
||||
<thead class="bg-stone-50 dark:bg-stone-800 text-stone-500 font-bold border-b border-stone-200 dark:border-stone-800">
|
||||
<tr>
|
||||
<th class="py-3 px-4">نام طلبه</th>
|
||||
<th class="py-3 px-4">کد تحصیلی</th>
|
||||
<th class="py-3 px-4">کلاس درسی</th>
|
||||
<th class="py-3 px-4 text-center">تعداد غیبت</th>
|
||||
<th class="py-3 px-4 text-center">تعداد تاخیر</th>
|
||||
<th class="py-3 px-4 text-center">وضعیت</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-stone-100 dark:divide-stone-800">
|
||||
<tr class="bg-rose-50/40 dark:bg-rose-950/20">
|
||||
<td class="py-3 px-4 font-bold text-stone-900 dark:text-white">محمدصادق حسینی</td>
|
||||
<td class="py-3 px-4 font-mono text-stone-500">۱۴۰۱۰۱۲۳</td>
|
||||
<td class="py-3 px-4">کفایة الاصول (آخوند خراسانی)</td>
|
||||
<td class="py-3 px-4 text-center font-bold text-rose-600 font-mono">۴ جلسه</td>
|
||||
<td class="py-3 px-4 text-center font-mono">۱ بار</td>
|
||||
<td class="py-3 px-4 text-center">
|
||||
<UiBadge status="dropped" label="حذف شده" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="bg-amber-50/40 dark:bg-amber-950/20">
|
||||
<td class="py-3 px-4 font-bold text-stone-900 dark:text-white">جعفر ابراهیمی</td>
|
||||
<td class="py-3 px-4 font-mono text-stone-500">۱۴۰۱۰۱۲۹</td>
|
||||
<td class="py-3 px-4">مکاسب محرمه (شیخ انصاری)</td>
|
||||
<td class="py-3 px-4 text-center font-bold text-amber-600 font-mono">۳ جلسه</td>
|
||||
<td class="py-3 px-4 text-center font-mono">۲ بار</td>
|
||||
<td class="py-3 px-4 text-center">
|
||||
<UiBadge status="warning" label="در آستانه حذف" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ============================================================= -->
|
||||
<!-- ۳. داشبورد آموزش (ADMIN DASHBOARD + CLASS MANAGEMENT) -->
|
||||
<!-- ============================================================= -->
|
||||
<div v-else-if="currentRole === 'admin'" class="space-y-8">
|
||||
<!-- Admin Top Stats -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 sm:gap-6">
|
||||
<UiStatCard
|
||||
title="تعداد کل کلاسها"
|
||||
:value="adminOverallStats.totalClassesCount"
|
||||
unit="کلاس"
|
||||
icon="i-lucide-book-open"
|
||||
color="primary"
|
||||
subText="فعال در ترم جاری"
|
||||
/>
|
||||
<UiStatCard
|
||||
title="تعداد اساتید"
|
||||
:value="adminOverallStats.totalTeachersCount"
|
||||
unit="نفر"
|
||||
icon="i-lucide-users"
|
||||
color="blue"
|
||||
subText="سطوح عالی و تخصصی"
|
||||
/>
|
||||
<UiStatCard
|
||||
title="کل طلاب حوزه"
|
||||
:value="adminOverallStats.totalStudentsCount"
|
||||
unit="نفر"
|
||||
icon="i-lucide-graduation-cap"
|
||||
color="emerald"
|
||||
subText="پایههای مختلف"
|
||||
/>
|
||||
<UiStatCard
|
||||
title="میانگین حضور کل"
|
||||
:value="`${adminOverallStats.attendancePercentage}%`"
|
||||
icon="i-lucide-pie-chart"
|
||||
color="amber"
|
||||
subText="آمار تجمیعی امروز"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Tab Buttons for Admin: 1. Reports & Excel, 2. Manage Classes -->
|
||||
<div class="flex items-center gap-3 border-b border-stone-200 dark:border-stone-800 pb-3">
|
||||
<button
|
||||
type="button"
|
||||
class="px-4 py-2 rounded-xl text-xs sm:text-sm font-bold transition flex items-center gap-2"
|
||||
:class="adminActiveTab === 'reports'
|
||||
? 'bg-primary-500 text-white shadow-md shadow-primary-500/20'
|
||||
: 'bg-white dark:bg-stone-900 text-stone-600 hover:bg-stone-100 dark:hover:bg-stone-800 border border-stone-200 dark:border-stone-800'"
|
||||
@click="adminActiveTab = 'reports'"
|
||||
>
|
||||
<UIcon name="i-lucide-file-spreadsheet" class="w-4 h-4" />
|
||||
<span>گزارش جامع و خروجی Excel</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="px-4 py-2 rounded-xl text-xs sm:text-sm font-bold transition flex items-center gap-2"
|
||||
:class="adminActiveTab === 'manage'
|
||||
? 'bg-primary-500 text-white shadow-md shadow-primary-500/20'
|
||||
: 'bg-white dark:bg-stone-900 text-stone-600 hover:bg-stone-100 dark:hover:bg-stone-800 border border-stone-200 dark:border-stone-800'"
|
||||
@click="adminActiveTab = 'manage'"
|
||||
>
|
||||
<UIcon name="i-lucide-settings-2" class="w-4 h-4" />
|
||||
<span>مدیریت کلاسها و اتصال طلاب</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- ---------------- TAB 1: Reports & Excel Export ---------------- -->
|
||||
<div v-if="adminActiveTab === 'reports'" class="space-y-6">
|
||||
<!-- Filter and Export Actions -->
|
||||
<div class="bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-800 rounded-3xl p-6 shadow-sm space-y-4">
|
||||
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="text-base font-bold text-stone-900 dark:text-white">گزارشات حضور و غیاب به تفکیک درس</h3>
|
||||
<p class="text-xs text-stone-500">امکان فیلتر و دریافت خروجی استاندارد فایل Excel برای نرمافزارهای آموزش</p>
|
||||
</div>
|
||||
|
||||
<!-- Global Excel Export Button -->
|
||||
<UButton
|
||||
color="primary"
|
||||
variant="solid"
|
||||
size="md"
|
||||
icon="i-lucide-download"
|
||||
label="خروجی Excel کل گزارشات امروز"
|
||||
class="font-bold shadow-md shadow-primary-500/20"
|
||||
@click="exportAllToExcel"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Filters -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3 pt-2 text-xs">
|
||||
<div>
|
||||
<label class="block text-stone-500 mb-1">فیلتر درس:</label>
|
||||
<input
|
||||
v-model="adminReportClassFilter"
|
||||
type="text"
|
||||
placeholder="نام یا کد درس..."
|
||||
class="w-full px-3 py-2 rounded-xl border border-stone-200 dark:border-stone-800 bg-white dark:bg-stone-900 focus:outline-none focus:ring-2 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-stone-500 mb-1">فیلتر استاد:</label>
|
||||
<select
|
||||
v-model="adminReportTeacherFilter"
|
||||
class="w-full px-3 py-2 rounded-xl border border-stone-200 dark:border-stone-800 bg-white dark:bg-stone-900 focus:outline-none focus:ring-2 focus:ring-primary-500"
|
||||
>
|
||||
<option value="">همه اساتید</option>
|
||||
<option v-for="t in teachers" :key="t.id" :value="t.name">{{ t.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-stone-500 mb-1">بازه تاریخی:</label>
|
||||
<select
|
||||
class="w-full px-3 py-2 rounded-xl border border-stone-200 dark:border-stone-800 bg-white dark:bg-stone-900 focus:outline-none focus:ring-2 focus:ring-primary-500"
|
||||
>
|
||||
<option>امروز (۱۴ آبان ۱۴۰۵)</option>
|
||||
<option>هفته جاری</option>
|
||||
<option>ماه جاری (آبان ۱۴۰۵)</option>
|
||||
<option>کل ترم تحصیلی</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Classes Reports Table -->
|
||||
<div class="bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-800 rounded-3xl p-6 shadow-sm overflow-x-auto">
|
||||
<table class="w-full text-right text-xs">
|
||||
<thead class="bg-stone-50 dark:bg-stone-800/60 text-stone-500 font-bold border-b border-stone-200 dark:border-stone-800">
|
||||
<tr>
|
||||
<th class="py-3 px-4">کد درس</th>
|
||||
<th class="py-3 px-4">عنوان درس</th>
|
||||
<th class="py-3 px-4">استاد</th>
|
||||
<th class="py-3 px-4 text-center">کل طلاب</th>
|
||||
<th class="py-3 px-4 text-center">حاضرین</th>
|
||||
<th class="py-3 px-4 text-center">غایبین</th>
|
||||
<th class="py-3 px-4 text-center">درصد حضور</th>
|
||||
<th class="py-3 px-4 text-center">خروجی اکسل درس</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-stone-100 dark:divide-stone-800">
|
||||
<tr v-for="c in filteredReportClasses" :key="c.id" class="hover:bg-stone-50/50 dark:hover:bg-stone-800/30">
|
||||
<td class="py-3 px-4 font-mono font-bold text-primary-600">{{ c.code }}</td>
|
||||
<td class="py-3 px-4 font-bold text-stone-900 dark:text-white">{{ c.title }}</td>
|
||||
<td class="py-3 px-4 text-stone-600 dark:text-stone-300">{{ c.teacherName }}</td>
|
||||
<td class="py-3 px-4 text-center font-mono">{{ c.studentCount }}</td>
|
||||
<td class="py-3 px-4 text-center font-mono text-emerald-600 font-bold">
|
||||
{{ getClassStats(c.id).present }}
|
||||
</td>
|
||||
<td class="py-3 px-4 text-center font-mono text-rose-600 font-bold">
|
||||
{{ getClassStats(c.id).absent }}
|
||||
</td>
|
||||
<td class="py-3 px-4 text-center">
|
||||
<span class="font-mono font-bold">{{ getClassStats(c.id).rate }}%</span>
|
||||
</td>
|
||||
<td class="py-3 px-4 text-center">
|
||||
<UButton
|
||||
size="xs"
|
||||
color="neutral"
|
||||
variant="outline"
|
||||
icon="i-lucide-file-spreadsheet"
|
||||
label="دانلود Excel"
|
||||
@click="exportSingleClassExcel(c)"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ---------------- TAB 2: Class Management ---------------- -->
|
||||
<div v-else-if="adminActiveTab === 'manage'" class="space-y-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h3 class="text-base font-bold text-stone-900 dark:text-white">مدیریت کلاسهای حوزه و تخصیص طلاب</h3>
|
||||
<p class="text-xs text-stone-500">تعریف دروس جدید، انتخاب استاد و اتصال طلاب به کلاس</p>
|
||||
</div>
|
||||
|
||||
<UButton
|
||||
color="primary"
|
||||
variant="solid"
|
||||
size="md"
|
||||
icon="i-lucide-plus"
|
||||
label="تعریف کلاس جدید"
|
||||
@click="openNewClassModal"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Classes List Table -->
|
||||
<div class="bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-800 rounded-3xl p-6 shadow-sm overflow-x-auto">
|
||||
<table class="w-full text-right text-xs">
|
||||
<thead class="bg-stone-50 dark:bg-stone-800/60 text-stone-500 font-bold border-b border-stone-200 dark:border-stone-800">
|
||||
<tr>
|
||||
<th class="py-3 px-4">کد</th>
|
||||
<th class="py-3 px-4">نام درس</th>
|
||||
<th class="py-3 px-4">استاد</th>
|
||||
<th class="py-3 px-4">روزها و ساعت</th>
|
||||
<th class="py-3 px-4">مکان</th>
|
||||
<th class="py-3 px-4 text-center">طلاب متصل</th>
|
||||
<th class="py-3 px-4 text-center">عملیات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-stone-100 dark:divide-stone-800">
|
||||
<tr v-for="c in classes" :key="c.id" class="hover:bg-stone-50/50 dark:hover:bg-stone-800/30">
|
||||
<td class="py-3 px-4 font-mono font-bold text-primary-600">{{ c.code }}</td>
|
||||
<td class="py-3 px-4 font-bold text-stone-900 dark:text-white">{{ c.title }}</td>
|
||||
<td class="py-3 px-4">{{ c.teacherName }}</td>
|
||||
<td class="py-3 px-4 text-stone-500">{{ c.days.join('، ') }} ({{ c.time }})</td>
|
||||
<td class="py-3 px-4 text-stone-500">{{ c.room }}</td>
|
||||
<td class="py-3 px-4 text-center font-mono font-bold">{{ c.studentCount }} نفر</td>
|
||||
<td class="py-3 px-4 text-center">
|
||||
<div class="flex items-center justify-center gap-1">
|
||||
<UButton
|
||||
size="xs"
|
||||
color="neutral"
|
||||
variant="ghost"
|
||||
icon="i-lucide-edit-3"
|
||||
title="ویرایش کلاس"
|
||||
@click="openEditClassModal(c)"
|
||||
/>
|
||||
<UButton
|
||||
size="xs"
|
||||
color="rose"
|
||||
variant="ghost"
|
||||
icon="i-lucide-trash-2"
|
||||
title="حذف کلاس"
|
||||
@click="handleDeleteClass(c)"
|
||||
/>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal: Add / Edit Class -->
|
||||
<AppModal
|
||||
v-model="isClassModalOpen"
|
||||
:title="isEditingClass ? 'ویرایش کلاس درسی' : 'تعریف کلاس جدید'"
|
||||
description="ثبت مشخصات و اتصال طلاب به درس"
|
||||
size="lg"
|
||||
>
|
||||
<div class="space-y-4 text-xs">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="block font-bold mb-1">نام درس: <span class="text-rose-500">*</span></label>
|
||||
<input
|
||||
v-model="classForm.title"
|
||||
type="text"
|
||||
placeholder="مثال: رسائل (شیخ انصاری)"
|
||||
class="w-full px-3 py-2 rounded-xl border border-stone-200 dark:border-stone-800 bg-white dark:bg-stone-900 focus:outline-none focus:ring-2 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block font-bold mb-1">کد درس: <span class="text-rose-500">*</span></label>
|
||||
<input
|
||||
v-model="classForm.code"
|
||||
type="text"
|
||||
placeholder="مثال: USUL-301"
|
||||
class="w-full px-3 py-2 rounded-xl border border-stone-200 dark:border-stone-800 bg-white dark:bg-stone-900 focus:outline-none focus:ring-2 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="block font-bold mb-1">انتخاب استاد: <span class="text-rose-500">*</span></label>
|
||||
<select
|
||||
v-model="classForm.teacherName"
|
||||
class="w-full px-3 py-2 rounded-xl border border-stone-200 dark:border-stone-800 bg-white dark:bg-stone-900 focus:outline-none focus:ring-2 focus:ring-primary-500"
|
||||
>
|
||||
<option v-for="t in teachers" :key="t.id" :value="t.name">{{ t.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block font-bold mb-1">محل تشکیل (مدرس):</label>
|
||||
<input
|
||||
v-model="classForm.room"
|
||||
type="text"
|
||||
placeholder="مثال: مدرس امام باقر (ع)"
|
||||
class="w-full px-3 py-2 rounded-xl border border-stone-200 dark:border-stone-800 bg-white dark:bg-stone-900 focus:outline-none focus:ring-2 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="block font-bold mb-1">روزهای برگزاری (با کاما جدا کنید):</label>
|
||||
<input
|
||||
v-model="classForm.daysStr"
|
||||
type="text"
|
||||
placeholder="شنبه، دوشنبه، چهارشنبه"
|
||||
class="w-full px-3 py-2 rounded-xl border border-stone-200 dark:border-stone-800 bg-white dark:bg-stone-900 focus:outline-none focus:ring-2 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block font-bold mb-1">ساعت شروع و پایان:</label>
|
||||
<input
|
||||
v-model="classForm.time"
|
||||
type="text"
|
||||
placeholder="۰۸:۰۰ الی ۰۹:۳۰"
|
||||
class="w-full px-3 py-2 rounded-xl border border-stone-200 dark:border-stone-800 bg-white dark:bg-stone-900 focus:outline-none focus:ring-2 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Student Multi-Select with Search -->
|
||||
<div class="space-y-2 pt-2 border-t border-stone-100 dark:border-stone-800">
|
||||
<div class="flex items-center justify-between">
|
||||
<label class="block font-bold">اتصال طلاب به این کلاس ({{ classForm.studentIds.length }} نفر انتخاب شده):</label>
|
||||
<input
|
||||
v-model="studentSearchInModal"
|
||||
type="text"
|
||||
placeholder="جستجوی نام یا کد طلبه..."
|
||||
class="px-2.5 py-1 text-xs rounded-lg border border-stone-200 dark:border-stone-800 bg-white dark:bg-stone-900"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2 max-h-48 overflow-y-auto p-2 bg-stone-50 dark:bg-stone-800/40 rounded-xl border border-stone-200 dark:border-stone-700">
|
||||
<label
|
||||
v-for="st in filteredStudentsInModal"
|
||||
:key="st.id"
|
||||
class="flex items-center gap-2 p-2 rounded-lg bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-800 cursor-pointer hover:border-primary-400 transition"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
:value="st.id"
|
||||
v-model="classForm.studentIds"
|
||||
class="rounded text-primary-600 focus:ring-primary-500 w-4 h-4"
|
||||
/>
|
||||
<span class="font-bold text-stone-800 dark:text-stone-200">{{ st.name }}</span>
|
||||
<span class="text-stone-400 text-[10px] font-mono">({{ st.code }})</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer="{ close }">
|
||||
<UButton color="neutral" variant="outline" label="انصراف" @click="close" />
|
||||
<UButton color="primary" variant="solid" label="ذخیره اطلاعات کلاس" @click="handleSaveClass" />
|
||||
</template>
|
||||
</AppModal>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { useAuth } from '~/composables/useAuth'
|
||||
import { useMockData, type ClassItem, type AttendanceStatus, type StudentClassReport } from '~/composables/useMockData'
|
||||
import RoleSwitcher from '~/components/common/RoleSwitcher.vue'
|
||||
import UiBadge from '~/components/common/UiBadge.vue'
|
||||
import UiStatCard from '~/components/common/UiStatCard.vue'
|
||||
import AppModal from '~/components/common/AppModal.vue'
|
||||
|
||||
const { currentRole, currentUser } = useAuth()
|
||||
const {
|
||||
classes,
|
||||
students,
|
||||
teachers,
|
||||
attendanceRecords,
|
||||
studentReports,
|
||||
studentTotalStats,
|
||||
adminOverallStats,
|
||||
exportToExcel,
|
||||
addClass,
|
||||
updateClass,
|
||||
deleteClass
|
||||
} = useMockData()
|
||||
|
||||
const getStatusLabel = (st: AttendanceStatus) => {
|
||||
switch (st) {
|
||||
case 'present': return 'حاضر'
|
||||
case 'absent': return 'غایب'
|
||||
case 'late': return 'تاخیر'
|
||||
case 'excused': return 'مجاز'
|
||||
default: return 'غایب'
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// طلبه (Student Dashboard)
|
||||
// -------------------------------------------------------------
|
||||
const isStudentClassModalOpen = ref(false)
|
||||
const selectedStudentReport = ref<StudentClassReport | null>(null)
|
||||
|
||||
const openStudentClassDetails = (report: StudentClassReport) => {
|
||||
selectedStudentReport.value = report
|
||||
isStudentClassModalOpen.value = true
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// استاد (Teacher Dashboard)
|
||||
// -------------------------------------------------------------
|
||||
const teacherClasses = computed(() => {
|
||||
return classes.value.filter(c => c.teacherId === currentUser.value.id || c.teacherId === 't-201')
|
||||
})
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// آموزش (Admin Dashboard)
|
||||
// -------------------------------------------------------------
|
||||
const adminActiveTab = ref<'reports' | 'manage'>('reports')
|
||||
const adminReportClassFilter = ref('')
|
||||
const adminReportTeacherFilter = ref('')
|
||||
|
||||
const filteredReportClasses = computed(() => {
|
||||
return classes.value.filter(c => {
|
||||
const matchClass = c.title.includes(adminReportClassFilter.value) || c.code.includes(adminReportClassFilter.value)
|
||||
const matchTeacher = !adminReportTeacherFilter.value || c.teacherName === adminReportTeacherFilter.value
|
||||
return matchClass && matchTeacher
|
||||
})
|
||||
})
|
||||
|
||||
const getClassStats = (classId: string) => {
|
||||
const c = classes.value.find(item => item.id === classId)
|
||||
if (!c) return { present: 0, absent: 0, late: 0, rate: 0 }
|
||||
|
||||
const records = attendanceRecords.value.filter(r => r.classId === classId)
|
||||
const present = records.filter(r => r.status === 'present').length
|
||||
const late = records.filter(r => r.status === 'late').length
|
||||
const absent = c.studentCount - (present + late)
|
||||
const rate = c.studentCount > 0 ? Math.round(((present + late) / c.studentCount) * 100) : 0
|
||||
|
||||
return { present, absent, late, rate }
|
||||
}
|
||||
|
||||
// خروجی Excel کل گزارشات آموزش
|
||||
const exportAllToExcel = () => {
|
||||
const exportData = attendanceRecords.value.map(r => {
|
||||
const cls = classes.value.find(c => c.id === r.classId)
|
||||
return {
|
||||
'تاریخ': r.date,
|
||||
'کد درس': cls?.code || '',
|
||||
'نام درس': cls?.title || '',
|
||||
'استاد': cls?.teacherName || '',
|
||||
'نام طلبه': r.studentName,
|
||||
'کد تحصیلی': r.studentCode,
|
||||
'وضعیت حضور': getStatusLabel(r.status),
|
||||
'دقایق تاخیر': r.delayMinutes || 0,
|
||||
'علت تاخیر یا غیبت': r.delayReason || '',
|
||||
'زمان ثبت': r.recordedAt || ''
|
||||
}
|
||||
})
|
||||
|
||||
exportToExcel(exportData, `گزارش_جامع_حضور_غیاب_حوزه_${Date.now()}`)
|
||||
}
|
||||
|
||||
// خروجی Excel برای یک کلاس مشخص
|
||||
const exportSingleClassExcel = (cls: ClassItem) => {
|
||||
const records = attendanceRecords.value.filter(r => r.classId === cls.id)
|
||||
const exportData = records.map(r => ({
|
||||
'تاریخ': r.date,
|
||||
'کلاس': cls.title,
|
||||
'استاد': cls.teacherName,
|
||||
'نام طلبه': r.studentName,
|
||||
'کد تحصیلی': r.studentCode,
|
||||
'وضعیت': getStatusLabel(r.status),
|
||||
'تاخیر (دقیقه)': r.delayMinutes,
|
||||
'علت': r.delayReason || ''
|
||||
}))
|
||||
|
||||
exportToExcel(exportData, `گزارش_${cls.title.replace(/\s+/g, '_')}`)
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// مدیریت کلاسها (Class Management Form)
|
||||
// -------------------------------------------------------------
|
||||
const isClassModalOpen = ref(false)
|
||||
const isEditingClass = ref(false)
|
||||
const editingClassId = ref('')
|
||||
const studentSearchInModal = ref('')
|
||||
|
||||
const classForm = ref({
|
||||
title: '',
|
||||
code: '',
|
||||
teacherName: 'حجتالاسلام والمسلمین استاد رفیعی',
|
||||
room: '',
|
||||
daysStr: 'شنبه، دوشنبه، چهارشنبه',
|
||||
time: '۰۸:۰۰ الی ۰۹:۳۰',
|
||||
studentIds: [] as string[]
|
||||
})
|
||||
|
||||
const filteredStudentsInModal = computed(() => {
|
||||
if (!studentSearchInModal.value) return students.value
|
||||
return students.value.filter(s =>
|
||||
s.name.includes(studentSearchInModal.value) || s.code.includes(studentSearchInModal.value)
|
||||
)
|
||||
})
|
||||
|
||||
const openNewClassModal = () => {
|
||||
isEditingClass.value = false
|
||||
editingClassId.value = ''
|
||||
classForm.value = {
|
||||
title: '',
|
||||
code: `CLS-${Math.floor(100 + Math.random() * 900)}`,
|
||||
teacherName: teachers[0]?.name || '',
|
||||
room: 'مدرس علامه طباطبایی (ره)',
|
||||
daysStr: 'شنبه، چهارشنبه',
|
||||
time: '۰۸:۰۰ الی ۰۹:۳۰',
|
||||
studentIds: ['s-101', 's-102', 's-103', 's-104']
|
||||
}
|
||||
isClassModalOpen.value = true
|
||||
}
|
||||
|
||||
const openEditClassModal = (c: ClassItem) => {
|
||||
isEditingClass.value = true
|
||||
editingClassId.value = c.id
|
||||
classForm.value = {
|
||||
title: c.title,
|
||||
code: c.code,
|
||||
teacherName: c.teacherName,
|
||||
room: c.room,
|
||||
daysStr: c.days.join('، '),
|
||||
time: c.time,
|
||||
studentIds: [...c.studentIds]
|
||||
}
|
||||
isClassModalOpen.value = true
|
||||
}
|
||||
|
||||
const handleSaveClass = () => {
|
||||
if (!classForm.value.title || !classForm.value.code) {
|
||||
alert('لطفاً عنوان و کد درس را وارد فرمایید.')
|
||||
return
|
||||
}
|
||||
|
||||
const days = classForm.value.daysStr.split('،').map(d => d.trim()).filter(Boolean)
|
||||
const teacher = teachers.find(t => t.name === classForm.value.teacherName)
|
||||
|
||||
if (isEditingClass.value) {
|
||||
updateClass(editingClassId.value, {
|
||||
title: classForm.value.title,
|
||||
code: classForm.value.code,
|
||||
teacherId: teacher?.id || 't-201',
|
||||
teacherName: classForm.value.teacherName,
|
||||
room: classForm.value.room,
|
||||
days,
|
||||
time: classForm.value.time,
|
||||
studentIds: classForm.value.studentIds
|
||||
})
|
||||
alert('اطلاعات کلاس با موفقیت بهروزرسانی شد.')
|
||||
} else {
|
||||
addClass({
|
||||
title: classForm.value.title,
|
||||
code: classForm.value.code,
|
||||
teacherId: teacher?.id || 't-201',
|
||||
teacherName: classForm.value.teacherName,
|
||||
room: classForm.value.room,
|
||||
days,
|
||||
time: classForm.value.time,
|
||||
startTime: '08:00',
|
||||
endTime: '09:30',
|
||||
studentIds: classForm.value.studentIds
|
||||
})
|
||||
alert('کلاس جدید با موفقیت به سامانه افزوده شد.')
|
||||
}
|
||||
|
||||
isClassModalOpen.value = false
|
||||
}
|
||||
|
||||
const handleDeleteClass = (c: ClassItem) => {
|
||||
if (confirm(`آیا از حذف کلاس "${c.title}" اطمینان دارید؟`)) {
|
||||
deleteClass(c.id)
|
||||
alert('کلاس با موفقیت حذف گردید.')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user