Merge remote-tracking branch 'origin/develop' into dev-denzel
This commit is contained in:
commit
ad09c98825
3 files changed
+162
-79
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-row class="pt-2 mx-1">
|
|
||||||
|
<v-row class="pt-2 mx-1 bg-pink flex-column fill-height" >
|
||||||
<template v-if="isVoteCreated">
|
<template v-if="isVoteCreated">
|
||||||
<v-card class="text-center pa-8" flat>
|
<v-card class="text-center pa-8" flat>
|
||||||
<v-icon color="success" size="48">mdi-check-circle</v-icon>
|
<v-icon color="success" size="48">mdi-check-circle</v-icon>
|
||||||
@@ -8,9 +9,11 @@
|
|||||||
</v-card>
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div class="v-col ">
|
|
||||||
<v-stepper v-model="step" editable>
|
<div class="v-col-12 bg-green flex-grow-1 flex-shrink-0">
|
||||||
<v-stepper-header>
|
|
||||||
|
<v-stepper v-model="step" editable class="full-height">
|
||||||
|
<v-stepper-header class="">
|
||||||
<v-stepper-item :complete="step > 0" step="1">Основная информация</v-stepper-item>
|
<v-stepper-item :complete="step > 0" step="1">Основная информация</v-stepper-item>
|
||||||
<v-divider></v-divider>
|
<v-divider></v-divider>
|
||||||
<v-stepper-item :complete="step > 1" step="2">Создание опроса</v-stepper-item>
|
<v-stepper-item :complete="step > 1" step="2">Создание опроса</v-stepper-item>
|
||||||
@@ -18,7 +21,7 @@
|
|||||||
<v-stepper-item :complete="step > 2" step="3">Подтверждение</v-stepper-item>
|
<v-stepper-item :complete="step > 2" step="3">Подтверждение</v-stepper-item>
|
||||||
</v-stepper-header>
|
</v-stepper-header>
|
||||||
|
|
||||||
<v-stepper-window class="">
|
<v-stepper-window class="bg-green flex-grow-1 flex-shrink-0 mb-6">
|
||||||
<!-- Основная информация -->
|
<!-- Основная информация -->
|
||||||
<v-stepper-window-item step="1">
|
<v-stepper-window-item step="1">
|
||||||
<v-card flat>
|
<v-card flat>
|
||||||
@@ -123,34 +126,86 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div class="v-row">
|
<div class="v-row">
|
||||||
<v-switch color="teal-darken-4" v-model="question.settings.onlyDep"
|
|
||||||
:label="`Голосование по отделам: ${question.settings.onlyDep ? 'да ' : 'нет'}`" hide-details
|
<v-radio-group inline label="Голосование по отделам:" v-model="question.settings.onlyDep">
|
||||||
class="v-col-auto"></v-switch>
|
<v-radio v-for="x in onlyDepdict" :key="x.name" :label="x.name" :value=x.value></v-radio>
|
||||||
<v-switch color="teal-darken-4" v-model="question.settings.withoutDirector"
|
</v-radio-group>
|
||||||
|
|
||||||
|
<v-switch color="teal-darken-4" v-model="question.settings.withoutDirector"
|
||||||
:label="`Без начальства : ${question.settings.withoutDirector ? 'да ' : 'нет'}`" hide-details
|
:label="`Без начальства : ${question.settings.withoutDirector ? 'да ' : 'нет'}`" hide-details
|
||||||
class="v-col-auto"></v-switch>
|
class="v-col-auto"></v-switch>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{{ question.selectedEmployees }}
|
|
||||||
<v-autocomplete clearable v-model="question.selectedEmployees" :items="allEmployees"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<v-autocomplete
|
||||||
|
class=" text-no-wrap"
|
||||||
|
v-model="question.selectedEmployees" :items="allEmployeesgroupedbydep"
|
||||||
item-title="fio" item-value="id" label="Выберите сотрудников" multiple variant="outlined"
|
item-title="fio" item-value="id" label="Выберите сотрудников" multiple variant="outlined"
|
||||||
density="compact" :value-comparator="(a, b) => a === b" @update:model-value="(selected)=>onEmployeesChange(selected, index)">
|
density="compact"
|
||||||
|
@update:model-value="(selected)=>question.answers=question.answers.filter(e=>selected.includes(e.text))"
|
||||||
|
>
|
||||||
<template #prepend-item>
|
<template #prepend-item>
|
||||||
<v-checkbox :value="question.selectedEmployees.length==allEmployees.length" label="Все"
|
<v-checkbox class="pa-0" :model-value="question.selectedEmployees.length==allEmployees.length" label="Все"
|
||||||
@change="() => handleSelectAll(question.selectedEmployees.length==allEmployees.length)"></v-checkbox>
|
@update:model-value="handleSelectAll(question.selectedEmployees.length==allEmployees.length, index)"></v-checkbox>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template #item="data">
|
||||||
|
|
||||||
|
<template v-if="typeof data.item.raw !== 'object'">
|
||||||
|
<v-divider/>
|
||||||
|
<v-list-group class='pa-4 text-overline text-grey' v-text="data.item.raw"></v-list-group>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<v-list-item
|
||||||
|
|
||||||
|
slim
|
||||||
|
density="compact"
|
||||||
|
:append-avatar="checkremote(`${spravURL}${data.item.raw.login}.jpg`)"
|
||||||
|
@click="onEmployeesChange(data.item.raw.id, index)"
|
||||||
|
>
|
||||||
|
<template #prepend>
|
||||||
|
|
||||||
|
<v-checkbox hide-details
|
||||||
|
|
||||||
|
:model-value="question.selectedEmployees.includes(data.item.raw.id)"
|
||||||
|
density="compact"></v-checkbox>
|
||||||
|
</template>
|
||||||
|
<v-list-item-title class="text-third" v-text="data.item.raw.fio"></v-list-item-title>
|
||||||
|
</v-list-item>
|
||||||
|
<!-- <v-list-tile-avatar> -->
|
||||||
|
|
||||||
|
<!-- </v-list-tile-avatar> -->
|
||||||
|
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</v-autocomplete>
|
</v-autocomplete>
|
||||||
<div v-for="(person, ind) in question.answers" :key="person" class="v-row align-center mb-4">
|
<div v-for="(person, ind) in question.answers" :key="person" class="v-row align-center mb-4">
|
||||||
<v-col cols="7" class="py-0">
|
<v-col cols="7" class="py-0" >
|
||||||
|
|
||||||
<v-chip class="">{{ findEmployeeById(person.text)?.fio }}</v-chip>
|
<v-chip :prepend-avatar="checkremote(`${spravURL}${findEmployeeById(person.text)?.login}.jpg`)" :text="findEmployeeById(person.text)?.fio ">
|
||||||
|
|
||||||
|
|
||||||
|
</v-chip>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col class="py-0 d-flex" cols="5">
|
<v-col class="py-0 d-flex" cols="5">
|
||||||
<v-file-input v-model="person.image" accept="image/*" dense hide-details label="Картинка"
|
<v-file-input v-model="person.image" accept="image/*" dense hide-details label="Картинка"
|
||||||
variant="outlined" density="compact"></v-file-input>
|
variant="outlined" density="compact"></v-file-input>
|
||||||
<v-btn class="ms-1" color="error" icon="mdi-delete" size="small"
|
<v-btn class="ms-1" color="error" icon="mdi-delete" size="small"
|
||||||
@click="removeAnswer(index,ind)">
|
@click="question.selectedEmployees.splice(ind,1); removeAnswer(index,ind)">
|
||||||
|
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -165,6 +220,7 @@
|
|||||||
<v-btn color="teal-darken-4" size="medium" @click="step = 2">Далее</v-btn>
|
<v-btn color="teal-darken-4" size="medium" @click="step = 2">Далее</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
|
||||||
</v-stepper-window-item>
|
</v-stepper-window-item>
|
||||||
|
|
||||||
<!-- Подтверждение -->
|
<!-- Подтверждение -->
|
||||||
@@ -172,23 +228,31 @@
|
|||||||
<v-card flat>
|
<v-card flat>
|
||||||
<v-card-title>Подтверждение</v-card-title>
|
<v-card-title>Подтверждение</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<p><strong>Название:</strong> {{ form.title }}</p>
|
|
||||||
<p><strong>Описание:</strong> {{ form.description }}</p>
|
<p><v-icon size="xsmall" :class="form.title===null||form.title.length==0?'':'opacity-0'" color='red' icon="mdi-alert"/><strong class="px-2">Название:</strong> {{ form.title }}</p>
|
||||||
<p><strong>Дата начала:</strong> {{ form.startDate.toLocaleDateString() }}</p>
|
<p><v-icon size="xsmall" :class="form.description===null||form.description.length==0?'':'opacity-0'" color='red' icon="mdi-alert"/><strong class="px-2">Описание:</strong> {{ form.description }}</p>
|
||||||
<p><strong>Дата окончания:</strong> {{ form.endDate.toLocaleDateString() }}</p>
|
<p><strong class="px-2">Дата начала:</strong> {{ form.startDate.toLocaleDateString() }}</p>
|
||||||
<p><strong>Вопросы:</strong></p>
|
<p><strong class="px-2">Дата окончания:</strong> {{ form.endDate.toLocaleDateString() }}</p>
|
||||||
<ul>
|
<p><strong class="px-2">Вопросы:</strong></p>
|
||||||
<li v-for="(question, index) in form.questions" :key="index" class="mb-4">
|
|
||||||
<p><strong>Вопрос {{ index + 1 }}:</strong> {{ question.text }} ({{ question.type }})</p>
|
<v-card v-for="(question, index) in form.questions" :key="index" class="mb-4 pa-3">
|
||||||
<div v-if="question.settings.type === 'Ввести вручную' && question.answers.length">
|
<div class="pa-2">
|
||||||
<p><strong>Варианты ответов:</strong></p>
|
|
||||||
<ul>
|
<p><strong>Вопрос {{ index + 1 }}:</strong> {{ question.text }} ({{ question.type }})</p>
|
||||||
<li v-for="(answer, answerIndex) in question.answers" :key="answerIndex">
|
|
||||||
{{ answer.text }}
|
<div v-if="question.settings.choice === 'free' && question.answers.length">
|
||||||
|
<p><strong>Варианты ответов:</strong></p>
|
||||||
|
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li v-for="(answer, answerIndex) in question.answers" :key="answerIndex">
|
||||||
|
{{ answer.text }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="question.settings.type === 'Выбрать сотрудника' && question.answers.length">
|
<div v-if="question.settings.choice === 'employee' && question.answers.length">
|
||||||
|
<div>Количество допустимых ответов: {{ question.settings.multiChoice }}</div>
|
||||||
|
<div class="">Голосование по отделам: {{ onlyDepdict.find(e=>e.value===question.settings.onlyDep).name}}</div>
|
||||||
<p><strong>Выбранные сотрудники:</strong></p>
|
<p><strong>Выбранные сотрудники:</strong></p>
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="employeeId in question.answers" :key="employeeId">
|
<li v-for="employeeId in question.answers" :key="employeeId">
|
||||||
@@ -196,8 +260,9 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</div>
|
||||||
</ul>
|
</v-card>
|
||||||
|
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
||||||
@@ -212,16 +277,19 @@
|
|||||||
</v-stepper-window>
|
</v-stepper-window>
|
||||||
</v-stepper>
|
</v-stepper>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { computed, ref, watch } from "vue";
|
import { computed, ref, watch } from "vue";
|
||||||
|
import { spravURL } from "@/utils/axios-api";
|
||||||
import { createVote, getEmployees } from "@/utils/axios-api";
|
import { createVote, getEmployees } from "@/utils/axios-api";
|
||||||
import DateSelect from "@/components/UI/date-select.vue";
|
import DateSelect from "@/components/UI/date-select.vue";
|
||||||
import { useAccountStore } from "@/store/AccountStore";
|
import { useAccountStore } from "@/store/AccountStore";
|
||||||
|
import { checkremote } from "@/utils/universal_functions";
|
||||||
export default {
|
export default {
|
||||||
components: { DateSelect },
|
components: { DateSelect },
|
||||||
emits: ['updating'],
|
emits: ['updating'],
|
||||||
@@ -256,22 +324,30 @@ export default {
|
|||||||
const currentQuestion = computed(() =>
|
const currentQuestion = computed(() =>
|
||||||
form.value.questions[currentQuestionIndex.value] || null
|
form.value.questions[currentQuestionIndex.value] || null
|
||||||
);
|
);
|
||||||
|
const allEmployeesgroupedbydep = computed(()=>{
|
||||||
|
let groupped = []
|
||||||
|
for (let x of allEmployees.value.sort((a,b)=>a.id_dict_department-b.id_dict_department)){
|
||||||
|
if(!groupped.includes(x.department))groupped.push(x.department)
|
||||||
|
groupped.push(x)
|
||||||
|
}
|
||||||
|
return groupped
|
||||||
|
})
|
||||||
const findEmployeeById = (id) =>
|
const findEmployeeById = (id) =>
|
||||||
groupedEmployees.value.find((employee) => employee.id === id) || {};
|
groupedEmployees.value.find((employee) => employee.id === id) || {};
|
||||||
|
|
||||||
|
|
||||||
const handleSelectAll = (selected) => {
|
const handleSelectAll = (selected, index) => {
|
||||||
console.log(selected);
|
console.log(selected, index);
|
||||||
// if (selected.includes("all")) {
|
if (!selected) {
|
||||||
// form.value.questions[currentQuestionIndex.value].answers = groupedEmployees.value.map((employee) => ({
|
form.value.questions[index].answers = groupedEmployees.value.map((employee) => ({
|
||||||
// text: employee.id,
|
text: employee.id,
|
||||||
// image: null,
|
image: null,
|
||||||
// }));
|
}));
|
||||||
// selectedEmployees.value = groupedEmployees.value.map(employee => employee.id);
|
form.value.questions[index].selectedEmployees = groupedEmployees.value.map(employee => employee.id);
|
||||||
// } else {
|
} else {
|
||||||
// form.value.questions[currentQuestionIndex.value].answers = selected.map((id) => ({ text: id, image: null }));
|
form.value.questions[index].answers = [];
|
||||||
// }
|
form.value.questions[index].selectedEmployees=[]
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const isAllSelected = computed(() => currentQuestion.value.answers.length === groupedEmployees.value.length);
|
const isAllSelected = computed(() => currentQuestion.value.answers.length === groupedEmployees.value.length);
|
||||||
@@ -279,7 +355,7 @@ export default {
|
|||||||
const addQuestion = () => {
|
const addQuestion = () => {
|
||||||
form.value.questions.push({
|
form.value.questions.push({
|
||||||
text: "",
|
text: "",
|
||||||
settings: { choice: "free", multiChoice: 1, onlyDep: false, withoutDirector: false },
|
settings: { choice: "free", multiChoice: 1, onlyDep: null, withoutDirector: false },
|
||||||
image: null,
|
image: null,
|
||||||
answers: [],
|
answers: [],
|
||||||
selectedEmployees: []
|
selectedEmployees: []
|
||||||
@@ -391,11 +467,22 @@ export default {
|
|||||||
const selectedEmployees = ref([]);
|
const selectedEmployees = ref([]);
|
||||||
|
|
||||||
const onEmployeesChange = (selected, index) => {
|
const onEmployeesChange = (selected, index) => {
|
||||||
|
let ind = form.value.questions[index].selectedEmployees.findIndex(e=>e==selected)
|
||||||
form.value.questions[index].answers = selected.map((id) => ({ text: id, image: null }));
|
if(ind>-1){
|
||||||
|
form.value.questions[index].selectedEmployees.splice(ind,1)
|
||||||
|
let answ =form.value.questions[index].answers.findIndex(a=>a.text==selected)
|
||||||
|
form.value.questions[index].answers.splice(answ,1)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
form.value.questions[index].selectedEmployees.push(selected)
|
||||||
|
form.value.questions[index].answers.push({ text: selected, image: null });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onlyDepdict = [{name:'За любого сотрудника' ,value:null},{name:"Кроме своего отдела" ,value:false}, {name:"Только за свой отдел" ,value:true}]
|
||||||
return {
|
return {
|
||||||
|
onlyDepdict,
|
||||||
|
allEmployeesgroupedbydep,
|
||||||
onEmployeesChange,
|
onEmployeesChange,
|
||||||
returnend,
|
returnend,
|
||||||
returnstart,
|
returnstart,
|
||||||
@@ -417,7 +504,9 @@ export default {
|
|||||||
selectedTimeEnd,
|
selectedTimeEnd,
|
||||||
allEmployees,
|
allEmployees,
|
||||||
handleSelectAll,
|
handleSelectAll,
|
||||||
isAllSelected
|
isAllSelected,
|
||||||
|
checkremote,
|
||||||
|
spravURL
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -146,25 +146,25 @@ async function getVoteDetail(id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateVote(id, updatedData) {
|
// async function updateVote(id, updatedData) {
|
||||||
try {
|
// try {
|
||||||
const response = await axiosApiInstance.put(`/api/vote/votedetail/${id}/`, updatedData);
|
// const response = await axiosApiInstance.put(`/api/vote/votedetail/${id}/`, updatedData);
|
||||||
return response.data;
|
// return response.data;
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
console.error("Ошибка обновления голосования:", error);
|
// console.error("Ошибка обновления голосования:", error);
|
||||||
throw error;
|
// throw error;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
async function patchVote(id, partialData) {
|
// async function patchVote(id, partialData) {
|
||||||
try {
|
// try {
|
||||||
const response = await axiosApiInstance.patch(`/api/vote/votedetail/${id}/`, partialData);
|
// const response = await axiosApiInstance.patch(`/api/vote/votedetail/${id}/`, partialData);
|
||||||
return response.data;
|
// return response.data;
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
console.error("Ошибка частичного обновления голосования:", error);
|
// console.error("Ошибка частичного обновления голосования:", error);
|
||||||
throw error;
|
// throw error;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
async function deleteVote(id) {
|
async function deleteVote(id) {
|
||||||
try {
|
try {
|
||||||
@@ -207,8 +207,8 @@ export {
|
|||||||
getVotes,
|
getVotes,
|
||||||
createVote,
|
createVote,
|
||||||
getVoteDetail,
|
getVoteDetail,
|
||||||
updateVote,
|
// updateVote,
|
||||||
patchVote,
|
// patchVote,
|
||||||
deleteVote,
|
deleteVote,
|
||||||
getEmployees,
|
getEmployees,
|
||||||
getVoteResult,
|
getVoteResult,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<v-tab v-for="x in tabs" :key="x.value" :value="x.value">{{ x.text }}</v-tab>
|
<v-tab v-for="x in tabs" :key="x.value" :value="x.value">{{ x.text }}</v-tab>
|
||||||
</v-tabs>
|
</v-tabs>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col class="overflow-auto pa-0">
|
<v-col class=" pa-0 overflow-hidden">
|
||||||
<v-window v-model="currentTab" class=" h-100">
|
<v-window v-model="currentTab" class=" h-100">
|
||||||
<!-- Текущие голосования -->
|
<!-- Текущие голосования -->
|
||||||
<v-tabs-window-item v-for="x in ['active','completed']" :value="x" class="h-100 overflow-auto">
|
<v-tabs-window-item v-for="x in ['active','completed']" :value="x" class="h-100 overflow-auto">
|
||||||
@@ -32,17 +32,11 @@
|
|||||||
</v-tabs-window-item>
|
</v-tabs-window-item>
|
||||||
|
|
||||||
<!-- Конструктор -->
|
<!-- Конструктор -->
|
||||||
<v-tabs-window-item class="h-100 overflow-auto bg-yellow" value="constructor">
|
<v-tabs-window-item class="h-100 " value="constructor">
|
||||||
<VoteConstructor @updating="updating"/>
|
<VoteConstructor @updating="updating"/>
|
||||||
</v-tabs-window-item>
|
</v-tabs-window-item>
|
||||||
|
|
||||||
|
|
||||||
<!-- Конструктор -->
|
|
||||||
<v-tabs-window-item class="h-100 overflow-auto" value="constructor">
|
|
||||||
<VoteConstructor @updating="updating"/>
|
|
||||||
</v-tabs-window-item>
|
|
||||||
<!-- </v-tabs-window> -->
|
|
||||||
|
|
||||||
</v-window>
|
</v-window>
|
||||||
|
|
||||||
<!-- Модальные окна -->
|
<!-- Модальные окна -->
|
||||||
|
|||||||
Reference in new issue
Block a user