добавлена фильтрация и группировка, кнопка закрыть в результатах и убран свитчер из конструктора
This commit is contained in:
1 parent
ad09c98825
commit
502f860a8d
4 files changed
+221
-168
No files matched your search
@@ -31,37 +31,54 @@
|
|||||||
</template>
|
</template>
|
||||||
</v-stepper-header>
|
</v-stepper-header>
|
||||||
<v-stepper-window class="d-flex flex-column flex-fill">
|
<v-stepper-window class="d-flex flex-column flex-fill">
|
||||||
<v-stepper-window-item v-for="(question, index) in data.questions" :key="question.numb"
|
<v-stepper-window-item
|
||||||
:step="question.numb">
|
v-for="(question, index) in data.questions"
|
||||||
|
:key="question.numb"
|
||||||
|
:step="question.numb">
|
||||||
<div>
|
<div>
|
||||||
<h3 class="text-center">{{ question.name }} <span class="text-subtitle-1">(вариантов ответа: {{question.settings.multiChoice}})</span></h3>
|
<h3 class="text-center">
|
||||||
|
{{ question.name }}
|
||||||
|
<span class="text-subtitle-1">(вариантов ответа: {{ question.settings.multiChoice }})</span>
|
||||||
|
</h3>
|
||||||
<v-row>
|
<v-row>
|
||||||
<div class="v-col align-self-start">
|
<div class="v-col align-self-start">
|
||||||
<v-img :src="question.file"
|
<v-img
|
||||||
class="cursor-pointer"
|
:src="question.file"
|
||||||
style="max-height:45vh"
|
class="cursor-pointer"
|
||||||
@click.stop="opendialog({answer:question.question, file:question.file})"/>
|
style="max-height:45vh"
|
||||||
|
@click.stop="opendialog({ answer: question.question, file: question.file })"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="v-col-6" style="max-height:50vh">
|
<div class="v-col-6" style="max-height:50vh">
|
||||||
<v-list v-model:selected="result[question.id]" density="compact" select-strategy="leaf" slim style="max-height: 100%; overflow-y: auto;">
|
<v-list v-model:selected="result[question.id]" density="compact" select-strategy="leaf" slim style="max-height: 100%; overflow-y: auto;">
|
||||||
<v-list-item
|
<template v-for="(answers, department) in groupedAnswers(question)" :key="department">
|
||||||
v-for="answer in question.answers"
|
<v-list-item-subtitle v-if="department">
|
||||||
:key="answer.id"
|
{{ department }}
|
||||||
:value="answer.id"
|
</v-list-item-subtitle>
|
||||||
:disabled="result[question.id].length >= question.settings.multiChoice && !result[question.id].includes(answer.id)"
|
<v-list-item
|
||||||
density="compact"
|
v-for="answer in answers"
|
||||||
>
|
:key="answer.id"
|
||||||
{{ answer.employee?.fio || answer.name }}
|
:value="answer.id"
|
||||||
<template v-slot:prepend="{ isSelected }">
|
:disabled="result[question.id]?.length >= question.settings.multiChoice && !result[question.id]?.includes(answer.id)"
|
||||||
<v-list-item-action start>
|
density="compact">
|
||||||
<v-checkbox-btn :model-value="isSelected"></v-checkbox-btn>
|
{{ answer.employee?.fio || answer.name }}
|
||||||
</v-list-item-action>
|
<template v-slot:prepend="{ isSelected }">
|
||||||
</template>
|
<v-list-item-action start>
|
||||||
<template v-slot:append>
|
<v-checkbox-btn :model-value="isSelected"></v-checkbox-btn>
|
||||||
<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-list-item-action>
|
||||||
<v-avatar v-if="answer.file !== null" :image="answer.file" @click.stop="opendialog(answer)"></v-avatar>
|
</template>
|
||||||
</template>
|
<template v-slot:append>
|
||||||
</v-list-item>
|
<v-avatar
|
||||||
|
v-if="answer.file === null && answer.employee"
|
||||||
|
:image="checkremote(`${spravURL}${answer.employee.login}.jpg`)"
|
||||||
|
@click.stop="opendialog(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>
|
||||||
|
</template>
|
||||||
</v-list>
|
</v-list>
|
||||||
</div>
|
</div>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -181,8 +198,6 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const submitVote = () => {
|
const submitVote = () => {
|
||||||
console.log(props.data);
|
|
||||||
console.log("Отправляем данные голосования:", result.value);
|
|
||||||
let voteData = []
|
let voteData = []
|
||||||
for (let val of Object.values(result.value)) {
|
for (let val of Object.values(result.value)) {
|
||||||
val.forEach(e => voteData.push({answer: e, comment: null, user: accountStore.user.id}))
|
val.forEach(e => voteData.push({answer: e, comment: null, user: accountStore.user.id}))
|
||||||
@@ -198,6 +213,7 @@ export default {
|
|||||||
).finally(() => isVoteSubmitted.value = true)
|
).finally(() => isVoteSubmitted.value = true)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const activepick = ref(null)
|
const activepick = ref(null)
|
||||||
const dialog = ref(false)
|
const dialog = ref(false)
|
||||||
const opendialog = (val) => {
|
const opendialog = (val) => {
|
||||||
@@ -205,7 +221,38 @@ export default {
|
|||||||
activepick.value = val
|
activepick.value = val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const groupedAnswers = (question) => {
|
||||||
|
const filtered = question.answers.filter(answer => answer.employee?.id !== accountStore.user.is_idEmployee);
|
||||||
|
|
||||||
|
if (question.settings.onlyDep === null) {
|
||||||
|
return groupByDepartment(filtered);
|
||||||
|
} else if (question.settings.onlyDep) {
|
||||||
|
const byDepartment = filtered.filter(
|
||||||
|
(answer) => answer.employee?.department === accountStore.user.department
|
||||||
|
);
|
||||||
|
return groupByDepartment(byDepartment);
|
||||||
|
} else {
|
||||||
|
const notByDepartment = filtered.filter(
|
||||||
|
(answer) => answer.employee?.department !== accountStore.user.department
|
||||||
|
);
|
||||||
|
return groupByDepartment(notByDepartment);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const groupByDepartment = (answers) => {
|
||||||
|
return answers.reduce((groups, answer) => {
|
||||||
|
const department = answer.employee?.department || "";
|
||||||
|
if (!groups[department]) {
|
||||||
|
groups[department] = [];
|
||||||
|
}
|
||||||
|
groups[department].push(answer);
|
||||||
|
return groups;
|
||||||
|
}, {});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
groupedAnswers,
|
||||||
activepick,
|
activepick,
|
||||||
opendialog,
|
opendialog,
|
||||||
dialog,
|
dialog,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
|
|
||||||
<v-row class="pt-2 mx-1 bg-pink flex-column fill-height" >
|
<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>
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<div class="v-col-12 bg-green flex-grow-1 flex-shrink-0">
|
<div class="v-col-12 bg-green flex-grow-1 flex-shrink-0">
|
||||||
|
|
||||||
<v-stepper v-model="step" editable class="full-height">
|
<v-stepper v-model="step" class="full-height" editable>
|
||||||
<v-stepper-header class="">
|
<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>
|
||||||
@@ -28,29 +28,30 @@
|
|||||||
<v-card-title>Основная информация</v-card-title>
|
<v-card-title>Основная информация</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-text-field v-model="form.title" :rules="[rules.required]" label="Название голосования"
|
<v-text-field v-model="form.title" :rules="[rules.required]" label="Название голосования"
|
||||||
variant="underlined"></v-text-field>
|
variant="underlined"></v-text-field>
|
||||||
<v-textarea v-model="form.description" :rules="[rules.required]" label="Описание"
|
<v-textarea v-model="form.description" :rules="[rules.required]" label="Описание"
|
||||||
variant="outlined"></v-textarea>
|
variant="outlined"></v-textarea>
|
||||||
<v-divider></v-divider>
|
<v-divider></v-divider>
|
||||||
<div class="pt-2">Дата и время:</div>
|
<div class="pt-2">Дата и время:</div>
|
||||||
<div class="d-flex justify-space-around">
|
<div class="d-flex justify-space-around">
|
||||||
<div class="d-flex ga-3 align-center">
|
<div class="d-flex ga-3 align-center">
|
||||||
<h6 class="text-subtitle-1 pt-2">начало:</h6>
|
<h6 class="text-subtitle-1 pt-2">начало:</h6>
|
||||||
<date-select :datedefault="form.startDate" @returndate="returnstart" />
|
<date-select :datedefault="form.startDate" @returndate="returnstart"/>
|
||||||
<v-select v-model="selectedTimeStart" :items="timeOptions" density="compact" variant="plain"
|
<v-select v-model="selectedTimeStart" :items="timeOptions" density="compact" hide-details
|
||||||
hide-details>
|
variant="plain">
|
||||||
<template v-slot:prepend-inner>
|
<template v-slot:prepend-inner>
|
||||||
<v-icon icon="mdi-timer" size="xsmall" color="red"></v-icon>
|
<v-icon color="red" icon="mdi-timer" size="xsmall"></v-icon>
|
||||||
</template>
|
</template>
|
||||||
</v-select>
|
</v-select>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex ga-3 align-center">
|
<div class="d-flex ga-3 align-center">
|
||||||
<h6 class="text-subtitle-1 pt-2">окончание:</h6>
|
<h6 class="text-subtitle-1 pt-2">окончание:</h6>
|
||||||
<date-select :datedefault="form.endDate" @returndate="returnend" />
|
<date-select :datedefault="form.endDate" @returndate="returnend"/>
|
||||||
<v-select v-model="selectedTimeEnd" :items="timeOptions" density="compact" outlined variant="plain"
|
<v-select v-model="selectedTimeEnd" :items="timeOptions" density="compact" hide-details
|
||||||
hide-details>
|
outlined
|
||||||
|
variant="plain">
|
||||||
<template v-slot:prepend-inner>
|
<template v-slot:prepend-inner>
|
||||||
<v-icon icon="mdi-timer" size="xsmall" color="red"></v-icon>
|
<v-icon color="red" icon="mdi-timer" size="xsmall"></v-icon>
|
||||||
</template>
|
</template>
|
||||||
</v-select>
|
</v-select>
|
||||||
</div>
|
</div>
|
||||||
@@ -64,24 +65,23 @@
|
|||||||
|
|
||||||
<!-- Создание опроса -->
|
<!-- Создание опроса -->
|
||||||
<v-stepper-window-item step="2">
|
<v-stepper-window-item step="2">
|
||||||
<v-card flat class="h-100 ">
|
<v-card class="h-100 " flat>
|
||||||
<v-card-title>Создание опроса:</v-card-title>
|
<v-card-title>Создание опроса:</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<div v-for="(question, index) in form.questions" :key="index" class="mb-4">
|
<div v-for="(question, index) in form.questions" :key="index" class="mb-4">
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<v-text-field density="comfortable" v-model="question.text" :label="'Вопрос ' + (index + 1)"
|
<v-text-field v-model="question.text" :label="'Вопрос ' + (index + 1)" :rules="[rules.required]"
|
||||||
:rules="[rules.required]" variant="underlined">
|
density="comfortable" variant="underlined">
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<v-btn color="error" icon="mdi-delete" size="small" @click="removeQuestion(index)" />
|
<v-btn color="error" icon="mdi-delete" size="small" @click="removeQuestion(index)"/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</v-text-field>
|
</v-text-field>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<v-file-input density="comfortable" v-model="question.image" accept="image/*"
|
<v-file-input v-model="question.image" accept="image/*" density="comfortable"
|
||||||
label="Картинка для вопроса" variant="outlined"></v-file-input>
|
label="Картинка для вопроса" variant="outlined"></v-file-input>
|
||||||
<v-divider></v-divider>
|
<v-divider></v-divider>
|
||||||
<div class="py-2">Настройки вопроса</div>
|
<div class="py-2">Настройки вопроса</div>
|
||||||
<div class="v-row ">
|
<div class="v-row ">
|
||||||
@@ -89,10 +89,11 @@
|
|||||||
<v-col class="align-self-center font-weight-bold py-0">
|
<v-col class="align-self-center font-weight-bold py-0">
|
||||||
Тип ответа
|
Тип ответа
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="3" class="py-0">
|
<v-col class="py-0" cols="3">
|
||||||
|
|
||||||
<v-select density="compact" v-model="question.settings.choice" :items="questionTypes"
|
<v-select v-model="question.settings.choice" :items="questionTypes" density="compact"
|
||||||
item-title="name" item-value="choice" label="" hide-details variant="outlined"></v-select>
|
hide-details item-title="name" item-value="choice" label=""
|
||||||
|
variant="outlined"></v-select>
|
||||||
<!-- choice -->
|
<!-- choice -->
|
||||||
</v-col>
|
</v-col>
|
||||||
</div>
|
</div>
|
||||||
@@ -100,10 +101,11 @@
|
|||||||
<v-col class="align-self-center font-weight-bold">
|
<v-col class="align-self-center font-weight-bold">
|
||||||
Число возможных ответов
|
Число возможных ответов
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="2" class="">
|
<v-col class="" cols="2">
|
||||||
<v-text-field density="compact" v-model="question.settings.multiChoice"
|
<v-text-field v-model="question.settings.multiChoice" :rules="[rules.required && question.settings.multiChoice > 0]"
|
||||||
:rules="[rules.required && question.settings.multiChoice > 0]" hide-details type="number"
|
density="compact" hide-details
|
||||||
min="1" variant="outlined">
|
min="1"
|
||||||
|
type="number" variant="outlined">
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
@@ -115,10 +117,11 @@
|
|||||||
<div v-if="question.settings.choice === 'free'">
|
<div v-if="question.settings.choice === 'free'">
|
||||||
<div v-for="(answer, ind) in question.answers" :key="ind" class="d-flex align-start mb-4">
|
<div v-for="(answer, ind) in question.answers" :key="ind" class="d-flex align-start mb-4">
|
||||||
<v-text-field v-model="answer.text" :label="'Ответ ' + (ind + 1)" :rules="[rules.required]"
|
<v-text-field v-model="answer.text" :label="'Ответ ' + (ind + 1)" :rules="[rules.required]"
|
||||||
class="mr-4" variant="outlined" density="compact"></v-text-field>
|
class="mr-4" density="compact" variant="outlined"></v-text-field>
|
||||||
<v-file-input v-model="answer.image" accept="image/*" dense hide-details label="Картинка"
|
<v-file-input v-model="answer.image" accept="image/*" dense density="compact" hide-details
|
||||||
variant="outlined" density="compact"></v-file-input>
|
label="Картинка" variant="outlined"></v-file-input>
|
||||||
<v-btn class="ms-1" color="error" icon="mdi-delete" size="small" @click="removeAnswer(index,ind)">
|
<v-btn class="ms-1" color="error" icon="mdi-delete" size="small"
|
||||||
|
@click="removeAnswer(index,ind)">
|
||||||
|
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</div>
|
</div>
|
||||||
@@ -127,85 +130,75 @@
|
|||||||
<div v-else>
|
<div v-else>
|
||||||
<div class="v-row">
|
<div class="v-row">
|
||||||
|
|
||||||
<v-radio-group inline label="Голосование по отделам:" v-model="question.settings.onlyDep">
|
<v-radio-group v-model="question.settings.onlyDep" inline label="Голосование по отделам:">
|
||||||
<v-radio v-for="x in onlyDepdict" :key="x.name" :label="x.name" :value=x.value></v-radio>
|
<v-radio v-for="x in onlyDepdict" :key="x.name" :label="x.name" :value=x.value></v-radio>
|
||||||
</v-radio-group>
|
</v-radio-group>
|
||||||
|
|
||||||
<v-switch color="teal-darken-4" v-model="question.settings.withoutDirector"
|
<!-- <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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<v-autocomplete
|
<v-autocomplete
|
||||||
class=" text-no-wrap"
|
v-model="question.selectedEmployees"
|
||||||
v-model="question.selectedEmployees" :items="allEmployeesgroupedbydep"
|
:items="allEmployeesgroupedbydep" class=" text-no-wrap"
|
||||||
item-title="fio" item-value="id" label="Выберите сотрудников" multiple variant="outlined"
|
density="compact" item-title="fio" item-value="id" label="Выберите сотрудников" multiple
|
||||||
density="compact"
|
variant="outlined"
|
||||||
@update:model-value="(selected)=>question.answers=question.answers.filter(e=>selected.includes(e.text))"
|
@update:model-value="(selected)=>question.answers=question.answers.filter(e=>selected.includes(e.text))"
|
||||||
>
|
>
|
||||||
<template #prepend-item>
|
<template #prepend-item>
|
||||||
<v-checkbox class="pa-0" :model-value="question.selectedEmployees.length==allEmployees.length" label="Все"
|
<v-checkbox :model-value="question.selectedEmployees.length==allEmployees.length"
|
||||||
@update:model-value="handleSelectAll(question.selectedEmployees.length==allEmployees.length, index)"></v-checkbox>
|
class="pa-0"
|
||||||
|
label="Все"
|
||||||
|
@update:model-value="handleSelectAll(question.selectedEmployees.length==allEmployees.length, index)"></v-checkbox>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #item="data">
|
<template #item="data">
|
||||||
|
|
||||||
<template v-if="typeof data.item.raw !== 'object'">
|
<template v-if="typeof data.item.raw !== 'object'">
|
||||||
<v-divider/>
|
<v-divider/>
|
||||||
<v-list-group class='pa-4 text-overline text-grey' v-text="data.item.raw"></v-list-group>
|
<v-list-group class='pa-4 text-overline text-grey' v-text="data.item.raw"></v-list-group>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<v-list-item
|
<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>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:append-avatar="checkremote(`${spravURL}${data.item.raw.login}.jpg`)"
|
||||||
|
density="compact"
|
||||||
|
slim
|
||||||
|
@click="onEmployeesChange(data.item.raw.id, index)"
|
||||||
|
>
|
||||||
|
<template #prepend>
|
||||||
|
|
||||||
|
<v-checkbox :model-value="question.selectedEmployees.includes(data.item.raw.id)"
|
||||||
|
|
||||||
|
density="compact"
|
||||||
|
hide-details></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 class="py-0" cols="7">
|
||||||
|
|
||||||
<v-chip :prepend-avatar="checkremote(`${spravURL}${findEmployeeById(person.text)?.login}.jpg`)" :text="findEmployeeById(person.text)?.fio ">
|
<v-chip
|
||||||
|
:prepend-avatar="checkremote(`${spravURL}${findEmployeeById(person.text)?.login}.jpg`)"
|
||||||
|
:text="findEmployeeById(person.text)?.fio ">
|
||||||
|
|
||||||
|
|
||||||
</v-chip>
|
</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 density="compact" hide-details
|
||||||
variant="outlined" density="compact"></v-file-input>
|
label="Картинка" variant="outlined"></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="question.selectedEmployees.splice(ind,1); removeAnswer(index,ind)">
|
@click="question.selectedEmployees.splice(ind,1); removeAnswer(index,ind)">
|
||||||
|
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -229,30 +222,40 @@
|
|||||||
<v-card-title>Подтверждение</v-card-title>
|
<v-card-title>Подтверждение</v-card-title>
|
||||||
<v-card-text>
|
<v-card-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>
|
||||||
<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>
|
<v-icon :class="form.title===null||form.title.length==0?'':'opacity-0'" color='red' icon="mdi-alert"
|
||||||
|
size="xsmall"/>
|
||||||
|
<strong class="px-2">Название:</strong> {{ form.title }}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<v-icon :class="form.description===null||form.description.length==0?'':'opacity-0'" color='red'
|
||||||
|
icon="mdi-alert" size="xsmall"/>
|
||||||
|
<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.startDate.toLocaleDateString() }}</p>
|
||||||
<p><strong class="px-2">Дата окончания:</strong> {{ form.endDate.toLocaleDateString() }}</p>
|
<p><strong class="px-2">Дата окончания:</strong> {{ form.endDate.toLocaleDateString() }}</p>
|
||||||
<p><strong class="px-2">Вопросы:</strong></p>
|
<p><strong class="px-2">Вопросы:</strong></p>
|
||||||
|
|
||||||
<v-card v-for="(question, index) in form.questions" :key="index" class="mb-4 pa-3">
|
<v-card v-for="(question, index) in form.questions" :key="index" class="mb-4 pa-3">
|
||||||
<div class="pa-2">
|
<div class="pa-2">
|
||||||
|
|
||||||
<p><strong>Вопрос {{ index + 1 }}:</strong> {{ question.text }} ({{ question.type }})</p>
|
<p><strong>Вопрос {{ index + 1 }}:</strong> {{ question.text }} ({{ question.type }})</p>
|
||||||
|
|
||||||
<div v-if="question.settings.choice === 'free' && question.answers.length">
|
<div v-if="question.settings.choice === 'free' && question.answers.length">
|
||||||
<p><strong>Варианты ответов:</strong></p>
|
<p><strong>Варианты ответов:</strong></p>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="(answer, answerIndex) in question.answers" :key="answerIndex">
|
<li v-for="(answer, answerIndex) in question.answers" :key="answerIndex">
|
||||||
{{ answer.text }}
|
{{ answer.text }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="question.settings.choice === 'employee' && question.answers.length">
|
<div v-if="question.settings.choice === 'employee' && question.answers.length">
|
||||||
<div>Количество допустимых ответов: {{ question.settings.multiChoice }}</div>
|
<div>Количество допустимых ответов: {{ question.settings.multiChoice }}</div>
|
||||||
<div class="">Голосование по отделам: {{ onlyDepdict.find(e=>e.value===question.settings.onlyDep).name}}</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">
|
||||||
@@ -261,7 +264,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
@@ -284,16 +287,16 @@
|
|||||||
</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, spravURL} 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";
|
import {checkremote} from "@/utils/universal_functions";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { DateSelect },
|
components: {DateSelect},
|
||||||
emits: ['updating'],
|
emits: ['updating'],
|
||||||
setup(props, { emit }) {
|
setup(props, {emit}) {
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
const user = accountStore.user;
|
const user = accountStore.user;
|
||||||
const step = ref(0);
|
const step = ref(0);
|
||||||
@@ -311,7 +314,7 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const currentQuestionIndex = ref(0);
|
const currentQuestionIndex = ref(0);
|
||||||
const questionTypes = [{ name: "Ввести вручную", choice: 'free' }, { name: "Выбрать сотрудника", choice: 'employee' }];
|
const questionTypes = [{name: "Ввести вручную", choice: 'free'}, {name: "Выбрать сотрудника", choice: 'employee'}];
|
||||||
|
|
||||||
const groupedEmployees = ref([]);
|
const groupedEmployees = ref([]);
|
||||||
const allEmployees = computed(() => [
|
const allEmployees = computed(() => [
|
||||||
@@ -324,10 +327,10 @@ export default {
|
|||||||
const currentQuestion = computed(() =>
|
const currentQuestion = computed(() =>
|
||||||
form.value.questions[currentQuestionIndex.value] || null
|
form.value.questions[currentQuestionIndex.value] || null
|
||||||
);
|
);
|
||||||
const allEmployeesgroupedbydep = computed(()=>{
|
const allEmployeesgroupedbydep = computed(() => {
|
||||||
let groupped = []
|
let groupped = []
|
||||||
for (let x of allEmployees.value.sort((a,b)=>a.id_dict_department-b.id_dict_department)){
|
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)
|
if (!groupped.includes(x.department)) groupped.push(x.department)
|
||||||
groupped.push(x)
|
groupped.push(x)
|
||||||
}
|
}
|
||||||
return groupped
|
return groupped
|
||||||
@@ -346,7 +349,7 @@ export default {
|
|||||||
form.value.questions[index].selectedEmployees = groupedEmployees.value.map(employee => employee.id);
|
form.value.questions[index].selectedEmployees = groupedEmployees.value.map(employee => employee.id);
|
||||||
} else {
|
} else {
|
||||||
form.value.questions[index].answers = [];
|
form.value.questions[index].answers = [];
|
||||||
form.value.questions[index].selectedEmployees=[]
|
form.value.questions[index].selectedEmployees = []
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -355,7 +358,7 @@ export default {
|
|||||||
const addQuestion = () => {
|
const addQuestion = () => {
|
||||||
form.value.questions.push({
|
form.value.questions.push({
|
||||||
text: "",
|
text: "",
|
||||||
settings: { choice: "free", multiChoice: 1, onlyDep: null, withoutDirector: false },
|
settings: {choice: "free", multiChoice: 1, onlyDep: null, withoutDirector: false},
|
||||||
image: null,
|
image: null,
|
||||||
answers: [],
|
answers: [],
|
||||||
selectedEmployees: []
|
selectedEmployees: []
|
||||||
@@ -372,14 +375,14 @@ export default {
|
|||||||
|
|
||||||
const addAnswer = (index) => {
|
const addAnswer = (index) => {
|
||||||
if (currentQuestion.value) {
|
if (currentQuestion.value) {
|
||||||
form.value.questions[index].answers.push({ text: "", image: null });
|
form.value.questions[index].answers.push({text: "", image: null});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeAnswer = (index,ind) => {
|
const removeAnswer = (index, ind) => {
|
||||||
// if (currentQuestion.value) {
|
// if (currentQuestion.value) {
|
||||||
form.value.questions[index].answers.splice(ind, 1)
|
form.value.questions[index].answers.splice(ind, 1)
|
||||||
// currentQuestion.value.answers.splice(index, 1);
|
// currentQuestion.value.answers.splice(index, 1);
|
||||||
// }
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -412,7 +415,7 @@ export default {
|
|||||||
isVoteCreated.value = false;
|
isVoteCreated.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const timeOptions = Array.from({ length: 48 }, (_, i) => {
|
const timeOptions = Array.from({length: 48}, (_, i) => {
|
||||||
const hours = String(Math.floor(i / 2)).padStart(2, "0");
|
const hours = String(Math.floor(i / 2)).padStart(2, "0");
|
||||||
const minutes = i % 2 === 0 ? "00" : "30";
|
const minutes = i % 2 === 0 ? "00" : "30";
|
||||||
return `${hours}:${minutes}`;
|
return `${hours}:${minutes}`;
|
||||||
@@ -467,19 +470,21 @@ 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)
|
let ind = form.value.questions[index].selectedEmployees.findIndex(e => e == selected)
|
||||||
if(ind>-1){
|
if (ind > -1) {
|
||||||
form.value.questions[index].selectedEmployees.splice(ind,1)
|
form.value.questions[index].selectedEmployees.splice(ind, 1)
|
||||||
let answ =form.value.questions[index].answers.findIndex(a=>a.text==selected)
|
let answ = form.value.questions[index].answers.findIndex(a => a.text == selected)
|
||||||
form.value.questions[index].answers.splice(answ,1)
|
form.value.questions[index].answers.splice(answ, 1)
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
form.value.questions[index].selectedEmployees.push(selected)
|
form.value.questions[index].selectedEmployees.push(selected)
|
||||||
form.value.questions[index].answers.push({ text: selected, image: null });
|
form.value.questions[index].answers.push({text: selected, image: null});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onlyDepdict = [{name:'За любого сотрудника' ,value:null},{name:"Кроме своего отдела" ,value:false}, {name:"Только за свой отдел" ,value:true}]
|
const onlyDepdict = [{name: 'За любого сотрудника', value: null}, {
|
||||||
|
name: "Кроме своего отдела",
|
||||||
|
value: false
|
||||||
|
}, {name: "Только за свой отдел", value: true}]
|
||||||
return {
|
return {
|
||||||
onlyDepdict,
|
onlyDepdict,
|
||||||
allEmployeesgroupedbydep,
|
allEmployeesgroupedbydep,
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container>
|
<v-container>
|
||||||
|
<div class="text-end">
|
||||||
|
<v-btn class="" color="red-darken-1" density="compact" icon="mdi-close-thick" size="small"
|
||||||
|
@click="$emit('closer')">
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
<v-card-title class="text-subtitle-1">Результат голосования: {{ title }}</v-card-title>
|
<v-card-title class="text-subtitle-1">Результат голосования: {{ title }}</v-card-title>
|
||||||
<v-card-subtitle class="text-subtitle-2">{{ description }}</v-card-subtitle>
|
<v-card-subtitle class="text-subtitle-2">{{ description }}</v-card-subtitle>
|
||||||
<v-tabs v-model="activeTab" class="mb-4">
|
<v-tabs v-model="activeTab" class="mb-4">
|
||||||
<v-tab
|
<v-tab
|
||||||
v-for="(question, questionIndex) in questions"
|
v-for="(question, questionIndex) in questions"
|
||||||
:key="questionIndex"
|
:key="questionIndex"
|
||||||
>
|
>
|
||||||
<template v-if="shouldShowTooltip(question.name || 'Без названия', 10)">
|
<template v-if="shouldShowTooltip(question.name || 'Без названия', 10)">
|
||||||
<v-tooltip bottom>
|
<v-tooltip bottom>
|
||||||
@@ -43,8 +48,8 @@
|
|||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-list style="max-height: 40vh; overflow-y: auto;">
|
<v-list style="max-height: 40vh; overflow-y: auto;">
|
||||||
<v-list-item
|
<v-list-item
|
||||||
v-for="(answer, answerIndex) in getTopResults(question)"
|
v-for="(answer, answerIndex) in getTopResults(question)"
|
||||||
:key="answerIndex"
|
:key="answerIndex"
|
||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
<v-avatar v-if="answer.file === null && answer.employee"
|
<v-avatar v-if="answer.file === null && answer.employee"
|
||||||
@@ -65,14 +70,14 @@
|
|||||||
</template>
|
</template>
|
||||||
</p>
|
</p>
|
||||||
<v-progress-linear
|
<v-progress-linear
|
||||||
:model-value="getPercentage(answer.count, question)"
|
:model-value="getPercentage(answer.count, question)"
|
||||||
color="teal-darken-4"
|
color="teal-darken-4"
|
||||||
height="13"
|
height="13"
|
||||||
rounded
|
rounded
|
||||||
striped
|
striped
|
||||||
>
|
>
|
||||||
<template v-slot:default="{ value }">
|
<template v-slot:default="{ value }">
|
||||||
<strong v-if="value < 40" class="text-grey-darken-3">{{ Math.ceil(value) }}%</strong>
|
<strong v-if="value < 50" class="text-grey-darken-3">{{ Math.ceil(value) }}%</strong>
|
||||||
<strong v-else class="text-grey-lighten-5">{{ Math.ceil(value) }}%</strong>
|
<strong v-else class="text-grey-lighten-5">{{ Math.ceil(value) }}%</strong>
|
||||||
</template>
|
</template>
|
||||||
</v-progress-linear>
|
</v-progress-linear>
|
||||||
@@ -136,6 +141,7 @@ export default {
|
|||||||
return baseURL
|
return baseURL
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
emits: ['closer'],
|
||||||
props: {
|
props: {
|
||||||
data: {
|
data: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -151,8 +157,8 @@ export default {
|
|||||||
|
|
||||||
const getWinner = (question) => {
|
const getWinner = (question) => {
|
||||||
return question.answers.reduce(
|
return question.answers.reduce(
|
||||||
(max, answer) => (answer.count > max.count ? answer : max),
|
(max, answer) => (answer.count > max.count ? answer : max),
|
||||||
{count: 0, employee: {fio: '', department: '', post: ''}, name: ''}
|
{count: 0, employee: {fio: '', department: '', post: ''}, name: ''}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,19 +30,14 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-tabs-window-item>
|
</v-tabs-window-item>
|
||||||
|
|
||||||
<!-- Конструктор -->
|
<!-- Конструктор -->
|
||||||
<v-tabs-window-item class="h-100 " 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-window>
|
</v-window>
|
||||||
|
|
||||||
<!-- Модальные окна -->
|
<!-- Модальные окна -->
|
||||||
<v-dialog v-model="voteModal" @click:outside="closeModal">
|
<v-dialog v-model="voteModal" @click:outside="closeModal">
|
||||||
|
|
||||||
|
|
||||||
<CurrentVote :data="res" @closer="closeModal"/>
|
<CurrentVote :data="res" @closer="closeModal"/>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
@@ -61,7 +56,7 @@
|
|||||||
|
|
||||||
<v-dialog v-model="resultsModal" max-width="1200px" @click:outside="closeModal">
|
<v-dialog v-model="resultsModal" max-width="1200px" @click:outside="closeModal">
|
||||||
<v-card>
|
<v-card>
|
||||||
<VoteResult :data="result"/>
|
<VoteResult :data="result" @closer="closeModal" />
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-btn @click="closeModal">Закрыть</v-btn>
|
<v-btn @click="closeModal">Закрыть</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
|
|||||||
Reference in new issue
Block a user