Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad877e9b81 | ||
|
|
cf6741119d | ||
|
|
a9b551c0a4 |
@@ -0,0 +1,42 @@
|
|||||||
|
export default {
|
||||||
|
base: {
|
||||||
|
get_document: "elp/v1/indices/{{type_name}}/{{doc_id}}",
|
||||||
|
update_document: "elp/v1/indices/{{type_name}}/update/{{doc_id}}",
|
||||||
|
update_field: "elp/v1/indices/{{type_name}}/update/field/{{doc_id}}",
|
||||||
|
compute_field: "elp/v1/indices/{{type_name}}/compute/field",
|
||||||
|
add_document: "elp/v1/indices/{{type_name}}/insert",
|
||||||
|
delete_document: "elp/v1/indices/{{type_name}}/delete/{{doc_id}}",
|
||||||
|
getSchema: "elp/schema/get",
|
||||||
|
},
|
||||||
|
search: {
|
||||||
|
elp_base_count: "elp/v1/indices/{{index_key}}/count",
|
||||||
|
elp_base_search: "elp/v1/indices/{{index_key}}/search",
|
||||||
|
elp_voice_search: "elp/voice/{{index_key}}/search",
|
||||||
|
elp_db_search: "elp/db/indices/{{index_key}}/search",
|
||||||
|
},
|
||||||
|
Info: {
|
||||||
|
elp_option_get: "elp/v1/base/option/doc/{{main_key}}",
|
||||||
|
elp_completion: "elp/v1/indices/{{type_name}}/completion/{{property_key}}",
|
||||||
|
elp_main_label: "elp/v1/base/option/get/items/{{main_label}}",
|
||||||
|
elp_update_field: "elp/v1/indices/{{type_name}}/update/field/{{doc_id}}",
|
||||||
|
elp_list_Tree: "/elp/tbase/{{type_name}}/list/tree",
|
||||||
|
elp_get_Tree: "/elp/tbase/{{type_name}}/get/item/all",
|
||||||
|
elp_update_Tree: "/elp/tbase/{{type_name}}/update/{{id}}",
|
||||||
|
elp_delete_Tree: "/elp/tbase/{{type_name}}/delete/{{id}}",
|
||||||
|
elp_move_in_Tree:
|
||||||
|
"/elp/tbase/{{type_name}}/move_in/{{drop_id}}/{{drag_id}}",
|
||||||
|
elp_insert_Tree: "/elp/tbase/{{type_name}}/insert",
|
||||||
|
elp_relation_Tree: "/elp/tbase/{{type_name}}/relation/add",
|
||||||
|
elp_relation_Tree_delete: "/elp/tbase/{{type_name}}/relation/delete",
|
||||||
|
elp_get_list_Tree: "/elp/db/indices/{{index_key}}/tree",
|
||||||
|
},
|
||||||
|
rag_chat: {
|
||||||
|
// elp_semantic_search: "elp/chat/semantic_search",
|
||||||
|
elp_chat: "elp/chat/query/{{type_name}}",
|
||||||
|
note_action: "elp/note/ai/action",
|
||||||
|
note_job_action: "elp/chat/job/add/action/{{note_id}}",
|
||||||
|
chat_job_query: "elp/chat/job/add/query/{{type_name}}/{{note_id}}",
|
||||||
|
chat_job_search_query: "elp/chat/job/search/query/{{type_name}}",
|
||||||
|
chat_job_get: "elp/chat/job/get/{{job_id}}",
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
export default {
|
||||||
|
search: {
|
||||||
|
mirror_search:
|
||||||
|
"repo/monir/mirror/{{mirror_type}}/{{index_key}}/{{search_type}}/{{sortKey}}/{{field_collapse}}/{{offset}}/{{limit}}/{{filter}}",
|
||||||
|
autoComplate: "monir/complation/{{index_key}}/{{filter}}",
|
||||||
|
queryNormal:
|
||||||
|
"repo/monir/search/{{index_key}}/{{search_type}}/{{sortKey}}/{{field_collapse}}/{{offset}}/{{limit}}/{{filter}}",
|
||||||
|
textSearch:
|
||||||
|
"repo/monir/search/text/{{index_key}}/{{field}}/{{offset}}/{{limit}}/{{filter}}",
|
||||||
|
// queryMirror:
|
||||||
|
// "monir/mirror/{{mirror_type}}/{{index_key}}/{{search_type}}/{{sortKey}}/{{field_collapse}}/{{offset}}/{{limit}}/{{filter}}",
|
||||||
|
},
|
||||||
|
|
||||||
|
public: {
|
||||||
|
updateProperty_full:
|
||||||
|
"public/{{index_key}}/edit/{{entity_id}}/{{property}}/index/full",
|
||||||
|
|
||||||
|
updateEntity: "repo/public/{{index_key}}/update/{{id}}",
|
||||||
|
get_doc_byid: "repo/public/get/byid/{{index_key}}/{{entity_id}}",
|
||||||
|
uplaod_file: "repo/public/file/{{type_key}}/uploadfile",
|
||||||
|
},
|
||||||
|
calendar: {
|
||||||
|
schema: {
|
||||||
|
list: "repo/schema",
|
||||||
|
},
|
||||||
|
list: "repo/calendar/@offset/@limit/@filter",
|
||||||
|
list_collpase: "repo/calendar/@field_collapsed/@offset/@limit/@filter",
|
||||||
|
addTask: "repo/calendar/add",
|
||||||
|
update: "repo/calendar/edit/@id",
|
||||||
|
delete: "repo/calendar/delete/@id",
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
<template>
|
||||||
|
<Teleport to="body">
|
||||||
|
<Transition
|
||||||
|
enter-active-class="transition duration-200 ease-out"
|
||||||
|
enter-from-class="opacity-0"
|
||||||
|
enter-to-class="opacity-100"
|
||||||
|
leave-active-class="transition duration-150 ease-in"
|
||||||
|
leave-from-class="opacity-100"
|
||||||
|
leave-to-class="opacity-0"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="modelValue"
|
||||||
|
class="fixed inset-0 z-50 flex items-center justify-center p-4 bg-stone-950/60 backdrop-blur-sm"
|
||||||
|
dir="rtl"
|
||||||
|
@click.self="onBackdropClick"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="bg-white dark:bg-stone-900 rounded-3xl border border-stone-200 dark:border-stone-800 shadow-2xl w-full max-h-[90vh] overflow-hidden flex flex-col"
|
||||||
|
:class="sizeClass"
|
||||||
|
>
|
||||||
|
<!-- Modal Header -->
|
||||||
|
<div class="px-6 py-4 border-b border-stone-100 dark:border-stone-800 flex items-center justify-between">
|
||||||
|
<div class="space-y-0.5">
|
||||||
|
<h3 class="text-base font-bold text-stone-900 dark:text-white">{{ title }}</h3>
|
||||||
|
<p v-if="description" class="text-xs text-stone-500 dark:text-stone-400">{{ description }}</p>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="w-8 h-8 rounded-xl text-stone-400 hover:text-stone-700 dark:hover:text-stone-200 hover:bg-stone-100 dark:hover:bg-stone-800 flex items-center justify-center transition"
|
||||||
|
@click="close"
|
||||||
|
>
|
||||||
|
<UIcon name="i-lucide-x" class="w-5 h-5" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal Body -->
|
||||||
|
<div class="p-6 overflow-y-auto flex-1 space-y-4">
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal Footer -->
|
||||||
|
<div v-if="$slots.footer" class="px-6 py-3.5 bg-stone-50/70 dark:bg-stone-800/40 border-t border-stone-100 dark:border-stone-800 flex items-center justify-end gap-2">
|
||||||
|
<slot name="footer" :close="close" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Transition>
|
||||||
|
</Teleport>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, watch } from 'vue'
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
modelValue: boolean
|
||||||
|
title?: string
|
||||||
|
description?: string
|
||||||
|
size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl'
|
||||||
|
dismissible?: boolean
|
||||||
|
}>(), {
|
||||||
|
modelValue: false,
|
||||||
|
title: 'پنجره پیام',
|
||||||
|
description: '',
|
||||||
|
size: 'md',
|
||||||
|
dismissible: true
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:modelValue', 'close'])
|
||||||
|
|
||||||
|
const sizeClass = computed(() => {
|
||||||
|
switch (props.size) {
|
||||||
|
case 'sm': return 'max-w-sm'
|
||||||
|
case 'lg': return 'max-w-2xl'
|
||||||
|
case 'xl': return 'max-w-4xl'
|
||||||
|
case '2xl': return 'max-w-5xl'
|
||||||
|
case 'md':
|
||||||
|
default: return 'max-w-lg'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const close = () => {
|
||||||
|
emit('update:modelValue', false)
|
||||||
|
emit('close')
|
||||||
|
}
|
||||||
|
|
||||||
|
const onBackdropClick = () => {
|
||||||
|
if (props.dismissible) {
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// بستن با کلید ESC
|
||||||
|
watch(() => props.modelValue, (isOpen) => {
|
||||||
|
if (import.meta.client) {
|
||||||
|
if (isOpen) {
|
||||||
|
document.body.classList.add('overflow-hidden')
|
||||||
|
} else {
|
||||||
|
document.body.classList.remove('overflow-hidden')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<template>
|
||||||
|
<div class="inline-flex items-center gap-2 bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-800 rounded-2xl p-1.5 shadow-sm">
|
||||||
|
<div class="flex items-center gap-2 px-2.5 py-1 text-xs text-stone-500 dark:text-stone-400 font-medium">
|
||||||
|
<UIcon name="i-lucide-user-check" class="w-4 h-4 text-primary-500" />
|
||||||
|
<span class="hidden sm:inline">نقش نمایشی:</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center gap-1">
|
||||||
|
<button
|
||||||
|
v-for="role in roles"
|
||||||
|
:key="role.key"
|
||||||
|
type="button"
|
||||||
|
class="px-3 py-1.5 rounded-xl text-xs font-bold transition-all flex items-center gap-1.5"
|
||||||
|
:class="currentRole === role.key
|
||||||
|
? 'bg-primary-500 text-white shadow-md shadow-primary-500/20'
|
||||||
|
: 'text-stone-600 dark:text-stone-400 hover:bg-stone-100 dark:hover:bg-stone-800'"
|
||||||
|
@click="setRole(role.key)"
|
||||||
|
>
|
||||||
|
<UIcon :name="role.icon" class="w-3.5 h-3.5" />
|
||||||
|
<span>{{ role.label }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- User Profile Badge -->
|
||||||
|
<div class="hidden md:flex items-center gap-2 border-r border-stone-200 dark:border-stone-800 pr-3 mr-1 text-xs">
|
||||||
|
<div class="w-7 h-7 rounded-full bg-primary-100 dark:bg-primary-950 text-primary-600 dark:text-primary-400 flex items-center justify-center font-bold text-xs">
|
||||||
|
{{ currentUser.name.charAt(0) }}
|
||||||
|
</div>
|
||||||
|
<div class="text-start leading-tight">
|
||||||
|
<div class="font-bold text-stone-900 dark:text-white">{{ currentUser.name }}</div>
|
||||||
|
<div class="text-[10px] text-stone-400">{{ currentUser.title }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useAuth, type UserRole } from '~/composables/useAuth'
|
||||||
|
|
||||||
|
const { currentRole, setRole, currentUser } = useAuth()
|
||||||
|
|
||||||
|
const roles: { key: UserRole; label: string; icon: string }[] = [
|
||||||
|
{ key: 'student', label: 'طلبه', icon: 'i-lucide-graduation-cap' },
|
||||||
|
{ key: 'teacher', label: 'استاد', icon: 'i-lucide-book-open' },
|
||||||
|
{ key: 'admin', label: 'آموزش', icon: 'i-lucide-shield-check' }
|
||||||
|
]
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<template>
|
||||||
|
<span
|
||||||
|
class="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs font-semibold tracking-tight transition"
|
||||||
|
:class="badgeClasses"
|
||||||
|
>
|
||||||
|
<span class="w-1.5 h-1.5 rounded-full" :class="dotClasses"></span>
|
||||||
|
<slot>{{ label }}</slot>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import type { AttendanceStatus } from '~/composables/useMockData'
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
status?: AttendanceStatus | 'normal' | 'warning' | 'dropped' | 'pending' | string
|
||||||
|
label?: string
|
||||||
|
size?: 'sm' | 'md'
|
||||||
|
}>(), {
|
||||||
|
status: 'present',
|
||||||
|
label: '',
|
||||||
|
size: 'md'
|
||||||
|
})
|
||||||
|
|
||||||
|
const badgeClasses = computed(() => {
|
||||||
|
switch (props.status) {
|
||||||
|
case 'present':
|
||||||
|
return 'bg-emerald-50 text-emerald-700 dark:bg-emerald-950/60 dark:text-emerald-300 border border-emerald-200 dark:border-emerald-800/40'
|
||||||
|
case 'absent':
|
||||||
|
return 'bg-rose-50 text-rose-700 dark:bg-rose-950/60 dark:text-rose-300 border border-rose-200 dark:border-rose-800/40'
|
||||||
|
case 'late':
|
||||||
|
return 'bg-amber-50 text-amber-700 dark:bg-amber-950/60 dark:text-amber-300 border border-amber-200 dark:border-amber-800/40'
|
||||||
|
case 'excused':
|
||||||
|
return 'bg-blue-50 text-blue-700 dark:bg-blue-950/60 dark:text-blue-300 border border-blue-200 dark:border-blue-800/40'
|
||||||
|
case 'warning':
|
||||||
|
return 'bg-amber-100 text-amber-800 dark:bg-amber-900/60 dark:text-amber-200 border border-amber-300'
|
||||||
|
case 'dropped':
|
||||||
|
return 'bg-rose-100 text-rose-800 dark:bg-rose-900/60 dark:text-rose-200 border border-rose-300'
|
||||||
|
case 'pending':
|
||||||
|
default:
|
||||||
|
return 'bg-stone-100 text-stone-600 dark:bg-stone-800 dark:text-stone-300 border border-stone-200 dark:border-stone-700'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const dotClasses = computed(() => {
|
||||||
|
switch (props.status) {
|
||||||
|
case 'present': return 'bg-emerald-500'
|
||||||
|
case 'absent': return 'bg-rose-500'
|
||||||
|
case 'late': return 'bg-amber-500'
|
||||||
|
case 'excused': return 'bg-blue-500'
|
||||||
|
case 'warning': return 'bg-amber-600'
|
||||||
|
case 'dropped': return 'bg-rose-600'
|
||||||
|
default: return 'bg-stone-400'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
<template>
|
||||||
|
<div class="p-5 rounded-2xl bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-800 shadow-sm relative overflow-hidden group hover:border-primary-500/40 transition">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<div class="space-y-1">
|
||||||
|
<div class="text-xs font-medium text-stone-500 dark:text-stone-400">{{ title }}</div>
|
||||||
|
<div class="text-2xl sm:text-3xl font-black text-stone-900 dark:text-white flex items-baseline gap-1.5">
|
||||||
|
<span>{{ value }}</span>
|
||||||
|
<span v-if="unit" class="text-xs font-normal text-stone-400">{{ unit }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="w-12 h-12 rounded-2xl flex items-center justify-center transition duration-200"
|
||||||
|
:class="iconBgClass"
|
||||||
|
>
|
||||||
|
<UIcon :name="icon" class="w-6 h-6" :class="iconColorClass" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="subText" class="mt-3 pt-3 border-t border-stone-100 dark:border-stone-800/80 text-xs flex items-center justify-between text-stone-500 dark:text-stone-400">
|
||||||
|
<span>{{ subText }}</span>
|
||||||
|
<span v-if="trend" :class="trendClass" class="font-bold font-mono">{{ trend }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
title: string
|
||||||
|
value: string | number
|
||||||
|
unit?: string
|
||||||
|
icon?: string
|
||||||
|
color?: 'primary' | 'emerald' | 'amber' | 'rose' | 'blue'
|
||||||
|
subText?: string
|
||||||
|
trend?: string
|
||||||
|
isPositive?: boolean
|
||||||
|
}>(), {
|
||||||
|
icon: 'i-lucide-activity',
|
||||||
|
color: 'primary',
|
||||||
|
unit: '',
|
||||||
|
subText: '',
|
||||||
|
trend: '',
|
||||||
|
isPositive: true
|
||||||
|
})
|
||||||
|
|
||||||
|
const iconBgClass = computed(() => {
|
||||||
|
switch (props.color) {
|
||||||
|
case 'emerald': return 'bg-emerald-50 dark:bg-emerald-950/60'
|
||||||
|
case 'amber': return 'bg-amber-50 dark:bg-amber-950/60'
|
||||||
|
case 'rose': return 'bg-rose-50 dark:bg-rose-950/60'
|
||||||
|
case 'blue': return 'bg-blue-50 dark:bg-blue-950/60'
|
||||||
|
default: return 'bg-primary-50 dark:bg-primary-950/60'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const iconColorClass = computed(() => {
|
||||||
|
switch (props.color) {
|
||||||
|
case 'emerald': return 'text-emerald-600 dark:text-emerald-400'
|
||||||
|
case 'amber': return 'text-amber-600 dark:text-amber-400'
|
||||||
|
case 'rose': return 'text-rose-600 dark:text-rose-400'
|
||||||
|
case 'blue': return 'text-blue-600 dark:text-blue-400'
|
||||||
|
default: return 'text-primary-600 dark:text-primary-400'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const trendClass = computed(() => {
|
||||||
|
return props.isPositive ? 'text-emerald-600 dark:text-emerald-400' : 'text-rose-600 dark:text-rose-400'
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
import { ref, computed } from 'vue'
|
||||||
|
|
||||||
|
export type UserRole = 'student' | 'teacher' | 'admin'
|
||||||
|
|
||||||
|
export interface UserProfile {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
role: UserRole
|
||||||
|
code: string
|
||||||
|
avatar?: string
|
||||||
|
title?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const mockUsers: Record<UserRole, UserProfile> = {
|
||||||
|
student: {
|
||||||
|
id: 's-101',
|
||||||
|
name: 'محمدصادق حسینی',
|
||||||
|
role: 'student',
|
||||||
|
code: '۱۴۰۱۰۱۲۳',
|
||||||
|
title: 'طلبه پایه چهارم',
|
||||||
|
avatar: 'https://api.dicebear.com/7.x/bottts/svg?seed=student1'
|
||||||
|
},
|
||||||
|
teacher: {
|
||||||
|
id: 't-201',
|
||||||
|
name: 'حجتالاسلام والمسلمین استاد رفیعی',
|
||||||
|
role: 'teacher',
|
||||||
|
code: '۱۰۸۵',
|
||||||
|
title: 'مدرس سطوح عالی فقه و اصول',
|
||||||
|
avatar: 'https://api.dicebear.com/7.x/bottts/svg?seed=teacher1'
|
||||||
|
},
|
||||||
|
admin: {
|
||||||
|
id: 'a-301',
|
||||||
|
name: 'حاج آقای حسینیان (معاونت آموزش)',
|
||||||
|
role: 'admin',
|
||||||
|
code: '۳۰۱',
|
||||||
|
title: 'مدیر آموزش و امور طلاب',
|
||||||
|
avatar: 'https://api.dicebear.com/7.x/bottts/svg?seed=admin1'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentRole = ref<UserRole>('student')
|
||||||
|
|
||||||
|
export const useAuth = () => {
|
||||||
|
const currentUser = computed(() => mockUsers[currentRole.value])
|
||||||
|
|
||||||
|
const setRole = (role: UserRole) => {
|
||||||
|
currentRole.value = role
|
||||||
|
}
|
||||||
|
|
||||||
|
const roleLabels: Record<UserRole, string> = {
|
||||||
|
student: 'طلبه',
|
||||||
|
teacher: 'استاد',
|
||||||
|
admin: 'آموزش'
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
currentRole,
|
||||||
|
currentUser,
|
||||||
|
setRole,
|
||||||
|
roleLabels,
|
||||||
|
mockUsers
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,977 @@
|
|||||||
|
// @/composables/useFormBuilder.js
|
||||||
|
import { useNuxtApp } from "#app";
|
||||||
|
import elpApi from "@/apis/elpApi";
|
||||||
|
import repoApi from "@/apis/repoApi";
|
||||||
|
import { cleanTextUnpermittedChars } from "@/utils/generalUtil";
|
||||||
|
|
||||||
|
export function useElpService(props, emit) {
|
||||||
|
const { $http: httpService } = useNuxtApp();
|
||||||
|
const toast = useToast();
|
||||||
|
|
||||||
|
///-----------------------------------------------------
|
||||||
|
///---- اسکیمای صفحات برنامه
|
||||||
|
///-----------------------------------------------------
|
||||||
|
async function uepGetSchema(system = "search", organ = "monir") {
|
||||||
|
let payload = {
|
||||||
|
organ: organ,
|
||||||
|
system: system,
|
||||||
|
};
|
||||||
|
|
||||||
|
const url = elpApi.base.getSchema;
|
||||||
|
|
||||||
|
return await httpService
|
||||||
|
.postRequest(url, payload)
|
||||||
|
.then((res) => {
|
||||||
|
return res?.data;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
toast.add({
|
||||||
|
title: "خطا",
|
||||||
|
description: err?.message,
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return {};
|
||||||
|
});
|
||||||
|
|
||||||
|
dataEntrySchema.value = res?.data || {};
|
||||||
|
}
|
||||||
|
|
||||||
|
///-----------------------------------------------------
|
||||||
|
///--- گرفتن اطلاعات سند (GET Document)
|
||||||
|
///-----------------------------------------------------
|
||||||
|
async function uepGetDocument(entityId, key = "") {
|
||||||
|
if (!entityId) {
|
||||||
|
toast.add({
|
||||||
|
title: "خطا",
|
||||||
|
description: "شناسه وجود ندارد",
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!key) {
|
||||||
|
const config = useRuntimeConfig();
|
||||||
|
key = config.public.NUXT_PUBLIC_INDEX_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = elpApi.base.get_document;
|
||||||
|
url = url.replace("{{type_name}}", key);
|
||||||
|
url = url.replace("{{doc_id}}", entityId);
|
||||||
|
|
||||||
|
return await httpService
|
||||||
|
.getRequest(url)
|
||||||
|
.then((res) => {
|
||||||
|
return res; // معمولاً شامل doc_id یا کل سند ایجاد شده است
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error in 1 :", error);
|
||||||
|
toast.add({
|
||||||
|
title: "خطا",
|
||||||
|
description: "خطا در گرفتن سند، دوباره تلاش کنید",
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function myPostRequest(
|
||||||
|
url,
|
||||||
|
payload,
|
||||||
|
by_message = false,
|
||||||
|
message = "عملیات با موفقیت انجام شد"
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
const res = await httpService.postRequest(url, payload);
|
||||||
|
|
||||||
|
if (by_message && toast?.add) {
|
||||||
|
toast.add({
|
||||||
|
title: "موفق",
|
||||||
|
description: message,
|
||||||
|
icon: "i-lucide-file-plus",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in myPostRequest:", error);
|
||||||
|
|
||||||
|
if (toast?.add) {
|
||||||
|
toast.add({
|
||||||
|
title: "خطا",
|
||||||
|
description: "خطا در عملیات، دوباره تلاش کنید",
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///-----------------------------------------------------
|
||||||
|
///--- ایجاد سند جدید (Add Document)
|
||||||
|
///-- payload = {
|
||||||
|
///-- id: "" -- اختیاری
|
||||||
|
///-- docuemnt : {
|
||||||
|
///-- title: "..."
|
||||||
|
///-- ...
|
||||||
|
///-- sections: [ ... ]
|
||||||
|
///-- ...
|
||||||
|
///-- }
|
||||||
|
///-- }
|
||||||
|
|
||||||
|
///-----------------------------------------------------
|
||||||
|
async function uepAddDocument(payload, key = "", by_message = false) {
|
||||||
|
if (!payload) {
|
||||||
|
toast.add({
|
||||||
|
title: "خطا",
|
||||||
|
description: "دادههای سند برای ایجاد الزامی است",
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
let doc = {
|
||||||
|
document: { ...payload },
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!key) {
|
||||||
|
const config = useRuntimeConfig();
|
||||||
|
key = config.public.NUXT_PUBLIC_INDEX_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = elpApi.base.add_document;
|
||||||
|
url = url.replace("{{type_name}}", key);
|
||||||
|
|
||||||
|
return await httpService
|
||||||
|
.postRequest(url, doc)
|
||||||
|
.then((res) => {
|
||||||
|
if (by_message)
|
||||||
|
toast.add({
|
||||||
|
title: "موفق",
|
||||||
|
description: "سند جدید با موفقیت ایجاد شد.",
|
||||||
|
icon: "i-lucide-file-plus",
|
||||||
|
});
|
||||||
|
return res; // معمولاً شامل doc_id یا کل سند ایجاد شده است
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error in 1 :", error);
|
||||||
|
toast.add({
|
||||||
|
title: "خطا",
|
||||||
|
description: "خطا در ایجاد سند جدید، دوباره تلاش کنید",
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
async function uepInsertTree(payload, typeName = "gntree") {
|
||||||
|
if (!payload) {
|
||||||
|
toast.add({
|
||||||
|
title: "خطا",
|
||||||
|
description: "اطلاعات گره برای ایجاد الزامی است",
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = elpApi.Info.elp_insert_Tree.replace("{{type_name}}", typeName);
|
||||||
|
|
||||||
|
return await httpService.postRequest(url, payload).catch((error) => {
|
||||||
|
console.error("ساخت گرهٔ درخت ناموفق بود:", error);
|
||||||
|
toast.add({
|
||||||
|
title: "خطا",
|
||||||
|
description: "خطا در ایجاد گرهٔ درخت، دوباره تلاش کنید",
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function uepGetTree(payload, typeName = "gntree") {
|
||||||
|
const url = elpApi.Info.elp_get_Tree.replace("{{type_name}}", typeName);
|
||||||
|
|
||||||
|
return await httpService.postRequest(url, payload).catch((error) => {
|
||||||
|
console.error("خواندن درخت ناموفق بود:", error);
|
||||||
|
return [];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function uepDeleteTree(nodeId, typeName = "gntree") {
|
||||||
|
const url = elpApi.Info.elp_delete_Tree
|
||||||
|
.replace("{{type_name}}", typeName)
|
||||||
|
.replace("{{id}}", nodeId);
|
||||||
|
|
||||||
|
return await httpService.postRequest(url).catch((error) => {
|
||||||
|
console.error("حذف گرهٔ درخت ناموفق بود:", error);
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
async function uepUpdateTree(nodeId, payload, typeName = "gntree") {
|
||||||
|
if (!nodeId) {
|
||||||
|
toast.add({
|
||||||
|
title: "خطا",
|
||||||
|
description: "شناسه گره برای ویرایش الزامی است",
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!payload) {
|
||||||
|
toast.add({
|
||||||
|
title: "خطا",
|
||||||
|
description: "اطلاعات گره برای ویرایش الزامی است",
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = elpApi.Info.elp_update_Tree
|
||||||
|
.replace("{{type_name}}", typeName)
|
||||||
|
.replace("{{id}}", nodeId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
return await httpService.postRequest(url, payload);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("ویرایش گره درخت ناموفق بود:", error);
|
||||||
|
|
||||||
|
toast.add({
|
||||||
|
title: "خطا",
|
||||||
|
description: "خطا در ویرایش گره، دوباره تلاش کنید",
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
///-----------------------------------------------------
|
||||||
|
///--- آپدیت کامل داکیومنت (چند فیلد باهم)
|
||||||
|
///-- payload = {
|
||||||
|
///-- document : {
|
||||||
|
///-- title: "..."
|
||||||
|
///-- ...
|
||||||
|
///-- sections: [ ... ]
|
||||||
|
///-- ...
|
||||||
|
///-- }
|
||||||
|
///-- }
|
||||||
|
///-----------------------------------------------------
|
||||||
|
async function uepUpdateDocument(
|
||||||
|
doc_id,
|
||||||
|
payload,
|
||||||
|
key = "",
|
||||||
|
by_message = false
|
||||||
|
) {
|
||||||
|
if (!doc_id) return;
|
||||||
|
|
||||||
|
let doc = {
|
||||||
|
id: doc_id,
|
||||||
|
document: { ...payload },
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!key) {
|
||||||
|
const config = useRuntimeConfig();
|
||||||
|
key = config.public.NUXT_PUBLIC_INDEX_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = elpApi.base.update_document; // باید این route در بک وجود داشته باشد
|
||||||
|
url = url.replace("{{type_name}}", key);
|
||||||
|
url = url.replace("{{doc_id}}", doc_id);
|
||||||
|
|
||||||
|
return await httpService
|
||||||
|
.postRequest(url, doc)
|
||||||
|
.then((res) => {
|
||||||
|
if (by_message)
|
||||||
|
toast.add({
|
||||||
|
title: "موفق",
|
||||||
|
description: "سند با موفقیت بروزرسانی شد.",
|
||||||
|
icon: "i-lucide-check",
|
||||||
|
});
|
||||||
|
return res;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error("Error in 2 :", err);
|
||||||
|
toast.add({
|
||||||
|
title: "خطا",
|
||||||
|
description: "خطا در بروزرسانی سند " + err.message,
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
///-----------------------------------------------------
|
||||||
|
///--- یک فیلد را بروزرسانی می کند
|
||||||
|
///-- payload = {
|
||||||
|
///-- field_key: str
|
||||||
|
///-- field_value: Any
|
||||||
|
///-- action: str = 'edit' # edit, add, delete, full
|
||||||
|
///-- index_in_array: Optional[int] = None
|
||||||
|
///-- id_in_array: Optional[str] = None
|
||||||
|
///-- }
|
||||||
|
///-----------------------------------------------------
|
||||||
|
async function uepUpdateField(doc_id, payload, key = "", by_message = false) {
|
||||||
|
if (!doc_id) {
|
||||||
|
alert("شناسه uepUpdateField !!");
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
if (!key) {
|
||||||
|
const config = useRuntimeConfig();
|
||||||
|
key = config.public.NUXT_PUBLIC_INDEX_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = elpApi.base.update_field;
|
||||||
|
url = url.replace("{{type_name}}", key);
|
||||||
|
url = url.replace("{{doc_id}}", doc_id);
|
||||||
|
return await httpService
|
||||||
|
.postRequest(url, payload)
|
||||||
|
.then(() => {
|
||||||
|
if (by_message)
|
||||||
|
toast.add({
|
||||||
|
title: "موفق",
|
||||||
|
description: "عملیات با موفقیت انجام شد.",
|
||||||
|
icon: "i-lucide-calendar-days",
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error("Error in 3 :", err);
|
||||||
|
toast.add({
|
||||||
|
title: "خطا",
|
||||||
|
description: "خطا در انجام دوباره تلاش کنید",
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
///-----------------------------------------------------
|
||||||
|
///- حذف کامل یک سند با شناسه مشخص
|
||||||
|
///-----------------------------------------------------
|
||||||
|
async function uepDeleteDocument(doc_id, key = "", by_message = false) {
|
||||||
|
if (!doc_id) return;
|
||||||
|
|
||||||
|
if (!key) {
|
||||||
|
const config = useRuntimeConfig();
|
||||||
|
key = config.public.NUXT_PUBLIC_INDEX_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = elpApi.base.delete_document;
|
||||||
|
url = url.replace("{{type_name}}", key);
|
||||||
|
url = url.replace("{{doc_id}}", doc_id);
|
||||||
|
return await httpService
|
||||||
|
.postRequest(url, {})
|
||||||
|
.then(() => {
|
||||||
|
if (by_message)
|
||||||
|
toast.add({
|
||||||
|
title: "موفق",
|
||||||
|
description: "عملیات با موفقیت انجام شد.",
|
||||||
|
icon: "i-lucide-calendar-days",
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error("Error in 7 :", err);
|
||||||
|
toast.add({
|
||||||
|
title: "خطا",
|
||||||
|
description: "خطا در انجام دوباره تلاش کنید",
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
///-----------------------------------------------------
|
||||||
|
///--- با توجه به یک فیلد، مقدار محاسبه شده ای بر میگردند مثلا : بیشترین مقدار یا مجموع یا ...
|
||||||
|
///-----------------------------------------------------
|
||||||
|
async function uepGetComputeField(
|
||||||
|
key = "",
|
||||||
|
property_key = "meet_no",
|
||||||
|
compute_key = "max",
|
||||||
|
filters = {}
|
||||||
|
) {
|
||||||
|
let payload = {
|
||||||
|
compute_key,
|
||||||
|
property_key,
|
||||||
|
filters,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!key) {
|
||||||
|
const config = useRuntimeConfig();
|
||||||
|
key = config.public.NUXT_PUBLIC_INDEX_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = elpApi.base.compute_field;
|
||||||
|
url = url.replace("{{type_name}}", key);
|
||||||
|
|
||||||
|
return await httpService
|
||||||
|
.postRequest(url, payload)
|
||||||
|
.then((res) => {
|
||||||
|
return res;
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
toast.add({
|
||||||
|
title: "خطا",
|
||||||
|
description: "خطا در انجام عملیات، دوباره تلاش کنید",
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------
|
||||||
|
//-------------------------------------------
|
||||||
|
async function createSearchRequest(
|
||||||
|
index_key,
|
||||||
|
textSearch,
|
||||||
|
searchTypeKey,
|
||||||
|
mode_url = "normal",
|
||||||
|
filterPanel = "",
|
||||||
|
filterExtended = "",
|
||||||
|
offset = 0,
|
||||||
|
limit = 10,
|
||||||
|
field_collapse = "normal",
|
||||||
|
sortKey = "normal",
|
||||||
|
domainKey = "all",
|
||||||
|
domainSchema = {},
|
||||||
|
user_synonyms = {},
|
||||||
|
mirror_type = ""
|
||||||
|
) {
|
||||||
|
let _payload = {};
|
||||||
|
let domain_label = "";
|
||||||
|
let query_string = cleanTextUnpermittedChars(textSearch);
|
||||||
|
|
||||||
|
/* ===== Base URL ===== */
|
||||||
|
if (!index_key) {
|
||||||
|
const config = useRuntimeConfig();
|
||||||
|
index_key = config.public.NUXT_PUBLIC_INDEX_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
let baseUrl = "";
|
||||||
|
if (mode_url === "count") {
|
||||||
|
baseUrl = elpApi.search.elp_base_count;
|
||||||
|
baseUrl = baseUrl.replace("{{index_key}}", index_key);
|
||||||
|
}
|
||||||
|
if (mode_url === "elp_db") {
|
||||||
|
baseUrl = elpApi.search.elp_db_search;
|
||||||
|
baseUrl = baseUrl.replace("{{index_key}}", index_key);
|
||||||
|
} else if (mode_url === "elp_voice") {
|
||||||
|
baseUrl = elpApi.search.elp_voice_search;
|
||||||
|
baseUrl = baseUrl.replace("{{index_key}}", index_key);
|
||||||
|
} else if (mode_url === "mirror") {
|
||||||
|
baseUrl = repoApi.search.mirror_search;
|
||||||
|
baseUrl = baseUrl.replace("{{mirror_type}}", mirror_type);
|
||||||
|
} else if (mode_url === "elp_tree") {
|
||||||
|
baseUrl = elpApi.Info.elp_get_list_Tree;
|
||||||
|
baseUrl = baseUrl.replace("{{index_key}}", index_key);
|
||||||
|
} // if (mode_url === "elp" || mode_url == "")
|
||||||
|
else {
|
||||||
|
baseUrl = elpApi.search.elp_base_search;
|
||||||
|
baseUrl = baseUrl.replace("{{index_key}}", index_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ====Synonym / Vector / Normal
|
||||||
|
let sysnonymSearchQuery = "";
|
||||||
|
|
||||||
|
if (!searchTypeKey) searchTypeKey = "normal";
|
||||||
|
|
||||||
|
if (searchTypeKey === "synonym") {
|
||||||
|
let newSynonym = {};
|
||||||
|
|
||||||
|
if (user_synonyms) {
|
||||||
|
Object.keys(user_synonyms).forEach((key) => {
|
||||||
|
if (
|
||||||
|
!(
|
||||||
|
"isStopWord" in user_synonyms[key] &&
|
||||||
|
user_synonyms[key].isStopWord
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
newSynonym[key] = user_synonyms[key].value;
|
||||||
|
sysnonymSearchQuery += " " + key;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (textSearch === "" || textSearch === undefined)
|
||||||
|
textSearch = sysnonymSearchQuery;
|
||||||
|
|
||||||
|
if (Object.keys(newSynonym).length) {
|
||||||
|
_payload = {
|
||||||
|
synonym: newSynonym,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else if (searchTypeKey === "vector") {
|
||||||
|
/* ===== Vector ===== */
|
||||||
|
_payload = {
|
||||||
|
text: query_string,
|
||||||
|
};
|
||||||
|
} else if (!(textSearch === "" || textSearch === undefined)) {
|
||||||
|
/* ===== Normal ===== */
|
||||||
|
query_string = query_string;
|
||||||
|
|
||||||
|
if (!domainKey) domainKey = "all";
|
||||||
|
|
||||||
|
if (domainKey === "all") {
|
||||||
|
if (domainSchema?.type_action) {
|
||||||
|
let isNumberInput = /^\d+$/.test(query_string);
|
||||||
|
|
||||||
|
if (isNumberInput && domainSchema.type_action.number) {
|
||||||
|
let tag = domainSchema.type_action.number;
|
||||||
|
query_string = encodeURIComponent("#") + tag + " " + query_string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (domainKey !== "advance") {
|
||||||
|
let domainItem = domainSchema?.domain?.find(
|
||||||
|
(item) => item.key === domainKey
|
||||||
|
);
|
||||||
|
|
||||||
|
if (domainItem) {
|
||||||
|
domain_label = domainItem.label;
|
||||||
|
query_string =
|
||||||
|
encodeURIComponent("#") + domainItem.tag + " " + query_string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// === Filters
|
||||||
|
let filterFull = "";
|
||||||
|
|
||||||
|
if (searchTypeKey !== "vector" && query_string) {
|
||||||
|
filterFull += "q=" + query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
filterFull += filterPanel + filterExtended;
|
||||||
|
|
||||||
|
if (!filterFull) filterFull = "none";
|
||||||
|
|
||||||
|
// ==== URL Replace
|
||||||
|
let url = baseUrl;
|
||||||
|
const buildName = import.meta.env.VITE_BUILD_NAME;
|
||||||
|
|
||||||
|
url = url.replace("{{appname}}", buildName);
|
||||||
|
url = url.replace("{{index_key}}", index_key);
|
||||||
|
url = url.replace("{{search_type}}", searchTypeKey);
|
||||||
|
url = url.replace("{{sortKey}}", sortKey);
|
||||||
|
url = url.replace("{{field_collapse}}", field_collapse);
|
||||||
|
url = url.replace("{{offset}}", offset);
|
||||||
|
url = url.replace("{{limit}}", limit);
|
||||||
|
url = url.replace("{{filter}}", filterFull);
|
||||||
|
|
||||||
|
// == Payload
|
||||||
|
let filters = (filterPanel + filterExtended)
|
||||||
|
.split("&")
|
||||||
|
.filter((e) => e.length);
|
||||||
|
|
||||||
|
let filters_obj = {};
|
||||||
|
filters.forEach((fl) => {
|
||||||
|
let fl_items = fl.split("=");
|
||||||
|
if (fl_items.length === 2) filters_obj[fl_items[0]] = fl_items[1];
|
||||||
|
});
|
||||||
|
|
||||||
|
let payload_full = {
|
||||||
|
track_total_hits: true,
|
||||||
|
query: query_string,
|
||||||
|
search_type: searchTypeKey,
|
||||||
|
filters: filters_obj,
|
||||||
|
sort: [sortKey],
|
||||||
|
from_: offset,
|
||||||
|
size: limit,
|
||||||
|
collapse_field: field_collapse,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_payload.synonym) {
|
||||||
|
payload_full.user_synonyms = _payload.synonym;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
url,
|
||||||
|
payload_full,
|
||||||
|
payload: _payload,
|
||||||
|
sysnonymSearchQuery,
|
||||||
|
domainLabel: domain_label,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------
|
||||||
|
async function uepGetDataSearch({
|
||||||
|
index_key,
|
||||||
|
textSearch,
|
||||||
|
searchTypeKey,
|
||||||
|
mode_url,
|
||||||
|
filterPanel,
|
||||||
|
filterExtended,
|
||||||
|
filterids,
|
||||||
|
offset,
|
||||||
|
limit,
|
||||||
|
field_collapse,
|
||||||
|
sortKey,
|
||||||
|
domainKey,
|
||||||
|
domainSchema,
|
||||||
|
user_synonyms,
|
||||||
|
mirror_type,
|
||||||
|
synonymData,
|
||||||
|
aggregations,
|
||||||
|
}) {
|
||||||
|
if (!index_key) {
|
||||||
|
const config = useRuntimeConfig();
|
||||||
|
index_key = config.public.NUXT_PUBLIC_INDEX_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
const request = await createSearchRequest(
|
||||||
|
index_key,
|
||||||
|
textSearch ?? "",
|
||||||
|
searchTypeKey ?? "normal",
|
||||||
|
mode_url ?? "elp",
|
||||||
|
filterPanel ?? "",
|
||||||
|
filterExtended ?? "",
|
||||||
|
offset ?? 0,
|
||||||
|
limit ?? 10,
|
||||||
|
field_collapse ?? "normal",
|
||||||
|
sortKey ?? "normal",
|
||||||
|
domainKey ?? "all",
|
||||||
|
domainSchema ?? {},
|
||||||
|
user_synonyms ?? {},
|
||||||
|
mirror_type ?? ""
|
||||||
|
);
|
||||||
|
|
||||||
|
let payload_full = request.payload_full;
|
||||||
|
if (filterids?.length) {
|
||||||
|
if (!"filters" in payload_full) payload_full["filters"] = {};
|
||||||
|
payload_full.filters["ids"] = filterids;
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------
|
||||||
|
if (aggregations && Object.keys(aggregations).length) {
|
||||||
|
request.payload_full.aggregation_fields = aggregations;
|
||||||
|
}
|
||||||
|
//------------------
|
||||||
|
if (synonymData && Object.keys(synonymData).length) {
|
||||||
|
if (synonymData.synonyms?.length > 0) {
|
||||||
|
request.payload_full.synonyms = synonymData.synonyms;
|
||||||
|
}
|
||||||
|
if (Object.keys(synonymData.user_synonyms)?.length) {
|
||||||
|
request.payload_full.user_synonyms = synonymData.user_synonyms;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await httpService.postRequest(request.url, payload_full);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
return {};
|
||||||
|
} finally {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function uepLogSearchQuery(query) {
|
||||||
|
let key = "logsearch";
|
||||||
|
|
||||||
|
let doc = {
|
||||||
|
query,
|
||||||
|
};
|
||||||
|
|
||||||
|
let url = elpApi.base.add_document;
|
||||||
|
url = url.replace("{{type_name}}", key);
|
||||||
|
return await myPostRequest(url, doc, by_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------
|
||||||
|
//-------------------------------------------
|
||||||
|
|
||||||
|
// جستجوی معنایی از مسیر کارهای چت (chat job)
|
||||||
|
/*
|
||||||
|
offset و limit برای صفحهبندی است (مثل بقیهٔ متدهای جستجو)؛
|
||||||
|
در پیلود با نامهای from_ و size فرستاده میشوند که فیلدهای سرورند.
|
||||||
|
*/
|
||||||
|
async function uepChatJobSearchQuery(
|
||||||
|
query,
|
||||||
|
key,
|
||||||
|
filters = [],
|
||||||
|
offset = 0,
|
||||||
|
limit = 10,
|
||||||
|
lexical_weight = 0.5,
|
||||||
|
vector_weight = 0.5,
|
||||||
|
vector_reranker = false
|
||||||
|
) {
|
||||||
|
|
||||||
|
|
||||||
|
const url = elpApi.rag_chat.chat_job_search_query.replace(
|
||||||
|
"{{type_name}}",
|
||||||
|
key
|
||||||
|
);
|
||||||
|
|
||||||
|
let filters_obj = {};
|
||||||
|
filters.forEach((el) => {
|
||||||
|
let fls = el.split("&");
|
||||||
|
fls.forEach((fl) => {
|
||||||
|
let fl_items = fl.split("=");
|
||||||
|
if (fl_items.length === 2) filters_obj[fl_items[0]] = fl_items[1];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
query: query ?? "",
|
||||||
|
from_: offset,
|
||||||
|
size: limit,
|
||||||
|
lexical_weight,
|
||||||
|
vector_weight,
|
||||||
|
vector_reranker,
|
||||||
|
filters: filters_obj,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await httpService.postRequest(url, payload);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
} catch (err) {
|
||||||
|
console.error("uepChatJobSearchQuery error:", err);
|
||||||
|
return {};
|
||||||
|
} finally {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function uepChatRag(query, key, filters = [], is_rerank = false) {
|
||||||
|
if (!key) {
|
||||||
|
const config = useRuntimeConfig();
|
||||||
|
key = config.public.NUXT_PUBLIC_INDEX_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
let filters_obj = {};
|
||||||
|
filters.forEach((fl) => {
|
||||||
|
let fl_items = fl.split("=");
|
||||||
|
if (fl_items.length === 2) filters_obj[fl_items[0]] = fl_items[1];
|
||||||
|
});
|
||||||
|
|
||||||
|
let payload = {
|
||||||
|
query,
|
||||||
|
filters: filters_obj,
|
||||||
|
sort: ["normal"],
|
||||||
|
size: 100,
|
||||||
|
is_rerank,
|
||||||
|
rerank_limit: 10,
|
||||||
|
};
|
||||||
|
|
||||||
|
let url = elpApi.rag_chat.elp_chat;
|
||||||
|
url = url.replace("{{type_name}}", key);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await httpService.postRequest(
|
||||||
|
url,
|
||||||
|
payload,
|
||||||
|
{ timeout: 180000 } // سه دقیقه
|
||||||
|
);
|
||||||
|
|
||||||
|
if (res.status == "success") return res.result;
|
||||||
|
else return res;
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
return {};
|
||||||
|
} finally {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function uepCahtLLM(user_prompt) {
|
||||||
|
let payload = {
|
||||||
|
user_prompt,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await httpService.postRequest(
|
||||||
|
elpApi.rag_chat.note_action,
|
||||||
|
payload
|
||||||
|
);
|
||||||
|
|
||||||
|
if (res.status == "success") return res.result;
|
||||||
|
else return res;
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
return {};
|
||||||
|
} finally {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function uepJobAdd(payload, note_id, key = "", onProgress) {
|
||||||
|
if (!key) {
|
||||||
|
const config = useRuntimeConfig();
|
||||||
|
key = config.public.NUXT_PUBLIC_INDEX_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = elpApi.rag_chat.chat_job_query
|
||||||
|
.replace("{{type_name}}", key)
|
||||||
|
.replace("{{note_id}}", note_id);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await httpService.postRequest(url, payload);
|
||||||
|
// console.log("add res ==> ", res);
|
||||||
|
|
||||||
|
if (!res?.id) return res;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
} catch (err) {
|
||||||
|
console.error("uepJobAdd error:", err);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function uepJobGet(job_id) {
|
||||||
|
if (!job_id) return { job_status: "error", result: {} };
|
||||||
|
|
||||||
|
const url = elpApi.rag_chat.chat_job_get.replace("{{job_id}}", job_id);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await httpService.getRequest(url);
|
||||||
|
// console.log("get res ==> ", res);
|
||||||
|
|
||||||
|
const body = res?.result ?? res ?? {};
|
||||||
|
|
||||||
|
return {
|
||||||
|
...body,
|
||||||
|
result: body,
|
||||||
|
job_status: body.job_status ?? res?.job_status ?? "wait",
|
||||||
|
};
|
||||||
|
} catch (err) {
|
||||||
|
console.error("uepJobGet error:", err);
|
||||||
|
|
||||||
|
return { job_status: "wait", result: {}, has_error: true };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function uepJobWaitForFinish(job_id, onProgress, options = {}) {
|
||||||
|
const repeatTimeQuery = 5000;
|
||||||
|
const maxRetryOnError = 5;
|
||||||
|
const abortSignal = options.signal;
|
||||||
|
|
||||||
|
/*
|
||||||
|
اگر کاربر «توقف» را بزند، حلقه فوراً و بدون درخواست بعدی خارج میشود.
|
||||||
|
*/
|
||||||
|
function throwIfStopped() {
|
||||||
|
if (!abortSignal?.aborted) return;
|
||||||
|
|
||||||
|
const abortError = new Error("پاسخ متوقف شد");
|
||||||
|
abortError.name = "AbortError";
|
||||||
|
throw abortError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* انتظار بین دو درخواست، با قابلیت قطع فوری */
|
||||||
|
function waitForNextPoll() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
if (!abortSignal) {
|
||||||
|
setTimeout(resolve, repeatTimeQuery);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const timeoutId = setTimeout(() => {
|
||||||
|
abortSignal.removeEventListener("abort", handleAbort);
|
||||||
|
resolve();
|
||||||
|
}, repeatTimeQuery);
|
||||||
|
|
||||||
|
function handleAbort() {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
abortSignal.addEventListener("abort", handleAbort, { once: true });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let retry = 0;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
throwIfStopped();
|
||||||
|
|
||||||
|
const res = await uepJobGet(job_id);
|
||||||
|
|
||||||
|
throwIfStopped();
|
||||||
|
|
||||||
|
const result = res.result ?? {};
|
||||||
|
const status = res.job_status;
|
||||||
|
|
||||||
|
if (res.has_error) {
|
||||||
|
retry += 1;
|
||||||
|
|
||||||
|
if (retry > maxRetryOnError) {
|
||||||
|
throw new Error(`Job unreachable after ${retry} tries: ${job_id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
await waitForNextPoll();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
retry = 0;
|
||||||
|
|
||||||
|
if (typeof onProgress === "function") {
|
||||||
|
try {
|
||||||
|
onProgress(result, { job_status: status });
|
||||||
|
} catch (err) {
|
||||||
|
console.error("onProgress error:", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status === "finish") {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status === "error" || status === "cancel") {
|
||||||
|
throw new Error(`Job ${status}: ${job_id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
await waitForNextPoll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function uepJobAction(note_id, payload) {
|
||||||
|
// console.log("note_id, payload ==> ", note_id, payload);
|
||||||
|
if (!note_id) return {};
|
||||||
|
|
||||||
|
const url = elpApi.rag_chat.note_job_action.replace("{{note_id}}", note_id);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await httpService.postRequest(url, payload);
|
||||||
|
// console.log("action res ==> ", res);
|
||||||
|
|
||||||
|
if (res?.status === "success") return res.result;
|
||||||
|
return res;
|
||||||
|
} catch (err) {
|
||||||
|
console.error("uepJobAction error:", err);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ========== دریافت مترادف از سرور ==========
|
||||||
|
const getSynonymsFromServer = async (word) => {
|
||||||
|
try {
|
||||||
|
let payload = {
|
||||||
|
query: word,
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await httpService.postRequest(
|
||||||
|
elpApi.search.repo_synonym_words,
|
||||||
|
payload
|
||||||
|
);
|
||||||
|
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error:", error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
///-----------------------------------------------------
|
||||||
|
///-----------------------------------------------------
|
||||||
|
return {
|
||||||
|
uepGetDocument,
|
||||||
|
uepAddDocument,
|
||||||
|
uepInsertTree,
|
||||||
|
uepGetTree,
|
||||||
|
uepDeleteTree,
|
||||||
|
uepUpdateDocument,
|
||||||
|
uepDeleteDocument,
|
||||||
|
uepGetDataSearch,
|
||||||
|
uepChatJobSearchQuery,
|
||||||
|
uepChatRag,
|
||||||
|
uepCahtLLM,
|
||||||
|
getSynonymsFromServer,
|
||||||
|
uepUpdateField,
|
||||||
|
uepJobAdd,
|
||||||
|
uepJobGet,
|
||||||
|
uepJobWaitForFinish,
|
||||||
|
uepGetSchema,
|
||||||
|
uepGetComputeField,
|
||||||
|
uepJobAction,
|
||||||
|
uepUpdateTree,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default useElpService;
|
||||||
@@ -0,0 +1,504 @@
|
|||||||
|
import { ref, computed } from 'vue'
|
||||||
|
import * as XLSX from 'xlsx'
|
||||||
|
|
||||||
|
export type AttendanceStatus = 'present' | 'absent' | 'late' | 'excused'
|
||||||
|
|
||||||
|
export interface Student {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
code: string
|
||||||
|
avatar?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ClassItem {
|
||||||
|
id: string
|
||||||
|
title: string
|
||||||
|
code: string
|
||||||
|
teacherId: string
|
||||||
|
teacherName: string
|
||||||
|
days: string[]
|
||||||
|
time: string
|
||||||
|
startTime: string // مثلا "08:00"
|
||||||
|
endTime: string // مثلا "09:30"
|
||||||
|
room: string
|
||||||
|
studentCount: number
|
||||||
|
studentIds: string[]
|
||||||
|
isOngoingToday?: boolean
|
||||||
|
currentSessionTopic?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AttendanceRecord {
|
||||||
|
id: string
|
||||||
|
classId: string
|
||||||
|
studentId: string
|
||||||
|
studentName: string
|
||||||
|
studentCode: string
|
||||||
|
date: string // تاریخ شمسی
|
||||||
|
status: AttendanceStatus
|
||||||
|
delayMinutes: number
|
||||||
|
delayReason?: string
|
||||||
|
recordedAt?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StudentClassReport {
|
||||||
|
classId: string
|
||||||
|
className: string
|
||||||
|
teacherName: string
|
||||||
|
totalSessions: number
|
||||||
|
absentCount: number
|
||||||
|
lateCount: number
|
||||||
|
excusedCount: number
|
||||||
|
presentCount: number
|
||||||
|
isDropped: boolean // آیا به دلیل غیبت بیش از ۳ جلسه حذف شده
|
||||||
|
status: 'normal' | 'warning' | 'dropped' // وضعیت
|
||||||
|
sessions: {
|
||||||
|
date: string
|
||||||
|
sessionNumber: number
|
||||||
|
status: AttendanceStatus
|
||||||
|
delayMinutes?: number
|
||||||
|
reason?: string
|
||||||
|
}[]
|
||||||
|
}
|
||||||
|
|
||||||
|
// لیست طلاب حوزه
|
||||||
|
const mockStudentsList: Student[] = [
|
||||||
|
{ id: 's-101', name: 'محمدصادق حسینی', code: '۱۴۰۱۰۱۲۳' },
|
||||||
|
{ id: 's-102', name: 'علیرضا موسوینژاد', code: '۱۴۰۱۰۱۲۴' },
|
||||||
|
{ id: 's-103', name: 'امیرحسین رضایی', code: '۱۴۰۱۰۱۲۵' },
|
||||||
|
{ id: 's-104', name: 'مهدی تقوی', code: '۱۴۰۱۰۱۲۶' },
|
||||||
|
{ id: 's-105', name: 'حسین شمسآبادی', code: '۱۴۰۱۰۱۲۷' },
|
||||||
|
{ id: 's-106', name: 'سید علی فاطمی', code: '۱۴۰۱۰۱۲۸' },
|
||||||
|
{ id: 's-107', name: 'جعفر ابراهیمی', code: '۱۴۰۱۰۱۲۹' },
|
||||||
|
{ id: 's-108', name: 'رضا کریمیان', code: '۱۴۰۱۰۱۳۰' },
|
||||||
|
]
|
||||||
|
|
||||||
|
// اساتید حوزه
|
||||||
|
export const mockTeachersList = [
|
||||||
|
{ id: 't-201', name: 'حجتالاسلام والمسلمین استاد رفیعی' },
|
||||||
|
{ id: 't-202', name: 'آیتالله موسوی تهرانی' },
|
||||||
|
{ id: 't-203', name: 'استاد حسینی قمی' },
|
||||||
|
{ id: 't-204', name: 'حجتالاسلام والمسلمین استاد فرحزاد' },
|
||||||
|
]
|
||||||
|
|
||||||
|
// لیست کلاسهای تعریفشده
|
||||||
|
const initialClasses: ClassItem[] = [
|
||||||
|
{
|
||||||
|
id: 'c-1',
|
||||||
|
title: 'مکاسب محرمه (شیخ انصاری)',
|
||||||
|
code: 'FIQH-401',
|
||||||
|
teacherId: 't-201',
|
||||||
|
teacherName: 'حجتالاسلام والمسلمین استاد رفیعی',
|
||||||
|
days: ['شنبه', 'دوشنبه', 'چهارشنبه'],
|
||||||
|
time: '۰۸:۰۰ الی ۰۹:۳۰',
|
||||||
|
startTime: '08:00',
|
||||||
|
endTime: '09:30',
|
||||||
|
room: 'مدرس علامه طباطبایی (ره)',
|
||||||
|
studentCount: 8,
|
||||||
|
studentIds: ['s-101', 's-102', 's-103', 's-104', 's-105', 's-106', 's-107', 's-108'],
|
||||||
|
isOngoingToday: true,
|
||||||
|
currentSessionTopic: 'مسئله بیع عذره و اعیان نجسه'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'c-2',
|
||||||
|
title: 'کفایة الاصول (آخوند خراسانی)',
|
||||||
|
code: 'USUL-402',
|
||||||
|
teacherId: 't-201',
|
||||||
|
teacherName: 'حجتالاسلام والمسلمین استاد رفیعی',
|
||||||
|
days: ['یکشنبه', 'سهشنبه'],
|
||||||
|
time: '۱۰:۰۰ الی ۱۱:۳۰',
|
||||||
|
startTime: '10:00',
|
||||||
|
endTime: '11:30',
|
||||||
|
room: 'مدرس شهید مطهری',
|
||||||
|
studentCount: 7,
|
||||||
|
studentIds: ['s-101', 's-102', 's-103', 's-104', 's-106', 's-107', 's-108'],
|
||||||
|
isOngoingToday: true,
|
||||||
|
currentSessionTopic: 'مبحث مشتق و ادوار آن'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'c-3',
|
||||||
|
title: 'تفسیر ترتیبی قرآن کریم',
|
||||||
|
code: 'TAFS-301',
|
||||||
|
teacherId: 't-202',
|
||||||
|
teacherName: 'آیتالله موسوی تهرانی',
|
||||||
|
days: ['شنبه', 'چهارشنبه'],
|
||||||
|
time: '۱۱:۴۵ الی ۱۲:۴۵',
|
||||||
|
startTime: '11:45',
|
||||||
|
endTime: '12:45',
|
||||||
|
room: 'شبستان امام صادق (ع)',
|
||||||
|
studentCount: 8,
|
||||||
|
studentIds: ['s-101', 's-102', 's-103', 's-104', 's-105', 's-106', 's-107', 's-108'],
|
||||||
|
isOngoingToday: true,
|
||||||
|
currentSessionTopic: 'آیات ولایت و هدایت سوره مائده'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'c-4',
|
||||||
|
title: 'فن خطابه و مهارتهای تبلیغی',
|
||||||
|
code: 'KHTB-201',
|
||||||
|
teacherId: 't-204',
|
||||||
|
teacherName: 'حجتالاسلام والمسلمین استاد فرحزاد',
|
||||||
|
days: ['دوشنبه'],
|
||||||
|
time: '۱۵:۰۰ الی ۱۶:۳۰',
|
||||||
|
startTime: '15:00',
|
||||||
|
endTime: '16:30',
|
||||||
|
room: 'سالن همایشهای بینالمللی حوزه',
|
||||||
|
studentCount: 6,
|
||||||
|
studentIds: ['s-101', 's-103', 's-104', 's-105', 's-106', 's-108'],
|
||||||
|
isOngoingToday: false,
|
||||||
|
currentSessionTopic: 'اصول جذب مخاطب جوان'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
// سوابق حضور و غیاب امروز (قابل تغییر)
|
||||||
|
const initialAttendanceRecords: AttendanceRecord[] = [
|
||||||
|
// کلاس ۱ امروز
|
||||||
|
{ id: 'att-1', classId: 'c-1', studentId: 's-101', studentName: 'محمدصادق حسینی', studentCode: '۱۴۰۱۰۱۲۳', date: '۱۴۰۵/۰۸/۱۴', status: 'late', delayMinutes: 15, delayReason: 'مشکل حملونقل و ترافیک بینشهری', recordedAt: '۰۸:۱۵' },
|
||||||
|
{ id: 'att-2', classId: 'c-1', studentId: 's-102', studentName: 'علیرضا موسوینژاد', studentCode: '۱۴۰۱۰۱۲۴', date: '۱۴۰۵/۰۸/۱۴', status: 'present', delayMinutes: 0, recordedAt: '۰۷:۵۵' },
|
||||||
|
{ id: 'att-3', classId: 'c-1', studentId: 's-103', studentName: 'امیرحسین رضایی', studentCode: '۱۴۰۱۰۱۲۵', date: '۱۴۰۵/۰۸/۱۴', status: 'absent', delayMinutes: 0 },
|
||||||
|
{ id: 'att-4', classId: 'c-1', studentId: 's-104', studentName: 'مهدی تقوی', studentCode: '۱۴۰۱۰۱۲۶', date: '۱۴۰۵/۰۸/۱۴', status: 'present', delayMinutes: 0, recordedAt: '۰۸:۰۲' },
|
||||||
|
{ id: 'att-5', classId: 'c-1', studentId: 's-105', studentName: 'حسین شمسآبادی', studentCode: '۱۴۰۱۰۱۲۷', date: '۱۴۰۵/۰۸/۱۴', status: 'excused', delayMinutes: 0, delayReason: 'گواهی پزشکی ارائه شده' },
|
||||||
|
{ id: 'att-6', classId: 'c-1', studentId: 's-106', studentName: 'سید علی فاطمی', studentCode: '۱۴۰۱۰۱۲۸', date: '۱۴۰۵/۰۸/۱۴', status: 'present', delayMinutes: 0, recordedAt: '۰۷:۵۸' },
|
||||||
|
{ id: 'att-7', classId: 'c-1', studentId: 's-107', studentName: 'جعفر ابراهیمی', studentCode: '۱۴۰۱۰۱۲۹', date: '۱۴۰۵/۰۸/۱۴', status: 'absent', delayMinutes: 0 },
|
||||||
|
{ id: 'att-8', classId: 'c-1', studentId: 's-108', studentName: 'رضا کریمیان', studentCode: '۱۴۰۱۰۱۳۰', date: '۱۴۰۵/۰۸/۱۴', status: 'present', delayMinutes: 0, recordedAt: '۰۸:۰۰' },
|
||||||
|
|
||||||
|
// کلاس ۲ امروز
|
||||||
|
{ id: 'att-9', classId: 'c-2', studentId: 's-101', studentName: 'محمدصادق حسینی', studentCode: '۱۴۰۱۰۱۲۳', date: '۱۴۰۵/۰۸/۱۴', status: 'absent', delayMinutes: 0 },
|
||||||
|
{ id: 'att-10', classId: 'c-2', studentId: 's-102', studentName: 'علیرضا موسوینژاد', studentCode: '۱۴۰۱۰۱۲۴', date: '۱۴۰۵/۰۸/۱۴', status: 'present', delayMinutes: 0, recordedAt: '۱۰:۰۱' },
|
||||||
|
{ id: 'att-11', classId: 'c-2', studentId: 's-103', studentName: 'امیرحسین رضایی', studentCode: '۱۴۰۱۰۱۲۵', date: '۱۴۰۵/۰۸/۱۴', status: 'present', delayMinutes: 0, recordedAt: '۰۹:۵۵' },
|
||||||
|
{ id: 'att-12', classId: 'c-2', studentId: 's-104', studentName: 'مهدی تقوی', studentCode: '۱۴۰۱۰۱۲۶', date: '۱۴۰۵/۰۸/۱۴', status: 'late', delayMinutes: 20, delayReason: 'تحویل کتاب به کتابخانه مرکزی', recordedAt: '۱۰:۲۰' },
|
||||||
|
{ id: 'att-13', classId: 'c-2', studentId: 's-106', studentName: 'سید علی فاطمی', studentCode: '۱۴۰۱۰۱۲۸', date: '۱۴۰۵/۰۸/۱۴', status: 'present', delayMinutes: 0, recordedAt: '۱۰:۰۵' },
|
||||||
|
{ id: 'att-14', classId: 'c-2', studentId: 's-107', studentName: 'جعفر ابراهیمی', studentCode: '۱۴۰۱۰۱۲۹', date: '۱۴۰۵/۰۸/۱۴', status: 'absent', delayMinutes: 0 },
|
||||||
|
{ id: 'att-15', classId: 'c-2', studentId: 's-108', studentName: 'رضا کریمیان', studentCode: '۱۴۰۱۰۱۳۰', date: '۱۴۰۵/۰۸/۱۴', status: 'present', delayMinutes: 0, recordedAt: '۰۹:۵۸' },
|
||||||
|
|
||||||
|
// کلاس ۳ امروز
|
||||||
|
{ id: 'att-16', classId: 'c-3', studentId: 's-101', studentName: 'محمدصادق حسینی', studentCode: '۱۴۰۱۰۱۲۳', date: '۱۴۰۵/۰۸/۱4', status: 'absent', delayMinutes: 0 },
|
||||||
|
{ id: 'att-17', classId: 'c-3', studentId: 's-102', studentName: 'علیرضا موسوینژاد', studentCode: '۱۴۰۱۰۱۲۴', date: '۱۴۰۵/۰۸/۱۴', status: 'present', delayMinutes: 0, recordedAt: '۱۱:۴۰' },
|
||||||
|
]
|
||||||
|
|
||||||
|
// دادههای ریز تاریخچه جلسات برای طلبه جاری
|
||||||
|
const mockStudentHistory: StudentClassReport[] = [
|
||||||
|
{
|
||||||
|
classId: 'c-1',
|
||||||
|
className: 'مکاسب محرمه (شیخ انصاری)',
|
||||||
|
teacherName: 'حجتالاسلام والمسلمین استاد رفیعی',
|
||||||
|
totalSessions: 16,
|
||||||
|
absentCount: 2,
|
||||||
|
lateCount: 3,
|
||||||
|
excusedCount: 1,
|
||||||
|
presentCount: 10,
|
||||||
|
isDropped: false,
|
||||||
|
status: 'warning',
|
||||||
|
sessions: [
|
||||||
|
{ date: '۱۴۰۵/۰۸/۱۴', sessionNumber: 16, status: 'late', delayMinutes: 15, reason: 'مشکل حملونقل و ترافیک بینشهری' },
|
||||||
|
{ date: '۱۴۰۵/۰۸/۱۲', sessionNumber: 15, status: 'present' },
|
||||||
|
{ date: '۱۴۰۵/۰۸/۰۹', sessionNumber: 14, status: 'absent', reason: 'عدم حضور بدون هماهنگی' },
|
||||||
|
{ date: '۱۴۰۵/۰۸/۰۷', sessionNumber: 13, status: 'late', delayMinutes: 10, reason: 'جلسه با معاونت پژوهش' },
|
||||||
|
{ date: '۱۴۰۵/۰۸/۰۵', sessionNumber: 12, status: 'present' },
|
||||||
|
{ date: '۱۴۰۵/۰۸/۰۲', sessionNumber: 11, status: 'excused', reason: 'ماموریت تبلیغی معتبر' },
|
||||||
|
{ date: '۱۴۰۵/۰۷/۳۰', sessionNumber: 10, status: 'absent', reason: 'غیبت غیرموجه' },
|
||||||
|
{ date: '۱۴۰۵/۰۷/۲۸', sessionNumber: 9, status: 'present' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
classId: 'c-2',
|
||||||
|
className: 'کفایة الاصول (آخوند خراسانی)',
|
||||||
|
teacherName: 'حجتالاسلام والمسلمین استاد رفیعی',
|
||||||
|
totalSessions: 14,
|
||||||
|
absentCount: 4,
|
||||||
|
lateCount: 1,
|
||||||
|
excusedCount: 0,
|
||||||
|
presentCount: 9,
|
||||||
|
isDropped: true, // غیبت بیش از ۳ جلسه -> حذف
|
||||||
|
status: 'dropped',
|
||||||
|
sessions: [
|
||||||
|
{ date: '۱۴۰۵/۰۸/۱۴', sessionNumber: 14, status: 'absent', reason: 'عدم ثبت حضور' },
|
||||||
|
{ date: '۱۴۰۵/۰۸/۱۰', sessionNumber: 13, status: 'absent', reason: 'غیبت غیرموجه' },
|
||||||
|
{ date: '۱۴۰۵/۰۸/۰۸', sessionNumber: 12, status: 'absent', reason: 'غیبت غیرموجه' },
|
||||||
|
{ date: '۱4۰۵/۰۸/۰۳', sessionNumber: 11, status: 'absent', reason: 'غیبت غیرموجه' },
|
||||||
|
{ date: '۱۴۰۵/۰۸/۰۱', sessionNumber: 10, status: 'late', delayMinutes: 25, reason: 'تاخیر شدید در ورود به مدرسه' },
|
||||||
|
{ date: '۱۴۰۵/۰۷/۲۶', sessionNumber: 9, status: 'present' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
classId: 'c-3',
|
||||||
|
className: 'تفسیر ترتیبی قرآن کریم',
|
||||||
|
teacherName: 'آیتالله موسوی تهرانی',
|
||||||
|
totalSessions: 12,
|
||||||
|
absentCount: 0,
|
||||||
|
lateCount: 1,
|
||||||
|
excusedCount: 0,
|
||||||
|
presentCount: 11,
|
||||||
|
isDropped: false,
|
||||||
|
status: 'normal',
|
||||||
|
sessions: [
|
||||||
|
{ date: '۱۴۰۵/۰۸/۱۴', sessionNumber: 12, status: 'late', delayMinutes: 5, reason: 'تاخیر جزئی پس از اذان' },
|
||||||
|
{ date: '۱۴۰۵/۰۸/۰۹', sessionNumber: 11, status: 'present' },
|
||||||
|
{ date: '۱۴۰۵/۰۸/۰۷', sessionNumber: 10, status: 'present' },
|
||||||
|
{ date: '۱۴۰۵/۰۸/۰۲', sessionNumber: 9, status: 'present' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
classId: 'c-4',
|
||||||
|
className: 'فن خطابه و مهارتهای تبلیغی',
|
||||||
|
teacherName: 'حجتالاسلام والمسلمین استاد فرحزاد',
|
||||||
|
totalSessions: 8,
|
||||||
|
absentCount: 1,
|
||||||
|
lateCount: 0,
|
||||||
|
excusedCount: 1,
|
||||||
|
presentCount: 6,
|
||||||
|
isDropped: false,
|
||||||
|
status: 'normal',
|
||||||
|
sessions: [
|
||||||
|
{ date: '۱۴۰۵/۰۸/۰۴', sessionNumber: 8, status: 'present' },
|
||||||
|
{ date: '۱۴۰۵/۰۷/۲۷', sessionNumber: 7, status: 'excused', reason: 'هماهنگی با مدیر گروه تبلیغ' },
|
||||||
|
{ date: '۱۴۰۵/۰۷/۲۰', sessionNumber: 6, status: 'absent', reason: 'غیبت' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
// State های سراسری
|
||||||
|
const classes = ref<ClassItem[]>([...initialClasses])
|
||||||
|
const attendanceRecords = ref<AttendanceRecord[]>([...initialAttendanceRecords])
|
||||||
|
const students = ref<Student[]>([...mockStudentsList])
|
||||||
|
const studentReports = ref<StudentClassReport[]>([...mockStudentHistory])
|
||||||
|
|
||||||
|
export const useMockData = () => {
|
||||||
|
// تاریخ امروز به شمسی
|
||||||
|
const todayShamsi = 'چهارشنبه، ۱۴ آبان ۱۴۰۵'
|
||||||
|
|
||||||
|
// محاسبه تاخیر نسبت به ساعت شروع کلاس
|
||||||
|
const calculateDelay = (startTime: string): { isLate: boolean; minutes: number } => {
|
||||||
|
try {
|
||||||
|
const now = new Date()
|
||||||
|
const currentHours = now.getHours()
|
||||||
|
const currentMinutes = now.getMinutes()
|
||||||
|
|
||||||
|
const [startHourStr, startMinStr] = startTime.split(':')
|
||||||
|
const startH = parseInt(startHourStr, 10)
|
||||||
|
const startM = parseInt(startMinStr, 10)
|
||||||
|
|
||||||
|
const startTotalMinutes = startH * 60 + startM
|
||||||
|
const currentTotalMinutes = currentHours * 60 + currentMinutes
|
||||||
|
|
||||||
|
const diff = currentTotalMinutes - startTotalMinutes
|
||||||
|
|
||||||
|
if (diff > 0) {
|
||||||
|
return { isLate: true, minutes: diff }
|
||||||
|
}
|
||||||
|
return { isLate: false, minutes: 0 }
|
||||||
|
} catch {
|
||||||
|
return { isLate: false, minutes: 0 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ثبت حضور توسط طلبه
|
||||||
|
const submitStudentAttendance = (classId: string, studentId: string, delayMinutes: number, delayReason?: string) => {
|
||||||
|
const student = students.value.find(s => s.id === studentId) || { name: 'طلبه', code: '۰' }
|
||||||
|
const status: AttendanceStatus = delayMinutes > 0 ? 'late' : 'present'
|
||||||
|
|
||||||
|
const existingIndex = attendanceRecords.value.findIndex(r => r.classId === classId && r.studentId === studentId)
|
||||||
|
|
||||||
|
const now = new Date()
|
||||||
|
const recordedAt = `${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`
|
||||||
|
|
||||||
|
if (existingIndex > -1) {
|
||||||
|
attendanceRecords.value[existingIndex] = {
|
||||||
|
...attendanceRecords.value[existingIndex],
|
||||||
|
status,
|
||||||
|
delayMinutes,
|
||||||
|
delayReason: delayReason || attendanceRecords.value[existingIndex].delayReason,
|
||||||
|
recordedAt
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
attendanceRecords.value.push({
|
||||||
|
id: `att-${Date.now()}`,
|
||||||
|
classId,
|
||||||
|
studentId,
|
||||||
|
studentName: student.name,
|
||||||
|
studentCode: student.code,
|
||||||
|
date: '۱۴۰۵/۰۸/۱۴',
|
||||||
|
status,
|
||||||
|
delayMinutes,
|
||||||
|
delayReason,
|
||||||
|
recordedAt
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// بهروزرسانی گزارش طلبه در صورت نیاز
|
||||||
|
const report = studentReports.value.find(r => r.classId === classId)
|
||||||
|
if (report) {
|
||||||
|
const existingSession = report.sessions.find(s => s.date === '۱۴۰۵/۰۸/۱۴')
|
||||||
|
if (existingSession) {
|
||||||
|
existingSession.status = status
|
||||||
|
existingSession.delayMinutes = delayMinutes
|
||||||
|
existingSession.reason = delayReason
|
||||||
|
} else {
|
||||||
|
report.sessions.unshift({
|
||||||
|
date: '۱۴۰۵/۰۸/۱۴',
|
||||||
|
sessionNumber: report.totalSessions + 1,
|
||||||
|
status,
|
||||||
|
delayMinutes,
|
||||||
|
reason: delayReason
|
||||||
|
})
|
||||||
|
report.totalSessions++
|
||||||
|
}
|
||||||
|
// بازسازی شمارشها
|
||||||
|
report.presentCount = report.sessions.filter(s => s.status === 'present').length
|
||||||
|
report.lateCount = report.sessions.filter(s => s.status === 'late').length
|
||||||
|
report.absentCount = report.sessions.filter(s => s.status === 'absent').length
|
||||||
|
report.excusedCount = report.sessions.filter(s => s.status === 'excused').length
|
||||||
|
report.isDropped = report.absentCount >= 3
|
||||||
|
report.status = report.isDropped ? 'dropped' : report.absentCount >= 2 ? 'warning' : 'normal'
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// ویرایش سریع حضور و غیاب توسط استاد
|
||||||
|
const updateStudentStatus = (classId: string, studentId: string, newStatus: AttendanceStatus, delayMinutes = 0, delayReason = '') => {
|
||||||
|
const student = students.value.find(s => s.id === studentId)
|
||||||
|
const existingIndex = attendanceRecords.value.findIndex(r => r.classId === classId && r.studentId === studentId)
|
||||||
|
|
||||||
|
if (existingIndex > -1) {
|
||||||
|
attendanceRecords.value[existingIndex].status = newStatus
|
||||||
|
if (newStatus === 'late') {
|
||||||
|
attendanceRecords.value[existingIndex].delayMinutes = delayMinutes || 10
|
||||||
|
if (delayReason) attendanceRecords.value[existingIndex].delayReason = delayReason
|
||||||
|
} else {
|
||||||
|
attendanceRecords.value[existingIndex].delayMinutes = 0
|
||||||
|
if (newStatus === 'excused' && delayReason) {
|
||||||
|
attendanceRecords.value[existingIndex].delayReason = delayReason
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (student) {
|
||||||
|
attendanceRecords.value.push({
|
||||||
|
id: `att-${Date.now()}`,
|
||||||
|
classId,
|
||||||
|
studentId,
|
||||||
|
studentName: student.name,
|
||||||
|
studentCode: student.code,
|
||||||
|
date: '۱۴۰۵/۰۸/۱۴',
|
||||||
|
status: newStatus,
|
||||||
|
delayMinutes: newStatus === 'late' ? (delayMinutes || 10) : 0,
|
||||||
|
delayReason,
|
||||||
|
recordedAt: '۰۸:۳۰'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// مدیریت کلاسها توسط آموزش
|
||||||
|
const addClass = (newClass: Omit<ClassItem, 'id' | 'studentCount'>) => {
|
||||||
|
const id = `c-${Date.now()}`
|
||||||
|
const created: ClassItem = {
|
||||||
|
...newClass,
|
||||||
|
id,
|
||||||
|
studentCount: newClass.studentIds.length,
|
||||||
|
isOngoingToday: true
|
||||||
|
}
|
||||||
|
classes.value.push(created)
|
||||||
|
return created
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateClass = (classId: string, payload: Partial<ClassItem>) => {
|
||||||
|
const index = classes.value.findIndex(c => c.id === classId)
|
||||||
|
if (index > -1) {
|
||||||
|
classes.value[index] = {
|
||||||
|
...classes.value[index],
|
||||||
|
...payload,
|
||||||
|
studentCount: payload.studentIds ? payload.studentIds.length : classes.value[index].studentCount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteClass = (classId: string) => {
|
||||||
|
classes.value = classes.value.filter(c => c.id !== classId)
|
||||||
|
attendanceRecords.value = attendanceRecords.value.filter(r => r.classId !== classId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// استخراج فایل اکسل با xlsx
|
||||||
|
const exportToExcel = (data: any[], fileName: string, sheetName = 'گزارش حضور و غیاب') => {
|
||||||
|
try {
|
||||||
|
const worksheet = XLSX.utils.json_to_sheet(data)
|
||||||
|
const workbook = XLSX.utils.book_new()
|
||||||
|
XLSX.utils.book_append_sheet(workbook, worksheet, sheetName)
|
||||||
|
|
||||||
|
// تنظیم راستچین و جهت شیت در صورت امکان
|
||||||
|
if (!workbook.Workbook) workbook.Workbook = {}
|
||||||
|
if (!workbook.Workbook.Views) workbook.Workbook.Views = []
|
||||||
|
workbook.Workbook.Views[0] = { RTL: true }
|
||||||
|
|
||||||
|
XLSX.writeFile(workbook, `${fileName}.xlsx`)
|
||||||
|
return true
|
||||||
|
} catch (err) {
|
||||||
|
console.error('خطا در صدور فایل اکسل:', err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// گزارش آمار طلبه جاری
|
||||||
|
const studentTotalStats = computed(() => {
|
||||||
|
let totalClasses = studentReports.value.length
|
||||||
|
let totalSessions = 0
|
||||||
|
let totalAbsents = 0
|
||||||
|
let totalLates = 0
|
||||||
|
let totalExcused = 0
|
||||||
|
let totalPresents = 0
|
||||||
|
|
||||||
|
studentReports.value.forEach(r => {
|
||||||
|
totalSessions += r.totalSessions
|
||||||
|
totalAbsents += r.absentCount
|
||||||
|
totalLates += r.lateCount
|
||||||
|
totalExcused += r.excusedCount
|
||||||
|
totalPresents += r.presentCount
|
||||||
|
})
|
||||||
|
|
||||||
|
const presentRate = totalSessions > 0 ? Math.round(((totalPresents + totalLates + totalExcused) / totalSessions) * 100) : 100
|
||||||
|
|
||||||
|
return {
|
||||||
|
totalClasses,
|
||||||
|
totalSessions,
|
||||||
|
totalAbsents,
|
||||||
|
totalLates,
|
||||||
|
totalExcused,
|
||||||
|
presentRate,
|
||||||
|
droppedClassesCount: studentReports.value.filter(r => r.isDropped).length
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// گزارش آمار آموزش کلی حوزه
|
||||||
|
const adminOverallStats = computed(() => {
|
||||||
|
const totalClassesCount = classes.value.length
|
||||||
|
const totalTeachersCount = mockTeachersList.length
|
||||||
|
const totalStudentsCount = students.value.length
|
||||||
|
|
||||||
|
// میانگین حضور در رکوردهای ثبتشده
|
||||||
|
const recorded = attendanceRecords.value
|
||||||
|
const presentOrLate = recorded.filter(r => r.status === 'present' || r.status === 'late').length
|
||||||
|
const attendancePercentage = recorded.length > 0 ? Math.round((presentOrLate / recorded.length) * 100) : 92
|
||||||
|
|
||||||
|
return {
|
||||||
|
totalClassesCount,
|
||||||
|
totalTeachersCount,
|
||||||
|
totalStudentsCount,
|
||||||
|
attendancePercentage,
|
||||||
|
totalRecordsToday: recorded.length
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
classes,
|
||||||
|
students,
|
||||||
|
teachers: mockTeachersList,
|
||||||
|
attendanceRecords,
|
||||||
|
studentReports,
|
||||||
|
todayShamsi,
|
||||||
|
calculateDelay,
|
||||||
|
submitStudentAttendance,
|
||||||
|
updateStudentStatus,
|
||||||
|
addClass,
|
||||||
|
updateClass,
|
||||||
|
deleteClass,
|
||||||
|
exportToExcel,
|
||||||
|
studentTotalStats,
|
||||||
|
adminOverallStats
|
||||||
|
}
|
||||||
|
}
|
||||||
+37
-23
@@ -32,30 +32,32 @@
|
|||||||
>
|
>
|
||||||
صفحه اصلی
|
صفحه اصلی
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
|
<NuxtLink
|
||||||
|
to="/attendance"
|
||||||
|
class="px-3.5 py-2 rounded-xl text-stone-700 dark:text-stone-200 hover:text-primary-600 dark:hover:text-primary-400 hover:bg-stone-100 dark:hover:bg-stone-800 transition flex items-center gap-1.5"
|
||||||
|
>
|
||||||
|
<UIcon name="i-lucide-clipboard-check" class="w-4 h-4 text-primary-500" />
|
||||||
|
<span>سامانه حضور و غیاب</span>
|
||||||
|
</NuxtLink>
|
||||||
|
<NuxtLink
|
||||||
|
to="/dashboard"
|
||||||
|
class="px-3.5 py-2 rounded-xl text-stone-700 dark:text-stone-200 hover:text-primary-600 dark:hover:text-primary-400 hover:bg-stone-100 dark:hover:bg-stone-800 transition flex items-center gap-1.5"
|
||||||
|
>
|
||||||
|
<UIcon name="i-lucide-layout-dashboard" class="w-4 h-4 text-primary-500" />
|
||||||
|
<span>داشبورد گزارشات</span>
|
||||||
|
</NuxtLink>
|
||||||
<a
|
<a
|
||||||
href="#departments"
|
href="/#departments"
|
||||||
class="px-3.5 py-2 rounded-xl text-stone-700 dark:text-stone-200 hover:text-primary-600 dark:hover:text-primary-400 hover:bg-stone-100 dark:hover:bg-stone-800 transition"
|
class="px-3.5 py-2 rounded-xl text-stone-700 dark:text-stone-200 hover:text-primary-600 dark:hover:text-primary-400 hover:bg-stone-100 dark:hover:bg-stone-800 transition"
|
||||||
>
|
>
|
||||||
معاونتها
|
معاونتها
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
href="#courses"
|
href="/#courses"
|
||||||
class="px-3.5 py-2 rounded-xl text-stone-700 dark:text-stone-200 hover:text-primary-600 dark:hover:text-primary-400 hover:bg-stone-100 dark:hover:bg-stone-800 transition"
|
class="px-3.5 py-2 rounded-xl text-stone-700 dark:text-stone-200 hover:text-primary-600 dark:hover:text-primary-400 hover:bg-stone-100 dark:hover:bg-stone-800 transition"
|
||||||
>
|
>
|
||||||
دورههای آموزشی
|
دورههای آموزشی
|
||||||
</a>
|
</a>
|
||||||
<a
|
|
||||||
href="#news"
|
|
||||||
class="px-3.5 py-2 rounded-xl text-stone-700 dark:text-stone-200 hover:text-primary-600 dark:hover:text-primary-400 hover:bg-stone-100 dark:hover:bg-stone-800 transition"
|
|
||||||
>
|
|
||||||
اخبار و اطلاعیهها
|
|
||||||
</a>
|
|
||||||
<a
|
|
||||||
href="#contact"
|
|
||||||
class="px-3.5 py-2 rounded-xl text-stone-700 dark:text-stone-200 hover:text-primary-600 dark:hover:text-primary-400 hover:bg-stone-100 dark:hover:bg-stone-800 transition"
|
|
||||||
>
|
|
||||||
ارتباط با مدرسه
|
|
||||||
</a>
|
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<!-- Header Actions & Theme Settings -->
|
<!-- Header Actions & Theme Settings -->
|
||||||
@@ -82,15 +84,27 @@
|
|||||||
@click="toggleDarkMode"
|
@click="toggleDarkMode"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- Student Portal Button -->
|
<!-- Portal Buttons in Header -->
|
||||||
<UButton
|
<NuxtLink to="/attendance">
|
||||||
color="primary"
|
<UButton
|
||||||
variant="solid"
|
color="primary"
|
||||||
size="md"
|
variant="solid"
|
||||||
:icon="getIcon('user', 'i-lucide-user')"
|
size="sm"
|
||||||
label="ورود طلاب و اساتید"
|
icon="i-lucide-clipboard-check"
|
||||||
class="hidden sm:inline-flex shadow-sm"
|
label="سامانه حضور و غیاب"
|
||||||
/>
|
class="hidden sm:inline-flex shadow-sm font-bold text-xs"
|
||||||
|
/>
|
||||||
|
</NuxtLink>
|
||||||
|
<NuxtLink to="/dashboard">
|
||||||
|
<UButton
|
||||||
|
color="neutral"
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
icon="i-lucide-layout-dashboard"
|
||||||
|
label="داشبورد گزارشات"
|
||||||
|
class="hidden md:inline-flex font-bold text-xs"
|
||||||
|
/>
|
||||||
|
</NuxtLink>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -0,0 +1,722 @@
|
|||||||
|
<template>
|
||||||
|
<div class="space-y-8 pb-16">
|
||||||
|
<!-- Top Bar: Title, Live Date & 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-clock" class="w-3.5 h-3.5 text-primary-600" />
|
||||||
|
<span>{{ todayShamsi }}</span>
|
||||||
|
<span class="text-stone-300 dark:text-stone-700">•</span>
|
||||||
|
<span class="font-mono font-bold">{{ currentTimeStr }}</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 Breadcrumb & Back to Home -->
|
||||||
|
<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="/"
|
||||||
|
class="px-3.5 py-1.5 rounded-xl text-xs sm:text-sm font-bold text-stone-700 dark:text-stone-200 hover:bg-stone-100 dark:hover:bg-stone-800 transition flex items-center gap-1.5 border border-stone-200 dark:border-stone-800"
|
||||||
|
>
|
||||||
|
<UIcon name="i-lucide-arrow-right" class="w-4 h-4 text-primary-500" />
|
||||||
|
<span>بازگشت به صفحه اصلی</span>
|
||||||
|
</NuxtLink>
|
||||||
|
<div class="h-4 w-px bg-stone-200 dark:bg-stone-800 mx-1"></div>
|
||||||
|
<span class="px-3 py-1.5 rounded-xl text-xs font-extrabold bg-primary-500/10 text-primary-600 dark:text-primary-400 border border-primary-500/20 flex items-center gap-1.5">
|
||||||
|
<UIcon name="i-lucide-clipboard-check" class="w-4 h-4" />
|
||||||
|
<span>سامانه حضور و غیاب امروز</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-xs text-stone-400 font-medium hidden sm:block">
|
||||||
|
نقش فعال: <strong class="text-primary-600">{{ roleLabels[currentRole] }}</strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ============================================================= -->
|
||||||
|
<!-- ۱. نمای طلبه (STUDENT VIEW) -->
|
||||||
|
<!-- ============================================================= -->
|
||||||
|
<div v-if="currentRole === 'student'" class="space-y-6">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<h2 class="text-lg font-extrabold text-stone-900 dark:text-white">کلاسهای امروز شما</h2>
|
||||||
|
<p class="text-xs text-stone-500 dark:text-stone-400">برای ثبت حضور در هر کلاس روی دکمه مربوطه کلیک کنید</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Grid of Today Classes -->
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||||
|
<div
|
||||||
|
v-for="c in todayStudentClasses"
|
||||||
|
:key="c.id"
|
||||||
|
class="p-6 rounded-3xl bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-800 shadow-sm flex flex-col justify-between space-y-4 hover:border-primary-500/50 transition group"
|
||||||
|
>
|
||||||
|
<div class="space-y-3">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<span class="text-[11px] font-mono px-2 py-0.5 rounded bg-stone-100 dark:bg-stone-800 text-stone-600 dark:text-stone-300">
|
||||||
|
{{ c.code }}
|
||||||
|
</span>
|
||||||
|
<UiBadge :status="getStudentStatusForClass(c.id).status" :label="getStudentStatusForClass(c.id).label" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3 class="text-base font-bold text-stone-900 dark:text-white leading-snug">
|
||||||
|
{{ c.title }}
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<div class="space-y-1.5 text-xs text-stone-600 dark:text-stone-300">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<UIcon name="i-lucide-user" class="w-4 h-4 text-primary-500" />
|
||||||
|
<span>{{ c.teacherName }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<UIcon name="i-lucide-clock" class="w-4 h-4 text-stone-400" />
|
||||||
|
<span>ساعت: <strong>{{ c.time }}</strong></span>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<UIcon name="i-lucide-map-pin" class="w-4 h-4 text-stone-400" />
|
||||||
|
<span>مکان: {{ c.room }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="c.currentSessionTopic" class="p-2.5 rounded-xl bg-stone-50 dark:bg-stone-800/60 text-[11px] text-stone-600 dark:text-stone-300 border border-stone-100 dark:border-stone-700/60">
|
||||||
|
<span class="font-bold text-primary-600">موضوع جلسه:</span> {{ c.currentSessionTopic }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Action Button -->
|
||||||
|
<div class="pt-3 border-t border-stone-100 dark:border-stone-800">
|
||||||
|
<UButton
|
||||||
|
v-if="getStudentStatusForClass(c.id).status === 'absent'"
|
||||||
|
block
|
||||||
|
color="primary"
|
||||||
|
variant="solid"
|
||||||
|
size="md"
|
||||||
|
label="ثبت حضور در کلاس"
|
||||||
|
icon="i-lucide-check-circle-2"
|
||||||
|
@click="openStudentAttendanceModal(c)"
|
||||||
|
/>
|
||||||
|
<div v-else class="flex items-center justify-between text-xs text-stone-500">
|
||||||
|
<span class="flex items-center gap-1.5 text-emerald-600 dark:text-emerald-400 font-bold">
|
||||||
|
<UIcon name="i-lucide-check-check" class="w-4 h-4" />
|
||||||
|
حضور شما ثبت شده است
|
||||||
|
</span>
|
||||||
|
<button
|
||||||
|
class="text-xs text-primary-600 hover:underline"
|
||||||
|
@click="openStudentAttendanceModal(c)"
|
||||||
|
>
|
||||||
|
مشاهده یا ویرایش
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal: Student Attendance Submission -->
|
||||||
|
<AppModal
|
||||||
|
v-model="isStudentModalOpen"
|
||||||
|
title="ثبت حضور در کلاس درس"
|
||||||
|
description="سامانه هوشمند حضور و غیاب حوزه علمیه سفیران هدایت"
|
||||||
|
size="md"
|
||||||
|
>
|
||||||
|
<div v-if="selectedClassForStudent" class="space-y-4 text-xs">
|
||||||
|
<!-- Class Summary Box -->
|
||||||
|
<div class="p-4 rounded-2xl bg-stone-50 dark:bg-stone-800/60 border border-stone-200 dark:border-stone-700 space-y-2">
|
||||||
|
<div class="text-sm font-bold text-stone-900 dark:text-white">{{ selectedClassForStudent.title }}</div>
|
||||||
|
<div class="grid grid-cols-2 gap-2 text-stone-600 dark:text-stone-300">
|
||||||
|
<div>استاد: <strong>{{ selectedClassForStudent.teacherName }}</strong></div>
|
||||||
|
<div>مکان: <strong>{{ selectedClassForStudent.room }}</strong></div>
|
||||||
|
<div>ساعت شروع: <strong class="font-mono text-primary-600">{{ selectedClassForStudent.startTime }}</strong></div>
|
||||||
|
<div>ساعت فعلی: <strong class="font-mono">{{ currentTimeStr }}</strong></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Delay Warning & Required Reason -->
|
||||||
|
<div v-if="studentDelayCalculation.isLate" class="p-4 rounded-2xl bg-amber-50 dark:bg-amber-950/40 border border-amber-300 dark:border-amber-800 space-y-3">
|
||||||
|
<div class="flex items-center gap-2 text-amber-800 dark:text-amber-200 font-bold">
|
||||||
|
<UIcon name="i-lucide-alert-triangle" class="w-5 h-5 text-amber-600" />
|
||||||
|
<span>محاسبه خودکار سیستم: {{ studentDelayCalculation.minutes }} دقیقه تاخیر نسبت به ساعت شروع</span>
|
||||||
|
</div>
|
||||||
|
<p class="text-[11px] text-amber-700 dark:text-amber-300 leading-relaxed">
|
||||||
|
با توجه به قوانین آموزشی حوزه، برای ثبت حضور با تاخیر باید **علت موجه تاخیر** خود را ثبت فرمایید:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-stone-800 dark:text-stone-200 mb-1">
|
||||||
|
علت تاخیر <span class="text-rose-500">* (الزامی)</span>:
|
||||||
|
</label>
|
||||||
|
<textarea
|
||||||
|
v-model="studentDelayReason"
|
||||||
|
rows="3"
|
||||||
|
placeholder="لطفاً دلیل تاخیر خود را به طور شفاف توضیح دهید (حداقل ۵ کاراکتر)..."
|
||||||
|
class="w-full px-3 py-2 text-xs rounded-xl border border-amber-300 dark:border-amber-700 bg-white dark:bg-stone-900 focus:outline-none focus:ring-2 focus:ring-amber-500"
|
||||||
|
></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Simulation Delay Toggle for Testing -->
|
||||||
|
<div class="p-3 rounded-xl border border-dashed border-stone-300 dark:border-stone-700 text-stone-500 flex items-center justify-between">
|
||||||
|
<span class="text-[11px]">شبیهسازی تاخیر برای تست مودال:</span>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="px-2 py-1 rounded text-[11px] font-bold"
|
||||||
|
:class="simulateLate ? 'bg-amber-500 text-white' : 'bg-stone-200 text-stone-700'"
|
||||||
|
@click="simulateLate = !simulateLate"
|
||||||
|
>
|
||||||
|
{{ simulateLate ? 'حالت با تاخیر فعال' : 'حالت سر وقت' }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #footer="{ close }">
|
||||||
|
<UButton color="neutral" variant="outline" label="انصراف" @click="close" />
|
||||||
|
<UButton
|
||||||
|
color="primary"
|
||||||
|
variant="solid"
|
||||||
|
label="ثبت قطعی حضور"
|
||||||
|
icon="i-lucide-check"
|
||||||
|
:disabled="studentDelayCalculation.isLate && (!studentDelayReason || studentDelayReason.trim().length < 5)"
|
||||||
|
@click="handleStudentSubmitAttendance"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</AppModal>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ============================================================= -->
|
||||||
|
<!-- ۲. نمای استاد (TEACHER VIEW) -->
|
||||||
|
<!-- ============================================================= -->
|
||||||
|
<div v-else-if="currentRole === 'teacher'" class="space-y-6">
|
||||||
|
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
||||||
|
<div>
|
||||||
|
<h2 class="text-lg font-extrabold text-stone-900 dark:text-white">کلاسهای شما (ثبت و بازبینی حضور و غیاب)</h2>
|
||||||
|
<p class="text-xs text-stone-500 dark:text-stone-400">کلاس مورد نظر را انتخاب و وضعیت طلاب را مشخص نمایید</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Class Selector Buttons -->
|
||||||
|
<div class="flex flex-wrap gap-2">
|
||||||
|
<button
|
||||||
|
v-for="c in teacherClasses"
|
||||||
|
:key="c.id"
|
||||||
|
type="button"
|
||||||
|
class="px-3.5 py-2 rounded-xl text-xs font-bold transition flex items-center gap-2 border"
|
||||||
|
:class="selectedTeacherClassId === c.id
|
||||||
|
? 'bg-primary-500 text-white border-primary-500 shadow-md shadow-primary-500/20'
|
||||||
|
: 'bg-white dark:bg-stone-900 text-stone-700 dark:text-stone-300 border-stone-200 dark:border-stone-800 hover:border-primary-400'"
|
||||||
|
@click="selectedTeacherClassId = c.id"
|
||||||
|
>
|
||||||
|
<UIcon name="i-lucide-book" class="w-3.5 h-3.5" />
|
||||||
|
<span>{{ c.title }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Class Attendance Table & Stats Card -->
|
||||||
|
<div v-if="currentTeacherClass" class="bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-800 rounded-3xl p-6 shadow-sm space-y-6">
|
||||||
|
<!-- Summary Counters Header -->
|
||||||
|
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4 pb-4 border-b border-stone-100 dark:border-stone-800">
|
||||||
|
<div>
|
||||||
|
<h3 class="text-base font-bold text-stone-900 dark:text-white flex items-center gap-2">
|
||||||
|
<span>لیست طلاب کلاس: {{ currentTeacherClass.title }}</span>
|
||||||
|
<span class="text-xs font-normal text-stone-400">({{ currentTeacherClass.time }} - {{ currentTeacherClass.room }})</span>
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Quick Stats Pills -->
|
||||||
|
<div class="flex flex-wrap items-center gap-2 text-xs">
|
||||||
|
<span class="px-3 py-1 rounded-xl bg-stone-100 dark:bg-stone-800 text-stone-700 dark:text-stone-300 font-bold">
|
||||||
|
کل طلاب: {{ teacherClassStats.total }}
|
||||||
|
</span>
|
||||||
|
<span class="px-3 py-1 rounded-xl bg-emerald-100 dark:bg-emerald-950/60 text-emerald-800 dark:text-emerald-300 font-bold">
|
||||||
|
حاضر: {{ teacherClassStats.present }}
|
||||||
|
</span>
|
||||||
|
<span class="px-3 py-1 rounded-xl bg-amber-100 dark:bg-amber-950/60 text-amber-800 dark:text-amber-300 font-bold">
|
||||||
|
تاخیر: {{ teacherClassStats.late }}
|
||||||
|
</span>
|
||||||
|
<span class="px-3 py-1 rounded-xl bg-rose-100 dark:bg-rose-950/60 text-rose-800 dark:text-rose-300 font-bold">
|
||||||
|
غایب: {{ teacherClassStats.absent }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Attendance Students Table -->
|
||||||
|
<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">کد تحصیلی</th>
|
||||||
|
<th class="py-3 px-4">وضعیت حضور</th>
|
||||||
|
<th class="py-3 px-4">میزان و علت تاخیر</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="(st, idx) in teacherClassStudents"
|
||||||
|
:key="st.id"
|
||||||
|
class="hover:bg-stone-50/50 dark:hover:bg-stone-800/30 transition"
|
||||||
|
:class="getTeacherRecord(st.id)?.status === 'absent' ? 'bg-rose-50/30 dark:bg-rose-950/10' : ''"
|
||||||
|
>
|
||||||
|
<td class="py-3 px-4 font-mono text-stone-400">{{ idx + 1 }}</td>
|
||||||
|
<td class="py-3 px-4 font-bold text-stone-900 dark:text-white flex items-center gap-2">
|
||||||
|
<div class="w-7 h-7 rounded-full bg-stone-200 dark:bg-stone-800 text-stone-700 dark:text-stone-300 flex items-center justify-center font-bold text-[11px]">
|
||||||
|
{{ st.name.charAt(0) }}
|
||||||
|
</div>
|
||||||
|
<span>{{ st.name }}</span>
|
||||||
|
</td>
|
||||||
|
<td class="py-3 px-4 font-mono text-stone-500">{{ st.code }}</td>
|
||||||
|
<td class="py-3 px-4">
|
||||||
|
<UiBadge
|
||||||
|
:status="getTeacherRecord(st.id)?.status || 'absent'"
|
||||||
|
:label="getStatusLabel(getTeacherRecord(st.id)?.status || 'absent')"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td class="py-3 px-4 text-stone-600 dark:text-stone-300 max-w-xs">
|
||||||
|
<div v-if="getTeacherRecord(st.id)?.status === 'late'">
|
||||||
|
<span class="font-bold text-amber-600">{{ getTeacherRecord(st.id)?.delayMinutes }} دقیقه: </span>
|
||||||
|
<span>{{ getTeacherRecord(st.id)?.delayReason || 'بدون توضیح' }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="getTeacherRecord(st.id)?.status === 'excused'">
|
||||||
|
<span class="text-blue-600 font-semibold">{{ getTeacherRecord(st.id)?.delayReason || 'غیبت موجه' }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-else class="text-stone-400">-</div>
|
||||||
|
</td>
|
||||||
|
<td class="py-3 px-4">
|
||||||
|
<!-- Quick status selector buttons for teacher -->
|
||||||
|
<div class="flex items-center justify-center gap-1">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="px-2 py-1 rounded text-[11px] font-bold transition"
|
||||||
|
:class="getTeacherRecord(st.id)?.status === 'present' ? 'bg-emerald-500 text-white' : 'bg-stone-100 dark:bg-stone-800 text-stone-600 hover:bg-emerald-100'"
|
||||||
|
title="حاضر"
|
||||||
|
@click="setStudentAttendance(st.id, 'present')"
|
||||||
|
>
|
||||||
|
حاضر
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="px-2 py-1 rounded text-[11px] font-bold transition"
|
||||||
|
:class="getTeacherRecord(st.id)?.status === 'late' ? 'bg-amber-500 text-white' : 'bg-stone-100 dark:bg-stone-800 text-stone-600 hover:bg-amber-100'"
|
||||||
|
title="تاخیر"
|
||||||
|
@click="promptTeacherLate(st)"
|
||||||
|
>
|
||||||
|
تاخیر
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="px-2 py-1 rounded text-[11px] font-bold transition"
|
||||||
|
:class="getTeacherRecord(st.id)?.status === 'excused' ? 'bg-blue-500 text-white' : 'bg-stone-100 dark:bg-stone-800 text-stone-600 hover:bg-blue-100'"
|
||||||
|
title="موجه"
|
||||||
|
@click="promptTeacherExcused(st)"
|
||||||
|
>
|
||||||
|
مجاز
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="px-2 py-1 rounded text-[11px] font-bold transition"
|
||||||
|
:class="getTeacherRecord(st.id)?.status === 'absent' ? 'bg-rose-500 text-white' : 'bg-stone-100 dark:bg-stone-800 text-stone-600 hover:bg-rose-100'"
|
||||||
|
title="غایب"
|
||||||
|
@click="setStudentAttendance(st.id, 'absent')"
|
||||||
|
>
|
||||||
|
غایب
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ============================================================= -->
|
||||||
|
<!-- ۳. نمای آموزش (ADMIN MONITORING VIEW) -->
|
||||||
|
<!-- ============================================================= -->
|
||||||
|
<div v-else-if="currentRole === 'admin'" class="space-y-6">
|
||||||
|
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
||||||
|
<div>
|
||||||
|
<h2 class="text-lg font-extrabold text-stone-900 dark:text-white">نظارت بر کلاسهای در حال برگزاری</h2>
|
||||||
|
<p class="text-xs text-stone-500 dark:text-stone-400">مشاهده آمار حضور و غیاب لحظهای کلاسها به تفکیک درس و استاد</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Filter bar -->
|
||||||
|
<div class="flex flex-wrap items-center gap-3 text-xs">
|
||||||
|
<input
|
||||||
|
v-model="adminSearchQuery"
|
||||||
|
type="text"
|
||||||
|
placeholder="جستجوی درس، استاد یا مدرس..."
|
||||||
|
class="px-3.5 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"
|
||||||
|
/>
|
||||||
|
<select
|
||||||
|
v-model="adminTeacherFilter"
|
||||||
|
class="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>
|
||||||
|
|
||||||
|
<!-- Classes Grid for Admin -->
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||||
|
<div
|
||||||
|
v-for="c in filteredAdminClasses"
|
||||||
|
:key="c.id"
|
||||||
|
class="p-6 rounded-3xl bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-800 shadow-sm hover:border-primary-500/50 transition cursor-pointer flex flex-col justify-between space-y-4"
|
||||||
|
@click="openAdminClassDetails(c)"
|
||||||
|
>
|
||||||
|
<div class="space-y-3">
|
||||||
|
<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 py-0.5 rounded">
|
||||||
|
{{ c.code }}
|
||||||
|
</span>
|
||||||
|
<span class="text-xs text-stone-500">{{ c.time }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3 class="font-bold text-base text-stone-900 dark:text-white leading-snug">
|
||||||
|
{{ c.title }}
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<div class="space-y-1 text-xs text-stone-600 dark:text-stone-300">
|
||||||
|
<div>استاد: <strong class="text-stone-800 dark:text-stone-100">{{ c.teacherName }}</strong></div>
|
||||||
|
<div>مکان: {{ c.room }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Progress bar of attendance -->
|
||||||
|
<div class="space-y-1.5 pt-2">
|
||||||
|
<div class="flex items-center justify-between text-xs">
|
||||||
|
<span>تعداد حاضرین:</span>
|
||||||
|
<span class="font-bold font-mono">
|
||||||
|
{{ getAdminClassAttendanceStats(c.id).presentCount }} از {{ c.studentCount }} نفر
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="w-full h-2 rounded-full bg-stone-100 dark:bg-stone-800 overflow-hidden">
|
||||||
|
<div
|
||||||
|
class="h-full bg-primary-500 rounded-full transition-all duration-300"
|
||||||
|
:style="{ width: `${getAdminClassAttendanceStats(c.id).percentage}%` }"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pt-3 border-t border-stone-100 dark:border-stone-800 flex items-center justify-between text-xs">
|
||||||
|
<span class="text-stone-400">کلیک برای مشاهده لیست طلاب</span>
|
||||||
|
<span class="text-primary-600 font-bold flex items-center gap-1">
|
||||||
|
مشاهده جزییات
|
||||||
|
<UIcon name="i-lucide-chevron-left" class="w-3.5 h-3.5" />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Admin Class Details Modal (Read-Only) -->
|
||||||
|
<AppModal
|
||||||
|
v-model="isAdminDetailsModalOpen"
|
||||||
|
:title="selectedAdminClass ? `وضعیت حضور طلاب در کلاس ${selectedAdminClass.title}` : 'جزییات کلاس'"
|
||||||
|
description="نظارت مدیریت آموزش حوزه علمیه سفیران هدایت"
|
||||||
|
size="lg"
|
||||||
|
>
|
||||||
|
<div v-if="selectedAdminClass" class="space-y-4 text-xs">
|
||||||
|
<!-- Class info cards -->
|
||||||
|
<div class="grid grid-cols-2 sm:grid-cols-4 gap-2 text-center">
|
||||||
|
<div class="p-3 rounded-xl bg-stone-50 dark:bg-stone-800">
|
||||||
|
<div class="text-stone-400 text-[11px]">کل طلاب</div>
|
||||||
|
<div class="text-lg font-bold text-stone-900 dark:text-white">{{ selectedAdminClass.studentCount }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="p-3 rounded-xl bg-emerald-50 dark:bg-emerald-950/60">
|
||||||
|
<div class="text-emerald-700 text-[11px]">حاضر</div>
|
||||||
|
<div class="text-lg font-bold text-emerald-800 dark:text-emerald-300">
|
||||||
|
{{ getAdminClassAttendanceStats(selectedAdminClass.id).presentCount }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="p-3 rounded-xl bg-amber-50 dark:bg-amber-950/60">
|
||||||
|
<div class="text-amber-700 text-[11px]">با تاخیر</div>
|
||||||
|
<div class="text-lg font-bold text-amber-800 dark:text-amber-300">
|
||||||
|
{{ getAdminClassAttendanceStats(selectedAdminClass.id).lateCount }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="p-3 rounded-xl bg-rose-50 dark:bg-rose-950/60">
|
||||||
|
<div class="text-rose-700 text-[11px]">غایب</div>
|
||||||
|
<div class="text-lg font-bold text-rose-800 dark:text-rose-300">
|
||||||
|
{{ getAdminClassAttendanceStats(selectedAdminClass.id).absentCount }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Students List (View Only) -->
|
||||||
|
<div class="overflow-x-auto max-h-72">
|
||||||
|
<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="st in getAdminClassStudents(selectedAdminClass.id)" :key="st.id">
|
||||||
|
<td class="p-2 font-bold">{{ st.name }}</td>
|
||||||
|
<td class="p-2 font-mono text-stone-500">{{ st.code }}</td>
|
||||||
|
<td class="p-2">
|
||||||
|
<UiBadge :status="st.status" :label="getStatusLabel(st.status)" />
|
||||||
|
</td>
|
||||||
|
<td class="p-2 text-stone-500">
|
||||||
|
<span v-if="st.status === 'late'">{{ st.delayMinutes }} دقیقه ({{ st.delayReason || 'بدون ثبت علت' }})</span>
|
||||||
|
<span v-else-if="st.status === 'excused'">{{ st.delayReason || 'موجه' }}</span>
|
||||||
|
<span v-else>-</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #footer="{ close }">
|
||||||
|
<UButton color="neutral" variant="outline" label="بستن پنجره" @click="close" />
|
||||||
|
</template>
|
||||||
|
</AppModal>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||||
|
import { useAuth } from '~/composables/useAuth'
|
||||||
|
import { useMockData, type ClassItem, type AttendanceStatus, type Student } from '~/composables/useMockData'
|
||||||
|
import RoleSwitcher from '~/components/common/RoleSwitcher.vue'
|
||||||
|
import UiBadge from '~/components/common/UiBadge.vue'
|
||||||
|
import AppModal from '~/components/common/AppModal.vue'
|
||||||
|
|
||||||
|
const { currentRole, currentUser, roleLabels } = useAuth()
|
||||||
|
const {
|
||||||
|
classes,
|
||||||
|
students,
|
||||||
|
teachers,
|
||||||
|
attendanceRecords,
|
||||||
|
todayShamsi,
|
||||||
|
calculateDelay,
|
||||||
|
submitStudentAttendance,
|
||||||
|
updateStudentStatus
|
||||||
|
} = useMockData()
|
||||||
|
|
||||||
|
// ساعت زنده
|
||||||
|
const currentTimeStr = ref('۰۸:۱۵')
|
||||||
|
let clockInterval: any = null
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
const updateClock = () => {
|
||||||
|
const now = new Date()
|
||||||
|
currentTimeStr.value = `${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`
|
||||||
|
}
|
||||||
|
updateClock()
|
||||||
|
clockInterval = setInterval(updateClock, 1000)
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (clockInterval) clearInterval(clockInterval)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getStatusLabel = (st: AttendanceStatus) => {
|
||||||
|
switch (st) {
|
||||||
|
case 'present': return 'حاضر'
|
||||||
|
case 'absent': return 'غایب'
|
||||||
|
case 'late': return 'تاخیر'
|
||||||
|
case 'excused': return 'مجاز'
|
||||||
|
default: return 'غایب'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
// منطق طلبه (Student Logic)
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
const todayStudentClasses = computed(() => {
|
||||||
|
return classes.value.filter(c => c.isOngoingToday)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getStudentStatusForClass = (classId: string) => {
|
||||||
|
const record = attendanceRecords.value.find(
|
||||||
|
r => r.classId === classId && r.studentId === currentUser.value.id
|
||||||
|
)
|
||||||
|
if (!record || record.status === 'absent') {
|
||||||
|
return { status: 'absent' as AttendanceStatus, label: 'غایب / ثبت نشده' }
|
||||||
|
}
|
||||||
|
return { status: record.status, label: getStatusLabel(record.status) }
|
||||||
|
}
|
||||||
|
|
||||||
|
const isStudentModalOpen = ref(false)
|
||||||
|
const selectedClassForStudent = ref<ClassItem | null>(null)
|
||||||
|
const studentDelayReason = ref('')
|
||||||
|
const simulateLate = ref(true) // پیشفرض فعال برای مشاهده الزامی بودن علت تاخیر
|
||||||
|
|
||||||
|
const studentDelayCalculation = computed(() => {
|
||||||
|
if (!selectedClassForStudent.value) return { isLate: false, minutes: 0 }
|
||||||
|
if (simulateLate.value) {
|
||||||
|
return { isLate: true, minutes: 15 }
|
||||||
|
}
|
||||||
|
return calculateDelay(selectedClassForStudent.value.startTime)
|
||||||
|
})
|
||||||
|
|
||||||
|
const openStudentAttendanceModal = (c: ClassItem) => {
|
||||||
|
selectedClassForStudent.value = c
|
||||||
|
const existingRecord = attendanceRecords.value.find(
|
||||||
|
r => r.classId === c.id && r.studentId === currentUser.value.id
|
||||||
|
)
|
||||||
|
if (existingRecord && existingRecord.delayReason) {
|
||||||
|
studentDelayReason.value = existingRecord.delayReason
|
||||||
|
} else {
|
||||||
|
studentDelayReason.value = ''
|
||||||
|
}
|
||||||
|
isStudentModalOpen.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleStudentSubmitAttendance = () => {
|
||||||
|
if (!selectedClassForStudent.value) return
|
||||||
|
|
||||||
|
const isLate = studentDelayCalculation.value.isLate
|
||||||
|
const minutes = studentDelayCalculation.value.minutes
|
||||||
|
|
||||||
|
if (isLate && (!studentDelayReason.value || studentDelayReason.value.trim().length < 5)) {
|
||||||
|
alert('لطفاً علت تاخیر را وارد فرمایید.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
submitStudentAttendance(
|
||||||
|
selectedClassForStudent.value.id,
|
||||||
|
currentUser.value.id,
|
||||||
|
isLate ? minutes : 0,
|
||||||
|
isLate ? studentDelayReason.value : undefined
|
||||||
|
)
|
||||||
|
|
||||||
|
isStudentModalOpen.value = false
|
||||||
|
alert('حضور شما با موفقیت در سامانه ثبت گردید.')
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
// منطق استاد (Teacher Logic)
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
const teacherClasses = computed(() => {
|
||||||
|
return classes.value.filter(c => c.teacherId === currentUser.value.id || c.teacherId === 't-201')
|
||||||
|
})
|
||||||
|
|
||||||
|
const selectedTeacherClassId = ref<string>('c-1')
|
||||||
|
|
||||||
|
const currentTeacherClass = computed(() => {
|
||||||
|
return classes.value.find(c => c.id === selectedTeacherClassId.value) || teacherClasses.value[0]
|
||||||
|
})
|
||||||
|
|
||||||
|
const teacherClassStudents = computed(() => {
|
||||||
|
if (!currentTeacherClass.value) return []
|
||||||
|
return students.value.filter(s => currentTeacherClass.value.studentIds.includes(s.id))
|
||||||
|
})
|
||||||
|
|
||||||
|
const getTeacherRecord = (studentId: string) => {
|
||||||
|
if (!currentTeacherClass.value) return null
|
||||||
|
return attendanceRecords.value.find(
|
||||||
|
r => r.classId === currentTeacherClass.value.id && r.studentId === studentId
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const teacherClassStats = computed(() => {
|
||||||
|
const total = teacherClassStudents.value.length
|
||||||
|
let present = 0
|
||||||
|
let late = 0
|
||||||
|
let absent = 0
|
||||||
|
|
||||||
|
teacherClassStudents.value.forEach(st => {
|
||||||
|
const rec = getTeacherRecord(st.id)
|
||||||
|
if (!rec || rec.status === 'absent') absent++
|
||||||
|
else if (rec.status === 'present') present++
|
||||||
|
else if (rec.status === 'late') late++
|
||||||
|
})
|
||||||
|
|
||||||
|
return { total, present, late, absent }
|
||||||
|
})
|
||||||
|
|
||||||
|
const setStudentAttendance = (studentId: string, status: AttendanceStatus, minutes = 0, reason = '') => {
|
||||||
|
if (!currentTeacherClass.value) return
|
||||||
|
updateStudentStatus(currentTeacherClass.value.id, studentId, status, minutes, reason)
|
||||||
|
}
|
||||||
|
|
||||||
|
const promptTeacherLate = (student: Student) => {
|
||||||
|
const minutesStr = prompt(`تعداد دقایق تاخیر طلبه (${student.name}):`, '15')
|
||||||
|
if (minutesStr === null) return
|
||||||
|
const minutes = parseInt(minutesStr, 10) || 10
|
||||||
|
const reason = prompt('علت تاخیر (اختیاری):', 'تاخیر در ورود به جلسه') || ''
|
||||||
|
setStudentAttendance(student.id, 'late', minutes, reason)
|
||||||
|
}
|
||||||
|
|
||||||
|
const promptTeacherExcused = (student: Student) => {
|
||||||
|
const reason = prompt(`علت موجه بودن غیبت طلبه (${student.name}):`, 'گواهی پزشکی یا ماموریت تبلیغی') || 'موجه'
|
||||||
|
setStudentAttendance(student.id, 'excused', 0, reason)
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
// منطق آموزش (Admin Logic)
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
const adminSearchQuery = ref('')
|
||||||
|
const adminTeacherFilter = ref('')
|
||||||
|
|
||||||
|
const filteredAdminClasses = computed(() => {
|
||||||
|
return classes.value.filter(c => {
|
||||||
|
const matchesSearch = c.title.includes(adminSearchQuery.value) ||
|
||||||
|
c.teacherName.includes(adminSearchQuery.value) ||
|
||||||
|
c.room.includes(adminSearchQuery.value)
|
||||||
|
const matchesTeacher = !adminTeacherFilter.value || c.teacherName === adminTeacherFilter.value
|
||||||
|
return matchesSearch && matchesTeacher
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
const getAdminClassAttendanceStats = (classId: string) => {
|
||||||
|
const c = classes.value.find(item => item.id === classId)
|
||||||
|
if (!c) return { presentCount: 0, lateCount: 0, absentCount: 0, percentage: 0 }
|
||||||
|
|
||||||
|
const records = attendanceRecords.value.filter(r => r.classId === classId)
|
||||||
|
const presentCount = records.filter(r => r.status === 'present').length
|
||||||
|
const lateCount = records.filter(r => r.status === 'late').length
|
||||||
|
const absentCount = c.studentCount - (presentCount + lateCount)
|
||||||
|
const percentage = c.studentCount > 0 ? Math.round(((presentCount + lateCount) / c.studentCount) * 100) : 0
|
||||||
|
|
||||||
|
return { presentCount, lateCount, absentCount, percentage }
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectedAdminClass = ref<ClassItem | null>(null)
|
||||||
|
const isAdminDetailsModalOpen = ref(false)
|
||||||
|
|
||||||
|
const openAdminClassDetails = (c: ClassItem) => {
|
||||||
|
selectedAdminClass.value = c
|
||||||
|
isAdminDetailsModalOpen.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const getAdminClassStudents = (classId: string) => {
|
||||||
|
const c = classes.value.find(item => item.id === classId)
|
||||||
|
if (!c) return []
|
||||||
|
|
||||||
|
return students.value
|
||||||
|
.filter(s => c.studentIds.includes(s.id))
|
||||||
|
.map(s => {
|
||||||
|
const rec = attendanceRecords.value.find(r => r.classId === classId && r.studentId === s.id)
|
||||||
|
return {
|
||||||
|
id: s.id,
|
||||||
|
name: s.name,
|
||||||
|
code: s.code,
|
||||||
|
status: rec ? rec.status : ('absent' as AttendanceStatus),
|
||||||
|
delayMinutes: rec?.delayMinutes || 0,
|
||||||
|
delayReason: rec?.delayReason || ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,857 @@
|
|||||||
|
<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 Breadcrumb & Back to Home -->
|
||||||
|
<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="/"
|
||||||
|
class="px-3.5 py-1.5 rounded-xl text-xs sm:text-sm font-bold text-stone-700 dark:text-stone-200 hover:bg-stone-100 dark:hover:bg-stone-800 transition flex items-center gap-1.5 border border-stone-200 dark:border-stone-800"
|
||||||
|
>
|
||||||
|
<UIcon name="i-lucide-arrow-right" class="w-4 h-4 text-primary-500" />
|
||||||
|
<span>بازگشت به صفحه اصلی</span>
|
||||||
|
</NuxtLink>
|
||||||
|
<div class="h-4 w-px bg-stone-200 dark:bg-stone-800 mx-1"></div>
|
||||||
|
<span class="px-3 py-1.5 rounded-xl text-xs font-extrabold bg-amber-500/10 text-amber-700 dark:text-amber-400 border border-amber-500/20 flex items-center gap-1.5">
|
||||||
|
<UIcon name="i-lucide-layout-dashboard" class="w-4 h-4" />
|
||||||
|
<span>داشبورد جامع و گزارشات تحلیلی</span>
|
||||||
|
</span>
|
||||||
|
</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>
|
||||||
+160
-27
@@ -19,25 +19,35 @@
|
|||||||
مرکز تخصصی تربیت مبلغان متعهد، آشنا به شیوههای نوین تبلیغ و پژوهشگران معارف اهلبیت (علیهمالسلام) در فضایی معنوی و پویا.
|
مرکز تخصصی تربیت مبلغان متعهد، آشنا به شیوههای نوین تبلیغ و پژوهشگران معارف اهلبیت (علیهمالسلام) در فضایی معنوی و پویا.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<!-- Action Buttons -->
|
<!-- Action Buttons: دو دکمه اختصاصی برای رفتن به سامانه حضور و غیاب و داشبورد -->
|
||||||
<div class="flex flex-wrap items-center justify-center lg:justify-start gap-3.5 pt-2">
|
<div class="flex flex-wrap items-center justify-center lg:justify-start gap-3.5 pt-2">
|
||||||
<UButton
|
<NuxtLink to="/attendance">
|
||||||
color="primary"
|
<UButton
|
||||||
variant="solid"
|
color="primary"
|
||||||
size="lg"
|
variant="solid"
|
||||||
:icon="getIcon('graduationCap', 'i-lucide-graduation-cap')"
|
size="lg"
|
||||||
label="ثبتنام و پذیرش دوره جدید"
|
icon="i-lucide-clipboard-check"
|
||||||
class="shadow-lg shadow-primary-500/25 px-6 font-bold"
|
label="ورود به سامانه حضور و غیاب"
|
||||||
@click="openAdmissionModal"
|
class="shadow-lg shadow-primary-500/25 px-6 font-bold text-sm"
|
||||||
/>
|
/>
|
||||||
|
</NuxtLink>
|
||||||
|
<NuxtLink to="/dashboard">
|
||||||
|
<UButton
|
||||||
|
color="neutral"
|
||||||
|
variant="outline"
|
||||||
|
size="lg"
|
||||||
|
icon="i-lucide-layout-dashboard"
|
||||||
|
label="ورود به داشبورد و گزارشات"
|
||||||
|
class="px-5 font-bold text-sm border-stone-300 dark:border-stone-700 hover:border-primary-500 transition"
|
||||||
|
/>
|
||||||
|
</NuxtLink>
|
||||||
<UButton
|
<UButton
|
||||||
color="neutral"
|
color="neutral"
|
||||||
variant="outline"
|
variant="ghost"
|
||||||
size="lg"
|
size="md"
|
||||||
:icon="getIcon('bookOpen', 'i-lucide-book-open')"
|
:icon="getIcon('graduationCap', 'i-lucide-graduation-cap')"
|
||||||
label="آشنایی با نظام آموزشی"
|
label="پذیرش دوره جدید"
|
||||||
class="px-5 font-semibold"
|
@click="openAdmissionModal"
|
||||||
@click="scrollToCourses"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -101,16 +111,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Fast entrance link -->
|
<!-- Fast entrance links to Attendance & Dashboard -->
|
||||||
<div class="pt-2">
|
<div class="pt-2 grid grid-cols-2 gap-2">
|
||||||
<UButton
|
<NuxtLink to="/attendance" class="block">
|
||||||
block
|
<UButton
|
||||||
color="primary"
|
block
|
||||||
variant="soft"
|
color="primary"
|
||||||
size="md"
|
variant="solid"
|
||||||
label="ورود به سامانه انتخاب واحد و دروس"
|
size="sm"
|
||||||
:icon="getIcon('chevronLeft', 'i-lucide-chevron-left')"
|
label="سامانه حضور و غیاب"
|
||||||
/>
|
icon="i-lucide-clipboard-check"
|
||||||
|
class="font-bold text-xs"
|
||||||
|
/>
|
||||||
|
</NuxtLink>
|
||||||
|
<NuxtLink to="/dashboard" class="block">
|
||||||
|
<UButton
|
||||||
|
block
|
||||||
|
color="neutral"
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
label="داشبورد و گزارشات"
|
||||||
|
icon="i-lucide-layout-dashboard"
|
||||||
|
class="font-bold text-xs"
|
||||||
|
/>
|
||||||
|
</NuxtLink>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -119,7 +143,116 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- 2. Interactive Theme & Font Customizer Live Bar -->
|
<!-- 2. Dedicated Portal Access Cards: Attendance & Dashboard -->
|
||||||
|
<section class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
|
<!-- Card 1: Attendance System -->
|
||||||
|
<div class="p-8 rounded-3xl bg-white dark:bg-stone-900 border-2 border-stone-200/90 dark:border-stone-800 hover:border-primary-500 shadow-sm hover:shadow-xl transition-all duration-300 flex flex-col justify-between space-y-6 group">
|
||||||
|
<div class="space-y-4">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<div class="w-14 h-14 rounded-2xl bg-primary-500/10 text-primary-600 dark:text-primary-400 flex items-center justify-center group-hover:scale-110 group-hover:bg-primary-500 group-hover:text-white transition duration-300">
|
||||||
|
<UIcon name="i-lucide-clipboard-check" class="w-7 h-7" />
|
||||||
|
</div>
|
||||||
|
<span class="px-3 py-1 rounded-full text-xs font-bold bg-emerald-50 text-emerald-700 dark:bg-emerald-950/60 dark:text-emerald-300 border border-emerald-200 dark:border-emerald-800">
|
||||||
|
فعال برای امروز
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-2">
|
||||||
|
<h3 class="text-xl font-black text-stone-900 dark:text-white group-hover:text-primary-600 transition">
|
||||||
|
سامانه ثبت حضور و غیاب طلاب
|
||||||
|
</h3>
|
||||||
|
<p class="text-xs sm:text-sm text-stone-600 dark:text-stone-300 leading-relaxed">
|
||||||
|
ثبت بهنگام حضور در کلاسهای درس، محاسبه خودکار تاخیر، ثبت دلایل انضباطی، نظارت استاد و پایش برخط توسط آموزش حوزه.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="space-y-1.5 text-xs text-stone-500 dark:text-stone-400 pt-2 border-t border-stone-100 dark:border-stone-800">
|
||||||
|
<li class="flex items-center gap-2">
|
||||||
|
<UIcon name="i-lucide-check" class="w-4 h-4 text-primary-500" />
|
||||||
|
<span>نمای اختصاصی طلبه برای ثبت حضور و تاخیر</span>
|
||||||
|
</li>
|
||||||
|
<li class="flex items-center gap-2">
|
||||||
|
<UIcon name="i-lucide-check" class="w-4 h-4 text-primary-500" />
|
||||||
|
<span>پنل استاد با امکان تغییر سریع وضعیت (حاضر/غایب/تاخیر/موجه)</span>
|
||||||
|
</li>
|
||||||
|
<li class="flex items-center gap-2">
|
||||||
|
<UIcon name="i-lucide-check" class="w-4 h-4 text-primary-500" />
|
||||||
|
<span>پایش زنده کلاسها توسط معاونت آموزش</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pt-2">
|
||||||
|
<NuxtLink to="/attendance" class="block">
|
||||||
|
<UButton
|
||||||
|
block
|
||||||
|
color="primary"
|
||||||
|
variant="solid"
|
||||||
|
size="lg"
|
||||||
|
label="ورود به سامانه حضور و غیاب"
|
||||||
|
icon="i-lucide-arrow-left"
|
||||||
|
class="font-bold py-3 shadow-md shadow-primary-500/20"
|
||||||
|
/>
|
||||||
|
</NuxtLink>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Card 2: Dashboard & Reports -->
|
||||||
|
<div class="p-8 rounded-3xl bg-white dark:bg-stone-900 border-2 border-stone-200/90 dark:border-stone-800 hover:border-primary-500 shadow-sm hover:shadow-xl transition-all duration-300 flex flex-col justify-between space-y-6 group">
|
||||||
|
<div class="space-y-4">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<div class="w-14 h-14 rounded-2xl bg-amber-500/10 text-amber-600 dark:text-amber-400 flex items-center justify-center group-hover:scale-110 group-hover:bg-amber-500 group-hover:text-white transition duration-300">
|
||||||
|
<UIcon name="i-lucide-layout-dashboard" class="w-7 h-7" />
|
||||||
|
</div>
|
||||||
|
<span class="px-3 py-1 rounded-full text-xs font-bold bg-amber-50 text-amber-700 dark:bg-amber-950/60 dark:text-amber-300 border border-amber-200 dark:border-amber-800">
|
||||||
|
گزارشات و خروجی Excel
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-2">
|
||||||
|
<h3 class="text-xl font-black text-stone-900 dark:text-white group-hover:text-primary-600 transition">
|
||||||
|
داشبورد تحلیل و آمار انضباطی
|
||||||
|
</h3>
|
||||||
|
<p class="text-xs sm:text-sm text-stone-600 dark:text-stone-300 leading-relaxed">
|
||||||
|
گزارش تفکیکی درصد حضور، هشدار طلاب در معرض محرومیت، خروجی فایلهای رسمی Excel، و بخش مدیریت جامع کلاسها و اساتید.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="space-y-1.5 text-xs text-stone-500 dark:text-stone-400 pt-2 border-t border-stone-100 dark:border-stone-800">
|
||||||
|
<li class="flex items-center gap-2">
|
||||||
|
<UIcon name="i-lucide-check" class="w-4 h-4 text-amber-500" />
|
||||||
|
<span>ریز سوابق غیبتها و تاخیرها برای هر درس</span>
|
||||||
|
</li>
|
||||||
|
<li class="flex items-center gap-2">
|
||||||
|
<UIcon name="i-lucide-check" class="w-4 h-4 text-amber-500" />
|
||||||
|
<span>خروجی استاندارد Excel برای نرمافزارهای آموزش</span>
|
||||||
|
</li>
|
||||||
|
<li class="flex items-center gap-2">
|
||||||
|
<UIcon name="i-lucide-check" class="w-4 h-4 text-amber-500" />
|
||||||
|
<span>سکشن مدیریت کلاسها و تخصیص طلاب و اساتید</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pt-2">
|
||||||
|
<NuxtLink to="/dashboard" class="block">
|
||||||
|
<UButton
|
||||||
|
block
|
||||||
|
color="neutral"
|
||||||
|
variant="outline"
|
||||||
|
size="lg"
|
||||||
|
label="ورود به داشبورد و گزارشات"
|
||||||
|
icon="i-lucide-arrow-left"
|
||||||
|
class="font-bold py-3 border-2 hover:border-primary-500 hover:text-primary-600 transition"
|
||||||
|
/>
|
||||||
|
</NuxtLink>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- 3. Interactive Theme & Font Customizer Live Bar -->
|
||||||
<section class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
<section class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||||
<div class="p-6 rounded-2xl bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-800 shadow-sm space-y-4">
|
<div class="p-6 rounded-2xl bg-white dark:bg-stone-900 border border-stone-200 dark:border-stone-800 shadow-sm space-y-4">
|
||||||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4 border-b border-stone-100 dark:border-stone-800 pb-4">
|
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4 border-b border-stone-100 dark:border-stone-800 pb-4">
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
+6
-1
@@ -5,6 +5,11 @@ export default defineNuxtConfig({
|
|||||||
devtools: { enabled: false },
|
devtools: { enabled: false },
|
||||||
ssr: false,
|
ssr: false,
|
||||||
|
|
||||||
|
devServer: {
|
||||||
|
host: "0.0.0.0",
|
||||||
|
port: 3002,
|
||||||
|
},
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
"@nuxt/ui",
|
"@nuxt/ui",
|
||||||
"@pinia/nuxt",
|
"@pinia/nuxt",
|
||||||
@@ -14,7 +19,7 @@ export default defineNuxtConfig({
|
|||||||
css: ["~/assets/css/main.css"],
|
css: ["~/assets/css/main.css"],
|
||||||
|
|
||||||
imports: {
|
imports: {
|
||||||
dirs: ["stores", "composables", "apis"],
|
dirs: ["stores", "composables", "apis", "utils"],
|
||||||
},
|
},
|
||||||
|
|
||||||
colorMode: {
|
colorMode: {
|
||||||
|
|||||||
+3
-3
@@ -4,9 +4,9 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxt dev",
|
"dev": "nuxt dev --host 0.0.0.0 --port 3002",
|
||||||
"dev:school": "env-cmd -f .env.school nuxt dev --port 3002",
|
"dev:school": "env-cmd -f .env.school nuxt dev --host 0.0.0.0 --port 3002",
|
||||||
"dev:hamyar": "env-cmd -f .env.hamyar nuxt dev --port 3001",
|
"dev:hamyar": "env-cmd -f .env.hamyar nuxt dev --host 0.0.0.0 --port 3003",
|
||||||
"build": "nuxt build",
|
"build": "nuxt build",
|
||||||
"build:school": "env-cmd -f .env.school nuxt build",
|
"build:school": "env-cmd -f .env.school nuxt build",
|
||||||
"build:hamyar": "env-cmd -f .env.hamyar nuxt build",
|
"build:hamyar": "env-cmd -f .env.hamyar nuxt build",
|
||||||
|
|||||||
Reference in New Issue
Block a user