This commit is contained in:
F4ilji
2026-04-07 17:54:26 +05:00
parent 04adba6682
commit 936b1fb5b0
468 changed files with 43498 additions and 4176 deletions
@@ -0,0 +1,244 @@
<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.users.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 md:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-foreground mb-1">
ФИО <span class="text-danger">*</span>
</label>
<input
v-model="form.name"
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.name" class="mt-1 text-sm text-danger">{{ errors.name }}</p>
</div>
<div>
<label class="block text-sm font-medium text-foreground mb-1">
Email <span class="text-danger">*</span>
</label>
<input
v-model="form.email"
type="email"
required
maxlength="255"
placeholder="example@ntspi.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"
/>
<p v-if="errors.email" class="mt-1 text-sm text-danger">{{ errors.email }}</p>
</div>
<div>
<label class="block text-sm font-medium text-foreground mb-1">
Пароль <span class="text-danger">*</span>
</label>
<input
v-model="form.password"
type="password"
required
minlength="8"
maxlength="255"
placeholder="Минимум 8 символов"
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.password" class="mt-1 text-sm text-danger">{{ errors.password }}</p>
</div>
<div>
<label class="block text-sm font-medium text-foreground mb-1">
Роль
</label>
<div class="relative" ref="rolesDropdownRef">
<button
type="button"
@click="showRolesDropdown = !showRolesDropdown"
class="w-full min-h-[42px] 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 text-left flex flex-wrap gap-1.5 items-center"
>
<span v-if="form.roles.length === 0" class="text-muted-foreground-1 text-sm">
Выберите роли
</span>
<span
v-for="role in form.roles"
:key="role"
class="inline-flex items-center gap-1 px-2 py-0.5 bg-primary/10 text-primary text-xs font-medium rounded"
>
{{ role }}
<button
type="button"
@click.stop="removeRole(role)"
class="text-primary hover:text-primary-hover"
>
×
</button>
</span>
</button>
<div
v-if="showRolesDropdown"
class="absolute z-[100] w-full mt-1 bg-white border border-layer-line rounded-lg shadow-lg max-h-60 overflow-auto"
>
<label
v-for="role in roles"
:key="role.id"
class="flex items-center gap-3 px-3 py-2.5 hover:bg-muted-hover cursor-pointer transition-colors"
>
<input
type="checkbox"
:checked="form.roles.includes(role.name)"
@change="toggleRole(role.name)"
class="w-4 h-4 rounded border-layer-line text-primary focus:ring-primary focus:ring-offset-0"
/>
<span class="text-sm text-foreground">{{ role.name }}</span>
</label>
<div v-if="roles.length === 0" class="px-3 py-4 text-sm text-muted-foreground-1 text-center">
Нет доступных ролей
</div>
</div>
</div>
<p class="mt-1 text-xs text-muted-foreground-1">Можно выбрать несколько ролей</p>
<p v-if="errors.roles" class="mt-1 text-sm text-danger">{{ errors.roles }}</p>
</div>
</div>
</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.users.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';
export default {
name: 'UserCreate',
components: {
DashboardLayout,
DashboardIcon,
FlashMessages,
},
props: {
roles: {
type: Array,
required: true
},
errors: {
type: Object,
default: () => ({})
}
},
data() {
return {
form: {
name: '',
email: '',
password: '',
roles: []
},
processing: false,
showRolesDropdown: false
}
},
mounted() {
this.SET_DOCUMENT_TITLE('Создание пользователя');
document.addEventListener('click', this.handleClickOutside);
},
beforeUnmount() {
document.removeEventListener('click', this.handleClickOutside);
},
methods: {
toggleRole(roleName) {
const index = this.form.roles.indexOf(roleName);
if (index === -1) {
this.form.roles.push(roleName);
} else {
this.form.roles.splice(index, 1);
}
},
removeRole(roleName) {
const index = this.form.roles.indexOf(roleName);
if (index !== -1) {
this.form.roles.splice(index, 1);
}
},
handleClickOutside(event) {
if (this.$refs.rolesDropdownRef && !this.$refs.rolesDropdownRef.contains(event.target)) {
this.showRolesDropdown = false;
}
},
submit() {
this.processing = true;
const formData = {
name: this.form.name,
email: this.form.email,
password: this.form.password,
roles: [...this.form.roles]
};
this.$inertia.post(route('dashboard.users.store'), formData, {
onFinish: () => {
this.processing = false;
}
});
}
}
}
</script>
+392
View File
@@ -0,0 +1,392 @@
<template>
<DashboardLayout>
<template #header-icon>
<DashboardIcon name="pencil-square" size="5" class="text-primary" />
</template>
<template #header-title>Редактирование пользователя</template>
<template #header-subtitle>{{ user.name }}</template>
<template #header-actions>
<a
:href="route('dashboard.users.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 md:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-foreground mb-1">
ФИО <span class="text-danger">*</span>
</label>
<input
v-model="form.name"
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.name" class="mt-1 text-sm text-danger">{{ errors.name }}</p>
</div>
<div>
<label class="block text-sm font-medium text-foreground mb-1">
Email <span class="text-danger">*</span>
</label>
<input
v-model="form.email"
type="email"
required
maxlength="255"
placeholder="example@ntspi.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"
/>
<p v-if="errors.email" class="mt-1 text-sm text-danger">{{ errors.email }}</p>
</div>
<div>
<label class="block text-sm font-medium text-foreground mb-1">
Новый пароль
</label>
<input
v-model="form.password"
type="password"
minlength="8"
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 class="mt-1 text-xs text-muted-foreground-1">Минимум 8 символов</p>
<p v-if="errors.password" class="mt-1 text-sm text-danger">{{ errors.password }}</p>
</div>
<div>
<label class="block text-sm font-medium text-foreground mb-1">
Роль
</label>
<div class="relative" ref="rolesDropdownRef">
<button
type="button"
@click="showRolesDropdown = !showRolesDropdown"
class="w-full min-h-[42px] 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 text-left flex flex-wrap gap-1.5 items-center"
>
<span v-if="form.roles.length === 0" class="text-muted-foreground-1 text-sm">
Выберите роли
</span>
<span
v-for="role in form.roles"
:key="role"
class="inline-flex items-center gap-1 px-2 py-0.5 bg-primary/10 text-primary text-xs font-medium rounded"
>
{{ role }}
<button
type="button"
@click.stop="removeRole(role)"
class="text-primary hover:text-primary-hover"
>
×
</button>
</span>
</button>
<div
v-if="showRolesDropdown"
class="absolute z-[100] w-full mt-1 bg-white border border-layer-line rounded-lg shadow-lg max-h-60 overflow-auto"
>
<label
v-for="role in roles"
:key="role.id"
class="flex items-center gap-3 px-3 py-2.5 hover:bg-muted-hover cursor-pointer transition-colors"
>
<input
type="checkbox"
:checked="form.roles.includes(role.name)"
@change="toggleRole(role.name)"
class="w-4 h-4 rounded border-layer-line text-primary focus:ring-primary focus:ring-offset-0"
/>
<span class="text-sm text-foreground">{{ role.name }}</span>
</label>
<div v-if="roles.length === 0" class="px-3 py-4 text-sm text-muted-foreground-1 text-center">
Нет доступных ролей
</div>
</div>
</div>
<p class="mt-1 text-xs text-muted-foreground-1">Можно выбрать несколько ролей</p>
<p v-if="errors.roles" class="mt-1 text-sm text-danger">{{ errors.roles }}</p>
</div>
</div>
</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.users.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>
<!-- User Detail Section -->
<div class="mt-6 bg-white border border-layer-line rounded-lg shadow-xs overflow-hidden">
<div class="px-6 py-4 border-b border-layer-line">
<div class="flex items-center justify-between">
<h3 class="text-lg font-medium text-foreground">Детальная информация</h3>
<a
v-if="!user.user_detail"
:href="route('dashboard.users.detail.create', user.id)"
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" />
Добавить
</a>
<a
v-else
:href="route('dashboard.users.detail.edit', { user: user.id, userDetail: user.user_detail.id })"
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="pencil-square" size="4" />
Редактировать
</a>
</div>
</div>
<div class="p-6">
<div v-if="user.user_detail" class="space-y-6">
<!-- Photo -->
<div v-if="user.user_detail.photo" class="flex items-center gap-4">
<img
:src="RESOLVE_ASSET_URL(user.user_detail.photo)"
alt="Фото"
class="w-20 h-20 rounded-full object-cover border border-layer-line"
/>
<div>
<span class="text-xs text-muted-foreground-1">Фото</span>
<p class="text-sm text-foreground">{{ user.user_detail.photo.split('/').pop() }}</p>
</div>
</div>
<!-- Contact Info -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div v-if="user.user_detail.contactEmail">
<span class="text-xs text-muted-foreground-1">Контактный Email</span>
<p class="text-sm text-foreground">{{ user.user_detail.contactEmail }}</p>
</div>
<div v-if="user.user_detail.contactPhone">
<span class="text-xs text-muted-foreground-1">Контактный телефон</span>
<p class="text-sm text-foreground">{{ user.user_detail.contactPhone }}</p>
</div>
</div>
<!-- Academic Info -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div v-if="user.user_detail.academicTitle">
<span class="text-xs text-muted-foreground-1">Ученая степень</span>
<p class="text-sm text-foreground">{{ user.user_detail.academicTitle }}</p>
</div>
<div v-if="user.user_detail.AcademicDegree">
<span class="text-xs text-muted-foreground-1">Ученое звание</span>
<p class="text-sm text-foreground">{{ user.user_detail.AcademicDegree }}</p>
</div>
</div>
<!-- Status -->
<div v-if="user.user_detail.is_only_worker !== null">
<span class="text-xs text-muted-foreground-1">Только работник</span>
<p class="text-sm text-foreground">
<span :class="STATUS_BADGE_CLASS(!user.user_detail.is_only_worker)">
{{ user.user_detail.is_only_worker ? 'Да' : 'Нет' }}
</span>
</p>
</div>
<!-- Text Sections -->
<div class="space-y-4">
<div v-if="user.user_detail.education" class="bg-muted/30 rounded-lg p-4">
<span class="text-xs font-medium text-muted-foreground-1 uppercase tracking-wide">Образование</span>
<div class="mt-2 text-sm text-foreground whitespace-pre-line">{{ FORMAT_JSON_FIELD(user.user_detail.education) }}</div>
</div>
<div v-if="FORMAT_JSON_FIELD(user.user_detail.awards)" class="bg-muted/30 rounded-lg p-4">
<span class="text-xs font-medium text-muted-foreground-1 uppercase tracking-wide">Награды</span>
<div class="mt-2 text-sm text-foreground whitespace-pre-line">{{ FORMAT_JSON_FIELD(user.user_detail.awards) }}</div>
</div>
<div v-if="user.user_detail.professDisciplines" class="bg-muted/30 rounded-lg p-4">
<span class="text-xs font-medium text-muted-foreground-1 uppercase tracking-wide">Преподаваемые программы</span>
<div class="mt-2 text-sm text-foreground whitespace-pre-line">{{ FORMAT_JSON_FIELD(user.user_detail.professDisciplines) }}</div>
</div>
<div v-if="FORMAT_JSON_FIELD(user.user_detail.professionalRetraining)" class="bg-muted/30 rounded-lg p-4">
<span class="text-xs font-medium text-muted-foreground-1 uppercase tracking-wide">Профессиональная переподготовка</span>
<div class="mt-2 text-sm text-foreground whitespace-pre-line">{{ FORMAT_JSON_FIELD(user.user_detail.professionalRetraining) }}</div>
</div>
<div v-if="user.user_detail.professionalDevelopment" class="bg-muted/30 rounded-lg p-4">
<span class="text-xs font-medium text-muted-foreground-1 uppercase tracking-wide">Повышение квалификации</span>
<div class="mt-2 text-sm text-foreground whitespace-pre-line">{{ FORMAT_JSON_FIELD(user.user_detail.professionalDevelopment) }}</div>
</div>
<div v-if="user.user_detail.workExperience" class="bg-muted/30 rounded-lg p-4">
<span class="text-xs font-medium text-muted-foreground-1 uppercase tracking-wide">Стаж работы</span>
<div class="mt-2 text-sm text-foreground whitespace-pre-line">{{ FORMAT_JSON_FIELD(user.user_detail.workExperience) }}</div>
</div>
<div v-if="user.user_detail.attendedConferences" class="bg-muted/30 rounded-lg p-4">
<span class="text-xs font-medium text-muted-foreground-1 uppercase tracking-wide">Участие в конференциях</span>
<div class="mt-2 text-sm text-foreground whitespace-pre-line">{{ FORMAT_JSON_FIELD(user.user_detail.attendedConferences) }}</div>
</div>
<div v-if="user.user_detail.participationScienceProjects" class="bg-muted/30 rounded-lg p-4">
<span class="text-xs font-medium text-muted-foreground-1 uppercase tracking-wide">Участие в научных проектах</span>
<div class="mt-2 text-sm text-foreground whitespace-pre-line">{{ FORMAT_JSON_FIELD(user.user_detail.participationScienceProjects) }}</div>
</div>
<div v-if="user.user_detail.publications" class="bg-muted/30 rounded-lg p-4">
<span class="text-xs font-medium text-muted-foreground-1 uppercase tracking-wide">Публикации</span>
<div class="mt-2 text-sm text-foreground whitespace-pre-line">{{ FORMAT_JSON_FIELD(user.user_detail.publications) }}</div>
</div>
<div v-if="FORMAT_JSON_FIELD(user.user_detail.other)" class="bg-muted/30 rounded-lg p-4">
<span class="text-xs font-medium text-muted-foreground-1 uppercase tracking-wide">Прочее</span>
<div class="mt-2 text-sm text-foreground whitespace-pre-line">{{ FORMAT_JSON_FIELD(user.user_detail.other) }}</div>
</div>
</div>
<!-- Metadata -->
<div class="pt-4 border-t border-layer-line grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<span class="text-xs text-muted-foreground-1">Создан</span>
<p class="text-sm text-foreground">{{ FORMAT_DATE(user.user_detail.created_at, 'full') }}</p>
</div>
<div>
<span class="text-xs text-muted-foreground-1">Обновлён</span>
<p class="text-sm text-foreground">{{ FORMAT_DATE(user.user_detail.updated_at, 'full') }}</p>
</div>
</div>
</div>
<p v-else class="text-sm text-muted-foreground-1 text-center py-4">
Детальная информация еще не добавлена
</p>
</div>
</div>
</DashboardLayout>
</template>
<script>
import DashboardLayout from '../Components/DashboardLayout.vue';
import DashboardIcon from '../Components/DashboardIcon.vue';
import FlashMessages from '../Components/shared/FlashMessages.vue';
export default {
name: 'UserEdit',
components: {
DashboardLayout,
DashboardIcon,
FlashMessages,
},
props: {
user: {
type: Object,
required: true
},
roles: {
type: Array,
required: true
},
errors: {
type: Object,
default: () => ({})
}
},
data() {
return {
form: {
name: this.user.name || '',
email: this.user.email || '',
password: '',
roles: (this.user.roles || []).map(r => r.name)
},
processing: false,
showRolesDropdown: false
}
},
mounted() {
this.SET_DOCUMENT_TITLE('Редактирование пользователя - ' + this.user.name);
document.addEventListener('click', this.handleClickOutside);
},
beforeUnmount() {
document.removeEventListener('click', this.handleClickOutside);
},
methods: {
toggleRole(roleName) {
const index = this.form.roles.indexOf(roleName);
if (index === -1) {
this.form.roles.push(roleName);
} else {
this.form.roles.splice(index, 1);
}
},
removeRole(roleName) {
const index = this.form.roles.indexOf(roleName);
if (index !== -1) {
this.form.roles.splice(index, 1);
}
},
handleClickOutside(event) {
if (this.$refs.rolesDropdownRef && !this.$refs.rolesDropdownRef.contains(event.target)) {
this.showRolesDropdown = false;
}
},
submit() {
this.processing = true;
const formData = {
name: this.form.name,
email: this.form.email,
password: this.form.password,
roles: [...this.form.roles]
};
this.$inertia.put(route('dashboard.users.update', this.user.id), formData, {
onFinish: () => {
this.processing = false;
}
});
}
}
}
</script>
@@ -0,0 +1,254 @@
<template>
<DashboardLayout>
<template #header-icon>
<DashboardIcon name="user-circle" size="5" class="text-primary" />
</template>
<template #header-title>Пользователи</template>
<template #header-subtitle>Управление пользователями системы</template>
<template #header-actions>
<a
:href="route('dashboard.users.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" />
Создать пользователя
</a>
</template>
<template #breadcrumbs>
<Breadcrumbs :crumbs="[{ label: 'Пользователи', href: route('dashboard.users.index') }]" />
</template>
<!-- Flash Messages -->
<FlashMessages />
<!-- Filters Card -->
<DataFilters title="Фильтры" @reset="resetFilters">
<SearchInput
v-model="searchQuery"
label="Поиск по имени или email"
placeholder="Введите имя или email..."
@search="search"
/>
<SelectFilter
v-model="roleQuery"
label="Роль"
placeholder="Все роли"
@change="filterByRole"
>
<option v-for="role in roles" :key="role.id" :value="role.id">
{{ role.name }}
</option>
</SelectFilter>
</DataFilters>
<!-- Users 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-surface/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">{{ users.total }}</span>
</span>
<span class="text-xs text-muted-foreground-1 px-2 py-0.5 bg-primary/10 text-primary rounded-full">
{{ users.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">
Email
</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="user in users.data"
:key="user.id"
class="group hover:bg-muted-hover/50 transition-all duration-200"
>
<td class="px-6 py-4">
<div class="flex items-center gap-3">
<div class="w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0">
<span class="text-xs font-medium text-primary">{{ GET_INITIALS(user.name) }}</span>
</div>
<div class="text-sm font-medium text-foreground group-hover:text-primary transition-colors">
{{ user.name }}
</div>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="text-sm text-foreground">{{ user.email }}</span>
<span v-if="user.email_verified_at" class="ml-1 text-success" title="Email подтвержден"></span>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex flex-wrap gap-1">
<span
v-for="role in user.roles"
:key="role.id"
class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-primary/10 text-primary"
>
{{ role.name }}
</span>
<span v-if="!user.roles || user.roles.length === 0" class="text-xs text-muted-foreground-1"></span>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-foreground">{{ FORMAT_DATE(user.created_at, 'short') }}</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.users.edit', user.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(user, 'dashboard.users.destroy', {
message: 'Удалить пользователя «' + user.name + '»?'
})"
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="users.data.length === 0"
:columns="5"
title="Пользователи не найдены"
description="Создайте первого пользователя или измените параметры поиска"
:action-url="route('dashboard.users.create')"
action-text="Создать пользователя"
icon-path="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"
/>
</tbody>
</table>
</div>
<!-- Pagination -->
<Pagination :data="users" />
</div>
</DashboardLayout>
</template>
<script>
import DashboardLayout from '../Components/DashboardLayout.vue';
import DashboardIcon from '../Components/DashboardIcon.vue';
import Breadcrumbs from '../Components/shared/Breadcrumbs.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';
export default {
name: 'UserIndex',
components: {
DashboardLayout,
DashboardIcon,
Breadcrumbs,
FlashMessages,
DataFilters,
SearchInput,
SelectFilter,
EmptyState,
Pagination
},
props: {
users: {
type: Object,
required: true
},
filters: {
type: Object,
default: () => ({
search: '',
role_id: ''
})
},
roles: {
type: Array,
required: true
}
},
data() {
return {
searchQuery: this.filters?.search || '',
roleQuery: this.filters?.role_id || ''
}
},
mounted() {
this.SET_DOCUMENT_TITLE('Пользователи');
},
methods: {
search() {
this.INERTIA_FILTER('dashboard.users.index', {
search: this.searchQuery,
role_id: this.roleQuery
});
},
filterByRole() {
this.search();
},
resetFilters() {
this.RESET_FILTERS(
['searchQuery', 'roleQuery'],
'dashboard.users.index'
);
},
refreshPage() {
this.$inertia.get(route('dashboard.users.index'), {
search: this.searchQuery,
role_id: this.roleQuery
}, {
preserveState: true
});
}
}
}
</script>
@@ -0,0 +1,507 @@
<template>
<DashboardLayout>
<template #header-icon>
<DashboardIcon name="plus" size="5" class="text-primary" />
</template>
<template #header-title>Добавление детальной информации</template>
<template #header-subtitle>{{ user.name }}</template>
<template #header-actions>
<a
:href="route('dashboard.users.edit', user.id)"
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="flex items-center gap-4">
<label class="flex items-center gap-2">
<input
v-model="form.is_only_worker"
type="checkbox"
class="h-4 w-4 text-primary focus:ring-primary border-layer-line rounded"
/>
<span class="text-sm font-medium text-foreground">Только сотрудник</span>
</label>
</div>
<!-- Tabs -->
<div>
<!-- Tab Navigation -->
<div class="border-b border-layer-line mb-6">
<nav class="-mb-px flex space-x-8">
<button
v-for="tab in tabs"
:key="tab.key"
type="button"
@click="activeTab = tab.key"
:class="[
activeTab === tab.key
? 'border-primary text-primary'
: 'border-transparent text-muted-foreground-1 hover:text-foreground hover:border-line-2',
'whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm transition-colors'
]"
>
{{ tab.label }}
</button>
</nav>
</div>
<!-- Tab Content: Основная информация -->
<div v-show="activeTab === 'main'">
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-foreground mb-1">
Фотография
</label>
<input
ref="photoInput"
type="file"
accept="image/*"
@change="handlePhotoChange"
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"
/>
<p v-if="fileError" class="mt-1 text-sm text-danger">{{ fileError }}</p>
<p v-if="form.photo && typeof form.photo === 'string'" class="mt-2">
<img :src="RESOLVE_ASSET_URL(form.photo)" alt="Фото" class="w-24 h-24 rounded-full object-cover" />
</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">
Контактный Email
</label>
<input
v-model="form.contactEmail"
type="email"
maxlength="255"
placeholder="contact@example.com"
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.contactEmail" class="mt-1 text-sm text-danger">{{ errors.contactEmail }}</p>
</div>
<div>
<label class="block text-sm font-medium text-foreground mb-1">
Контактный телефон
</label>
<input
v-model="form.contactPhone"
type="text"
maxlength="255"
placeholder="+7 (999) 123-45-67"
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>
</div>
<!-- Tab Content: Образование -->
<div v-show="activeTab === 'education'" class="space-y-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-foreground mb-1">
Ученая степень
</label>
<input
v-model="form.academicTitle"
type="text"
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>
<label class="block text-sm font-medium text-foreground mb-1">
Ученое звание
</label>
<input
v-model="form.AcademicDegree"
type="text"
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>
<!-- Образование (repeater) -->
<div class="border border-layer-line rounded-lg p-4">
<div class="flex items-center justify-between mb-3">
<h4 class="text-sm font-medium text-foreground">Образование</h4>
<button type="button" @click="addEducation" class="text-xs text-primary hover:underline">
+ Добавить
</button>
</div>
<div v-for="(edu, index) in form.education" :key="index" class="mb-3 p-3 bg-muted/30 rounded-lg">
<div class="flex justify-between mb-2">
<span class="text-xs font-medium text-foreground">#{{ index + 1 }}</span>
<button type="button" @click="removeEducation(index)" class="text-danger text-xs hover:underline">
Удалить
</button>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-2">
<input v-model="edu.year" type="text" placeholder="Года обучения" class="px-3 py-2 border border-layer-line rounded-lg text-sm" />
<input v-model="edu.content" type="text" placeholder="Общая информация" class="px-3 py-2 border border-layer-line rounded-lg text-sm" />
<input v-model="edu.institution" type="text" placeholder="Учебное заведение" class="px-3 py-2 border border-layer-line rounded-lg text-sm" />
</div>
</div>
<p v-if="!form.education || form.education.length === 0" class="text-xs text-muted-foreground-1 text-center py-2">
Нет записей об образовании
</p>
</div>
<!-- Профессиональная переподготовка -->
<div class="border border-layer-line rounded-lg p-4">
<div class="flex items-center justify-between mb-3">
<h4 class="text-sm font-medium text-foreground">Профессиональная переподготовка</h4>
<button type="button" @click="addProfessionalRetraining" class="text-xs text-primary hover:underline">
+ Добавить
</button>
</div>
<div v-for="(item, index) in form.professionalRetraining" :key="index" class="mb-2 flex gap-2">
<input v-model="item.item" type="text" placeholder="" class="flex-1 px-3 py-2 border border-layer-line rounded-lg text-sm" />
<button type="button" @click="removeProfessionalRetraining(index)" class="text-danger text-xs hover:underline px-2">
</button>
</div>
<p v-if="!form.professionalRetraining || form.professionalRetraining.length === 0" class="text-xs text-muted-foreground-1 text-center py-2">
Нет записей
</p>
</div>
<!-- Повышение квалификации -->
<div class="border border-layer-line rounded-lg p-4">
<div class="flex items-center justify-between mb-3">
<h4 class="text-sm font-medium text-foreground">Повышение квалификации</h4>
<button type="button" @click="addProfessionalDevelopment" class="text-xs text-primary hover:underline">
+ Добавить
</button>
</div>
<div v-for="(item, index) in form.professionalDevelopment" :key="index" class="mb-2 flex gap-2">
<input v-model="item.item" type="text" placeholder="" class="flex-1 px-3 py-2 border border-layer-line rounded-lg text-sm" />
<button type="button" @click="removeProfessionalDevelopment(index)" class="text-danger text-xs hover:underline px-2">
</button>
</div>
<p v-if="!form.professionalDevelopment || form.professionalDevelopment.length === 0" class="text-xs text-muted-foreground-1 text-center py-2">
Нет записей
</p>
</div>
<!-- Награды -->
<div class="border border-layer-line rounded-lg p-4">
<div class="flex items-center justify-between mb-3">
<h4 class="text-sm font-medium text-foreground">Награды</h4>
<button type="button" @click="addAwards" class="text-xs text-primary hover:underline">
+ Добавить
</button>
</div>
<div v-for="(item, index) in form.awards" :key="index" class="mb-2 flex gap-2">
<input v-model="item.item" type="text" placeholder="" class="flex-1 px-3 py-2 border border-layer-line rounded-lg text-sm" />
<button type="button" @click="removeAwards(index)" class="text-danger text-xs hover:underline px-2">
</button>
</div>
<p v-if="!form.awards || form.awards.length === 0" class="text-xs text-muted-foreground-1 text-center py-2">
Нет записей
</p>
</div>
</div>
<!-- Tab Content: Преподавание -->
<div v-show="activeTab === 'teaching'" class="space-y-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-foreground mb-1">
Стаж работы в общем
</label>
<input
v-model.number="form.workExperience.total"
type="number"
placeholder="0"
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.number="form.workExperience.byProf"
type="number"
placeholder="0"
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 class="border border-layer-line rounded-lg p-4">
<div class="flex items-center justify-between mb-3">
<h4 class="text-sm font-medium text-foreground">Преподаваемые дисциплины</h4>
<button type="button" @click="addProfessDisciplines" class="text-xs text-primary hover:underline">
+ Добавить
</button>
</div>
<div v-for="(item, index) in form.professDisciplines" :key="index" class="mb-2 flex gap-2">
<input v-model="item.item" type="text" placeholder="" class="flex-1 px-3 py-2 border border-layer-line rounded-lg text-sm" />
<button type="button" @click="removeProfessDisciplines(index)" class="text-danger text-xs hover:underline px-2">
</button>
</div>
<p v-if="!form.professDisciplines || form.professDisciplines.length === 0" class="text-xs text-muted-foreground-1 text-center py-2">
Нет записей
</p>
</div>
</div>
<!-- Tab Content: Научная деятельность -->
<div v-show="activeTab === 'science'" class="space-y-6">
<!-- Участие в конференциях -->
<div class="border border-layer-line rounded-lg p-4">
<div class="flex items-center justify-between mb-3">
<h4 class="text-sm font-medium text-foreground">Участие в выставках, конференциях, проектах</h4>
<button type="button" @click="addAttendedConferences" class="text-xs text-primary hover:underline">
+ Добавить
</button>
</div>
<div v-for="(item, index) in form.attendedConferences" :key="index" class="mb-2 flex gap-2">
<input v-model="item.item" type="text" placeholder="" class="flex-1 px-3 py-2 border border-layer-line rounded-lg text-sm" />
<button type="button" @click="removeAttendedConferences(index)" class="text-danger text-xs hover:underline px-2">
</button>
</div>
<p v-if="!form.attendedConferences || form.attendedConferences.length === 0" class="text-xs text-muted-foreground-1 text-center py-2">
Нет записей
</p>
</div>
<!-- Публикации -->
<div class="border border-layer-line rounded-lg p-4">
<div class="flex items-center justify-between mb-3">
<h4 class="text-sm font-medium text-foreground">Публикации</h4>
<button type="button" @click="addPublication" class="text-xs text-primary hover:underline">
+ Добавить категорию
</button>
</div>
<div v-for="(pub, index) in form.publications" :key="index" class="mb-4 p-3 bg-muted/30 rounded-lg">
<div class="flex justify-between mb-2">
<span class="text-xs font-medium text-foreground">Категория #{{ index + 1 }}</span>
<button type="button" @click="removePublication(index)" class="text-danger text-xs hover:underline">
Удалить
</button>
</div>
<input v-model="pub.category_publication" type="text" placeholder="Категория публикаций" class="w-full px-3 py-2 border border-layer-line rounded-lg text-sm mb-2" />
<div v-for="(item, itemIndex) in pub.publication" :key="itemIndex" class="mb-2 flex gap-2 ml-4">
<input v-model="item.item" type="text" placeholder="Публикация" class="flex-1 px-3 py-2 border border-layer-line rounded-lg text-sm" />
<button type="button" @click="removePublicationItem(index, itemIndex)" class="text-danger text-xs hover:underline px-2">
</button>
</div>
<button type="button" @click="addPublicationItem(index)" class="text-xs text-primary hover:underline ml-4">
+ Добавить публикацию
</button>
</div>
<p v-if="!form.publications || form.publications.length === 0" class="text-xs text-muted-foreground-1 text-center py-2">
Нет публикаций
</p>
</div>
</div>
<!-- Tab Content: Другое (ContentBuilder) -->
<div v-show="activeTab === 'other'">
<ContentBuilder
v-model="form.other"
label="Другое"
/>
</div>
</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.users.edit', user.id)"
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: 'UserDetailCreate',
components: {
DashboardLayout,
DashboardIcon,
FlashMessages,
ContentBuilder,
},
props: {
user: {
type: Object,
required: true
},
errors: {
type: Object,
default: () => ({})
}
},
data() {
return {
activeTab: 'main',
tabs: [
{ key: 'main', label: 'Основная информация' },
{ key: 'education', label: 'Образование' },
{ key: 'teaching', label: 'Преподавание' },
{ key: 'science', label: 'Научная деятельность' },
{ key: 'other', label: 'Другое' },
],
form: {
is_only_worker: false,
photo: null,
contactEmail: '',
contactPhone: '',
academicTitle: '',
AcademicDegree: '',
workExperience: { total: null, byProf: null },
education: [],
professionalRetraining: [],
professionalDevelopment: [],
awards: [],
professDisciplines: [],
attendedConferences: [],
publications: [],
other: []
},
fileError: null,
processing: false
}
},
mounted() {
this.SET_DOCUMENT_TITLE('Добавление детальной информации');
},
methods: {
handlePhotoChange(event) {
const file = event.target.files[0];
this.fileError = null;
if (!file) return;
if (!file.type.startsWith('image/')) {
this.fileError = 'Выберите изображение';
event.target.value = '';
return;
}
const maxSize = 10 * 1024 * 1024;
if (file.size > maxSize) {
this.fileError = 'Размер файла не должен превышать 10MB';
event.target.value = '';
return;
}
this.form.photo = file;
},
// Education repeater
addEducation() { this.form.education.push({ year: '', content: '', institution: '' }); },
removeEducation(index) { this.form.education.splice(index, 1); },
// Professional retraining
addProfessionalRetraining() { this.form.professionalRetraining.push({ item: '' }); },
removeProfessionalRetraining(index) { this.form.professionalRetraining.splice(index, 1); },
// Professional development
addProfessionalDevelopment() { this.form.professionalDevelopment.push({ item: '' }); },
removeProfessionalDevelopment(index) { this.form.professionalDevelopment.splice(index, 1); },
// Awards
addAwards() { this.form.awards.push({ item: '' }); },
removeAwards(index) { this.form.awards.splice(index, 1); },
// Profess disciplines
addProfessDisciplines() { this.form.professDisciplines.push({ item: '' }); },
removeProfessDisciplines(index) { this.form.professDisciplines.splice(index, 1); },
// Attended conferences
addAttendedConferences() { this.form.attendedConferences.push({ item: '' }); },
removeAttendedConferences(index) { this.form.attendedConferences.splice(index, 1); },
// Publications
addPublication() { this.form.publications.push({ category_publication: '', publication: [] }); },
removePublication(index) { this.form.publications.splice(index, 1); },
addPublicationItem(pubIndex) { this.form.publications[pubIndex].publication.push({ item: '' }); },
removePublicationItem(pubIndex, itemIndex) { this.form.publications[pubIndex].publication.splice(itemIndex, 1); },
submit() {
this.processing = true;
const formData = new FormData();
formData.append('is_only_worker', this.form.is_only_worker ? 1 : 0);
formData.append('contactEmail', this.form.contactEmail);
formData.append('contactPhone', this.form.contactPhone);
formData.append('academicTitle', this.form.academicTitle);
formData.append('AcademicDegree', this.form.AcademicDegree);
formData.append('workExperience', JSON.stringify(this.form.workExperience));
formData.append('education', JSON.stringify(this.form.education));
formData.append('professionalRetraining', JSON.stringify(this.form.professionalRetraining));
formData.append('professionalDevelopment', JSON.stringify(this.form.professionalDevelopment));
formData.append('awards', JSON.stringify(this.form.awards));
formData.append('professDisciplines', JSON.stringify(this.form.professDisciplines));
formData.append('attendedConferences', JSON.stringify(this.form.attendedConferences));
formData.append('publications', JSON.stringify(this.form.publications));
formData.append('other', JSON.stringify(this.form.other));
if (this.form.photo instanceof File) {
formData.append('photo', this.form.photo);
}
this.$inertia.post(route('dashboard.users.detail.store', this.user.id), formData, {
forceFormData: true,
onFinish: () => {
this.processing = false;
}
});
}
}
}
</script>
@@ -0,0 +1,521 @@
<template>
<DashboardLayout>
<template #header-icon>
<DashboardIcon name="pencil-square" size="5" class="text-primary" />
</template>
<template #header-title>Редактирование детальной информации</template>
<template #header-subtitle>{{ user.name }}</template>
<template #header-actions>
<a
:href="route('dashboard.users.edit', user.id)"
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="flex items-center gap-4">
<label class="flex items-center gap-2">
<input
v-model="form.is_only_worker"
type="checkbox"
class="h-4 w-4 text-primary focus:ring-primary border-layer-line rounded"
/>
<span class="text-sm font-medium text-foreground">Только сотрудник</span>
</label>
</div>
<!-- Tabs -->
<div>
<!-- Tab Navigation -->
<div class="border-b border-layer-line mb-6">
<nav class="-mb-px flex space-x-8">
<button
v-for="tab in tabs"
:key="tab.key"
type="button"
@click="activeTab = tab.key"
:class="[
activeTab === tab.key
? 'border-primary text-primary'
: 'border-transparent text-muted-foreground-1 hover:text-foreground hover:border-line-2',
'whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm transition-colors'
]"
>
{{ tab.label }}
</button>
</nav>
</div>
<!-- Tab Content: Основная информация -->
<div v-show="activeTab === 'main'">
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-foreground mb-1">
Фотография
</label>
<!-- Текущее фото -->
<div v-if="form.photo && typeof form.photo === 'string'" class="mb-2">
<img :src="RESOLVE_ASSET_URL(form.photo)" alt="Фото" class="w-24 h-24 rounded-full object-cover" />
<p class="text-xs text-muted-foreground-1 mt-1">Текущее фото</p>
</div>
<input
ref="photoInput"
type="file"
accept="image/*"
@change="handlePhotoChange"
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"
/>
<p class="mt-1 text-xs text-muted-foreground-1">Оставьте пустым, чтобы сохранить текущее фото</p>
<p v-if="fileError" class="mt-1 text-sm text-danger">{{ fileError }}</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">
Контактный Email
</label>
<input
v-model="form.contactEmail"
type="email"
maxlength="255"
placeholder="contact@example.com"
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.contactEmail" class="mt-1 text-sm text-danger">{{ errors.contactEmail }}</p>
</div>
<div>
<label class="block text-sm font-medium text-foreground mb-1">
Контактный телефон
</label>
<input
v-model="form.contactPhone"
type="text"
maxlength="255"
placeholder="+7 (999) 123-45-67"
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>
</div>
<!-- Tab Content: Образование -->
<div v-show="activeTab === 'education'" class="space-y-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-foreground mb-1">
Ученая степень
</label>
<input
v-model="form.academicTitle"
type="text"
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>
<label class="block text-sm font-medium text-foreground mb-1">
Ученое звание
</label>
<input
v-model="form.AcademicDegree"
type="text"
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>
<!-- Образование (repeater) -->
<div class="border border-layer-line rounded-lg p-4">
<div class="flex items-center justify-between mb-3">
<h4 class="text-sm font-medium text-foreground">Образование</h4>
<button type="button" @click="addEducation" class="text-xs text-primary hover:underline">
+ Добавить
</button>
</div>
<div v-for="(edu, index) in form.education" :key="index" class="mb-3 p-3 bg-muted/30 rounded-lg">
<div class="flex justify-between mb-2">
<span class="text-xs font-medium text-foreground">#{{ index + 1 }}</span>
<button type="button" @click="removeEducation(index)" class="text-danger text-xs hover:underline">
Удалить
</button>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-2">
<input v-model="edu.year" type="text" placeholder="Года обучения" class="px-3 py-2 border border-layer-line rounded-lg text-sm" />
<input v-model="edu.content" type="text" placeholder="Общая информация" class="px-3 py-2 border border-layer-line rounded-lg text-sm" />
<input v-model="edu.institution" type="text" placeholder="Учебное заведение" class="px-3 py-2 border border-layer-line rounded-lg text-sm" />
</div>
</div>
<p v-if="!form.education || form.education.length === 0" class="text-xs text-muted-foreground-1 text-center py-2">
Нет записей об образовании
</p>
</div>
<!-- Профессиональная переподготовка -->
<div class="border border-layer-line rounded-lg p-4">
<div class="flex items-center justify-between mb-3">
<h4 class="text-sm font-medium text-foreground">Профессиональная переподготовка</h4>
<button type="button" @click="addProfessionalRetraining" class="text-xs text-primary hover:underline">
+ Добавить
</button>
</div>
<div v-for="(item, index) in form.professionalRetraining" :key="index" class="mb-2 flex gap-2">
<input v-model="item.item" type="text" placeholder="" class="flex-1 px-3 py-2 border border-layer-line rounded-lg text-sm" />
<button type="button" @click="removeProfessionalRetraining(index)" class="text-danger text-xs hover:underline px-2">
</button>
</div>
<p v-if="!form.professionalRetraining || form.professionalRetraining.length === 0" class="text-xs text-muted-foreground-1 text-center py-2">
Нет записей
</p>
</div>
<!-- Повышение квалификации -->
<div class="border border-layer-line rounded-lg p-4">
<div class="flex items-center justify-between mb-3">
<h4 class="text-sm font-medium text-foreground">Повышение квалификации</h4>
<button type="button" @click="addProfessionalDevelopment" class="text-xs text-primary hover:underline">
+ Добавить
</button>
</div>
<div v-for="(item, index) in form.professionalDevelopment" :key="index" class="mb-2 flex gap-2">
<input v-model="item.item" type="text" placeholder="" class="flex-1 px-3 py-2 border border-layer-line rounded-lg text-sm" />
<button type="button" @click="removeProfessionalDevelopment(index)" class="text-danger text-xs hover:underline px-2">
</button>
</div>
<p v-if="!form.professionalDevelopment || form.professionalDevelopment.length === 0" class="text-xs text-muted-foreground-1 text-center py-2">
Нет записей
</p>
</div>
<!-- Награды -->
<div class="border border-layer-line rounded-lg p-4">
<div class="flex items-center justify-between mb-3">
<h4 class="text-sm font-medium text-foreground">Награды</h4>
<button type="button" @click="addAwards" class="text-xs text-primary hover:underline">
+ Добавить
</button>
</div>
<div v-for="(item, index) in form.awards" :key="index" class="mb-2 flex gap-2">
<input v-model="item.item" type="text" placeholder="" class="flex-1 px-3 py-2 border border-layer-line rounded-lg text-sm" />
<button type="button" @click="removeAwards(index)" class="text-danger text-xs hover:underline px-2">
</button>
</div>
<p v-if="!form.awards || form.awards.length === 0" class="text-xs text-muted-foreground-1 text-center py-2">
Нет записей
</p>
</div>
</div>
<!-- Tab Content: Преподавание -->
<div v-show="activeTab === 'teaching'" class="space-y-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-foreground mb-1">
Стаж работы в общем
</label>
<input
v-model.number="form.workExperience.total"
type="number"
placeholder="0"
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.number="form.workExperience.byProf"
type="number"
placeholder="0"
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 class="border border-layer-line rounded-lg p-4">
<div class="flex items-center justify-between mb-3">
<h4 class="text-sm font-medium text-foreground">Преподаваемые дисциплины</h4>
<button type="button" @click="addProfessDisciplines" class="text-xs text-primary hover:underline">
+ Добавить
</button>
</div>
<div v-for="(item, index) in form.professDisciplines" :key="index" class="mb-2 flex gap-2">
<input v-model="item.item" type="text" placeholder="" class="flex-1 px-3 py-2 border border-layer-line rounded-lg text-sm" />
<button type="button" @click="removeProfessDisciplines(index)" class="text-danger text-xs hover:underline px-2">
</button>
</div>
<p v-if="!form.professDisciplines || form.professDisciplines.length === 0" class="text-xs text-muted-foreground-1 text-center py-2">
Нет записей
</p>
</div>
</div>
<!-- Tab Content: Научная деятельность -->
<div v-show="activeTab === 'science'" class="space-y-6">
<!-- Участие в конференциях -->
<div class="border border-layer-line rounded-lg p-4">
<div class="flex items-center justify-between mb-3">
<h4 class="text-sm font-medium text-foreground">Участие в выставках, конференциях, проектах</h4>
<button type="button" @click="addAttendedConferences" class="text-xs text-primary hover:underline">
+ Добавить
</button>
</div>
<div v-for="(item, index) in form.attendedConferences" :key="index" class="mb-2 flex gap-2">
<input v-model="item.item" type="text" placeholder="" class="flex-1 px-3 py-2 border border-layer-line rounded-lg text-sm" />
<button type="button" @click="removeAttendedConferences(index)" class="text-danger text-xs hover:underline px-2">
</button>
</div>
<p v-if="!form.attendedConferences || form.attendedConferences.length === 0" class="text-xs text-muted-foreground-1 text-center py-2">
Нет записей
</p>
</div>
<!-- Публикации -->
<div class="border border-layer-line rounded-lg p-4">
<div class="flex items-center justify-between mb-3">
<h4 class="text-sm font-medium text-foreground">Публикации</h4>
<button type="button" @click="addPublication" class="text-xs text-primary hover:underline">
+ Добавить категорию
</button>
</div>
<div v-for="(pub, index) in form.publications" :key="index" class="mb-4 p-3 bg-muted/30 rounded-lg">
<div class="flex justify-between mb-2">
<span class="text-xs font-medium text-foreground">Категория #{{ index + 1 }}</span>
<button type="button" @click="removePublication(index)" class="text-danger text-xs hover:underline">
Удалить
</button>
</div>
<input v-model="pub.category_publication" type="text" placeholder="Категория публикаций" class="w-full px-3 py-2 border border-layer-line rounded-lg text-sm mb-2" />
<div v-for="(item, itemIndex) in pub.publication" :key="itemIndex" class="mb-2 flex gap-2 ml-4">
<input v-model="item.item" type="text" placeholder="Публикация" class="flex-1 px-3 py-2 border border-layer-line rounded-lg text-sm" />
<button type="button" @click="removePublicationItem(index, itemIndex)" class="text-danger text-xs hover:underline px-2">
</button>
</div>
<button type="button" @click="addPublicationItem(index)" class="text-xs text-primary hover:underline ml-4">
+ Добавить публикацию
</button>
</div>
<p v-if="!form.publications || form.publications.length === 0" class="text-xs text-muted-foreground-1 text-center py-2">
Нет публикаций
</p>
</div>
</div>
<!-- Tab Content: Другое (ContentBuilder) -->
<div v-show="activeTab === 'other'">
<ContentBuilder
v-model="form.other"
label="Другое"
/>
</div>
</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.users.edit', user.id)"
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: 'UserDetailEdit',
components: {
DashboardLayout,
DashboardIcon,
FlashMessages,
ContentBuilder,
},
props: {
user: {
type: Object,
required: true
},
userDetail: {
type: Object,
required: true
},
errors: {
type: Object,
default: () => ({})
}
},
data() {
return {
activeTab: 'main',
tabs: [
{ key: 'main', label: 'Основная информация' },
{ key: 'education', label: 'Образование' },
{ key: 'teaching', label: 'Преподавание' },
{ key: 'science', label: 'Научная деятельность' },
{ key: 'other', label: 'Другое' },
],
form: {
is_only_worker: this.userDetail?.is_only_worker || false,
photo: this.userDetail?.photo || null,
contactEmail: this.userDetail?.contactEmail || '',
contactPhone: this.userDetail?.contactPhone || '',
academicTitle: this.userDetail?.academicTitle || '',
AcademicDegree: this.userDetail?.AcademicDegree || '',
workExperience: this.userDetail?.workExperience || { total: null, byProf: null },
education: this.userDetail?.education || [],
professionalRetraining: this.userDetail?.professionalRetraining || [],
professionalDevelopment: this.userDetail?.professionalDevelopment || [],
awards: this.userDetail?.awards || [],
professDisciplines: this.userDetail?.professDisciplines || [],
attendedConferences: this.userDetail?.attendedConferences || [],
publications: this.userDetail?.publications || [],
other: this.userDetail?.other || []
},
fileError: null,
processing: false
}
},
mounted() {
this.SET_DOCUMENT_TITLE('Редактирование детальной информации');
},
methods: {
handlePhotoChange(event) {
const file = event.target.files[0];
this.fileError = null;
if (!file) return;
if (!file.type.startsWith('image/')) {
this.fileError = 'Выберите изображение';
event.target.value = '';
return;
}
const maxSize = 10 * 1024 * 1024;
if (file.size > maxSize) {
this.fileError = 'Размер файла не должен превышать 10MB';
event.target.value = '';
return;
}
this.form.photo = file;
},
// Education repeater
addEducation() { this.form.education.push({ year: '', content: '', institution: '' }); },
removeEducation(index) { this.form.education.splice(index, 1); },
// Professional retraining
addProfessionalRetraining() { this.form.professionalRetraining.push({ item: '' }); },
removeProfessionalRetraining(index) { this.form.professionalRetraining.splice(index, 1); },
// Professional development
addProfessionalDevelopment() { this.form.professionalDevelopment.push({ item: '' }); },
removeProfessionalDevelopment(index) { this.form.professionalDevelopment.splice(index, 1); },
// Awards
addAwards() { this.form.awards.push({ item: '' }); },
removeAwards(index) { this.form.awards.splice(index, 1); },
// Profess disciplines
addProfessDisciplines() { this.form.professDisciplines.push({ item: '' }); },
removeProfessDisciplines(index) { this.form.professDisciplines.splice(index, 1); },
// Attended conferences
addAttendedConferences() { this.form.attendedConferences.push({ item: '' }); },
removeAttendedConferences(index) { this.form.attendedConferences.splice(index, 1); },
// Publications
addPublication() { this.form.publications.push({ category_publication: '', publication: [] }); },
removePublication(index) { this.form.publications.splice(index, 1); },
addPublicationItem(pubIndex) { this.form.publications[pubIndex].publication.push({ item: '' }); },
removePublicationItem(pubIndex, itemIndex) { this.form.publications[pubIndex].publication.splice(itemIndex, 1); },
submit() {
this.processing = true;
const formData = new FormData();
formData.append('is_only_worker', this.form.is_only_worker ? 1 : 0);
formData.append('contactEmail', this.form.contactEmail);
formData.append('contactPhone', this.form.contactPhone);
formData.append('academicTitle', this.form.academicTitle);
formData.append('AcademicDegree', this.form.AcademicDegree);
formData.append('workExperience', JSON.stringify(this.form.workExperience));
formData.append('education', JSON.stringify(this.form.education));
formData.append('professionalRetraining', JSON.stringify(this.form.professionalRetraining));
formData.append('professionalDevelopment', JSON.stringify(this.form.professionalDevelopment));
formData.append('awards', JSON.stringify(this.form.awards));
formData.append('professDisciplines', JSON.stringify(this.form.professDisciplines));
formData.append('attendedConferences', JSON.stringify(this.form.attendedConferences));
formData.append('publications', JSON.stringify(this.form.publications));
formData.append('other', JSON.stringify(this.form.other));
formData.append('_method', 'PUT');
if (this.form.photo instanceof File) {
formData.append('photo', this.form.photo);
}
this.$inertia.post(
route('dashboard.users.detail.update', { user: this.user.id, userDetail: this.userDetail.id }),
formData,
{
forceFormData: true,
onFinish: () => {
this.processing = false;
}
}
);
}
}
}
</script>