Merge branch 'develop' into сja

This commit is contained in:
Cja committed 2025-01-22 13:35:04 +03:00
commit f4372e48e2
6 files changed
+252 -98

No files matched your search

@@ -4,7 +4,7 @@
persistent
width="600"
class="mx-auto"
>
>
<v-card height="500">
<v-card-title class="pl-6">
Информация
@@ -22,7 +22,7 @@
max-height="222px"
:src="checkremote(`${spravURL}${author.login}.jpg`)"
/>
</v-col>
<v-col class="d-flex flex-column">
<v-row
@@ -101,9 +101,9 @@ export default {
setup (props, {emit}) {
const mydialog = computed({
get: () => props.opendialog,
set: (value) => emit('update:opendialog', value)
})
get: () => props.opendialog,
set: (value) => emit('update:opendialog', value)
})
const basicInformation = () => [
{title: 'Отдел:', info: props.author.department},
@@ -131,4 +131,4 @@ export default {
<style>
</style>
</style>
+11 -3
View File
@@ -58,7 +58,8 @@
</v-list-item-action>
</template>
<template v-slot:append>
<v-avatar :image="answer.file" @click.stop="opendialog(answer)"></v-avatar>
<v-avatar v-if="answer.file === null && answer.employee" @click.stop="opendialog(checkremote(`${spravURL()}${answer.employee.login}.jpg`))" :image="checkremote(`${spravURL()}${answer.employee.login}.jpg`)" />
<v-avatar v-if="answer.file !== null" :image="answer.file" @click.stop="opendialog(answer)"></v-avatar>
</template>
</v-list-item>
</v-list>
@@ -102,7 +103,7 @@
</v-card-title>
<v-card-item>
<v-img :src="activepick.file" max-height="600"></v-img>
<v-img :src="activepick.file ?? activepick" max-height="600"></v-img>
</v-card-item>
</v-card>
</v-dialog>
@@ -123,12 +124,19 @@
</template>
<script>
import {axiosApiInstance} from "@/utils/axios-api";
import {axiosApiInstance, spravURL} from "@/utils/axios-api";
import {computed, ref} from "vue";
import {useAccountStore} from "@/store/AccountStore";
import {checkremote} from "@/utils/universal_functions";
export default {
name: 'CurrentVote',
methods: {
checkremote,
spravURL() {
return spravURL
}
},
emits: ['closer'],
props: {
data: {
+143 -54
View File
@@ -1,5 +1,6 @@
<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">
<v-card class="text-center pa-8" flat>
<v-icon color="success" size="48">mdi-check-circle</v-icon>
@@ -8,9 +9,11 @@
</v-card>
</template>
<template v-else>
<div class="v-col ">
<v-stepper v-model="step" editable>
<v-stepper-header>
<div class="v-col-12 bg-green flex-grow-1 flex-shrink-0">
<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-divider></v-divider>
<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-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-card flat>
@@ -122,35 +125,87 @@
<v-btn color="teal-darken-4" @click="addAnswer(index)">Добавить ответ</v-btn>
</div>
<div v-else>
<div class="v-row">
<v-switch color="teal-darken-4" v-model="question.settings.onlyDep"
:label="`Голосование по отделам: ${question.settings.onlyDep ? 'да ' : 'нет'}`" hide-details
class="v-col-auto"></v-switch>
<v-switch color="teal-darken-4" v-model="question.settings.withoutDirector"
<div class="v-row">
<v-radio-group inline label="Голосование по отделам:" v-model="question.settings.onlyDep">
<v-radio v-for="x in onlyDepdict" :key="x.name" :label="x.name" :value=x.value></v-radio>
</v-radio-group>
<v-switch color="teal-darken-4" v-model="question.settings.withoutDirector"
:label="`Без начальства : ${question.settings.withoutDirector ? 'да ' : 'нет'}`" hide-details
class="v-col-auto"></v-switch>
</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"
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>
<v-checkbox :value="question.selectedEmployees.length==allEmployees.length" label="Все"
@change="() => handleSelectAll(question.selectedEmployees.length==allEmployees.length)"></v-checkbox>
<v-checkbox class="pa-0" :model-value="question.selectedEmployees.length==allEmployees.length" label="Все"
@update:model-value="handleSelectAll(question.selectedEmployees.length==allEmployees.length, index)"></v-checkbox>
</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>
<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-chip class="">{{ findEmployeeById(person.text)?.fio }}</v-chip>
<v-col cols="7" class="py-0" >
<v-chip :prepend-avatar="checkremote(`${spravURL}${findEmployeeById(person.text)?.login}.jpg`)" :text="findEmployeeById(person.text)?.fio ">
</v-chip>
</v-col>
<v-col class="py-0 d-flex" cols="5">
<v-file-input v-model="person.image" accept="image/*" dense hide-details label="Картинка"
variant="outlined" density="compact"></v-file-input>
<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-col>
@@ -165,6 +220,7 @@
<v-btn color="teal-darken-4" size="medium" @click="step = 2">Далее</v-btn>
</v-card-actions>
</v-card>
</v-stepper-window-item>
<!-- Подтверждение -->
@@ -172,23 +228,31 @@
<v-card flat>
<v-card-title>Подтверждение</v-card-title>
<v-card-text>
<p><strong>Название:</strong> {{ form.title }}</p>
<p><strong>Описание:</strong> {{ form.description }}</p>
<p><strong>Дата начала:</strong> {{ form.startDate.toLocaleDateString() }}</p>
<p><strong>Дата окончания:</strong> {{ form.endDate.toLocaleDateString() }}</p>
<p><strong>Вопросы:</strong></p>
<ul>
<li v-for="(question, index) in form.questions" :key="index" class="mb-4">
<p><strong>Вопрос {{ index + 1 }}:</strong> {{ question.text }} ({{ question.type }})</p>
<div v-if="question.settings.type === 'Ввести вручную' && question.answers.length">
<p><strong>Варианты ответов:</strong></p>
<ul>
<li v-for="(answer, answerIndex) in question.answers" :key="answerIndex">
{{ answer.text }}
<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><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 class="px-2">Дата начала:</strong> {{ form.startDate.toLocaleDateString() }}</p>
<p><strong class="px-2">Дата окончания:</strong> {{ form.endDate.toLocaleDateString() }}</p>
<p><strong class="px-2">Вопросы:</strong></p>
<v-card v-for="(question, index) in form.questions" :key="index" class="mb-4 pa-3">
<div class="pa-2">
<p><strong>Вопрос {{ index + 1 }}:</strong> {{ question.text }} ({{ question.type }})</p>
<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>
</ul>
</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>
<ul>
<li v-for="employeeId in question.answers" :key="employeeId">
@@ -196,8 +260,9 @@
</li>
</ul>
</div>
</li>
</ul>
</div>
</v-card>
</v-card-text>
<v-card-actions>
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
@@ -212,16 +277,19 @@
</v-stepper-window>
</v-stepper>
</div>
</template>
</v-row>
</template>
<script>
import { computed, ref, watch } from "vue";
import { spravURL } from "@/utils/axios-api";
import { createVote, getEmployees } from "@/utils/axios-api";
import DateSelect from "@/components/UI/date-select.vue";
import { useAccountStore } from "@/store/AccountStore";
import { checkremote } from "@/utils/universal_functions";
export default {
components: { DateSelect },
emits: ['updating'],
@@ -256,22 +324,30 @@ export default {
const currentQuestion = computed(() =>
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) =>
groupedEmployees.value.find((employee) => employee.id === id) || {};
const handleSelectAll = (selected) => {
console.log(selected);
// if (selected.includes("all")) {
// form.value.questions[currentQuestionIndex.value].answers = groupedEmployees.value.map((employee) => ({
// text: employee.id,
// image: null,
// }));
// selectedEmployees.value = groupedEmployees.value.map(employee => employee.id);
// } else {
// form.value.questions[currentQuestionIndex.value].answers = selected.map((id) => ({ text: id, image: null }));
// }
const handleSelectAll = (selected, index) => {
console.log(selected, index);
if (!selected) {
form.value.questions[index].answers = groupedEmployees.value.map((employee) => ({
text: employee.id,
image: null,
}));
form.value.questions[index].selectedEmployees = groupedEmployees.value.map(employee => employee.id);
} else {
form.value.questions[index].answers = [];
form.value.questions[index].selectedEmployees=[]
}
};
const isAllSelected = computed(() => currentQuestion.value.answers.length === groupedEmployees.value.length);
@@ -279,7 +355,7 @@ export default {
const addQuestion = () => {
form.value.questions.push({
text: "",
settings: { choice: "free", multiChoice: 1, onlyDep: false, withoutDirector: false },
settings: { choice: "free", multiChoice: 1, onlyDep: null, withoutDirector: false },
image: null,
answers: [],
selectedEmployees: []
@@ -391,11 +467,22 @@ export default {
const selectedEmployees = ref([]);
const onEmployeesChange = (selected, index) => {
form.value.questions[index].answers = selected.map((id) => ({ text: id, image: null }));
let ind = form.value.questions[index].selectedEmployees.findIndex(e=>e==selected)
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 {
onlyDepdict,
allEmployeesgroupedbydep,
onEmployeesChange,
returnend,
returnstart,
@@ -417,7 +504,9 @@ export default {
selectedTimeEnd,
allEmployees,
handleSelectAll,
isAllSelected
isAllSelected,
checkremote,
spravURL
};
},
};
+69 -6
View File
@@ -10,9 +10,9 @@
<template v-if="shouldShowTooltip(question.name || 'Без названия', 10)">
<v-tooltip bottom>
<template v-slot:activator="{ props }">
<span v-bind="props">
{{ truncateText(question.name || 'Без названия', 10) }}
</span>
<span v-bind="props">
{{ truncateText(question.name || 'Без названия', 10) }}
</span>
</template>
<span>{{ question.name || 'Без названия' }}</span>
</v-tooltip>
@@ -21,6 +21,7 @@
<span>{{ truncateText(question.name || 'Без названия', 10) }}</span>
</template>
</v-tab>
<v-tab>Не голосовали</v-tab>
</v-tabs>
<v-tabs-window v-model="activeTab">
@@ -46,7 +47,15 @@
:key="answerIndex"
>
<p>
<strong>{{ answer.employee ? answer.employee.fio : answer.name }}</strong>: {{ answer.count }}
<v-avatar v-if="answer.file === null && answer.employee"
:image="checkremote(`${spravURL()}${answer.employee.login}.jpg`)"
class="cursor-pointer"
@click.stop="opendialog(checkremote(`${spravURL()}${answer.employee.login}.jpg`))"/>
<v-avatar v-if="answer.file !== null" :image="baseURL.slice(0, -1) + answer.file"
class="cursor-pointer"
@click.stop="opendialog(answer)"/>
<strong class="ml-4">{{ answer.employee ? answer.employee.fio : answer.name }}</strong>:
{{ answer.count }}
{{ voteCount(answer.count) }}
<template v-if="answer.employee">
<br/>
@@ -57,10 +66,10 @@
</p>
<v-progress-linear
:model-value="getPercentage(answer.count, question)"
height="10"
color="teal-darken-4"
striped
height="10"
rounded
striped
/>
</v-list-item>
</v-list>
@@ -69,15 +78,59 @@
</v-col>
</v-row>
</v-tabs-window-item>
<!-- Не голосовали -->
<!-- <v-tabs-window-item v-for="(question, questionIndex) in questions" :key="questionIndex">-->
<!-- <v-card-title class="text-red-darken-3">Не голосовали:</v-card-title>-->
<!-- <v-list style="max-height: 40vh; overflow-y: auto;">-->
<!-- <v-list-item-->
<!-- v-for="(answer, answerIndex) in getTopResults(question)"-->
<!-- :key="answerIndex"-->
<!-- >-->
<!-- {{answer.employee.fio}}-->
<!-- </v-list-item>-->
<!-- </v-list>-->
<!-- </v-tabs-window-item>-->
</v-tabs-window>
</v-container>
<v-dialog v-model="dialog" max-width="100vh">
<v-card max-height="800">
<v-card-title class="v-row">
<div class="v-col-auto">
{{ activepick.answer }}
</div>
<v-spacer></v-spacer>
<div>
<v-btn color="red-darken-1" density="compact" icon="mdi-close-thick" size="small" @click="dialog=false"/>
</div>
</v-card-title>
<v-card-item>
<v-img :src="activepick.file !== undefined ? baseURL.slice(0, -1) + activepick.file : activepick"
max-height="600"></v-img>
</v-card-item>
</v-card>
</v-dialog>
</template>
<script>
import {computed, ref} from 'vue';
import {baseURL, spravURL} from "@/utils/axios-api";
import {checkremote} from "@/utils/universal_functions";
export default {
name: 'VoteResult',
methods: {
checkremote,
spravURL() {
return spravURL
}
},
computed: {
baseURL() {
return baseURL
}
},
props: {
data: {
type: Object,
@@ -125,7 +178,17 @@ export default {
return totalVotes > 0 ? (count / totalVotes) * 100 : 0;
};
const activepick = ref(null)
const dialog = ref(false)
const opendialog = (val) => {
dialog.value = true
activepick.value = val
}
return {
activepick,
opendialog,
dialog,
activeTab,
questions,
getWinner,
+21 -21
View File
@@ -146,25 +146,25 @@ async function getVoteDetail(id) {
}
}
async function updateVote(id, updatedData) {
try {
const response = await axiosApiInstance.put(`/api/vote/votedetail/${id}/`, updatedData);
return response.data;
} catch (error) {
console.error("Ошибка обновления голосования:", error);
throw error;
}
}
// async function updateVote(id, updatedData) {
// try {
// const response = await axiosApiInstance.put(`/api/vote/votedetail/${id}/`, updatedData);
// return response.data;
// } catch (error) {
// console.error("Ошибка обновления голосования:", error);
// throw error;
// }
// }
async function patchVote(id, partialData) {
try {
const response = await axiosApiInstance.patch(`/api/vote/votedetail/${id}/`, partialData);
return response.data;
} catch (error) {
console.error("Ошибка частичного обновления голосования:", error);
throw error;
}
}
// async function patchVote(id, partialData) {
// try {
// const response = await axiosApiInstance.patch(`/api/vote/votedetail/${id}/`, partialData);
// return response.data;
// } catch (error) {
// console.error("Ошибка частичного обновления голосования:", error);
// throw error;
// }
// }
async function deleteVote(id) {
try {
@@ -207,9 +207,9 @@ export {
getVotes,
createVote,
getVoteDetail,
updateVote,
patchVote,
// updateVote,
// patchVote,
deleteVote,
getEmployees,
getVoteResult
getVoteResult,
}
+2 -8
View File
@@ -8,7 +8,7 @@
<v-tab v-for="x in tabs" :key="x.value" :value="x.value">{{ x.text }}</v-tab>
</v-tabs>
</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-tabs-window-item v-for="x in ['active','completed']" :value="x" class="h-100 overflow-auto">
@@ -33,17 +33,11 @@
</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"/>
</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>
<!-- Модальные окна -->