changes
This commit is contained in:
@@ -0,0 +1,200 @@
|
||||
<template>
|
||||
<DashboardLayout>
|
||||
<template #header-icon>
|
||||
<DashboardIcon name="plus" size="5" class="text-primary" />
|
||||
</template>
|
||||
<template #header-title>Создание кафедры</template>
|
||||
<template #header-subtitle>Добавление новой кафедры в институт</template>
|
||||
<template #header-actions>
|
||||
<a
|
||||
:href="route('dashboard.departments.index')"
|
||||
class="inline-flex items-center gap-2 px-4 py-2 bg-surface text-foreground text-sm font-medium rounded-lg border border-layer-line hover:bg-muted-hover transition-all duration-200"
|
||||
>
|
||||
<DashboardIcon name="arrow-left" size="4" />
|
||||
Назад к списку
|
||||
</a>
|
||||
</template>
|
||||
|
||||
<!-- Flash Messages -->
|
||||
<FlashMessages />
|
||||
|
||||
<!-- Form Card -->
|
||||
<div class="bg-layer border border-layer-line rounded-lg shadow-xs overflow-hidden">
|
||||
<form @submit.prevent="submit">
|
||||
<div class="p-6 space-y-6">
|
||||
<!-- Основные поля -->
|
||||
<div class="space-y-4">
|
||||
<h3 class="text-lg font-medium text-foreground">Основная информация</h3>
|
||||
|
||||
<div class="grid grid-cols-1 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Полное название <span class="text-danger">*</span>
|
||||
</label>
|
||||
<input
|
||||
v-model="form.title"
|
||||
type="text"
|
||||
required
|
||||
maxlength="255"
|
||||
placeholder="Например: Кафедра программной инженерии"
|
||||
class="w-full px-3 py-2 border border-layer-line rounded-lg bg-white text-foreground placeholder-muted-foreground-1 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
@input="generateSlug"
|
||||
/>
|
||||
<p v-if="errors.title" class="mt-1 text-sm text-danger">{{ errors.title }}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
URL-адрес <span class="text-danger">*</span>
|
||||
</label>
|
||||
<div class="flex items-center">
|
||||
<span class="inline-flex items-center px-3 py-2 border border-r-0 border-layer-line rounded-l-lg bg-muted text-muted-foreground-1 text-sm">
|
||||
{{ baseUrl }}/
|
||||
</span>
|
||||
<input
|
||||
v-model="form.slug"
|
||||
type="text"
|
||||
required
|
||||
readonly
|
||||
class="flex-1 px-3 py-2 border border-layer-line rounded-r-lg bg-muted text-muted-foreground-1 text-sm cursor-not-allowed"
|
||||
/>
|
||||
</div>
|
||||
<p class="mt-1 text-xs text-muted-foreground-1">Формируется автоматически из названия</p>
|
||||
<p v-if="errors.slug" class="mt-1 text-sm text-danger">{{ errors.slug }}</p>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Факультет <span class="text-danger">*</span>
|
||||
</label>
|
||||
<select
|
||||
v-model="form.faculty_id"
|
||||
required
|
||||
class="w-full px-3 py-2 border border-layer-line rounded-lg bg-white text-foreground focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
>
|
||||
<option value="">Выберите факультет</option>
|
||||
<option v-for="faculty in faculties" :key="faculty.id" :value="faculty.id">
|
||||
{{ faculty.title }}
|
||||
</option>
|
||||
</select>
|
||||
<p v-if="errors.faculty_id" class="mt-1 text-sm text-danger">{{ errors.faculty_id }}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Статус
|
||||
</label>
|
||||
<div class="flex items-center mt-2">
|
||||
<input
|
||||
v-model="form.is_active"
|
||||
type="checkbox"
|
||||
class="h-4 w-4 text-primary focus:ring-primary border-layer-line rounded"
|
||||
/>
|
||||
<label class="ml-2 text-sm text-foreground">
|
||||
Активная кафедра
|
||||
</label>
|
||||
</div>
|
||||
<p class="mt-1 text-xs text-muted-foreground-1">Отображать ли кафедру на сайте</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Контент -->
|
||||
<div class="space-y-4">
|
||||
<h3 class="text-lg font-medium text-foreground">Контент</h3>
|
||||
<ContentBuilder
|
||||
v-model="form.content"
|
||||
label="Содержимое страницы"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Form Actions -->
|
||||
<div class="px-6 py-4 bg-surface/50 border-t border-layer-line flex items-center justify-end gap-3">
|
||||
<a
|
||||
:href="route('dashboard.departments.index')"
|
||||
class="px-4 py-2 text-sm font-medium text-foreground bg-surface border border-layer-line rounded-lg hover:bg-muted-hover transition-all"
|
||||
>
|
||||
Отмена
|
||||
</a>
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="processing"
|
||||
class="px-4 py-2 text-sm font-medium text-white bg-primary rounded-lg hover:bg-primary-hover transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
<svg v-if="processing" class="animate-spin -ml-1 mr-2 h-4 w-4 text-white inline" fill="none" viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>
|
||||
{{ processing ? 'Создание...' : 'Создать кафедру' }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</DashboardLayout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DashboardLayout from '../Components/DashboardLayout.vue';
|
||||
import DashboardIcon from '../Components/DashboardIcon.vue';
|
||||
import FlashMessages from '../Components/shared/FlashMessages.vue';
|
||||
import ContentBuilder from '../Components/ContentBuilder/ContentBuilder.vue';
|
||||
|
||||
export default {
|
||||
name: 'DepartmentCreate',
|
||||
components: {
|
||||
DashboardLayout,
|
||||
DashboardIcon,
|
||||
FlashMessages,
|
||||
ContentBuilder,
|
||||
},
|
||||
|
||||
props: {
|
||||
faculties: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
title: '',
|
||||
slug: '',
|
||||
faculty_id: '',
|
||||
is_active: true,
|
||||
content: []
|
||||
},
|
||||
processing: false,
|
||||
baseUrl: this.GET_BASE_URL() + 'department',
|
||||
errors: {}
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.SET_DOCUMENT_TITLE('Создание кафедры');
|
||||
},
|
||||
|
||||
methods: {
|
||||
generateSlug() {
|
||||
if (this.form.title) {
|
||||
this.form.slug = this.GENERATE_SLUG(this.form.title);
|
||||
}
|
||||
},
|
||||
|
||||
submit() {
|
||||
this.processing = true;
|
||||
this.$inertia.post(route('dashboard.departments.store'), this.form, {
|
||||
onFinish: () => {
|
||||
this.processing = false;
|
||||
},
|
||||
onError: (errors) => {
|
||||
this.errors = errors;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,269 @@
|
||||
<template>
|
||||
<DashboardLayout>
|
||||
<template #header-icon>
|
||||
<DashboardIcon name="building-office" size="5" class="text-primary" />
|
||||
</template>
|
||||
<template #header-title>
|
||||
<div class="flex items-center gap-2">
|
||||
<span>Редактирование кафедры</span>
|
||||
<span class="text-muted-foreground-1">/</span>
|
||||
<span class="text-primary">{{ department.title }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template #header-subtitle>
|
||||
<div class="flex items-center gap-3">
|
||||
<span class="inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium bg-primary/10 text-primary border border-primary/20">
|
||||
{{ department.faculty?.abbreviation || department.faculty?.title || '—' }}
|
||||
</span>
|
||||
<span class="text-muted-foreground-1">•</span>
|
||||
<span :class="department.is_active ? 'text-success' : 'text-danger'" class="flex items-center gap-1">
|
||||
<DashboardIcon v-if="department.is_active" name="check" size="3" class="text-success" />
|
||||
<DashboardIcon v-else name="x-mark" size="3" class="text-danger" />
|
||||
{{ department.is_active ? 'Активная' : 'Неактивная' }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<template #header-actions>
|
||||
<a
|
||||
:href="route('dashboard.departments.index')"
|
||||
class="inline-flex items-center gap-2 px-4 py-2 bg-surface text-foreground text-sm font-medium rounded-lg border border-layer-line hover:bg-muted-hover transition-all duration-200"
|
||||
>
|
||||
<DashboardIcon name="arrow-left" size="4" />
|
||||
Назад к списку
|
||||
</a>
|
||||
</template>
|
||||
|
||||
<!-- Flash Messages -->
|
||||
<FlashMessages />
|
||||
|
||||
<!-- Form Card -->
|
||||
<div class="bg-layer border border-layer-line rounded-lg shadow-xs overflow-hidden">
|
||||
<form @submit.prevent="submit">
|
||||
<div class="p-6 space-y-6">
|
||||
<!-- Основные поля -->
|
||||
<div class="space-y-4">
|
||||
<h3 class="text-lg font-medium text-foreground">Основная информация</h3>
|
||||
|
||||
<div class="grid grid-cols-1 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Полное название <span class="text-danger">*</span>
|
||||
</label>
|
||||
<input
|
||||
v-model="form.title"
|
||||
type="text"
|
||||
required
|
||||
maxlength="255"
|
||||
placeholder="Например: Кафедра программной инженерии"
|
||||
class="w-full px-3 py-2 border border-layer-line rounded-lg bg-white text-foreground placeholder-muted-foreground-1 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
/>
|
||||
<p v-if="errors.title" class="mt-1 text-sm text-danger">{{ errors.title }}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
URL-адрес <span class="text-danger">*</span>
|
||||
</label>
|
||||
<div class="flex items-center">
|
||||
<span class="inline-flex items-center px-3 py-2 border border-r-0 border-layer-line rounded-l-lg bg-muted text-muted-foreground-1 text-sm">
|
||||
{{ baseUrl }}/
|
||||
</span>
|
||||
<input
|
||||
v-model="form.slug"
|
||||
type="text"
|
||||
required
|
||||
readonly
|
||||
class="flex-1 px-3 py-2 border border-layer-line rounded-r-lg bg-muted text-muted-foreground-1 text-sm cursor-not-allowed"
|
||||
/>
|
||||
</div>
|
||||
<p class="mt-1 text-xs text-muted-foreground-1">Формируется автоматически из названия</p>
|
||||
<p v-if="errors.slug" class="mt-1 text-sm text-danger">{{ errors.slug }}</p>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Факультет <span class="text-danger">*</span>
|
||||
</label>
|
||||
<select
|
||||
v-model="form.faculty_id"
|
||||
required
|
||||
class="w-full px-3 py-2 border border-layer-line rounded-lg bg-white text-foreground focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
>
|
||||
<option value="">Выберите факультет</option>
|
||||
<option v-for="faculty in faculties" :key="faculty.id" :value="faculty.id">
|
||||
{{ faculty.title }}
|
||||
</option>
|
||||
</select>
|
||||
<p v-if="errors.faculty_id" class="mt-1 text-sm text-danger">{{ errors.faculty_id }}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Статус
|
||||
</label>
|
||||
<div class="flex items-center mt-2">
|
||||
<input
|
||||
v-model="form.is_active"
|
||||
type="checkbox"
|
||||
class="h-4 w-4 text-primary focus:ring-primary border-layer-line rounded"
|
||||
/>
|
||||
<label class="ml-2 text-sm text-foreground">
|
||||
Активная кафедра
|
||||
</label>
|
||||
</div>
|
||||
<p class="mt-1 text-xs text-muted-foreground-1">Отображать ли кафедру на сайте</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Контент -->
|
||||
<div class="space-y-4">
|
||||
<h3 class="text-lg font-medium text-foreground">Контент</h3>
|
||||
<ContentBuilder
|
||||
v-model="form.content"
|
||||
label="Содержимое страницы"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Сотрудники кафедры -->
|
||||
<DepartmentWorkers
|
||||
v-if="department.id"
|
||||
:department="department"
|
||||
:workers="workers"
|
||||
:available-users="availableWorkers"
|
||||
/>
|
||||
|
||||
<!-- Преподаватели кафедры -->
|
||||
<DepartmentTeachers
|
||||
v-if="department.id"
|
||||
:department="department"
|
||||
:teachers="teachers"
|
||||
:available-users="availableTeachers"
|
||||
/>
|
||||
|
||||
<!-- Образовательные программы -->
|
||||
<DepartmentPrograms
|
||||
v-if="department.id"
|
||||
:department="department"
|
||||
:programs="programs"
|
||||
:available-programs="availablePrograms"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Form Actions -->
|
||||
<div class="px-6 py-4 bg-surface/50 border-t border-layer-line flex items-center justify-end gap-3">
|
||||
<a
|
||||
:href="route('dashboard.departments.index')"
|
||||
class="px-4 py-2 text-sm font-medium text-foreground bg-surface border border-layer-line rounded-lg hover:bg-muted-hover transition-all"
|
||||
>
|
||||
Отмена
|
||||
</a>
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="processing"
|
||||
class="px-4 py-2 text-sm font-medium text-white bg-primary rounded-lg hover:bg-primary-hover transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
<svg v-if="processing" class="animate-spin -ml-1 mr-2 h-4 w-4 text-white inline" fill="none" viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>
|
||||
{{ processing ? 'Сохранение...' : 'Сохранить изменения' }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</DashboardLayout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DashboardLayout from '../Components/DashboardLayout.vue';
|
||||
import DashboardIcon from '../Components/DashboardIcon.vue';
|
||||
import FlashMessages from '../Components/shared/FlashMessages.vue';
|
||||
import ContentBuilder from '../Components/ContentBuilder/ContentBuilder.vue';
|
||||
import DepartmentWorkers from './Workers/Index.vue';
|
||||
import DepartmentTeachers from './Teachers/Index.vue';
|
||||
import DepartmentPrograms from './Programs/Index.vue';
|
||||
|
||||
export default {
|
||||
name: 'DepartmentEdit',
|
||||
components: {
|
||||
DashboardLayout,
|
||||
DashboardIcon,
|
||||
FlashMessages,
|
||||
ContentBuilder,
|
||||
DepartmentWorkers,
|
||||
DepartmentTeachers,
|
||||
DepartmentPrograms,
|
||||
},
|
||||
|
||||
props: {
|
||||
department: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
faculties: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
workers: {
|
||||
type: Object,
|
||||
default: () => ({ data: [], total: 0 })
|
||||
},
|
||||
availableWorkers: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
teachers: {
|
||||
type: Object,
|
||||
default: () => ({ data: [], total: 0 })
|
||||
},
|
||||
availableTeachers: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
programs: {
|
||||
type: Object,
|
||||
default: () => ({ data: [], total: 0 })
|
||||
},
|
||||
availablePrograms: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
errors: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
title: this.department.title || '',
|
||||
slug: this.department.slug || '',
|
||||
faculty_id: this.department.faculty_id || '',
|
||||
is_active: Boolean(this.department.is_active ?? true),
|
||||
content: this.department.content || []
|
||||
},
|
||||
processing: false,
|
||||
baseUrl: this.GET_BASE_URL() + 'department'
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.SET_DOCUMENT_TITLE(`Редактирование кафедры - ${this.department.title}`);
|
||||
},
|
||||
|
||||
methods: {
|
||||
submit() {
|
||||
this.processing = true;
|
||||
this.$inertia.put(route('dashboard.departments.update', this.department.id), this.form, {
|
||||
onFinish: () => {
|
||||
this.processing = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,263 @@
|
||||
<template>
|
||||
<DashboardLayout>
|
||||
<template #header-icon>
|
||||
<DashboardIcon name="building-office" class="text-primary" />
|
||||
</template>
|
||||
<template #header-title>Кафедры</template>
|
||||
<template #header-subtitle>Управление кафедрами института</template>
|
||||
<template #header-actions>
|
||||
<a
|
||||
:href="route('dashboard.departments.create')"
|
||||
class="inline-flex items-center gap-2 px-4 py-2 bg-primary text-white text-sm font-medium rounded-lg hover:bg-primary-hover transition-all duration-200 shadow-sm hover:shadow-md"
|
||||
>
|
||||
<DashboardIcon name="plus" size="4" color="currentColor" />
|
||||
Создать кафедру
|
||||
</a>
|
||||
</template>
|
||||
|
||||
<!-- Flash Messages -->
|
||||
<FlashMessages />
|
||||
|
||||
<!-- Filters Card -->
|
||||
<DataFilters title="Фильтры" @reset="resetFilters">
|
||||
<SearchInput
|
||||
v-model="searchQuery"
|
||||
label="Поиск по названию"
|
||||
placeholder="Введите название кафедры..."
|
||||
@search="search"
|
||||
/>
|
||||
|
||||
<SelectFilter
|
||||
v-model="facultyQuery"
|
||||
label="Факультет"
|
||||
placeholder="Все факультеты"
|
||||
@change="filterByFaculty"
|
||||
>
|
||||
<option
|
||||
v-for="faculty in faculties"
|
||||
:key="faculty.id"
|
||||
:value="faculty.id"
|
||||
>
|
||||
{{ faculty.title }}
|
||||
</option>
|
||||
</SelectFilter>
|
||||
|
||||
<SelectFilter
|
||||
v-model="isActiveQuery"
|
||||
label="Статус"
|
||||
placeholder="Все статусы"
|
||||
@change="filterByStatus"
|
||||
>
|
||||
<option value="1">Активные</option>
|
||||
<option value="0">Неактивные</option>
|
||||
</SelectFilter>
|
||||
</DataFilters>
|
||||
|
||||
<!-- Departments Table -->
|
||||
<div class="bg-layer border border-layer-line rounded-lg shadow-xs overflow-hidden">
|
||||
<!-- Table Header Stats -->
|
||||
<div class="px-6 py-4 border-b border-line-2 bg-white/50">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-4">
|
||||
<span class="text-sm text-foreground">
|
||||
Всего: <span class="font-medium">{{ departments.total }}</span>
|
||||
</span>
|
||||
<span class="text-xs text-muted-foreground-1 px-2 py-0.5 bg-primary/10 text-primary rounded-full">
|
||||
{{ departments.data.length }} на странице
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
@click="refreshPage"
|
||||
class="p-2 text-muted-foreground-1 hover:text-foreground hover:bg-muted-hover rounded-lg transition-all"
|
||||
title="Обновить"
|
||||
>
|
||||
<DashboardIcon name="arrow-path" size="4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Table -->
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-line-2">
|
||||
<thead class="bg-surface/50">
|
||||
<tr>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Название
|
||||
</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Факультет
|
||||
</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Статус
|
||||
</th>
|
||||
<th class="px-6 py-3 text-left text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Обновлено
|
||||
</th>
|
||||
<th class="px-6 py-3 text-right text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Действия
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-line-2">
|
||||
<tr
|
||||
v-for="department in departments.data"
|
||||
:key="department.id"
|
||||
class="group hover:bg-muted-hover/50 transition-all duration-200"
|
||||
>
|
||||
<td class="px-6 py-4">
|
||||
<div class="text-sm font-medium text-foreground group-hover:text-primary transition-colors">
|
||||
{{ department.title }}
|
||||
</div>
|
||||
<div v-if="department.faculty" class="text-xs text-muted-foreground-1 mt-0.5">
|
||||
{{ department.faculty.abbreviation || department.faculty.title }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-md text-xs font-medium bg-primary/10 text-primary border border-primary/20">
|
||||
{{ department.faculty?.title || '—' }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span :class="STATUS_BADGE_CLASS(department.is_active)">
|
||||
<DashboardIcon
|
||||
:name="department.is_active ? 'check-circle' : 'x-circle'"
|
||||
size="3"
|
||||
class="mr-1"
|
||||
/>
|
||||
{{ department.is_active ? 'Активная' : 'Неактивная' }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="text-sm text-foreground">{{ FORMAT_DATE(department.updated_at, 'full') }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-right">
|
||||
<div class="flex items-center justify-end gap-1.5 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
<a
|
||||
:href="route('dashboard.departments.edit', department.id)"
|
||||
class="p-2 text-muted-foreground-1 hover:text-primary hover:bg-primary/10 rounded-lg transition-all"
|
||||
title="Редактировать"
|
||||
>
|
||||
<DashboardIcon name="pencil-square" size="4" />
|
||||
</a>
|
||||
<button
|
||||
@click.prevent="CONFIRM_AND_DELETE(department, 'dashboard.departments.destroy')"
|
||||
class="p-2 text-muted-foreground-1 hover:text-rose-600 hover:bg-rose-500/10 rounded-lg transition-all"
|
||||
title="Удалить"
|
||||
>
|
||||
<DashboardIcon name="trash" size="4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Empty State -->
|
||||
<EmptyState
|
||||
v-if="departments.data.length === 0"
|
||||
:columns="5"
|
||||
title="Кафедры не найдены"
|
||||
description="Создайте первую кафедру или измените параметры поиска"
|
||||
:action-url="route('dashboard.departments.create')"
|
||||
action-text="Создать кафедру"
|
||||
icon-name="building-office"
|
||||
/>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
<Pagination :data="departments" />
|
||||
</div>
|
||||
</DashboardLayout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DashboardLayout from '../Components/DashboardLayout.vue';
|
||||
import FlashMessages from '../Components/shared/FlashMessages.vue';
|
||||
import DataFilters from '../Components/shared/DataFilters.vue';
|
||||
import SearchInput from '../Components/shared/SearchInput.vue';
|
||||
import SelectFilter from '../Components/shared/SelectFilter.vue';
|
||||
import EmptyState from '../Components/shared/EmptyState.vue';
|
||||
import Pagination from '../Components/shared/Pagination.vue';
|
||||
import DashboardIcon from '../Components/DashboardIcon.vue';
|
||||
|
||||
export default {
|
||||
name: 'DepartmentIndex',
|
||||
components: {
|
||||
DashboardLayout,
|
||||
FlashMessages,
|
||||
DataFilters,
|
||||
SearchInput,
|
||||
SelectFilter,
|
||||
EmptyState,
|
||||
Pagination,
|
||||
DashboardIcon,
|
||||
},
|
||||
|
||||
props: {
|
||||
departments: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
faculties: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
filters: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
faculty_id: '',
|
||||
is_active: '',
|
||||
search: ''
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
searchQuery: this.filters?.search || '',
|
||||
facultyQuery: this.filters?.faculty_id || '',
|
||||
isActiveQuery: this.filters?.is_active || '',
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.SET_DOCUMENT_TITLE('Кафедры');
|
||||
},
|
||||
|
||||
methods: {
|
||||
search() {
|
||||
this.INERTIA_FILTER('dashboard.departments.index', {
|
||||
search: this.searchQuery,
|
||||
faculty_id: this.facultyQuery,
|
||||
is_active: this.isActiveQuery
|
||||
});
|
||||
},
|
||||
|
||||
filterByFaculty() {
|
||||
this.search();
|
||||
},
|
||||
|
||||
filterByStatus() {
|
||||
this.search();
|
||||
},
|
||||
|
||||
resetFilters() {
|
||||
this.RESET_FILTERS(
|
||||
['searchQuery', 'facultyQuery', 'isActiveQuery'],
|
||||
'dashboard.departments.index'
|
||||
);
|
||||
},
|
||||
|
||||
refreshPage() {
|
||||
this.INERTIA_FILTER('dashboard.departments.index', {
|
||||
search: this.searchQuery,
|
||||
faculty_id: this.facultyQuery,
|
||||
is_active: this.isActiveQuery
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,200 @@
|
||||
<template>
|
||||
<div class="space-y-4">
|
||||
<!-- Header -->
|
||||
<div class="flex items-center justify-between">
|
||||
<h3 class="text-lg font-medium text-foreground">Образовательные программы</h3>
|
||||
<button
|
||||
type="button"
|
||||
@click="showAddModal = true"
|
||||
class="inline-flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-primary bg-primary/10 rounded-lg hover:bg-primary/20 transition-all"
|
||||
>
|
||||
<DashboardIcon name="plus" size="4" />
|
||||
Добавить программу
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Programs Table -->
|
||||
<div class="border border-layer-line rounded-lg overflow-hidden">
|
||||
<table class="min-w-full divide-y divide-line-2">
|
||||
<thead class="bg-muted/30">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Название программы
|
||||
</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Статус
|
||||
</th>
|
||||
<th class="px-4 py-3 text-right text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Действия
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-line-2 bg-layer">
|
||||
<tr v-for="program in programs.data" :key="program.id" class="hover:bg-muted/20">
|
||||
<td class="px-4 py-3 text-sm font-medium text-foreground">
|
||||
{{ program.name }}
|
||||
</td>
|
||||
<td class="px-4 py-3 whitespace-nowrap">
|
||||
<span :class="getStatusBadgeClass(program.status)">
|
||||
{{ getStatusLabel(program.status) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-right">
|
||||
<button
|
||||
type="button"
|
||||
@click="confirmDetach(program)"
|
||||
class="p-1.5 text-muted-foreground-1 hover:text-danger hover:bg-danger/10 rounded transition-all"
|
||||
title="Открепить программу"
|
||||
>
|
||||
<DashboardIcon name="trash" size="4" />
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Empty State -->
|
||||
<tr v-if="programs.data.length === 0">
|
||||
<td colspan="3" class="px-4 py-12 text-center">
|
||||
<DashboardIcon name="book-open" size="12" class="mx-auto text-muted-foreground-1" />
|
||||
<p class="mt-2 text-sm text-muted-foreground-1">Нет образовательных программ</p>
|
||||
<p class="text-xs text-muted-foreground-1">Добавьте первую программу</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Add Modal -->
|
||||
<div
|
||||
v-if="showAddModal"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50"
|
||||
@click.self="closeModal"
|
||||
>
|
||||
<div class="bg-layer border border-layer-line rounded-lg shadow-xl max-w-lg w-full">
|
||||
<div class="px-6 py-4 border-b border-layer-line flex items-center justify-between">
|
||||
<h3 class="text-lg font-medium text-foreground">
|
||||
Добавить программу
|
||||
</h3>
|
||||
<button
|
||||
type="button"
|
||||
@click="closeModal"
|
||||
class="p-1.5 text-muted-foreground-1 hover:text-foreground hover:bg-muted-hover rounded transition-all"
|
||||
>
|
||||
<DashboardIcon name="x-mark" size="5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<form @submit.prevent="submit" class="p-6 space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Образовательная программа <span class="text-danger">*</span>
|
||||
</label>
|
||||
<select
|
||||
v-model="form.program_id"
|
||||
required
|
||||
class="w-full px-3 py-2 border border-layer-line rounded-lg bg-white text-foreground focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
>
|
||||
<option :value="null">Выберите программу...</option>
|
||||
<option v-for="program in availablePrograms" :key="program.id" :value="program.id">
|
||||
{{ program.name }}
|
||||
</option>
|
||||
</select>
|
||||
<p class="mt-1 text-xs text-muted-foreground-1">Только опубликованные программы</p>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end gap-3 pt-4">
|
||||
<button
|
||||
type="button"
|
||||
@click="closeModal"
|
||||
class="px-4 py-2 text-sm font-medium text-foreground bg-surface border border-layer-line rounded-lg hover:bg-muted-hover transition-all"
|
||||
>
|
||||
Отмена
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="processing"
|
||||
class="px-4 py-2 text-sm font-medium text-white bg-primary rounded-lg hover:bg-primary-hover transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
{{ processing ? 'Сохранение...' : 'Добавить' }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DashboardIcon from '../../Components/DashboardIcon.vue';
|
||||
|
||||
export default {
|
||||
name: 'DepartmentPrograms',
|
||||
components: {
|
||||
DashboardIcon,
|
||||
},
|
||||
props: {
|
||||
department: { type: Object, required: true },
|
||||
programs: { type: Object, required: true },
|
||||
availablePrograms: { type: Array, required: true },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
showAddModal: false,
|
||||
processing: false,
|
||||
form: {
|
||||
program_id: null
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
getStatusBadgeClass(status) {
|
||||
const classes = {
|
||||
published: 'inline-flex items-center px-2.5 py-1 rounded-md text-xs font-medium bg-success/10 text-success border border-success/20',
|
||||
draft: 'inline-flex items-center px-2.5 py-1 rounded-md text-xs font-medium bg-warning/10 text-warning border border-warning/20',
|
||||
archived: 'inline-flex items-center px-2.5 py-1 rounded-md text-xs font-medium bg-muted text-muted-foreground-1 border border-layer-line',
|
||||
};
|
||||
return classes[status] || classes.draft;
|
||||
},
|
||||
getStatusLabel(status) {
|
||||
const labels = {
|
||||
published: 'Опубликована',
|
||||
draft: 'Черновик',
|
||||
archived: 'Архив',
|
||||
};
|
||||
return labels[status] || status;
|
||||
},
|
||||
confirmDetach(program) {
|
||||
if (confirm(`Вы уверены, что хотите открепить программу "${program.name}" от кафедры?`)) {
|
||||
this.detachProgram(program);
|
||||
}
|
||||
},
|
||||
detachProgram(program) {
|
||||
this.$inertia.delete(route('dashboard.departments.programs.detach', [this.department.id, program.id]), {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => {
|
||||
// Остаемся на странице edit, flash message покажется автоматически
|
||||
}
|
||||
});
|
||||
},
|
||||
submit() {
|
||||
this.processing = true;
|
||||
|
||||
this.$inertia.post(route('dashboard.departments.programs.attach', this.department.id), this.form, {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => {
|
||||
this.processing = false;
|
||||
this.closeModal();
|
||||
},
|
||||
onError: () => {
|
||||
this.processing = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
closeModal() {
|
||||
this.showAddModal = false;
|
||||
this.form = {
|
||||
program_id: null
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,290 @@
|
||||
<template>
|
||||
<div class="space-y-4">
|
||||
<!-- Header -->
|
||||
<div class="flex items-center justify-between">
|
||||
<h3 class="text-lg font-medium text-foreground">Преподаватели кафедры</h3>
|
||||
<button
|
||||
type="button"
|
||||
@click="showAddModal = true"
|
||||
class="inline-flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-primary bg-primary/10 rounded-lg hover:bg-primary/20 transition-all"
|
||||
>
|
||||
<DashboardIcon name="plus" size="4" />
|
||||
Добавить преподавателя
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Teachers Table -->
|
||||
<div class="border border-layer-line rounded-lg overflow-hidden">
|
||||
<table class="min-w-full divide-y divide-line-2">
|
||||
<thead class="bg-muted/30">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
ФИО
|
||||
</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Должность
|
||||
</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Почта
|
||||
</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Телефон
|
||||
</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Кабинет
|
||||
</th>
|
||||
<th class="px-4 py-3 text-right text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Действия
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-line-2 bg-layer">
|
||||
<tr v-for="teacher in teachers.data" :key="teacher.id" class="hover:bg-muted/20">
|
||||
<td class="px-4 py-3 text-sm font-medium text-foreground">
|
||||
{{ teacher.name }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm text-foreground">
|
||||
{{ teacher.pivot.teaching_position }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm text-foreground">
|
||||
{{ teacher.pivot.service_email || '—' }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm text-foreground">
|
||||
{{ teacher.pivot.service_phone || '—' }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm text-foreground">
|
||||
{{ teacher.pivot.cabinet || '—' }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-right">
|
||||
<div class="flex items-center justify-end gap-1">
|
||||
<button
|
||||
type="button"
|
||||
@click="editTeacher(teacher)"
|
||||
class="p-1.5 text-muted-foreground-1 hover:text-primary hover:bg-primary/10 rounded transition-all"
|
||||
title="Редактировать"
|
||||
>
|
||||
<DashboardIcon name="pencil-square" size="4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
@click="confirmDetach(teacher)"
|
||||
class="p-1.5 text-muted-foreground-1 hover:text-danger hover:bg-danger/10 rounded transition-all"
|
||||
title="Удалить"
|
||||
>
|
||||
<DashboardIcon name="trash" size="4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Empty State -->
|
||||
<tr v-if="teachers.data.length === 0">
|
||||
<td colspan="6" class="px-4 py-12 text-center">
|
||||
<DashboardIcon name="user-group" size="12" class="mx-auto text-muted-foreground-1" />
|
||||
<p class="mt-2 text-sm text-muted-foreground-1">Нет преподавателей</p>
|
||||
<p class="text-xs text-muted-foreground-1">Добавьте первого преподавателя</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Add/Edit Modal -->
|
||||
<div
|
||||
v-if="showAddModal || editingTeacher"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50"
|
||||
@click.self="closeModal"
|
||||
>
|
||||
<div class="bg-layer border border-layer-line rounded-lg shadow-xl max-w-lg w-full">
|
||||
<div class="px-6 py-4 border-b border-layer-line flex items-center justify-between">
|
||||
<h3 class="text-lg font-medium text-foreground">
|
||||
{{ editingTeacher ? 'Редактировать преподавателя' : 'Добавить преподавателя' }}
|
||||
</h3>
|
||||
<button
|
||||
type="button"
|
||||
@click="closeModal"
|
||||
class="p-1.5 text-muted-foreground-1 hover:text-foreground hover:bg-muted-hover rounded transition-all"
|
||||
>
|
||||
<DashboardIcon name="x-mark" size="5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<form @submit.prevent="submit" class="p-6 space-y-4">
|
||||
<div v-if="!editingTeacher">
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Преподаватель <span class="text-danger">*</span>
|
||||
</label>
|
||||
<select
|
||||
v-model="form.user_id"
|
||||
required
|
||||
class="w-full px-3 py-2 border border-layer-line rounded-lg bg-white text-foreground focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
>
|
||||
<option :value="null">Выберите преподавателя...</option>
|
||||
<option v-for="user in availableUsers" :key="user.id" :value="user.id">
|
||||
{{ user.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Преподавательская должность <span class="text-danger">*</span>
|
||||
</label>
|
||||
<input
|
||||
v-model="form.teaching_position"
|
||||
type="text"
|
||||
required
|
||||
maxlength="255"
|
||||
placeholder="Например: Профессор"
|
||||
class="w-full px-3 py-2 border border-layer-line rounded-lg bg-white text-foreground placeholder-muted-foreground-1 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Рабочая почта
|
||||
</label>
|
||||
<input
|
||||
v-model="form.service_email"
|
||||
type="email"
|
||||
maxlength="255"
|
||||
placeholder="example@university.ru"
|
||||
class="w-full px-3 py-2 border border-layer-line rounded-lg bg-white text-foreground placeholder-muted-foreground-1 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Рабочий телефон
|
||||
</label>
|
||||
<input
|
||||
v-model="form.service_phone"
|
||||
type="text"
|
||||
maxlength="20"
|
||||
placeholder="+7 (XXX) XXX-XX-XX"
|
||||
class="w-full px-3 py-2 border border-layer-line rounded-lg bg-white text-foreground placeholder-muted-foreground-1 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Кабинет
|
||||
</label>
|
||||
<input
|
||||
v-model="form.cabinet"
|
||||
type="text"
|
||||
maxlength="10"
|
||||
placeholder="Например: 305а"
|
||||
class="w-full px-3 py-2 border border-layer-line rounded-lg bg-white text-foreground placeholder-muted-foreground-1 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end gap-3 pt-4">
|
||||
<button
|
||||
type="button"
|
||||
@click="closeModal"
|
||||
class="px-4 py-2 text-sm font-medium text-foreground bg-surface border border-layer-line rounded-lg hover:bg-muted-hover transition-all"
|
||||
>
|
||||
Отмена
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="processing"
|
||||
class="px-4 py-2 text-sm font-medium text-white bg-primary rounded-lg hover:bg-primary-hover transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
{{ processing ? 'Сохранение...' : 'Сохранить' }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DashboardIcon from '../../Components/DashboardIcon.vue';
|
||||
|
||||
export default {
|
||||
name: 'DepartmentTeachers',
|
||||
components: {
|
||||
DashboardIcon,
|
||||
},
|
||||
props: {
|
||||
department: { type: Object, required: true },
|
||||
teachers: { type: Object, required: true },
|
||||
availableUsers: { type: Array, required: true },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
showAddModal: false,
|
||||
editingTeacher: null,
|
||||
processing: false,
|
||||
form: {
|
||||
user_id: null,
|
||||
teaching_position: '',
|
||||
service_email: '',
|
||||
service_phone: '',
|
||||
cabinet: ''
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
editTeacher(teacher) {
|
||||
this.editingTeacher = teacher;
|
||||
this.form = {
|
||||
user_id: teacher.id,
|
||||
teaching_position: teacher.pivot.teaching_position,
|
||||
service_email: teacher.pivot.service_email || '',
|
||||
service_phone: teacher.pivot.service_phone || '',
|
||||
cabinet: teacher.pivot.cabinet || ''
|
||||
};
|
||||
},
|
||||
confirmDetach(teacher) {
|
||||
if (confirm(`Вы уверены, что хотите удалить "${teacher.name}" из преподавателей кафедры?`)) {
|
||||
this.detachTeacher(teacher);
|
||||
}
|
||||
},
|
||||
detachTeacher(teacher) {
|
||||
this.$inertia.delete(route('dashboard.departments.teachers.detach', [this.department.id, teacher.id]), {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => {
|
||||
// Остаемся на странице edit, flash message покажется автоматически
|
||||
}
|
||||
});
|
||||
},
|
||||
submit() {
|
||||
this.processing = true;
|
||||
|
||||
const url = this.editingTeacher
|
||||
? route('dashboard.departments.teachers.update', [this.department.id, this.editingTeacher.id])
|
||||
: route('dashboard.departments.teachers.attach', this.department.id);
|
||||
|
||||
const method = this.editingTeacher ? 'put' : 'post';
|
||||
|
||||
this.$inertia[method](url, this.form, {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => {
|
||||
this.processing = false;
|
||||
this.closeModal();
|
||||
},
|
||||
onError: () => {
|
||||
this.processing = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
closeModal() {
|
||||
this.showAddModal = false;
|
||||
this.editingTeacher = null;
|
||||
this.form = {
|
||||
user_id: null,
|
||||
teaching_position: '',
|
||||
service_email: '',
|
||||
service_phone: '',
|
||||
cabinet: ''
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,290 @@
|
||||
<template>
|
||||
<div class="space-y-4">
|
||||
<!-- Header -->
|
||||
<div class="flex items-center justify-between">
|
||||
<h3 class="text-lg font-medium text-foreground">Сотрудники кафедры</h3>
|
||||
<button
|
||||
type="button"
|
||||
@click="showAddModal = true"
|
||||
class="inline-flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-primary bg-primary/10 rounded-lg hover:bg-primary/20 transition-all"
|
||||
>
|
||||
<DashboardIcon name="plus" size="4" />
|
||||
Добавить сотрудника
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Workers Table -->
|
||||
<div class="border border-layer-line rounded-lg overflow-hidden">
|
||||
<table class="min-w-full divide-y divide-line-2">
|
||||
<thead class="bg-muted/30">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
ФИО
|
||||
</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Должность
|
||||
</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Почта
|
||||
</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Телефон
|
||||
</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Кабинет
|
||||
</th>
|
||||
<th class="px-4 py-3 text-right text-xs font-medium text-muted-foreground-1 uppercase tracking-wider">
|
||||
Действия
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-line-2 bg-layer">
|
||||
<tr v-for="worker in workers.data" :key="worker.id" class="hover:bg-muted/20">
|
||||
<td class="px-4 py-3 text-sm font-medium text-foreground">
|
||||
{{ worker.name }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm text-foreground">
|
||||
{{ worker.pivot.position }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm text-foreground">
|
||||
{{ worker.pivot.service_email || '—' }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm text-foreground">
|
||||
{{ worker.pivot.service_phone || '—' }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm text-foreground">
|
||||
{{ worker.pivot.cabinet || '—' }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-right">
|
||||
<div class="flex items-center justify-end gap-1">
|
||||
<button
|
||||
type="button"
|
||||
@click="editWorker(worker)"
|
||||
class="p-1.5 text-muted-foreground-1 hover:text-primary hover:bg-primary/10 rounded transition-all"
|
||||
title="Редактировать"
|
||||
>
|
||||
<DashboardIcon name="pencil-square" size="4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
@click="confirmDetach(worker)"
|
||||
class="p-1.5 text-muted-foreground-1 hover:text-danger hover:bg-danger/10 rounded transition-all"
|
||||
title="Удалить"
|
||||
>
|
||||
<DashboardIcon name="trash" size="4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Empty State -->
|
||||
<tr v-if="workers.data.length === 0">
|
||||
<td colspan="6" class="px-4 py-12 text-center">
|
||||
<DashboardIcon name="user-group" size="12" class="mx-auto text-muted-foreground-1" />
|
||||
<p class="mt-2 text-sm text-muted-foreground-1">Нет сотрудников</p>
|
||||
<p class="text-xs text-muted-foreground-1">Добавьте первого сотрудника</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Add/Edit Modal -->
|
||||
<div
|
||||
v-if="showAddModal || editingWorker"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50"
|
||||
@click.self="closeModal"
|
||||
>
|
||||
<div class="bg-layer border border-layer-line rounded-lg shadow-xl max-w-lg w-full">
|
||||
<div class="px-6 py-4 border-b border-layer-line flex items-center justify-between">
|
||||
<h3 class="text-lg font-medium text-foreground">
|
||||
{{ editingWorker ? 'Редактировать сотрудника' : 'Добавить сотрудника' }}
|
||||
</h3>
|
||||
<button
|
||||
type="button"
|
||||
@click="closeModal"
|
||||
class="p-1.5 text-muted-foreground-1 hover:text-foreground hover:bg-muted-hover rounded transition-all"
|
||||
>
|
||||
<DashboardIcon name="x-mark" size="5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<form @submit.prevent="submit" class="p-6 space-y-4">
|
||||
<div v-if="!editingWorker">
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Сотрудник <span class="text-danger">*</span>
|
||||
</label>
|
||||
<select
|
||||
v-model="form.user_id"
|
||||
required
|
||||
class="w-full px-3 py-2 border border-layer-line rounded-lg bg-white text-foreground focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
>
|
||||
<option :value="null">Выберите сотрудника...</option>
|
||||
<option v-for="user in availableUsers" :key="user.id" :value="user.id">
|
||||
{{ user.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Должность <span class="text-danger">*</span>
|
||||
</label>
|
||||
<input
|
||||
v-model="form.position"
|
||||
type="text"
|
||||
required
|
||||
maxlength="255"
|
||||
placeholder="Например: Заведующий кафедрой"
|
||||
class="w-full px-3 py-2 border border-layer-line rounded-lg bg-white text-foreground placeholder-muted-foreground-1 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Рабочая почта
|
||||
</label>
|
||||
<input
|
||||
v-model="form.service_email"
|
||||
type="email"
|
||||
maxlength="255"
|
||||
placeholder="example@university.ru"
|
||||
class="w-full px-3 py-2 border border-layer-line rounded-lg bg-white text-foreground placeholder-muted-foreground-1 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Рабочий телефон
|
||||
</label>
|
||||
<input
|
||||
v-model="form.service_phone"
|
||||
type="text"
|
||||
maxlength="20"
|
||||
placeholder="+7 (XXX) XXX-XX-XX"
|
||||
class="w-full px-3 py-2 border border-layer-line rounded-lg bg-white text-foreground placeholder-muted-foreground-1 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-foreground mb-1">
|
||||
Кабинет
|
||||
</label>
|
||||
<input
|
||||
v-model="form.cabinet"
|
||||
type="text"
|
||||
maxlength="10"
|
||||
placeholder="Например: 305а"
|
||||
class="w-full px-3 py-2 border border-layer-line rounded-lg bg-white text-foreground placeholder-muted-foreground-1 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end gap-3 pt-4">
|
||||
<button
|
||||
type="button"
|
||||
@click="closeModal"
|
||||
class="px-4 py-2 text-sm font-medium text-foreground bg-surface border border-layer-line rounded-lg hover:bg-muted-hover transition-all"
|
||||
>
|
||||
Отмена
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="processing"
|
||||
class="px-4 py-2 text-sm font-medium text-white bg-primary rounded-lg hover:bg-primary-hover transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
{{ processing ? 'Сохранение...' : 'Сохранить' }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DashboardIcon from '../../Components/DashboardIcon.vue';
|
||||
|
||||
export default {
|
||||
name: 'DepartmentWorkers',
|
||||
components: {
|
||||
DashboardIcon,
|
||||
},
|
||||
props: {
|
||||
department: { type: Object, required: true },
|
||||
workers: { type: Object, required: true },
|
||||
availableUsers: { type: Array, required: true },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
showAddModal: false,
|
||||
editingWorker: null,
|
||||
processing: false,
|
||||
form: {
|
||||
user_id: null,
|
||||
position: '',
|
||||
service_email: '',
|
||||
service_phone: '',
|
||||
cabinet: ''
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
editWorker(worker) {
|
||||
this.editingWorker = worker;
|
||||
this.form = {
|
||||
user_id: worker.id,
|
||||
position: worker.pivot.position,
|
||||
service_email: worker.pivot.service_email || '',
|
||||
service_phone: worker.pivot.service_phone || '',
|
||||
cabinet: worker.pivot.cabinet || ''
|
||||
};
|
||||
},
|
||||
confirmDetach(worker) {
|
||||
if (confirm(`Вы уверены, что хотите удалить "${worker.name}" из сотрудников кафедры?`)) {
|
||||
this.detachWorker(worker);
|
||||
}
|
||||
},
|
||||
detachWorker(worker) {
|
||||
this.$inertia.delete(route('dashboard.departments.workers.detach', [this.department.id, worker.id]), {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => {
|
||||
// Остаемся на странице edit, flash message покажется автоматически
|
||||
}
|
||||
});
|
||||
},
|
||||
submit() {
|
||||
this.processing = true;
|
||||
|
||||
const url = this.editingWorker
|
||||
? route('dashboard.departments.workers.update', [this.department.id, this.editingWorker.id])
|
||||
: route('dashboard.departments.workers.attach', this.department.id);
|
||||
|
||||
const method = this.editingWorker ? 'put' : 'post';
|
||||
|
||||
this.$inertia[method](url, this.form, {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => {
|
||||
this.processing = false;
|
||||
this.closeModal();
|
||||
},
|
||||
onError: () => {
|
||||
this.processing = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
closeModal() {
|
||||
this.showAddModal = false;
|
||||
this.editingWorker = null;
|
||||
this.form = {
|
||||
user_id: null,
|
||||
position: '',
|
||||
service_email: '',
|
||||
service_phone: '',
|
||||
cabinet: ''
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user