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