Merge branch 'dev-denzel' into develop
This commit is contained in:
commit
5c32a95404
3 files changed
+369
-272
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
|
||||
<v-row class="pt-2 mx-1 flex-column fill-height flex-grow-0 " >
|
||||
<v-row class="pt-2 mx-1 flex-column fill-height flex-grow-0 ">
|
||||
<template v-if="isVoteCreated">
|
||||
<v-card class="d-flex flex-column flex-grow-1 flex-shrink-0 text-center pa-8" flat>
|
||||
<v-spacer></v-spacer>
|
||||
@@ -14,10 +14,8 @@
|
||||
</v-card>
|
||||
</template>
|
||||
<template v-else>
|
||||
|
||||
<div class="v-col flex-grow-1 flex-shrink-0 ">
|
||||
|
||||
<v-stepper v-model="step" editable class="d-flex flex-column fill-height">
|
||||
<v-stepper v-model="step" class="d-flex flex-column fill-height" editable>
|
||||
<v-stepper-header class="flex-grow-0 flex-shrink-1">
|
||||
<v-stepper-item :complete="step > 0" step="1">Основная информация
|
||||
|
||||
@@ -30,44 +28,45 @@
|
||||
|
||||
<v-stepper-window class="fill-height">
|
||||
<!-- Основная информация -->
|
||||
<v-stepper-window-item step="1" class="fill-height">
|
||||
<v-card flat class="fill-height d-flex flex-column ">
|
||||
<v-stepper-window-item class="fill-height" step="1">
|
||||
<v-card class="fill-height d-flex flex-column " flat>
|
||||
<v-card-title>Основная информация</v-card-title>
|
||||
<v-card-text class="d-flex flex-column overflow-auto">
|
||||
<v-text-field v-model="form.title" :rules="[rules.required]" label="Название голосования"
|
||||
class="flex-grow-0 flex-shrink-1"
|
||||
variant="underlined"></v-text-field>
|
||||
<div class="flex-grow-1 flex-shrink-0">
|
||||
<v-text-field v-model="form.title" :rules="[rules.required]" class="flex-grow-0 flex-shrink-1"
|
||||
label="Название голосования"
|
||||
variant="underlined"></v-text-field>
|
||||
<div class="flex-grow-1 flex-shrink-0">
|
||||
|
||||
<v-textarea v-model="form.description" :rules="[rules.required]" label="Описание"
|
||||
<v-textarea v-model="form.description" :rules="[rules.required]" label="Описание"
|
||||
|
||||
variant="outlined"></v-textarea>
|
||||
</div>
|
||||
variant="outlined"></v-textarea>
|
||||
</div>
|
||||
<v-divider></v-divider>
|
||||
<div class="flex-grow-0 flex-shrink-1">
|
||||
<div class="pt-2 text-overline text-grey">Дата и время:</div>
|
||||
<div class="d-flex justify-space-around">
|
||||
<div class="d-flex ga-3 align-center">
|
||||
<h6 class="text-subtitle-1 pt-2">начало:</h6>
|
||||
<date-select :datedefault="form.startDate" @returndate="returnstart" />
|
||||
<v-select v-model="selectedTimeStart" :items="timeOptions" density="compact" variant="plain"
|
||||
hide-details>
|
||||
<template v-slot:prepend-inner>
|
||||
<v-icon icon="mdi-timer" size="xsmall" color="red"></v-icon>
|
||||
</template>
|
||||
</v-select>
|
||||
<div class="pt-2 text-overline text-grey">Дата и время:</div>
|
||||
<div class="d-flex justify-space-around">
|
||||
<div class="d-flex ga-3 align-center">
|
||||
<h6 class="text-subtitle-1 pt-2">начало:</h6>
|
||||
<date-select :datedefault="form.startDate" @returndate="returnstart"/>
|
||||
<v-select v-model="selectedTimeStart" :items="timeOptions" density="compact" hide-details
|
||||
variant="plain">
|
||||
<template v-slot:prepend-inner>
|
||||
<v-icon color="red" icon="mdi-timer" size="xsmall"></v-icon>
|
||||
</template>
|
||||
</v-select>
|
||||
</div>
|
||||
<div class="d-flex ga-3 align-center">
|
||||
<h6 class="text-subtitle-1 pt-2">окончание:</h6>
|
||||
<date-select :datedefault="form.endDate" @returndate="returnend"/>
|
||||
<v-select v-model="selectedTimeEnd" :items="timeOptions" density="compact" hide-details
|
||||
outlined
|
||||
variant="plain">
|
||||
<template v-slot:prepend-inner>
|
||||
<v-icon color="red" icon="mdi-timer" size="xsmall"></v-icon>
|
||||
</template>
|
||||
</v-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex ga-3 align-center">
|
||||
<h6 class="text-subtitle-1 pt-2">окончание:</h6>
|
||||
<date-select :datedefault="form.endDate" @returndate="returnend" />
|
||||
<v-select v-model="selectedTimeEnd" :items="timeOptions" density="compact" outlined variant="plain"
|
||||
hide-details>
|
||||
<template v-slot:prepend-inner>
|
||||
<v-icon icon="mdi-timer" size="xsmall" color="red"></v-icon>
|
||||
</template>
|
||||
</v-select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</v-card-text>
|
||||
|
||||
@@ -78,184 +77,171 @@
|
||||
</v-stepper-window-item>
|
||||
|
||||
<!-- Создание опроса -->
|
||||
<v-stepper-window-item step="2" class="fill-height">
|
||||
<v-stepper-window-item class="fill-height" step="2">
|
||||
|
||||
<v-card flat class="fill-height d-flex flex-column">
|
||||
<v-card class="fill-height d-flex flex-column" flat>
|
||||
<v-card-title>Создание опроса:</v-card-title>
|
||||
<v-card-text style="max-height: 62vh; overflow-y: auto;">
|
||||
<transition-group name="list" tag="div">
|
||||
<div v-for="(question, index) in form.questions" :key="index" class="mb-4">
|
||||
<div class="d-flex">
|
||||
<v-text-field density="comfortable" v-model="question.text" :label="'Вопрос ' + (index + 1)"
|
||||
:rules="[rules.required]" variant="underlined">
|
||||
<template v-slot:append>
|
||||
<v-btn color="error" icon="mdi-delete" size="small" @click="removeQuestion(index)" />
|
||||
</template>
|
||||
|
||||
</v-text-field>
|
||||
</div>
|
||||
<v-file-input density="comfortable" v-model="question.image" accept="image/*"
|
||||
label="Картинка для вопроса" variant="outlined"></v-file-input>
|
||||
<v-divider></v-divider>
|
||||
<div class="py-2 text-overline text-grey">Настройки вопроса</div>
|
||||
<div class="v-row ">
|
||||
|
||||
<v-col cols="auto" class="align-self-center font-weight-bold py-0">
|
||||
Тип ответа
|
||||
</v-col>
|
||||
<v-col cols="3" class="py-0 align-self-center ">
|
||||
|
||||
<v-select density="compact" v-model="question.settings.choice" :items="questionTypes"
|
||||
@update:model-value="question.answers=[]"
|
||||
:list-props="{density:'compact'}"
|
||||
item-title="name" item-value="choice" label="" hide-details variant="outlined"></v-select>
|
||||
<!-- choice -->
|
||||
|
||||
</v-col>
|
||||
<v-spacer/>
|
||||
<v-col cols="auto" class="align-self-center font-weight-bold">
|
||||
Число возможных ответов
|
||||
</v-col>
|
||||
<v-col cols="1" class="">
|
||||
<v-text-field density="compact" v-model="question.settings.multiChoice"
|
||||
:rules="[rules.required && question.settings.multiChoice > 0]" hide-details type="number"
|
||||
min="1" variant="outlined">
|
||||
<template v-slot:prepend>
|
||||
|
||||
<div v-for="(question, index) in form.questions" :key="index" class="mb-4">
|
||||
<div class="d-flex">
|
||||
<!-- <v-text-field v-model="question.text" :label="'Вопрос ' + (index + 1)" :rules="[rules.required]"-->
|
||||
<!-- density="comfortable" variant="underlined">-->
|
||||
<v-text-field
|
||||
v-model="question.text"
|
||||
:label="'Вопрос ' + (index + 1)"
|
||||
density="comfortable"
|
||||
variant="underlined"
|
||||
:rules="[rules.required]"
|
||||
@input="updateQuest(index)"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<v-btn color="error" icon="mdi-delete" size="small" @click="removeQuestion(index)"/>
|
||||
</template>
|
||||
|
||||
</v-text-field>
|
||||
</v-col>
|
||||
</div>
|
||||
<div class="v-row">
|
||||
</div>
|
||||
</div>
|
||||
<v-file-input v-model="question.image" accept="image/*" density="comfortable"
|
||||
label="Картинка для вопроса" variant="outlined"></v-file-input>
|
||||
<v-divider></v-divider>
|
||||
<div class="py-2 text-overline text-grey">Настройки вопроса</div>
|
||||
<div class="v-row ">
|
||||
|
||||
<v-card-text class="px-0">
|
||||
<div v-if="question.settings.choice === 'free'">
|
||||
<transition-group name="list" tag="div">
|
||||
<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]"
|
||||
class="mr-4" variant="outlined" density="compact"></v-text-field>
|
||||
<v-file-input v-model="answer.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)">
|
||||
<v-col class="align-self-center font-weight-bold py-0" cols="auto">
|
||||
Тип ответа
|
||||
</v-col>
|
||||
<v-col class="py-0 align-self-center " cols="3">
|
||||
|
||||
</v-btn>
|
||||
<v-select v-model="question.settings.choice" :items="questionTypes" :list-props="{density:'compact'}"
|
||||
density="compact"
|
||||
hide-details
|
||||
item-title="name" item-value="choice" label="" variant="outlined"
|
||||
@update:model-value="question.answers=[]"></v-select>
|
||||
<!-- choice -->
|
||||
|
||||
</v-col>
|
||||
<v-spacer/>
|
||||
<v-col class="align-self-center font-weight-bold" cols="auto">
|
||||
Число возможных ответов
|
||||
</v-col>
|
||||
<v-col class="" cols="1">
|
||||
<v-text-field v-model="question.settings.multiChoice" :rules="[rules.required && question.settings.multiChoice > 0]"
|
||||
density="compact" hide-details
|
||||
min="1"
|
||||
type="number" variant="outlined">
|
||||
<template v-slot:prepend>
|
||||
|
||||
</template>
|
||||
</v-text-field>
|
||||
</v-col>
|
||||
</div>
|
||||
<div class="v-row">
|
||||
</div>
|
||||
|
||||
<v-card-text class="px-0">
|
||||
<div v-if="question.settings.choice === 'free'">
|
||||
<transition-group name="list" tag="div">
|
||||
<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]"
|
||||
class="mr-4" density="compact" variant="outlined"></v-text-field>
|
||||
<v-file-input v-model="answer.image" accept="image/*" dense density="compact" hide-details
|
||||
label="Картинка" variant="outlined"></v-file-input>
|
||||
<v-btn class="ms-1" color="error" icon="mdi-delete" size="small"
|
||||
@click="removeAnswer(index,ind)">
|
||||
</v-btn>
|
||||
</div>
|
||||
</transition-group>
|
||||
<div class="d-flex justify-start">
|
||||
<v-btn color="teal-darken-4" size="small" @click="addAnswer(index)">Добавить ответ</v-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div class="v-row">
|
||||
<v-radio-group v-model="question.settings.onlyDep" class="text-caption" inline>
|
||||
<template v-slot:label>
|
||||
<div class="text-body-2 font-weight-bold">Голосование по отделам:</div>
|
||||
</template>
|
||||
<v-radio v-for="x in onlyDepdict" :key="x.name" :value=x.value>
|
||||
<template v-slot:label>
|
||||
<div class="text-caption">{{ x.name }}</div>
|
||||
</template>
|
||||
</v-radio>
|
||||
</v-radio-group>
|
||||
</div>
|
||||
<v-autocomplete
|
||||
v-model="question.selectedEmployees"
|
||||
:items="allEmployeesgroupedbydep" class=" text-no-wrap"
|
||||
density="compact" item-title="fio" item-value="id" label="Выберите сотрудников" multiple
|
||||
variant="outlined"
|
||||
@update:model-value="(selected)=>question.answers=question.answers.filter(e=>selected.includes(e.text))"
|
||||
>
|
||||
<template #prepend-item>
|
||||
<v-checkbox :model-value="question.selectedEmployees.length===allEmployees.length"
|
||||
class="pa-0"
|
||||
label="Все"
|
||||
@update:model-value="handleSelectAll(question.selectedEmployees.length===allEmployees.length, index)"></v-checkbox>
|
||||
</template>
|
||||
<template #selection="{item}">
|
||||
<v-chip
|
||||
:prepend-avatar="checkremote(`${spravURL}${item.raw.login}.jpg`)"
|
||||
>
|
||||
|
||||
</transition-group>
|
||||
{{ item.raw.familyname }}
|
||||
</v-chip>
|
||||
</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
|
||||
|
||||
<div class="d-flex justify-start">
|
||||
<v-btn size="small" color="teal-darken-4" @click="addAnswer(index)">Добавить ответ</v-btn>
|
||||
:append-avatar="checkremote(`${spravURL}${data.item.raw.login}.jpg`)"
|
||||
density="compact"
|
||||
slim
|
||||
@click="onEmployeesChange(data.item.raw.id, index)"
|
||||
>
|
||||
<template #prepend>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<v-checkbox :model-value="question.selectedEmployees.includes(data.item.raw.id)"
|
||||
|
||||
<div class="v-row">
|
||||
|
||||
<v-radio-group class="text-caption" inline v-model="question.settings.onlyDep">
|
||||
<template v-slot:label>
|
||||
<div class="text-body-2 font-weight-bold">Голосование по отделам:</div>
|
||||
density="compact"
|
||||
hide-details></v-checkbox>
|
||||
</template>
|
||||
<v-radio v-for="x in onlyDepdict" :key="x.name" :value=x.value>
|
||||
<template v-slot:label>
|
||||
<div class="text-caption">{{ x.name }}</div>
|
||||
</template>
|
||||
</v-radio>
|
||||
</v-radio-group>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<v-autocomplete
|
||||
class=" text-no-wrap"
|
||||
v-model="question.selectedEmployees" :items="allEmployeesgroupedbydep"
|
||||
item-title="fio" item-value="id" label="Выберите сотрудников" multiple variant="outlined"
|
||||
density="compact"
|
||||
@update:model-value="(selected)=>question.answers=question.answers.filter(e=>selected.includes(e.text))"
|
||||
>
|
||||
<template #prepend-item>
|
||||
<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 #selection="{item}">
|
||||
<v-chip
|
||||
:prepend-avatar="checkremote(`${spravURL}${item.raw.login}.jpg`)"
|
||||
>
|
||||
|
||||
{{ item.raw.familyname }}</v-chip>
|
||||
</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>
|
||||
|
||||
|
||||
</template>
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</v-autocomplete>
|
||||
<transition-group name="list" tag="div">
|
||||
<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 :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="question.selectedEmployees.splice(ind,1); removeAnswer(index,ind)">
|
||||
|
||||
</v-btn>
|
||||
</v-col>
|
||||
<v-list-item-title class="text-third" v-text="data.item.raw.fio"></v-list-item-title>
|
||||
</v-list-item>
|
||||
</template>
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
<transition-group name="list" tag="div">
|
||||
<div v-for="(person, ind) in question.answers" :key="person"
|
||||
class="v-row align-center mb-4">
|
||||
<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>
|
||||
</v-col>
|
||||
<v-col class="py-0 d-flex" cols="5">
|
||||
<v-file-input v-model="person.image" accept="image/*" dense density="compact"
|
||||
hide-details
|
||||
label="Картинка" variant="outlined"></v-file-input>
|
||||
<v-btn class="ms-1" color="error" icon="mdi-delete" size="small"
|
||||
@click="question.selectedEmployees.splice(ind,1); removeAnswer(index,ind)">
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</div>
|
||||
</transition-group>
|
||||
</div>
|
||||
</transition-group>
|
||||
</div>
|
||||
</v-card-text>
|
||||
</div>
|
||||
</transition-group>
|
||||
</v-card-text>
|
||||
</div>
|
||||
</transition-group>
|
||||
<v-divider class="ma-2 pa-1"></v-divider>
|
||||
<div class="d-flex justify-center">
|
||||
|
||||
<v-btn size="small" color="orange-darken-4" @click="addQuestion">Добавить вопрос</v-btn>
|
||||
<v-btn color="orange-darken-4" size="small" @click="addQuestion">Добавить вопрос</v-btn>
|
||||
</div>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
@@ -267,39 +253,49 @@
|
||||
</v-stepper-window-item>
|
||||
|
||||
<!-- Подтверждение -->
|
||||
<v-stepper-window-item step="3" class="fill-height">
|
||||
<v-stepper-window-item class="fill-height" step="3">
|
||||
|
||||
<v-card flat class="fill-height d-flex flex-column">
|
||||
<v-card class="fill-height d-flex flex-column" flat>
|
||||
<v-card-title>Подтверждение</v-card-title>
|
||||
<v-card-text style="max-height: 62vh; overflow-y: auto;">
|
||||
<v-alert v-if="errorMessage" class="mb-4 " type="error">
|
||||
{{ errorMessage }}
|
||||
</v-alert>
|
||||
|
||||
<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>
|
||||
<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.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">
|
||||
<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>
|
||||
<p><strong>Вопрос {{ index + 1 }}:</strong> {{ question.text }} ({{ question.type }})</p>
|
||||
|
||||
<div v-if="question.settings.choice === 'free' && question.answers.length">
|
||||
<p><strong>Варианты ответов:</strong></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 }}
|
||||
<ul>
|
||||
<li v-for="(answer, answerIndex) in question.answers" :key="answerIndex">
|
||||
{{ answer.text }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<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>
|
||||
<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">
|
||||
@@ -308,12 +304,14 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</v-card>
|
||||
</v-card>
|
||||
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
||||
<v-btn :disabled="errorMessage!=''" color="teal-darken-4" size="medium" @click="saveVoting">Сохранить</v-btn>
|
||||
<v-btn :disabled="errorMessage!=''" color="teal-darken-4" size="medium" @click="saveVoting">
|
||||
Сохранить
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
|
||||
</v-card>
|
||||
@@ -329,18 +327,15 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { spravURL } from "@/utils/axios-api";
|
||||
import { createVote, getEmployees } from "@/utils/axios-api";
|
||||
import {computed, ref, watch} from "vue";
|
||||
import {createVote, getEmployees, spravURL} from "@/utils/axios-api";
|
||||
import DateSelect from "@/components/UI/date-select.vue";
|
||||
import { useAccountStore } from "@/store/AccountStore";
|
||||
import { checkremote } from "@/utils/universal_functions";
|
||||
import {checkremote} from "@/utils/universal_functions";
|
||||
|
||||
export default {
|
||||
components: { DateSelect },
|
||||
components: {DateSelect},
|
||||
emits: ['updating'],
|
||||
setup(props, { emit }) {
|
||||
const accountStore = useAccountStore();
|
||||
const user = accountStore.user;
|
||||
setup(props, {emit}) {
|
||||
const step = ref(0);
|
||||
const isVoteCreated = ref(false);
|
||||
const form = ref({
|
||||
@@ -356,7 +351,7 @@ export default {
|
||||
};
|
||||
|
||||
const currentQuestionIndex = ref(0);
|
||||
const questionTypes = [{ name: "Ввести вручную", choice: 'free' }, { name: "Выбрать сотрудника", choice: 'employee' }];
|
||||
const questionTypes = [{name: "Ввести вручную", choice: 'free'}, {name: "Выбрать сотрудника", choice: 'employee'}];
|
||||
|
||||
const groupedEmployees = ref([]);
|
||||
const allEmployees = computed(() => [
|
||||
@@ -369,10 +364,10 @@ export default {
|
||||
const currentQuestion = computed(() =>
|
||||
form.value.questions[currentQuestionIndex.value] || null
|
||||
);
|
||||
const allEmployeesgroupedbydep = computed(()=>{
|
||||
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)
|
||||
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
|
||||
@@ -382,7 +377,6 @@ export default {
|
||||
|
||||
|
||||
const handleSelectAll = (selected, index) => {
|
||||
console.log(selected, index);
|
||||
if (!selected) {
|
||||
form.value.questions[index].answers = groupedEmployees.value.map((employee) => ({
|
||||
text: employee.id,
|
||||
@@ -391,7 +385,7 @@ export default {
|
||||
form.value.questions[index].selectedEmployees = groupedEmployees.value.map(employee => employee.id);
|
||||
} else {
|
||||
form.value.questions[index].answers = [];
|
||||
form.value.questions[index].selectedEmployees=[]
|
||||
form.value.questions[index].selectedEmployees = []
|
||||
}
|
||||
};
|
||||
|
||||
@@ -400,7 +394,7 @@ export default {
|
||||
const addQuestion = () => {
|
||||
form.value.questions.push({
|
||||
text: "",
|
||||
settings: { choice: "free", multiChoice: 1, onlyDep: null },
|
||||
settings: {choice: "free", multiChoice: 1, onlyDep: null},
|
||||
image: null,
|
||||
answers: [],
|
||||
selectedEmployees: []
|
||||
@@ -415,23 +409,25 @@ export default {
|
||||
}
|
||||
};
|
||||
|
||||
const updateQuest = (index) => {
|
||||
quests[index] = form.value.questions[index].text.length > 0;
|
||||
};
|
||||
|
||||
const addAnswer = (index) => {
|
||||
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) => {
|
||||
// if (currentQuestion.value) {
|
||||
form.value.questions[index].answers.splice(ind, 1)
|
||||
// currentQuestion.value.answers.splice(index, 1);
|
||||
// }
|
||||
const removeAnswer = (index, ind) => {
|
||||
form.value.questions[index].answers.splice(ind, 1)
|
||||
};
|
||||
|
||||
const errorMessage = ref("");
|
||||
|
||||
const saveVoting = async () => {
|
||||
if (!form.value.title || !form.value.description || form.value.questions.length < 1) {
|
||||
const hasEmptyQuestions = quests.value.includes(false);
|
||||
if (!form.value.title || !form.value.description || form.value.questions.length < 1 || hasEmptyQuestions) {
|
||||
errorMessage.value = "Все обязательные поля должны быть заполнены";
|
||||
return;
|
||||
}
|
||||
@@ -439,12 +435,13 @@ export default {
|
||||
const response = await createVote(form.value);
|
||||
console.log("Голосование успешно создано:", response);
|
||||
isVoteCreated.value = true;
|
||||
emit('updating', 'active')
|
||||
emit('updating', 'active');
|
||||
} catch (error) {
|
||||
console.error("Ошибка при создании голосования:", error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const resetForm = () => {
|
||||
form.value = {
|
||||
title: "",
|
||||
@@ -457,27 +454,42 @@ export default {
|
||||
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 minutes = i % 2 === 0 ? "00" : "30";
|
||||
return `${hours}:${minutes}`;
|
||||
});
|
||||
|
||||
const selectedTimeStart = ref(
|
||||
`${(form.value.startDate.getHours()+1).toString().padStart(2, "0")}:00`
|
||||
`${(form.value.startDate.getHours() + 1).toString().padStart(2, "0")}:00`
|
||||
);
|
||||
|
||||
const selectedTimeEnd = ref(
|
||||
`${(form.value.endDate.getHours()+1).toString().padStart(2, "0")}:00`
|
||||
`${(form.value.endDate.getHours() + 1).toString().padStart(2, "0")}:00`
|
||||
);
|
||||
|
||||
watch(form.value, () => {
|
||||
if (!form.value.title || !form.value.description || form.value.questions < 1) {
|
||||
const hasEmptyQuestions = quests.value.includes(false);
|
||||
if (!form.value.title || !form.value.description || form.value.questions.length < 1 || hasEmptyQuestions) {
|
||||
errorMessage.value = "Все обязательные поля должны быть заполнены";
|
||||
} else {
|
||||
errorMessage.value = "";
|
||||
}
|
||||
})
|
||||
}, { deep: true });
|
||||
|
||||
const updateQuests = () => {
|
||||
quests.value = form.value.questions.map((q) => !!q.text.trim());
|
||||
};
|
||||
|
||||
watch(() => form.value.questions, updateQuests, { deep: true });
|
||||
|
||||
watch(() => form.value.questions, (newQuestions) => {
|
||||
const hasEmptyQuestions = newQuestions.some((q) => !q.text || q.text.trim() === "");
|
||||
errorMessage.value = hasEmptyQuestions
|
||||
? "Все вопросы должны быть заполнены"
|
||||
: "";
|
||||
}, { deep: true });
|
||||
|
||||
|
||||
watch(selectedTimeStart, () => {
|
||||
updateStartDate()
|
||||
@@ -503,23 +515,30 @@ export default {
|
||||
form.value.endDate = dates
|
||||
}
|
||||
|
||||
const selectedEmployees = ref([]);
|
||||
|
||||
const onEmployeesChange = (selected, index) => {
|
||||
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{
|
||||
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 });
|
||||
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}]
|
||||
|
||||
const quests = computed(() =>
|
||||
form.value.questions.map((question) => question.text.length > 0)
|
||||
);
|
||||
|
||||
return {
|
||||
quests,
|
||||
updateQuest,
|
||||
onlyDepdict,
|
||||
allEmployeesgroupedbydep,
|
||||
onEmployeesChange,
|
||||
@@ -555,10 +574,12 @@ export default {
|
||||
.v-input--horizontal .v-input__prepend {
|
||||
margin-inline-end: 4px;
|
||||
}
|
||||
|
||||
.list-enter-active,
|
||||
.list-leave-active {
|
||||
transition: all 0.5s ease;
|
||||
}
|
||||
|
||||
.list-enter-from,
|
||||
.list-leave-to {
|
||||
opacity: 0;
|
||||
|
||||
@@ -30,10 +30,12 @@
|
||||
</v-tabs>
|
||||
<v-tabs-window v-model="activeTab">
|
||||
<v-tabs-window-item v-for="(question, questionIndex) in questions" :key="questionIndex">
|
||||
|
||||
<v-row v-if="question.settings.onlyDep">
|
||||
<v-col v-for="(winner, department) in getWinnersByDepartment(question)" :key="department">
|
||||
<v-card>
|
||||
<v-col
|
||||
v-for="(winner, department) in getWinnersByDepartment(question).winnersByDepartment"
|
||||
:key="department"
|
||||
>
|
||||
<v-card class="cursor-pointer" @click="opendialogWinn(department, getWinnersByDepartment(question).groupedByDepartment[department])" style="max-height: 50vh; overflow-y: auto;">
|
||||
<v-card-title>
|
||||
<strong class="text-teal-darken-4">{{ department }}</strong>
|
||||
</v-card-title>
|
||||
@@ -60,14 +62,15 @@
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-card class="mb-4">
|
||||
<v-card-title class="text-teal-darken-3">Топ {{ getTopResults(question).length }}</v-card-title>
|
||||
<v-card-title class="text-teal-darken-3">Распределение голосов:</v-card-title>
|
||||
<v-card-text>
|
||||
<v-list style="max-height: 45vh; overflow-y: auto;">
|
||||
<v-list-item
|
||||
v-for="(answer, answerIndex) in getTopResults(question)"
|
||||
v-for="(answer, answerIndex) in getTopResults(question).filter(el => el.count > 0)"
|
||||
:key="answerIndex"
|
||||
>
|
||||
<p>
|
||||
<strong class="mr-4">{{ answerIndex + 1 }}.</strong>
|
||||
<v-avatar v-if="answer.file === null && answer.employee"
|
||||
:image="checkremote(`${spravURL()}${answer.employee.login}.jpg`)"
|
||||
class="cursor-pointer"
|
||||
@@ -105,10 +108,12 @@
|
||||
</v-row>
|
||||
</v-tabs-window-item>
|
||||
<v-tabs-window-item>
|
||||
<NonVoteSad v-if="Object.keys(groupedByDepartment).length > 0" />
|
||||
<v-card-title v-if="Object.keys(groupedByDepartment).length > 0" class="text-red-darken-3">Не голосовали:</v-card-title>
|
||||
<NonVoteSad v-if="nonVoters.length > 0"/>
|
||||
<v-card-title v-if="nonVoters.length > 0" class="text-red-darken-3">Число сотрудников, которые не проголосовали
|
||||
<strong>{{ nonVoters.length }}</strong>
|
||||
</v-card-title>
|
||||
<v-card-item style="max-height: 50vh; overflow-y: auto;">
|
||||
<NonVoteHappy v-if="Object.keys(groupedByDepartment).length < 1"/>
|
||||
<NonVoteHappy v-if="nonVoters.length < 1"/>
|
||||
<template v-for="(voters, department) in groupedByDepartment" :key="department">
|
||||
<v-list-item-title class="text-teal-darken-4">{{ department }}</v-list-item-title>
|
||||
<v-list-item v-for="(voter, voterIndex) in voters" :key="`${department}-${voterIndex}`">
|
||||
@@ -119,9 +124,9 @@
|
||||
@click="userCardIndex = `${department}-${voterIndex}`"
|
||||
/>
|
||||
<InfoUserCard
|
||||
:author="voter"
|
||||
:opendialog="userCardIndex === `${department}-${voterIndex}`"
|
||||
@update:opendialog="userCardIndex = $event ? `${department}-${voterIndex}` : null"
|
||||
:author="voter"
|
||||
/>
|
||||
<strong class="ml-4">{{ voter.fio }}</strong>
|
||||
</p>
|
||||
@@ -150,6 +155,60 @@
|
||||
</v-card-item>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
<v-dialog v-model="dialogWinner" max-width="800">
|
||||
<v-card>
|
||||
<v-card-title class="d-flex">
|
||||
<strong class="text-teal-darken-4">Результаты голосования: {{ activeDepartment }}</strong>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="red-darken-1" density="compact" icon="mdi-close-thick" size="small" @click="dialogWinner=false"/>
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<v-list>
|
||||
<v-list-item
|
||||
v-for="(answer, index) in activeDepartmentResults.filter(el => el.count > 0)"
|
||||
:key="index"
|
||||
>
|
||||
|
||||
<p>
|
||||
<strong class="mr-4">{{ index + 1 }}.</strong>
|
||||
<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 }}
|
||||
<template v-if="answer.employee">
|
||||
<br/>
|
||||
<small>Отдел: {{ answer.employee ? answer.employee.department : '' }}</small>
|
||||
<br/>
|
||||
<small>Должность: {{ answer.employee ? answer.employee.post : '' }}</small>
|
||||
</template>
|
||||
</p>
|
||||
|
||||
<v-progress-linear
|
||||
:model-value="getPercentage(answer.count, questions[index])"
|
||||
color="teal-darken-4"
|
||||
height="13"
|
||||
rounded
|
||||
striped
|
||||
>
|
||||
<template v-slot:default="{ value }">
|
||||
<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>
|
||||
</template>
|
||||
</v-progress-linear>
|
||||
|
||||
</v-list-item>
|
||||
|
||||
</v-list>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -190,6 +249,17 @@ export default {
|
||||
const description = props.data.description;
|
||||
const nonVoters = props.data.nonvoting;
|
||||
|
||||
const activeDepartment = ref(null);
|
||||
const activeDepartmentResults = ref([]);
|
||||
const dialog = ref(false);
|
||||
const dialogWinner = ref(false);
|
||||
|
||||
const opendialogWinn = (department, results) => {
|
||||
activeDepartment.value = department;
|
||||
activeDepartmentResults.value = results;
|
||||
dialogWinner.value = true;
|
||||
};
|
||||
|
||||
const getWinner = (question) => {
|
||||
return question.answers.reduce(
|
||||
(max, answer) => (answer.count > max.count ? answer : max),
|
||||
@@ -198,7 +268,7 @@ export default {
|
||||
};
|
||||
|
||||
const getTopResults = (question) => {
|
||||
return [...question.answers].sort((a, b) => b.count - a.count).slice(0, 10);
|
||||
return [...question?.answers].sort((a, b) => b.count - a.count);
|
||||
};
|
||||
|
||||
const truncateText = (text, maxLength) => {
|
||||
@@ -225,7 +295,7 @@ export default {
|
||||
};
|
||||
|
||||
const activepick = ref(null)
|
||||
const dialog = ref(false)
|
||||
// const dialog = ref(false)
|
||||
const opendialog = (val) => {
|
||||
dialog.value = true
|
||||
activepick.value = val
|
||||
@@ -244,11 +314,18 @@ export default {
|
||||
|
||||
// Сортируем департаменты по id_dict_department
|
||||
const sortedDepartments = Object.keys(departments).sort((a, b) => {
|
||||
const idA = nonVoters.find(voter => voter.department === a)?.id_dict_department;
|
||||
const idB = nonVoters.find(voter => voter.department === b)?.id_dict_department;
|
||||
const idA = nonVoters.find(voter => voter.department === a)?.id_dict_department || 0;
|
||||
const idB = nonVoters.find(voter => voter.department === b)?.id_dict_department || 0;
|
||||
return idA - idB;
|
||||
});
|
||||
|
||||
// Сортируем сотрудников внутри каждого департамента по id_dict_position
|
||||
sortedDepartments.forEach(department => {
|
||||
departments[department].sort((voterA, voterB) => {
|
||||
return (voterA.id_dict_position || 0) - (voterB.id_dict_position || 0);
|
||||
});
|
||||
});
|
||||
|
||||
// Возвращаем отсортированные департаменты с пользователями
|
||||
const sortedGroupedByDepartment = {};
|
||||
sortedDepartments.forEach(department => {
|
||||
@@ -263,7 +340,7 @@ export default {
|
||||
const getWinnersByDepartment = (question) => {
|
||||
// Группируем ответы по департаментам
|
||||
const groupedByDepartment = question.answers.reduce((groups, answer) => {
|
||||
const department = answer.employee?.department || 'Без отдела'; // Отдел или 'Без отдела' если нет
|
||||
const department = answer.employee?.department;
|
||||
if (!groups[department]) {
|
||||
groups[department] = [];
|
||||
}
|
||||
@@ -282,11 +359,15 @@ export default {
|
||||
winnersByDepartment[department] = winner;
|
||||
}
|
||||
|
||||
return winnersByDepartment;
|
||||
return { groupedByDepartment, winnersByDepartment };
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
opendialogWinn,
|
||||
dialogWinner,
|
||||
activeDepartmentResults,
|
||||
activeDepartment,
|
||||
getWinnersByDepartment,
|
||||
userCardIndex,
|
||||
activepick,
|
||||
|
||||
@@ -140,7 +140,7 @@ const routes = [
|
||||
ico: "mdi-account",
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
path: "/vote",
|
||||
name: "VoteHomePage",
|
||||
@@ -177,11 +177,6 @@ const routes = [
|
||||
ico: "mdi-account",
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
path: '/secret',
|
||||
name: 'Secret Page',
|
||||
|
||||
Reference in new issue
Block a user