feat [P-01]: флаг для новостей в назначениях
This commit is contained in:
1 parent
b3e2bac70d
commit
adb2ab9648
3 files changed
+44
-24
No files matched your search
@@ -29,26 +29,41 @@
|
||||
|
||||
<v-divider class="mb-4"></v-divider>
|
||||
|
||||
<div class="mb-4">
|
||||
<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>
|
||||
<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>
|
||||
</div>
|
||||
<date-select
|
||||
:datedefault="startDate"
|
||||
@returndate="(date) => handleDateChange(date, 'start')"
|
||||
/>
|
||||
</div>
|
||||
<date-select
|
||||
:datedefault="startDate"
|
||||
@returndate="(date) => handleDateChange(date, 'start')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="mb-6">
|
||||
<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>
|
||||
<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>
|
||||
</div>
|
||||
<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-switch
|
||||
v-model="publishNews"
|
||||
color="teal-darken-2"
|
||||
hide-details
|
||||
inset
|
||||
></v-switch>
|
||||
</div>
|
||||
</div>
|
||||
<date-select
|
||||
:datedefault="completionDate"
|
||||
@returndate="(date) => handleDateChange(date, 'end')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-if="assignedEmployees?.length > 0" class="mb-4">
|
||||
@@ -164,6 +179,7 @@ export default {
|
||||
emits: ['update:modelValue', 'assign', 'unassign'],
|
||||
setup(props, { emit }) {
|
||||
const selectedEmployees = ref([]);
|
||||
const publishNews = ref(false);
|
||||
const defaultEndDate = new Date();
|
||||
defaultEndDate.setHours(18, 0, 0, 0);
|
||||
const defaultStartDate = new Date();
|
||||
@@ -253,10 +269,12 @@ export default {
|
||||
emit('assign', {
|
||||
selectedEmployees: selectedEmployees.value,
|
||||
completionDate: completionDate.value,
|
||||
startDate: startDate.value
|
||||
startDate: startDate.value,
|
||||
news: publishNews.value
|
||||
});
|
||||
|
||||
selectedEmployees.value = [];
|
||||
publishNews.value = false;
|
||||
};
|
||||
|
||||
const spravURLFunc = () => spravURL;
|
||||
@@ -265,6 +283,7 @@ export default {
|
||||
selectedEmployees,
|
||||
completionDate,
|
||||
startDate,
|
||||
publishNews,
|
||||
handleEmployeeSelection,
|
||||
handleAssign,
|
||||
handleDateChange,
|
||||
|
||||
@@ -243,7 +243,7 @@ async function createTest(testData) {
|
||||
}
|
||||
}
|
||||
|
||||
async function assignTest(testId, employeeIds, completionDate, startDate) {
|
||||
async function assignTest(testId, employeeIds, completionDate, startDate, news = false) {
|
||||
try {
|
||||
if (!completionDate) {
|
||||
const testDetails = await getTestDetail(testId);
|
||||
@@ -257,7 +257,7 @@ async function assignTest(testId, employeeIds, completionDate, startDate) {
|
||||
|
||||
const userIds = Array.from(employeeIds).map(id => Number(id));
|
||||
const promises = userIds.map(userId =>
|
||||
assignTestToUser(userId, testId, completionDate, startDate)
|
||||
assignTestToUser(userId, testId, completionDate, startDate, news)
|
||||
);
|
||||
|
||||
await Promise.all(promises);
|
||||
@@ -296,14 +296,15 @@ async function deleteTest(id) {
|
||||
}
|
||||
}
|
||||
|
||||
async function assignTestToUser(userId, testId, completionDate, startDate) {
|
||||
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
|
||||
datestart: startDate,
|
||||
news: news
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
|
||||
@@ -358,7 +358,7 @@ export default {
|
||||
}
|
||||
};
|
||||
|
||||
const handleAssign = async ({ selectedEmployees: employees, completionDate, startDate }) => {
|
||||
const handleAssign = async ({ selectedEmployees: employees, completionDate, startDate, news }) => {
|
||||
try {
|
||||
|
||||
let employeesToAssign = [...employees];
|
||||
@@ -369,7 +369,7 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
await assignTest(selectedTestId.value, employeesToAssign, completionDate, startDate);
|
||||
await assignTest(selectedTestId.value, employeesToAssign, completionDate, startDate, news);
|
||||
|
||||
addDialog.value = false;
|
||||
getTestById();
|
||||
|
||||
Reference in new issue
Block a user