chore [P-261]: denz
This commit is contained in:
commit
33b25f9e38
11 files changed
+334
-215
No files matched your search
@@ -67,7 +67,7 @@
|
||||
|
||||
<script>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { getEmployees, spravURL } from '@/utils/axios-api';
|
||||
import { getEmployees, getUsers, spravURL } from '@/utils/axios-api';
|
||||
import { checkremote } from '@/utils/universal_functions.js';
|
||||
|
||||
export default {
|
||||
@@ -76,6 +76,10 @@ export default {
|
||||
assignedEmployees: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
useUsersApi: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
emits: ['update:modelValue'],
|
||||
@@ -99,7 +103,8 @@ export default {
|
||||
allEmployees.value.filter(emp => !isEmployeeAssigned(emp.id))
|
||||
);
|
||||
|
||||
getEmployees().then((r) => (groupedEmployees.value = r));
|
||||
// Используем getUsers если установлен флаг useUsersApi, иначе используем getEmployees
|
||||
(props.useUsersApi ? getUsers() : getEmployees()).then((r) => (groupedEmployees.value = r));
|
||||
|
||||
const allEmployeesgroupedbydep = computed(() => {
|
||||
let groupped = [];
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
<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
|
||||
@@ -21,68 +19,44 @@
|
||||
</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"
|
||||
:useUsersApi="true"
|
||||
@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"
|
||||
@@ -95,80 +69,68 @@
|
||||
|
||||
<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>
|
||||
<v-spacer></v-spacer>
|
||||
<v-tooltip text="Снять все назначения" location="top">
|
||||
<template #activator="{ props }">
|
||||
<v-btn
|
||||
v-bind="props"
|
||||
icon="mdi-close"
|
||||
variant="text"
|
||||
density="compact"
|
||||
color="red-darken-1"
|
||||
@click="$emit('unassignAll')"
|
||||
size="big"
|
||||
>
|
||||
<v-icon icon="mdi-close" />
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-tooltip>
|
||||
</div>
|
||||
<v-list density="compact" class="bg-grey-lighten-4 rounded-lg">
|
||||
<template v-if="assignedEmployeesDetails.length > 0">
|
||||
<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-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>
|
||||
<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>
|
||||
@@ -201,126 +163,134 @@
|
||||
</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', 'unassignAll'],
|
||||
setup(props, { emit }) {
|
||||
const selectedEmployees = ref([]);
|
||||
const publishNews = ref(false);
|
||||
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 currentDate = new Date();
|
||||
const defaultStartDate = new Date(currentDate);
|
||||
defaultStartDate.setHours(9, 0, 0, 0);
|
||||
const showSnackbar = (text, color = 'error') => {
|
||||
snackbar.value = {
|
||||
show: true,
|
||||
text,
|
||||
color
|
||||
};
|
||||
};
|
||||
|
||||
const defaultEndDate = new Date(currentDate);
|
||||
defaultEndDate.setHours(18, 0, 0, 0);
|
||||
const handleEmployeeSelection = (value) => {
|
||||
selectedEmployees.value = value;
|
||||
// Сбросить переключатель "Публиковать новость", если выбрано меньше 2 сотрудников
|
||||
if (value?.length < 2) {
|
||||
publishNews.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const startDate = ref(defaultStartDate);
|
||||
const completionDate = ref(defaultEndDate);
|
||||
const handleDateChange = (date, type = 'end') => {
|
||||
if (!date) return;
|
||||
|
||||
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 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;
|
||||
};
|
||||
@@ -337,9 +307,9 @@ export default {
|
||||
handleDateChange,
|
||||
checkremote,
|
||||
spravURL: spravURLFunc(),
|
||||
snackbar,
|
||||
snackbar
|
||||
};
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -381,7 +381,7 @@ export default {
|
||||
groupedEmployees.value.find((employee) => employee.id === id) || {};
|
||||
|
||||
const handleSelectAll = (selected, index) => {
|
||||
if (!selected) {
|
||||
if (selected) {
|
||||
form.value.questions[index].answers = groupedEmployees.value.map((employee) => ({
|
||||
text: employee.id,
|
||||
image: null,
|
||||
|
||||
@@ -188,6 +188,16 @@ async function getEmployees() {
|
||||
}
|
||||
}
|
||||
|
||||
async function getUsers() {
|
||||
try {
|
||||
const response = await axiosApiInstance.get(`api/tests/getusers/`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Ошибка получения всех сотрудников:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function getVoteResult(id) {
|
||||
try {
|
||||
const response = await axiosApiInstance.get(`/api/vote/getresults/?id=${id}`);
|
||||
@@ -255,12 +265,10 @@ async function assignTest(testId, employeeIds, completionDate, startDate, news =
|
||||
startDate = testDetails.datestart;
|
||||
}
|
||||
|
||||
// Преобразуем ID сотрудников в числовой формат и отправляем весь массив за один запрос
|
||||
const userIds = Array.from(employeeIds).map(id => Number(id));
|
||||
const promises = userIds.map(userId =>
|
||||
assignTestToUser(userId, testId, completionDate, startDate, news)
|
||||
);
|
||||
|
||||
await Promise.all(promises);
|
||||
await assignTestToUser(userIds, testId, completionDate, startDate, news);
|
||||
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error('Ошибка назначения теста:', error);
|
||||
@@ -283,8 +291,9 @@ async function deleteTest(id) {
|
||||
const testingRecords = await getTestToUser(id);
|
||||
|
||||
if (testingRecords && testingRecords.length > 0) {
|
||||
const deletePromises = testingRecords.map(record => deleteTestingRecord(record.id));
|
||||
await Promise.all(deletePromises);
|
||||
// Собираем все ID назначений в массив и удаляем их за один запрос
|
||||
const recordIds = testingRecords.map(record => record.id);
|
||||
await deleteTestingRecord(recordIds);
|
||||
}
|
||||
|
||||
await axiosApiInstance.delete('/api/tests/gettests/', {
|
||||
@@ -298,17 +307,30 @@ async function deleteTest(id) {
|
||||
|
||||
async function assignTestToUser(userId, testId, completionDate, startDate, news = false) {
|
||||
try {
|
||||
|
||||
const response = await axiosApiInstance.post('/api/tests/testingview/', {
|
||||
user_id: Number(userId),
|
||||
test_id: Number(testId),
|
||||
completion_date: completionDate,
|
||||
datestart: startDate,
|
||||
news: news
|
||||
});
|
||||
return response.data;
|
||||
if (Array.isArray(userId)) {
|
||||
const response = await axiosApiInstance.post('/api/tests/testingview/', {
|
||||
'user_id': userId.map(id => Number(id)),
|
||||
test_id: Number(testId),
|
||||
completion_date: completionDate,
|
||||
datestart: startDate,
|
||||
news: news
|
||||
});
|
||||
return response.data;
|
||||
} else {
|
||||
const response = await axiosApiInstance.post('/api/tests/testingview/', {
|
||||
user_id: Number(userId),
|
||||
test_id: Number(testId),
|
||||
completion_date: completionDate,
|
||||
datestart: startDate,
|
||||
news: news
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Ошибка назначения теста пользователю:", error);
|
||||
const errorMsg = Array.isArray(userId)
|
||||
? `Ошибка при назначении теста пользователям: ${error}`
|
||||
: `Ошибка назначения теста пользователю ${userId}: ${error}`;
|
||||
console.error(errorMsg);
|
||||
console.error("Детали ошибки:", error.response?.data);
|
||||
throw error;
|
||||
}
|
||||
@@ -326,12 +348,22 @@ async function getTestToUser(testId) {
|
||||
|
||||
async function deleteTestingRecord(testingId) {
|
||||
try {
|
||||
await axiosApiInstance.put('/api/tests/testingview/', {
|
||||
id: testingId
|
||||
});
|
||||
return true;
|
||||
if (Array.isArray(testingId)) {
|
||||
await axiosApiInstance.put('/api/tests/testingview/', {
|
||||
'id': testingId
|
||||
});
|
||||
return true;
|
||||
} else {
|
||||
await axiosApiInstance.put('/api/tests/testingview/', {
|
||||
id: testingId
|
||||
});
|
||||
return true;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Ошибка удаления назначения теста с ID: ${testingId}`, error);
|
||||
const errorMsg = Array.isArray(testingId)
|
||||
? `Ошибка удаления назначений теста: ${error}`
|
||||
: `Ошибка удаления назначения теста с ID: ${testingId}: ${error}`;
|
||||
console.error(errorMsg);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -349,6 +381,7 @@ export {
|
||||
getVoteDetail,
|
||||
// updateVote,
|
||||
// patchVote,
|
||||
getUsers,
|
||||
deleteVote,
|
||||
getEmployees,
|
||||
getVoteResult,
|
||||
|
||||
@@ -161,6 +161,7 @@
|
||||
:assignedEmployeesDetails="assignedEmployeesDetails"
|
||||
@assign="handleAssign"
|
||||
@unassign="unassignEmployee"
|
||||
@unassignAll="unassignAllEmployees"
|
||||
:class="{'w-100': $vuetify.display.smAndDown}"
|
||||
/>
|
||||
|
||||
@@ -338,8 +339,9 @@ export default {
|
||||
const assignments = await getTestToUser(selectedTestId.value);
|
||||
const employeeAssignments = assignments.filter(a => a.user_details?.id === employee.id);
|
||||
|
||||
for (const assignment of employeeAssignments) {
|
||||
await deleteTestingRecord(assignment.id);
|
||||
const assignmentIds = employeeAssignments.map(assignment => assignment.id);
|
||||
if (assignmentIds.length > 0) {
|
||||
await deleteTestingRecord(assignmentIds);
|
||||
}
|
||||
|
||||
await openAddDialog(selectedTestId.value);
|
||||
@@ -348,6 +350,28 @@ export default {
|
||||
showNotification('Произошла ошибка при отмене назначения сотрудника');
|
||||
}
|
||||
};
|
||||
|
||||
const unassignAllEmployees = async () => {
|
||||
try {
|
||||
const assignments = await getTestToUser(selectedTestId.value);
|
||||
const activeAssignments = assignments.filter(a => a.is_active);
|
||||
|
||||
if (activeAssignments.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const assignmentIds = activeAssignments.map(assignment => assignment.id);
|
||||
await deleteTestingRecord(assignmentIds);
|
||||
|
||||
// Обновляем данные диалога после удаления всех назначений
|
||||
await openAddDialog(selectedTestId.value);
|
||||
|
||||
showNotification('Все назначения успешно отменены', 'green');
|
||||
} catch (error) {
|
||||
console.error('Ошибка при отмене всех назначений:', error);
|
||||
showNotification('Произошла ошибка при отмене всех назначений');
|
||||
}
|
||||
};
|
||||
|
||||
const deleteTest = async () => {
|
||||
try {
|
||||
@@ -455,6 +479,7 @@ export default {
|
||||
deleteTest,
|
||||
handleAssign,
|
||||
unassignEmployee,
|
||||
unassignAllEmployees,
|
||||
getTestById,
|
||||
startTest,
|
||||
showResults,
|
||||
|
||||
Reference in new issue
Block a user