chore [P-261]: cja
This commit is contained in:
commit
892bf1b1d7
56 files changed
+395
-67
No files matched your search
@@ -41,6 +41,7 @@
|
||||
<v-icon
|
||||
size="x-small"
|
||||
class="me-1"
|
||||
color="teal-darken-4"
|
||||
:icon="news.scores.filter(e=> e.user==accountStore.user.login && e.score == true).length>0?'mdi-thumb-up':'mdi-thumb-up-outline'"
|
||||
@click="toggleIncrementLike(news.id, true)"
|
||||
/>
|
||||
@@ -53,6 +54,7 @@
|
||||
<v-icon
|
||||
size="x-small"
|
||||
class="me-1"
|
||||
color="teal-darken-4"
|
||||
:icon="news.scores.filter(e=> e.user==accountStore.user.login && e.score == false).length>0?'mdi-thumb-down':'mdi-thumb-down-outline'"
|
||||
@click="toggleIncrementLike(news.id, false)"
|
||||
/>
|
||||
@@ -65,6 +67,7 @@
|
||||
<v-icon
|
||||
size="x-small"
|
||||
class="me-1"
|
||||
color="teal-darken-4"
|
||||
icon="mdi-message-text-outline"
|
||||
/>
|
||||
<span class="subheading">
|
||||
@@ -76,6 +79,7 @@
|
||||
<v-icon
|
||||
size="x-small"
|
||||
class="me-1 mb-1"
|
||||
color="teal-darken-4"
|
||||
icon="mdi-image"
|
||||
/>
|
||||
<span class="subheading">
|
||||
@@ -102,8 +106,7 @@
|
||||
<v-row class="flex-grow-0 ma-0">
|
||||
<v-col class="d-flex justify-space-between">
|
||||
<v-btn
|
||||
color="more_details_btn"
|
||||
|
||||
color="teal-darken-4"
|
||||
:to='`/newsfull?id=${news.id}`'
|
||||
size="small"
|
||||
rounded="xl"
|
||||
|
||||
@@ -18,6 +18,13 @@
|
||||
@click="handleSelectAll"
|
||||
></v-checkbox>
|
||||
</template>
|
||||
<template #no-data>
|
||||
<v-list-item>
|
||||
<v-list-item-title class="text-grey">
|
||||
Нет доступных данных
|
||||
</v-list-item-title>
|
||||
</v-list-item>
|
||||
</template>
|
||||
<template #selection="{ item }">
|
||||
<v-chip :prepend-avatar="checkremote(`${spravURL}${item.raw.login}.jpg`)">
|
||||
{{ item.raw.familyname }}
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
v-if="from_which == 'dialog-search'"
|
||||
class="pl-4 h-100 text-left pa-2"
|
||||
@click="open = true"
|
||||
active-color="teal-darken-4"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<v-avatar
|
||||
color="grey-darken-3"
|
||||
:color="'teal-darken-4'"
|
||||
:image="checkremote(`${spravURL}${author.login}.jpg`)"
|
||||
/>
|
||||
</template>
|
||||
@@ -23,16 +24,17 @@
|
||||
v-if="from_which == 'top-user'"
|
||||
class="h-100 text-left pa-0 pl-0"
|
||||
@click="open = true"
|
||||
active-color="teal-darken-4"
|
||||
>
|
||||
<v-chip
|
||||
class="cursor-pointer pa-0"
|
||||
variant="text"
|
||||
label
|
||||
color="grey-darken-3"
|
||||
color="teal-darken-4"
|
||||
size="small"
|
||||
>
|
||||
<v-avatar
|
||||
color="grey-darken-3"
|
||||
color="teal-darken-4"
|
||||
:image="checkremote(`${spravURL}${author.login}.jpg`)"
|
||||
class="mr-2"
|
||||
/>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
v-bind="attrs"
|
||||
v-on="on"
|
||||
size="large"
|
||||
color="indigo"
|
||||
color="teal-darken-4"
|
||||
icon="mdi-owl"
|
||||
@click="menu = !menu"
|
||||
></v-icon>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
hide-delimiters
|
||||
hide-delimiter-background
|
||||
:show-arrows="carous.length < 2 ? false : 'hover'"
|
||||
color="white"
|
||||
color="teal-darken-4"
|
||||
@update:modelValue="slidechanged"
|
||||
>
|
||||
<template v-for="(x, i) in carous" :key="i">
|
||||
@@ -187,3 +187,9 @@ export default {
|
||||
cursor: default !important;
|
||||
}
|
||||
</style>
|
||||
<style scoped>
|
||||
.titles, .text-text_carous, .text-text_caroustext-black, .v-card-title, .v-card-text, .v-textarea .v-field__input {
|
||||
color: #111 !important;
|
||||
text-shadow: none !important;
|
||||
}
|
||||
</style>
|
||||
@@ -28,7 +28,7 @@
|
||||
</v-card-title>
|
||||
<v-card-text
|
||||
@click="detailRound(x.position, x.position__name)"
|
||||
class="numstyle mt-2 py-0 font-weight-bold cursor-pointer bg-black_and_white"
|
||||
class="numstyle mt-2 py-0 font-weight-bold cursor-pointer bg-black_and_white text-teal-darken-4"
|
||||
>
|
||||
|
||||
<vue3-autocounter
|
||||
@@ -53,7 +53,7 @@
|
||||
v-if="accountStore.user.is_staff"
|
||||
v-model="changeData"
|
||||
class="pl-3 d-flex justify-end"
|
||||
color="white"
|
||||
color="teal-darken-4"
|
||||
@click="changeData=!changeData">
|
||||
</v-switch>
|
||||
</v-col>
|
||||
@@ -234,4 +234,14 @@ export default {
|
||||
.fiction .v-input__control {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped>
|
||||
.numstyle {
|
||||
font-size: 2.8rem !important;
|
||||
font-weight: 900 !important;
|
||||
color: #222 !important;
|
||||
letter-spacing: 0.05em;
|
||||
font-family: 'Montserrat', 'Arial', sans-serif;
|
||||
}
|
||||
</style>
|
||||
@@ -282,7 +282,7 @@
|
||||
variant="text"
|
||||
size="small"
|
||||
icon="mdi-delete"
|
||||
color="delete_btn"
|
||||
color="teal-darken-4"
|
||||
@click="deletComment(y.id, newsFull.id)"
|
||||
/>
|
||||
</v-col>
|
||||
@@ -353,6 +353,7 @@
|
||||
density="compact"
|
||||
variant="text"
|
||||
icon="mdi-close"
|
||||
color="teal-darken-4"
|
||||
@click="dialogfoto = false"
|
||||
/>
|
||||
</v-col>
|
||||
@@ -364,6 +365,7 @@
|
||||
density="compact"
|
||||
variant="text"
|
||||
icon="mdi-chevron-left"
|
||||
color="teal-darken-4"
|
||||
@click="
|
||||
indximg != 0
|
||||
? (indximg -= 1)
|
||||
@@ -382,6 +384,7 @@
|
||||
density="compact"
|
||||
variant="text"
|
||||
icon="mdi-chevron-right"
|
||||
color="teal-darken-4"
|
||||
@click="
|
||||
indximg != newsFull.gallery.length - 1
|
||||
? (indximg += 1)
|
||||
@@ -422,6 +425,7 @@
|
||||
density="compact"
|
||||
variant="text"
|
||||
icon="mdi-close"
|
||||
color="teal-darken-4"
|
||||
@click="dialogfotoOne = false"
|
||||
/>
|
||||
</v-col>
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
size="small"
|
||||
variant="text"
|
||||
icon="mdi-newspaper"
|
||||
color="blue-darken-4"
|
||||
color="teal-darken-4"
|
||||
:to='`/news`'
|
||||
/>
|
||||
</v-col>
|
||||
|
||||
@@ -57,12 +57,11 @@
|
||||
{{ data?.question_count }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="d-flex align-center mb-3">
|
||||
|
||||
<div class="d-flex align-center mb-3" v-if="isExamMode">
|
||||
<v-icon icon="mdi-refresh" color="teal-darken-2" class="mr-2" />
|
||||
<span class="text-body-1">
|
||||
<strong>Количество попыток:</strong>
|
||||
{{ data?.attemps_number }}
|
||||
<strong>Количество попыток:</strong> {{ remainingAttempts !== undefined ? remainingAttempts : data?.attemps_number }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -75,13 +74,23 @@
|
||||
</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
|
||||
v-if="!isExamMode || remainingAttempts === undefined || remainingAttempts > 0"
|
||||
color="btn_text"
|
||||
class="ml-auto px-9 text-white"
|
||||
@click="startTest"
|
||||
>
|
||||
{{ isExamMode ? "Начать" : "Тренироваться" }}
|
||||
</v-btn>
|
||||
<v-alert
|
||||
v-else
|
||||
type="warning"
|
||||
class="ml-auto my-2 w-100"
|
||||
border="start"
|
||||
density="compact"
|
||||
>
|
||||
Все попытки израсходованы
|
||||
</v-alert>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-col>
|
||||
@@ -100,8 +109,12 @@ export default {
|
||||
data: Object,
|
||||
isDialog: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
default: false
|
||||
},
|
||||
remainingAttempts: {
|
||||
type: Number,
|
||||
default: undefined
|
||||
}
|
||||
},
|
||||
setup(props) {
|
||||
const route = useRoute();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!-- Раздел с назначенным тестированием -->
|
||||
<template>
|
||||
<!-- <div class="my-4 text-h5 font-weight-medium">{{ title }}</div> -->
|
||||
<div :class="containerClass">
|
||||
<v-container :fluid="true">
|
||||
<v-row>
|
||||
<v-text-field
|
||||
@@ -80,6 +81,7 @@
|
||||
</v-card-title>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -103,9 +105,16 @@ export default {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
class: {
|
||||
type: [String, Object, Array],
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
setup(props) {
|
||||
const search = ref('');
|
||||
|
||||
// Create a computed property to handle the containerClass
|
||||
const containerClass = computed(() => props.class);
|
||||
|
||||
const searchTest = computed(() => {
|
||||
let filteredTests = props.testingCard;
|
||||
@@ -169,7 +178,7 @@ export default {
|
||||
return text.replace(/\r?\n/g, '<br>');
|
||||
};
|
||||
|
||||
return { search, searchTest, momenter, activeTabIcon, baseURL, formatDescription, defaultImage };
|
||||
return { search, searchTest, momenter, activeTabIcon, baseURL, formatDescription, defaultImage, containerClass };
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
/>
|
||||
|
||||
<!-- Блок информации о тесте -->
|
||||
<BodyDetailTesting v-if="!testStarted && !testFinished" :data="data" :startTest="startTest" />
|
||||
<BodyDetailTesting v-if="!testStarted && !testFinished" :data="data" :startTest="startTest" :remainingAttempts="remainingAttempts" />
|
||||
|
||||
<!-- Вопросы теста -->
|
||||
<QuestionBlock
|
||||
@@ -65,7 +65,7 @@ import HeaderDetailTesting from '@/components/testing/HeaderDetailTesting.vue';
|
||||
import BodyDetailTesting from '@/components/testing/BodyDetailTesting.vue';
|
||||
import QuestionBlock from '@/components/testing/QuestionBlock.vue';
|
||||
import TestResults from '@/components/testing/TestResults.vue';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
import { axiosApiInstance, getActiveTest } from '@/utils/axios-api';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
export default {
|
||||
@@ -82,6 +82,7 @@ export default {
|
||||
const testingId = ref(null);
|
||||
const testResults = ref(null);
|
||||
const spentTime = ref(0);
|
||||
const remainingAttempts = ref(undefined);
|
||||
|
||||
const formatSpentTime = computed(() => {
|
||||
const minutes = Math.floor(spentTime.value / 60);
|
||||
@@ -90,10 +91,23 @@ export default {
|
||||
});
|
||||
|
||||
const getTestById = async (id) => {
|
||||
// Загружаем детали теста из API testdetail
|
||||
const resp = await axiosApiInstance.get(`/api/tests/testdetail/${id}`);
|
||||
data.value = resp.data;
|
||||
|
||||
try {
|
||||
// Проверяем оставшиеся попытки из API gettests со статусом active
|
||||
const activeTest = await getActiveTest(id);
|
||||
|
||||
// Если нашли тест в активных, проверяем количество попыток
|
||||
if (activeTest) {
|
||||
remainingAttempts.value = activeTest.attemps_number;
|
||||
} else {
|
||||
// Если тест не найден в активных, устанавливаем 0 попыток
|
||||
remainingAttempts.value = 0;
|
||||
}
|
||||
|
||||
// Получаем данные о назначениях теста
|
||||
const testingResp = await axiosApiInstance.get(`/api/tests/testingview/?test_id=${id}`);
|
||||
const userTestings = testingResp.data;
|
||||
if (userTestings?.length > 0) {
|
||||
@@ -133,6 +147,13 @@ export default {
|
||||
const startTest = async () => {
|
||||
await getTestById(testId);
|
||||
|
||||
// Проверяем попытки только для режима экзамена
|
||||
const isExamMode = route.query.mode === 'exam';
|
||||
if (isExamMode && remainingAttempts.value !== undefined && remainingAttempts.value <= 0) {
|
||||
console.log('Нет оставшихся попыток для прохождения теста');
|
||||
return; // Прерываем запуск теста если попыток не осталось
|
||||
}
|
||||
|
||||
testStarted.value = true;
|
||||
testFinished.value = false;
|
||||
|
||||
@@ -206,11 +227,15 @@ export default {
|
||||
|
||||
const answers = ref([]);
|
||||
|
||||
watch(data.value?.questions, (newData) => {
|
||||
if (newData && Array.isArray(newData.questions)) {
|
||||
answers.value = newData.questions.map(() => null);
|
||||
}
|
||||
});
|
||||
watch(
|
||||
() => data.value?.questions,
|
||||
(newQuestions) => {
|
||||
if (newQuestions && Array.isArray(newQuestions)) {
|
||||
answers.value = newQuestions.map(() => null);
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
const correctAnswers = computed(
|
||||
() =>
|
||||
@@ -274,6 +299,7 @@ export default {
|
||||
answeredQuestions,
|
||||
testPassed,
|
||||
data,
|
||||
remainingAttempts,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<v-card-text>
|
||||
<v-img
|
||||
v-if="question.file"
|
||||
:src="`http://127.0.0.1:8000${question.file}`"
|
||||
:src="`${baseURL.slice(0, -1)}${question.file}`"
|
||||
class="w-50 mx-auto mb-4"
|
||||
/>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="text-center">
|
||||
<v-img
|
||||
v-if="option.file"
|
||||
:src="`http://127.0.0.1:8000${option.file}`"
|
||||
:src="`${baseURL.slice(0, -1)}${option.file}`"
|
||||
class="mb-4"
|
||||
width="400"
|
||||
min-width="300"
|
||||
@@ -56,7 +56,7 @@
|
||||
<div class="text-center">
|
||||
<v-img
|
||||
v-if="option.file"
|
||||
:src="`http://127.0.0.1:8000${option.file}`"
|
||||
:src="`${baseURL.slice(0, -1)}${option.file}`"
|
||||
class="mb-4"
|
||||
width="400"
|
||||
min-width="300"
|
||||
@@ -97,8 +97,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed, watch } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
import { computed, watch } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { baseURL } from '@/utils/axios-api';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -133,6 +134,7 @@ export default {
|
||||
return {
|
||||
isMultipleChoice,
|
||||
isPracticeMode,
|
||||
baseURL
|
||||
};
|
||||
},
|
||||
emits: ["change-question"],
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
label="Картинка"
|
||||
variant="outlined"
|
||||
:error-messages="answer.imageError"
|
||||
class="file-input-fixed"
|
||||
@update:model-value="(file) => handleImageUpload(file, answer, aIndex)"
|
||||
></v-file-input>
|
||||
|
||||
@@ -174,3 +175,11 @@ export default {
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.file-input-fixed {
|
||||
max-width: 250px;
|
||||
min-width: 200px;
|
||||
flex-grow: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -15,6 +15,7 @@
|
||||
:rules="[rules.required]"
|
||||
label="Описание"
|
||||
variant="outlined"
|
||||
class="scrollable-textarea"
|
||||
></v-textarea>
|
||||
</div>
|
||||
<div v-if="!isTest" class="pt-2 d-flex align-center">
|
||||
@@ -183,5 +184,54 @@ export default {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.scrollable-textarea :deep(.v-field__field) {
|
||||
overflow-y: auto !important;
|
||||
max-height: 300px !important;
|
||||
}
|
||||
|
||||
.scrollable-textarea :deep(textarea) {
|
||||
max-height: none !important;
|
||||
}
|
||||
|
||||
.scrollable-textarea :deep(::-webkit-scrollbar) {
|
||||
width: 14px !important;
|
||||
}
|
||||
|
||||
.scrollable-textarea :deep(::-webkit-scrollbar-track) {
|
||||
background-color: #f1f1f1 !important;
|
||||
border-radius: 8px !important;
|
||||
}
|
||||
|
||||
.scrollable-textarea :deep(::-webkit-scrollbar-thumb) {
|
||||
background-color: #004D40 !important;
|
||||
border-radius: 8px !important;
|
||||
border: 2px solid #f1f1f1 !important;
|
||||
}
|
||||
|
||||
.scrollable-textarea :deep(::-webkit-scrollbar-thumb:hover) {
|
||||
background-color: #00796B !important;
|
||||
}
|
||||
|
||||
.scrollable-textarea :deep(textarea)::-webkit-scrollbar,
|
||||
.scrollable-textarea :deep(.v-field__input)::-webkit-scrollbar {
|
||||
width: 14px !important;
|
||||
}
|
||||
|
||||
.scrollable-textarea :deep(textarea)::-webkit-scrollbar-track,
|
||||
.scrollable-textarea :deep(.v-field__input)::-webkit-scrollbar-track {
|
||||
background-color: #f1f1f1 !important;
|
||||
border-radius: 8px !important;
|
||||
}
|
||||
|
||||
.scrollable-textarea :deep(textarea)::-webkit-scrollbar-thumb,
|
||||
.scrollable-textarea :deep(.v-field__input)::-webkit-scrollbar-thumb {
|
||||
background-color: #004D40 !important;
|
||||
border-radius: 8px !important;
|
||||
border: 2px solid #f1f1f1 !important;
|
||||
}
|
||||
|
||||
.scrollable-textarea :deep(textarea)::-webkit-scrollbar-thumb:hover,
|
||||
.scrollable-textarea :deep(.v-field__input)::-webkit-scrollbar-thumb:hover {
|
||||
background-color: #00796B !important;
|
||||
}
|
||||
</style>
|
||||
@@ -45,7 +45,7 @@
|
||||
>
|
||||
<template v-slot:label>
|
||||
<div class="text-body-2 font-weight-bold">
|
||||
Голосование по отделам:
|
||||
Голосование:
|
||||
</div>
|
||||
</template>
|
||||
<v-radio
|
||||
@@ -60,6 +60,7 @@
|
||||
</v-radio-group>
|
||||
</div>
|
||||
<v-autocomplete
|
||||
v-if="question.settings.onlyDep === null"
|
||||
v-model="question.selectedEmployees"
|
||||
:items="allEmployeesgroupedbydep"
|
||||
class="text-no-wrap"
|
||||
@@ -68,6 +69,8 @@
|
||||
item-value="id"
|
||||
label="Выберите сотрудников"
|
||||
multiple
|
||||
chips
|
||||
closable-chips
|
||||
variant="outlined"
|
||||
@update:model-value="onEmployeeUpdate"
|
||||
>
|
||||
@@ -79,9 +82,11 @@
|
||||
@update:model-value="toggleSelectAll"
|
||||
></v-checkbox>
|
||||
</template>
|
||||
<template #selection="{ item }">
|
||||
<template #selection="{ item, index }">
|
||||
<v-chip
|
||||
:prepend-avatar="checkremote(`${spravURL}${item.raw.login}.jpg`)"
|
||||
closable
|
||||
@click:close="removeSelectedEmployee(item.raw.id)"
|
||||
>
|
||||
{{ item.raw.familyname }}
|
||||
</v-chip>
|
||||
@@ -116,7 +121,8 @@
|
||||
</template>
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
<transition-group name="list" tag="div">
|
||||
|
||||
<transition-group v-if="question.settings.onlyDep === null" name="list" tag="div">
|
||||
<div
|
||||
v-for="(person, pIndex) in question.answers"
|
||||
:key="person"
|
||||
@@ -125,6 +131,8 @@
|
||||
<v-col class="py-0" cols="7">
|
||||
<v-chip
|
||||
:prepend-avatar="checkremote(`${spravURL}${findEmployeeById(person.text)?.login}.jpg`)"
|
||||
closable
|
||||
@click:close="removeEmployeeAnswer(pIndex)"
|
||||
>
|
||||
{{ findEmployeeById(person.text)?.fio }}
|
||||
</v-chip>
|
||||
@@ -158,7 +166,7 @@
|
||||
import QuestionHeader from '@/components/vote/ConstructorVote/QuestionHeader.vue';
|
||||
import QuestionSettings from '@/components/vote/ConstructorVote/QuestionSettings.vue';
|
||||
import AnswerList from '@/components/vote/ConstructorVote/AnswerList.vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
export default {
|
||||
@@ -295,11 +303,55 @@ export default {
|
||||
};
|
||||
|
||||
const onEmployeeUpdate = (selected) => {
|
||||
// Filter existing answers to keep only those that are still selected
|
||||
props.question.answers = props.question.answers.filter((e) =>
|
||||
selected.includes(e.text)
|
||||
);
|
||||
|
||||
// Add new answers for newly selected employees that don't have answers yet
|
||||
const existingAnswerIds = props.question.answers.map(a => a.text);
|
||||
const newEmployeeIds = selected.filter(id => !existingAnswerIds.includes(id));
|
||||
|
||||
// Add new answers for the newly selected employees
|
||||
newEmployeeIds.forEach(employeeId => {
|
||||
props.question.answers.push({ text: employeeId, image: null });
|
||||
});
|
||||
|
||||
// Also update the saved state for potential future switching between radio options
|
||||
props.question._savedSelectedEmployees = [...selected];
|
||||
props.question._savedAnswers = [...props.question.answers];
|
||||
|
||||
emit('update:question', props.question);
|
||||
};
|
||||
|
||||
const removeSelectedEmployee = (employeeId) => {
|
||||
// Находим индекс сотрудника в массиве selectedEmployees
|
||||
const index = props.question.selectedEmployees.indexOf(employeeId);
|
||||
if (index !== -1) {
|
||||
// Удаляем сотрудника из списка выбранных
|
||||
props.question.selectedEmployees.splice(index, 1);
|
||||
// Находим соответствующий ответ и удаляем его
|
||||
const answerIndex = props.question.answers.findIndex(a => a.text === employeeId);
|
||||
if (answerIndex !== -1) {
|
||||
props.question.answers.splice(answerIndex, 1);
|
||||
}
|
||||
|
||||
// Обновляем сохраненное состояние
|
||||
if (props.question._savedSelectedEmployees) {
|
||||
const savedIndex = props.question._savedSelectedEmployees.indexOf(employeeId);
|
||||
if (savedIndex !== -1) {
|
||||
props.question._savedSelectedEmployees.splice(savedIndex, 1);
|
||||
}
|
||||
|
||||
const savedAnswerIndex = props.question._savedAnswers?.findIndex(a => a.text === employeeId);
|
||||
if (savedAnswerIndex !== -1) {
|
||||
props.question._savedAnswers.splice(savedAnswerIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
emit('update:question', props.question);
|
||||
}
|
||||
};
|
||||
|
||||
const toggleSelectAll = (value) => {
|
||||
props.handleSelectAll(value, props.index);
|
||||
@@ -307,8 +359,21 @@ export default {
|
||||
};
|
||||
|
||||
const removeEmployeeAnswer = (pIndex) => {
|
||||
props.question.selectedEmployees.splice(pIndex, 1);
|
||||
const employeeId = props.question.answers[pIndex].text;
|
||||
|
||||
props.question.selectedEmployees = props.question.selectedEmployees.filter(id => id !== employeeId);
|
||||
props.question.answers.splice(pIndex, 1);
|
||||
|
||||
// Обновляем сохраненное состояние
|
||||
if (props.question._savedSelectedEmployees) {
|
||||
props.question._savedSelectedEmployees = props.question._savedSelectedEmployees.filter(id => id !== employeeId);
|
||||
|
||||
const savedAnswerIndex = props.question._savedAnswers?.findIndex(a => a.text === employeeId);
|
||||
if (savedAnswerIndex !== -1) {
|
||||
props.question._savedAnswers.splice(savedAnswerIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
emit('update:question', props.question);
|
||||
};
|
||||
|
||||
@@ -320,6 +385,27 @@ export default {
|
||||
const isTestRoute = computed(() => {
|
||||
return route.path && String(route.path).includes('test');
|
||||
});
|
||||
|
||||
// Добавляем наблюдение за изменением выбора типа голосования
|
||||
watch(() => props.question.settings.onlyDep, (newValue, oldValue) => {
|
||||
// Если выбрано любое значение кроме null, автоматически выбрать всех сотрудников
|
||||
if (newValue !== null) {
|
||||
// Сохраняем выбранных сотрудников перед выбором "все"
|
||||
if (oldValue === null) {
|
||||
// Сохраняем текущий выбор сотрудников для возможного возврата к "произвольным сотрудникам"
|
||||
props.question._savedSelectedEmployees = [...props.question.selectedEmployees];
|
||||
props.question._savedAnswers = [...props.question.answers];
|
||||
}
|
||||
toggleSelectAll(true);
|
||||
}
|
||||
// Если переключаемся на "За произвольного сотрудника" (null) и у нас есть сохраненный выбор
|
||||
else if (newValue === null && oldValue !== null && props.question._savedSelectedEmployees) {
|
||||
// Восстанавливаем ранее сохраненный выбор сотрудников
|
||||
props.question.selectedEmployees = [...props.question._savedSelectedEmployees];
|
||||
props.question.answers = [...props.question._savedAnswers];
|
||||
emit('update:question', props.question);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
resetAnswers,
|
||||
@@ -328,6 +414,7 @@ export default {
|
||||
onEmployeeUpdate,
|
||||
toggleSelectAll,
|
||||
removeEmployeeAnswer,
|
||||
removeSelectedEmployee,
|
||||
onEmployeesChange,
|
||||
isTestRoute,
|
||||
questionImagePreview,
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
{{ answer.employee?.fio || answer.name }}
|
||||
|
||||
<template v-slot:prepend="{ isSelected }">
|
||||
<v-list-item-action start>
|
||||
<v-list-item-action start @click.stop="toggleAnswer(question.id, answer.id)">
|
||||
<v-checkbox-btn :model-value="isSelected"></v-checkbox-btn>
|
||||
</v-list-item-action>
|
||||
</template>
|
||||
@@ -197,6 +197,20 @@ export default {
|
||||
}
|
||||
};
|
||||
|
||||
const toggleAnswer = (questionId, answerId) => {
|
||||
const currentAnswers = result.value[questionId];
|
||||
const index = currentAnswers.indexOf(answerId);
|
||||
|
||||
if (index === -1) {
|
||||
const question = props.data.questions.find(q => q.id === questionId);
|
||||
if (currentAnswers.length < question.settings.multiChoice) {
|
||||
currentAnswers.push(answerId);
|
||||
}
|
||||
} else {
|
||||
currentAnswers.splice(index, 1);
|
||||
}
|
||||
};
|
||||
|
||||
const submitVote = () => {
|
||||
let voteData = []
|
||||
for (let val of Object.values(result.value)) {
|
||||
@@ -220,10 +234,10 @@ export default {
|
||||
activepick.value = val
|
||||
}
|
||||
|
||||
const groupedAnswers = (question) => {
|
||||
const groupedAnswers = (question) => {
|
||||
const filtered = question.answers.filter(answer => answer.employee?.id !== accountStore.user.is_idEmployee);
|
||||
|
||||
if (question.settings.onlyDep === null) {
|
||||
if (question.settings.onlyDep === null || question.settings.onlyDep === 'any') {
|
||||
return groupByDepartment(filtered);
|
||||
} else if (question.settings.onlyDep) {
|
||||
const byDepartment = filtered.filter(
|
||||
@@ -263,6 +277,7 @@ export default {
|
||||
isCurrentQuestionAnswered,
|
||||
nextStep,
|
||||
prevStep,
|
||||
toggleAnswer,
|
||||
submitVote,
|
||||
isVoteSubmitted,
|
||||
result
|
||||
|
||||
@@ -263,12 +263,17 @@
|
||||
Голосование по отделам:
|
||||
{{ onlyDepdict.find((e) => e.value === question.settings.onlyDep).name }}
|
||||
</div>
|
||||
<p><strong>Выбранные сотрудники:</strong></p>
|
||||
<ul>
|
||||
<li v-for="employeeId in question.answers" :key="employeeId">
|
||||
{{ findEmployeeById(employeeId.text).fio }}
|
||||
</li>
|
||||
</ul>
|
||||
<div v-if="question.settings.onlyDep !== null">
|
||||
<p><strong>Выбрано {{ question.answers.length }} сотрудников</strong></p>
|
||||
</div>
|
||||
<div v-else>
|
||||
<p><strong>Выбранные сотрудники:</strong></p>
|
||||
<ul>
|
||||
<li v-for="employeeId in question.answers" :key="employeeId">
|
||||
{{ findEmployeeById(employeeId.text).fio }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</v-card>
|
||||
@@ -588,9 +593,9 @@ export default {
|
||||
};
|
||||
|
||||
watch(
|
||||
form.value,
|
||||
() => {
|
||||
if (!form.value.title || !form.value.description || form.value.questions.length < 1) {
|
||||
() => form.value,
|
||||
(formValue) => {
|
||||
if (!formValue.title || !formValue.description || formValue.questions.length < 1) {
|
||||
errorMessage.value = 'Все обязательные поля должны быть заполнены';
|
||||
} else {
|
||||
errorMessage.value = '';
|
||||
@@ -602,7 +607,6 @@ export default {
|
||||
watch(
|
||||
() => form.value.questions,
|
||||
(newQuestions) => {
|
||||
quests.value = newQuestions.map((q) => !!q.text.trim());
|
||||
|
||||
const hasEmptyQuestions = newQuestions.some((q) => !q.text || q.text.trim() === '');
|
||||
const hasInvalidAnswers = validateAnswers();
|
||||
@@ -628,12 +632,13 @@ export default {
|
||||
};
|
||||
|
||||
const onlyDepdict = [
|
||||
{ name: 'За любого сотрудника', value: null },
|
||||
{ name: 'За любого сотрудника', value: 'any' },
|
||||
{
|
||||
name: 'Кроме своего отдела',
|
||||
name: 'Только за сотрудника из другого отдела',
|
||||
value: false,
|
||||
},
|
||||
{ name: 'Только за свой отдел', value: true },
|
||||
{ name: 'Только за сотрудника из своего отдела', value: true },
|
||||
{ name: 'За произвольного сотрудника (есть возможность добавить картинку)', value: null },
|
||||
];
|
||||
|
||||
const quests = computed(() => form.value.questions.map((question) => question.text.length > 0));
|
||||
@@ -686,11 +691,13 @@ export default {
|
||||
testImage,
|
||||
imagePreview,
|
||||
previewImage,
|
||||
handleTestImageUpload,
|
||||
getImagePreviewUrl,
|
||||
actualQuestionCount,
|
||||
actualTestQuestionCount,
|
||||
isTest: props.isTest,
|
||||
imageError
|
||||
imageError,
|
||||
validateImage
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</v-tabs>
|
||||
<v-tabs-window v-model="activeTab">
|
||||
<v-tabs-window-item v-for="(question, questionIndex) in questions" :key="questionIndex">
|
||||
<v-row v-if="question.settings.onlyDep">
|
||||
<v-row v-if="question.settings.onlyDep === true">
|
||||
<v-col
|
||||
v-for="(winner, department) in getWinnersByDepartment(question).winnersByDepartment"
|
||||
:key="department"
|
||||
|
||||
@@ -368,6 +368,18 @@ async function deleteTestingRecord(testingId) {
|
||||
}
|
||||
}
|
||||
|
||||
async function getActiveTest(id) {
|
||||
try {
|
||||
const response = await axiosApiInstance.get(`/api/tests/gettests/?status=active`);
|
||||
const activeTests = response.data;
|
||||
const activeTest = activeTests.find(test => test.id === Number(id));
|
||||
return activeTest || null;
|
||||
} catch (error) {
|
||||
console.error("Ошибка получения активного теста:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export {
|
||||
axiosApiInstance,
|
||||
@@ -392,4 +404,5 @@ export {
|
||||
assignTestToUser,
|
||||
getTestToUser,
|
||||
deleteTestingRecord,
|
||||
getActiveTest,
|
||||
}
|
||||
@@ -44,10 +44,10 @@
|
||||
<v-sheet class="mx-auto" :class="favorit.length > 10 ? 'mx-n3' : ''" max-width="800">
|
||||
<v-slide-group show-arrows>
|
||||
<v-slide-group-item v-for="x in favorit" :key="x">
|
||||
<v-btn-toggle v-model="toggle" divided variant="outlined">
|
||||
<v-btn-toggle v-model="toggle" divided variant="outlined" color="teal-darken-4">
|
||||
<v-tooltip :text="x.pages__page" location="top">
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-btn v-bind="props" :icon="x.pages__ico" :to="x.pages__fullPath" />
|
||||
<v-btn v-bind="props" :icon="x.pages__ico" :to="x.pages__fullPath" color="teal-darken-4" />
|
||||
</template>
|
||||
</v-tooltip>
|
||||
</v-btn-toggle>
|
||||
@@ -146,12 +146,22 @@ export default {
|
||||
}
|
||||
|
||||
.bgCard {
|
||||
/* #ffffff6b #ffffff8c*/
|
||||
background: #ffffff38;
|
||||
background: #fff !important;
|
||||
}
|
||||
|
||||
.bgText {
|
||||
background: #ffffffb0;
|
||||
background: #f5f5f5 !important;
|
||||
color: #222 !important;
|
||||
line-height: 2.1rem !important;
|
||||
}
|
||||
|
||||
.card-unified {
|
||||
border-radius: 18px;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.text-unified {
|
||||
color: #222 !important;
|
||||
font-family: 'Montserrat', 'Arial', sans-serif;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user