chore [P-261]: дев

This commit is contained in:
Nukeap committed 2025-06-03 12:25:21 +03:00
commit 4c7102a391
4 files changed
+287 -173

No files matched your search

@@ -1,13 +1,15 @@
<template>
<div>
<v-dialog
<v-dialog
:model-value="modelValue"
@update:model-value="$emit('update:modelValue', $event)"
max-width="800"
max-width="800"
persistent
>
<v-card class="rounded-lg" color="cards">
<v-card-title class="text-h5 font-weight-medium px-4 py-3 bg-teal-darken-4 text-white d-flex align-center">
<v-card-title
class="text-h5 font-weight-medium px-4 py-3 bg-teal-darken-4 text-white d-flex align-center"
>
<span>Назначение теста</span>
<v-spacer></v-spacer>
<v-btn
@@ -19,43 +21,68 @@
</v-card-title>
<v-divider></v-divider>
<v-card-text class="px-4 py-4">
<div class="text-subtitle-1 font-weight-medium mb-3 text-teal-darken-1">Выберите сотрудников</div>
<SearcEmployess
<div
class="text-subtitle-1 font-weight-medium mb-3 text-teal-darken-1"
>
Выберите сотрудников
</div>
<SearcEmployess
:modelValue="selectedEmployees"
:assignedEmployees="assignedEmployees"
@update:modelValue="handleEmployeeSelection"
class="mb-6"
/>
<v-divider class="mb-4"></v-divider>
<div class="d-flex gap-4 mb-6">
<div class="flex-grow-1">
<div class="d-flex align-center mb-2">
<v-icon icon="mdi-calendar-clock-outline" color="teal-darken-2" class="mr-2"></v-icon>
<span class="text-subtitle-1 font-weight-medium text-teal-darken-1">Дата начала теста</span>
<v-icon
icon="mdi-calendar-clock-outline"
color="teal-darken-2"
class="mr-2"
></v-icon>
<span
class="text-subtitle-1 font-weight-medium text-teal-darken-1"
>Дата начала теста</span
>
</div>
<date-select
:datedefault="startDate"
<date-select
:datedefault="startDate"
@returndate="(date) => handleDateChange(date, 'start')"
/>
</div>
<div class="flex-grow-1">
<div class="d-flex align-center mb-2">
<v-icon icon="mdi-calendar-clock" color="teal-darken-2" class="mr-2"></v-icon>
<span class="text-subtitle-1 font-weight-medium text-teal-darken-1">Дата окончания теста</span>
<v-icon
icon="mdi-calendar-clock"
color="teal-darken-2"
class="mr-2"
></v-icon>
<span
class="text-subtitle-1 font-weight-medium text-teal-darken-1"
>Дата окончания теста</span
>
</div>
<date-select
:datedefault="completionDate"
<date-select
:datedefault="completionDate"
@returndate="(date) => handleDateChange(date, 'end')"
/>
</div>
<div class="d-flex flex-column justify-center ml-4">
<div class="d-flex align-center">
<v-icon icon="mdi-newspaper" color="teal-darken-2" class="mr-2"></v-icon>
<span class="text-subtitle-1 font-weight-medium text-teal-darken-1 mr-4">Публиковать новость</span>
<v-icon
icon="mdi-newspaper"
color="teal-darken-2"
class="mr-2"
></v-icon>
<span
class="text-subtitle-1 font-weight-medium text-teal-darken-1 mr-4"
>Публиковать новость</span
>
<v-switch
v-model="publishNews"
color="teal-darken-2"
@@ -68,8 +95,14 @@
<div v-if="assignedEmployees?.length > 0" class="mb-4">
<div class="d-flex align-center mb-2">
<v-icon icon="mdi-account-multiple" color="orange-darken-2" class="mr-2"></v-icon>
<span class="text-subtitle-1 font-weight-medium text-orange-darken-2">
<v-icon
icon="mdi-account-multiple"
color="orange-darken-2"
class="mr-2"
></v-icon>
<span
class="text-subtitle-1 font-weight-medium text-orange-darken-2"
>
Уже назначено сотрудников: {{ assignedEmployees.length }}
</span>
</div>
@@ -78,35 +111,64 @@
<v-list-item
v-for="employee in assignedEmployeesDetails"
:key="employee.id"
:prepend-avatar="checkremote(`${spravURL}${employee.login}.jpg`)"
:prepend-avatar="
checkremote(`${spravURL}${employee.login}.jpg`)
"
class="py-1"
>
<template #title>
<div class="d-flex align-center">
<div>
<span class="text-orange-darken-2">{{ employee.fio }}</span>
<div class="text-caption text-grey-darken-1" v-if="employee.datestart">
Дата начала: {{ new Date(employee.datestart).toLocaleDateString('ru-RU') }}
<span class="text-orange-darken-2">{{
employee.fio
}}</span>
<div
class="text-caption text-grey-darken-1"
v-if="employee.datestart"
>
Дата начала:
{{
new Date(employee.datestart).toLocaleDateString(
"ru-RU",
)
}}
</div>
<div class="text-caption text-grey-darken-1" v-if="employee.completion_date">
Дата окончания: {{ new Date(employee.completion_date).toLocaleDateString('ru-RU') }}
<div
class="text-caption text-grey-darken-1"
v-if="employee.completion_date"
>
Дата окончания:
{{
new Date(
employee.completion_date,
).toLocaleDateString("ru-RU")
}}
</div>
</div>
<v-btn
icon="mdi-close"
variant="text"
density="compact"
color="red-darken-1"
class="ml-auto"
@click="$emit('unassign', employee)"
/>
<v-tooltip text="Снять назначение" location="top">
<template #activator="{ props }">
<v-btn
v-bind="props"
icon="mdi-close"
variant="text"
density="compact"
color="red-darken-1"
class="ml-auto"
@click="$emit('unassign', employee)"
>
<v-icon icon="mdi-close" />
</v-btn>
</template>
</v-tooltip>
</div>
</template>
</v-list-item>
</template>
<v-list-item v-else>
<template #title>
<span class="text-grey-darken-1">Загрузка списка сотрудников...</span>
<span class="text-grey-darken-1"
>Загрузка списка сотрудников...</span
>
</template>
</v-list-item>
</v-list>
@@ -139,130 +201,126 @@
</v-card>
</v-dialog>
<v-snackbar
v-model="snackbar.show"
:color="snackbar.color"
:timeout="3000"
>
<v-snackbar v-model="snackbar.show" :color="snackbar.color" :timeout="3000">
{{ snackbar.text }}
</v-snackbar>
</div>
</template>
<script>
import { ref } from 'vue';
import SearcEmployess from '@/components/UI/SearcEmployess.vue';
import DateSelect from '@/components/UI/date-select.vue';
import { spravURL } from '@/utils/axios-api';
import { checkremote } from '@/utils/universal_functions.js';
import { ref } from "vue";
import SearcEmployess from "@/components/UI/SearcEmployess.vue";
import DateSelect from "@/components/UI/date-select.vue";
import { spravURL } from "@/utils/axios-api";
import { checkremote } from "@/utils/universal_functions.js";
export default {
name: 'AssignTestDialog',
name: "AssignTestDialog",
components: {
SearcEmployess,
DateSelect
DateSelect,
},
props: {
modelValue: {
type: Boolean,
required: true
required: true,
},
assignedEmployees: {
type: Array,
default: () => []
default: () => [],
},
assignedEmployeesDetails: {
type: Array,
default: () => []
}
default: () => [],
},
},
emits: ['update:modelValue', 'assign', 'unassign'],
emits: ["update:modelValue", "assign", "unassign"],
setup(props, { emit }) {
const selectedEmployees = ref([]);
const publishNews = ref(false);
// Устанавливаем начальные даты
const currentDate = new Date();
const defaultStartDate = new Date(currentDate);
defaultStartDate.setHours(9, 0, 0, 0);
const defaultEndDate = new Date(currentDate);
defaultEndDate.setHours(18, 0, 0, 0);
const startDate = ref(defaultStartDate);
const completionDate = ref(defaultEndDate);
const snackbar = ref({
show: false,
text: '',
color: 'error'
});
const selectedEmployees = ref([]);
const publishNews = ref(false);
const showSnackbar = (text, color = 'error') => {
snackbar.value = {
show: true,
text,
color
};
};
// Устанавливаем начальные даты
const currentDate = new Date();
const defaultStartDate = new Date(currentDate);
defaultStartDate.setHours(9, 0, 0, 0);
const handleEmployeeSelection = (value) => {
selectedEmployees.value = value;
};
const defaultEndDate = new Date(currentDate);
defaultEndDate.setHours(18, 0, 0, 0);
const handleDateChange = (date, type = 'end') => {
if (!date) return;
const startDate = ref(defaultStartDate);
const completionDate = ref(defaultEndDate);
const newDate = new Date(date);
if (type === 'end') {
newDate.setHours(18, 0, 0, 0);
completionDate.value = newDate;
if (startDate.value && newDate < startDate.value) {
startDate.value = newDate;
startDate.value.setHours(9, 0, 0, 0);
}
} else {
newDate.setHours(9, 0, 0, 0);
startDate.value = newDate;
if (completionDate.value && newDate > completionDate.value) {
completionDate.value = newDate;
completionDate.value.setHours(18, 0, 0, 0);
}
}
};
const snackbar = ref({
show: false,
text: "",
color: "error",
});
const showSnackbar = (text, color = "error") => {
snackbar.value = {
show: true,
text,
color,
};
};
const handleEmployeeSelection = (value) => {
selectedEmployees.value = value;
};
const handleDateChange = (date, type = "end") => {
if (!date) return;
const newDate = new Date(date);
if (type === "end") {
newDate.setHours(18, 0, 0, 0);
completionDate.value = newDate;
if (startDate.value && newDate < startDate.value) {
startDate.value = newDate;
startDate.value.setHours(9, 0, 0, 0);
}
} else {
newDate.setHours(9, 0, 0, 0);
startDate.value = newDate;
if (completionDate.value && newDate > completionDate.value) {
completionDate.value = newDate;
completionDate.value.setHours(18, 0, 0, 0);
}
}
};
const handleAssign = () => {
if (!selectedEmployees.value.length) {
showSnackbar('Выберите хотя бы одного сотрудника');
showSnackbar("Выберите хотя бы одного сотрудника");
return;
}
if (!completionDate.value || !startDate.value) {
showSnackbar('Укажите дату начала и окончания теста');
showSnackbar("Укажите дату начала и окончания теста");
return;
}
const today = new Date();
today.setHours(0, 0, 0, 0);
if (completionDate.value < today || startDate.value < today) {
showSnackbar('Нельзя назначить прошедшую дату');
showSnackbar("Нельзя назначить прошедшую дату");
return;
}
if (startDate.value > completionDate.value) {
showSnackbar('Дата начала не может быть позже даты окончания');
showSnackbar("Дата начала не может быть позже даты окончания");
return;
}
emit('assign', {
emit("assign", {
selectedEmployees: selectedEmployees.value,
completionDate: completionDate.value,
startDate: startDate.value,
news: publishNews.value
news: publishNews.value,
});
selectedEmployees.value = [];
publishNews.value = false;
};
@@ -279,9 +337,9 @@ export default {
handleDateChange,
checkremote,
spravURL: spravURLFunc(),
snackbar
snackbar,
};
}
},
};
</script>
@@ -1,37 +1,71 @@
<template>
<v-container :class="{ 'pa-4': !isDialog, 'pa-0': isDialog }">
<v-row class="justify-center" :class="{ 'mt-6': !isDialog, 'ma-0': isDialog }">
<v-col :cols="isDialog ? 12 : '12'" :md="isDialog ? 12 : '8'" :lg="isDialog ? 12 : '6'" class="pa-0">
<v-row
class="justify-center"
:class="{ 'mt-6': !isDialog, 'ma-0': isDialog }"
>
<v-col
:cols="isDialog ? 12 : '12'"
:md="isDialog ? 12 : '8'"
:lg="isDialog ? 12 : '6'"
class="pa-0"
>
<v-card :elevation="isDialog ? 0 : 2" class="rounded-lg" color="cards">
<v-card-title v-if="!isDialog" class="text-h6 font-weight-bold">Информация</v-card-title>
<v-card-text :class="[
'd-flex flex-column ga-6',
{ 'border-b-thin': !isDialog, 'pa-0': isDialog }
]">
<v-card-title v-if="!isDialog" class="text-h6 font-weight-bold"
>Информация</v-card-title
>
<v-card-text
:class="[
'd-flex flex-column ga-6',
{ 'border-b-thin': !isDialog, 'pa-0': isDialog },
]"
>
<div class="test-info">
<div class="text-body-1 mb-4" v-html="formatDescription(data?.description)"></div>
<div class="d-flex justify-center mb-4">
<v-img
:src="data?.file || defaultImage"
class="rounded-lg"
max-height="200"
contain
/>
</div>
<div
class="text-body-1 mb-4"
v-html="formatDescription(data?.description)"
></div>
<div class="d-flex align-center mb-3">
<v-icon icon="mdi-clock-outline" color="teal-darken-2" class="mr-2" />
<v-icon
icon="mdi-clock-outline"
color="teal-darken-2"
class="mr-2"
/>
<span class="text-body-1">
<strong>Время на прохождение:</strong> {{ formatTime.value }} {{ formatTime.unit }}
<strong>Время на прохождение:</strong> {{ formatTime.value }}
{{ formatTime.unit }}
</span>
</div>
<div class="d-flex align-center mb-3">
<v-icon icon="mdi-format-list-numbered" color="teal-darken-2" class="mr-2" />
<v-icon
icon="mdi-format-list-numbered"
color="teal-darken-2"
class="mr-2"
/>
<span class="text-body-1">
<strong>Количество вопросов:</strong> {{ data?.question_count }}
<strong>Количество вопросов:</strong>
{{ data?.question_count }}
</span>
</div>
<div class="d-flex align-center mb-3">
<v-icon icon="mdi-refresh" color="teal-darken-2" class="mr-2" />
<span class="text-body-1">
<strong>Количество попыток:</strong> {{ data?.attemps_number }}
<strong>Количество попыток:</strong>
{{ data?.attemps_number }}
</span>
</div>
<div class="d-flex align-center">
<v-icon icon="mdi-percent" color="teal-darken-2" class="mr-2" />
<span class="text-body-1">
@@ -41,12 +75,12 @@
</div>
</v-card-text>
<v-card-actions v-if="!isDialog" class="mx-2 my-4">
<v-btn
color="btn_text"
class="ml-auto px-9 text-white"
<v-btn
color="btn_text"
class="ml-auto px-9 text-white"
@click="startTest"
>
{{ isExamMode ? 'Начать' : 'Тренироваться' }}
{{ isExamMode ? "Начать" : "Тренироваться" }}
</v-btn>
</v-card-actions>
</v-card>
@@ -56,8 +90,9 @@
</template>
<script>
import { useRoute } from 'vue-router';
import { computed } from 'vue';
import { useRoute } from "vue-router";
import { computed } from "vue";
import defaultImage from "@/assets/emblem.png";
export default {
props: {
@@ -65,16 +100,16 @@ export default {
data: Object,
isDialog: {
type: Boolean,
default: false
}
default: false,
},
},
setup(props) {
const route = useRoute();
const isExamMode = computed(() => route.query.mode === 'exam');
const isExamMode = computed(() => route.query.mode === "exam");
const formatTime = computed(() => {
if (!props.data?.time) return { value: 0, unit: 'минут' };
if (!props.data?.time) return { value: 0, unit: "минут" };
const time = Number(props.data.time);
// Если число больше 60, значит это секунды (таймер запущен)
@@ -83,41 +118,43 @@ export default {
const seconds = time % 60;
return {
value: `${minutes} мин. ${seconds}`,
unit: 'сек.'
unit: "сек.",
};
} else {
// Если меньше 60, значит это минуты (таймер не запущен)
return {
value: time,
unit: time === 1 ? 'минута' : time >= 2 && time <= 4 ? 'минуты' : 'минут'
unit:
time === 1 ? "минута" : time >= 2 && time <= 4 ? "минуты" : "минут",
};
}
});
const timeWordDeclension = computed(() => {
if (!props.data?.time) return 'минут';
if (!props.data?.time) return "минут";
const lastDigit = props.data.time % 10;
const lastTwoDigits = props.data.time % 100;
if (lastTwoDigits >= 11 && lastTwoDigits <= 14) return 'минут';
if (lastDigit === 1) return 'минута';
if (lastDigit >= 2 && lastDigit <= 4) return 'минуты';
return 'минут';
if (lastTwoDigits >= 11 && lastTwoDigits <= 14) return "минут";
if (lastDigit === 1) return "минута";
if (lastDigit >= 2 && lastDigit <= 4) return "минуты";
return "минут";
});
const formatDescription = (text) => {
if (!text) return '';
return text.replace(/\r?\n/g, '<br>');
if (!text) return "";
return text.replace(/\r?\n/g, "<br>");
};
return {
isExamMode,
timeWordDeclension,
formatDescription,
formatTime
formatTime,
defaultImage,
};
}
},
};
</script>
@@ -7,18 +7,21 @@
Вопрос {{ currentQuestion + 1 }} из {{ totalQuestions }}
</v-card-title>
<h3 class="mb-2 px-4">{{ question.name }}</h3>
<v-card-text style="overflow-y: scroll">
<v-card-text>
<v-img
v-if="question.file"
:src="`http://127.0.0.1:8000${question.file}`"
class="w-50 mx-auto"
class="w-50 mx-auto mb-4"
/>
<!-- Одиночный выбор -->
<v-radio-group v-if="!isMultipleChoice" v-model="answers[currentQuestion]">
<v-radio
v-for="(option, index) in question.answers"
:key="index"
<v-radio-group
v-if="!isMultipleChoice"
v-model="answers[currentQuestion]"
>
<v-radio
v-for="(option, index) in question.answers"
:key="index"
:value="option.name"
>
<template v-slot:label>
@@ -39,7 +42,9 @@
<!-- Множественный выбор -->
<div v-else>
<p class="text-subtitle-1 text-grey-darken-1 mb-4">Возможно несколько верных ответов</p>
<p class="text-subtitle-1 text-grey-darken-1 mb-4">
Возможно несколько верных ответов
</p>
<v-checkbox
v-for="(option, index) in question.answers"
:key="index"
@@ -92,8 +97,8 @@
</template>
<script>
import { computed, watch } from 'vue';
import { useRoute } from 'vue-router';
import { computed, watch } from "vue";
import { useRoute } from "vue-router";
export default {
props: {
@@ -105,10 +110,14 @@ export default {
},
setup(props) {
const route = useRoute();
const isPracticeMode = computed(() => !route.query.mode || route.query.mode === 'practice');
const isPracticeMode = computed(
() => !route.query.mode || route.query.mode === "practice",
);
const isMultipleChoice = computed(() => {
return props.question.answers.filter(answer => answer.right_wrong).length > 1;
return (
props.question.answers.filter((answer) => answer.right_wrong).length > 1
);
});
watch(
@@ -123,10 +132,10 @@ export default {
return {
isMultipleChoice,
isPracticeMode
isPracticeMode,
};
},
emits: ['change-question'],
emits: ["change-question"],
};
</script>
@@ -145,14 +154,19 @@ export default {
padding: 16px !important;
}
.v-radio-group :deep(.v-radio),
.v-card-text {
max-height: 550px;
overflow-y: auto;
}
.v-radio-group :deep(.v-radio),
.v-checkbox {
margin-bottom: 12px;
transition: transform 0.2s;
color: rgb(var(--v-theme-text_carous));
}
.v-radio-group :deep(.v-radio:hover),
.v-radio-group :deep(.v-radio:hover),
.v-checkbox:hover {
transform: translateX(4px);
}
@@ -186,4 +200,9 @@ export default {
margin: 0 auto;
display: block;
}
.v-img {
max-width: 100% !important;
height: auto !important;
}
</style>