TEST UPD
- /api/method/frappe.client.get DoesNotExistError
This commit is contained in:
@@ -54,19 +54,92 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- VIEW MODE -->
|
||||
<div v-if="!editMode" class="mt-6">
|
||||
<div v-if="schoolProfile.loading" class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
|
||||
<div class="flex items-center justify-center py-12">
|
||||
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-primary-600"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- VIEW MODE -->
|
||||
<div v-if="!editMode" class="mt-6">
|
||||
<!-- Пустой профиль -->
|
||||
<div v-if="schoolProfileNotFound" class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="p-8 text-center">
|
||||
<div class="max-w-md mx-auto">
|
||||
<div class="mx-auto w-20 h-20 bg-teal-100 rounded-full flex items-center justify-center mb-6">
|
||||
<svg class="w-10 h-10 text-teal-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<div v-else-if="schoolProfile.error" class="bg-white rounded-2xl shadow-sm border border-red-200 p-6">
|
||||
<p class="text-red-500 text-lg font-medium">Ошибка загрузки данных школьника: {{ schoolProfile.error.message }}</p>
|
||||
</div>
|
||||
<h3 class="text-2xl font-bold text-gray-900 mb-3">Профиль школьника еще не заполнен</h3>
|
||||
|
||||
<div v-else-if="schoolProfile.data" class="space-y-6">
|
||||
<p class="text-gray-600 mb-6">
|
||||
Чтобы получить доступ ко всем возможностям платформы, заполните информацию о себе.
|
||||
Это поможет наставникам лучше понять ваши интересы и цели.
|
||||
</p>
|
||||
|
||||
<div class="bg-teal-50 border border-teal-100 rounded-lg p-5 mb-6 text-left">
|
||||
<h4 class="font-semibold text-teal-800 mb-3 flex items-center gap-2">
|
||||
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
Заполнив профиль, вы получите:
|
||||
</h4>
|
||||
<ul class="space-y-2 text-sm text-gray-700">
|
||||
<li class="flex items-start gap-2">
|
||||
<svg class="w-4 h-4 text-teal-500 mt-0.5 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<span>Персонализированные рекомендации по обучению</span>
|
||||
</li>
|
||||
<li class="flex items-start gap-2">
|
||||
<svg class="w-4 h-4 text-teal-500 mt-0.5 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<span>Подбор наставников по вашим интересам</span>
|
||||
</li>
|
||||
<li class="flex items-start gap-2">
|
||||
<svg class="w-4 h-4 text-teal-500 mt-0.5 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<span>Доступ к закрытым мероприятиям и курсам</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
@click="toggleEdit()"
|
||||
class="bg-teal-600 hover:bg-teal-700 text-white px-8 py-3 rounded-lg font-medium transition-colors duration-200 shadow-sm hover:shadow-md"
|
||||
>
|
||||
<template #prefix>
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" />
|
||||
</svg>
|
||||
</template>
|
||||
Заполнить профиль школьника
|
||||
</Button>
|
||||
|
||||
<div class="mt-4">
|
||||
<button
|
||||
@click="editMode = true"
|
||||
class="text-sm text-teal-600 hover:text-teal-800 font-medium underline transition-colors"
|
||||
>
|
||||
Или заполнить позже
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Загружающийся профиль -->
|
||||
<div v-else-if="schoolProfile.loading" class="bg-white rounded-2xl shadow-sm border border-gray-200 p-8">
|
||||
<div class="flex items-center justify-center py-12">
|
||||
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-primary-600"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ошибка загрузки (кроме DoesNotExistError) -->
|
||||
<div v-else-if="schoolProfile.error && !schoolProfileNotFound" class="bg-white rounded-2xl shadow-sm border border-red-200 p-6">
|
||||
<p class="text-red-500 text-lg font-medium">Ошибка загрузки данных школьника: {{ schoolProfile.error.message }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Загруженный профиль -->
|
||||
<div v-else-if="schoolProfile.data && !schoolProfileNotFound" class="space-y-6">
|
||||
<!-- Основная информация -->
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 bg-teal-400">
|
||||
@@ -444,6 +517,7 @@ import DOMPurify from 'dompurify'
|
||||
|
||||
const { user } = sessionStore();
|
||||
const $user = inject('$user');
|
||||
const schoolProfileNotFound = ref(false);
|
||||
|
||||
// Логирование инициализации
|
||||
console.log('[DEBUG] Инициализация компонента:', {
|
||||
@@ -511,6 +585,10 @@ const schoolProfile = createResource({
|
||||
},
|
||||
auto: false,
|
||||
transform(data) {
|
||||
if (!data) {
|
||||
schoolProfileNotFound.value = true;
|
||||
return null;
|
||||
}
|
||||
let doc = data || {};
|
||||
console.log('[DEBUG] Данные schoolProfile до трансформации:', doc);
|
||||
try {
|
||||
@@ -527,14 +605,20 @@ const schoolProfile = createResource({
|
||||
onSuccess(data) {
|
||||
console.log('[DEBUG] Профиль школьника загружен:', data);
|
||||
},
|
||||
onError(error) {
|
||||
console.error('[DEBUG] Ошибка загрузки профиля школьника:', error);
|
||||
window.frappe?.msgprint({
|
||||
title: 'Ошибка',
|
||||
message: 'Не удалось загрузить профиль школьника: ' + (error.message || 'Неизвестная ошибка'),
|
||||
indicator: 'red',
|
||||
});
|
||||
},
|
||||
onError(error) {
|
||||
// Проверяем, является ли ошибка "не найдено"
|
||||
if (error.exc_type === 'DoesNotExistError' || error.message?.includes('DoesNotExist')) {
|
||||
console.log('[DEBUG] Профиль школьника не найден, создаем новый');
|
||||
schoolProfileNotFound.value = true;
|
||||
} else {
|
||||
console.error('[DEBUG] Ошибка загрузки профиля школьника:', error);
|
||||
window.frappe?.msgprint({
|
||||
title: 'Ошибка',
|
||||
message: 'Не удалось загрузить профиль школьника: ' + (error.message || 'Неизвестная ошибка'),
|
||||
indicator: 'red',
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const form = ref({
|
||||
@@ -736,6 +820,7 @@ async function saveProfile() {
|
||||
}
|
||||
|
||||
editMode.value = false;
|
||||
schoolProfileNotFound.value = false;
|
||||
if (window.frappe && window.frappe.msgprint) window.frappe.msgprint('Профиль сохранён');
|
||||
console.log('[DEBUG] Профиль успешно сохранён');
|
||||
} catch (e) {
|
||||
@@ -825,7 +910,7 @@ watch(
|
||||
() => schoolProfile.data,
|
||||
(newData, oldData) => {
|
||||
console.log('[DEBUG] Изменение schoolProfile.data:', { old: oldData, new: newData });
|
||||
if (newData && !editMode.value) {
|
||||
if (newData && !editMode.value && !schoolProfileNotFound.value) {
|
||||
console.log('[DEBUG] Заполнение формы из schoolProfile');
|
||||
fillFormFromProfile();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user