a
This commit is contained in:
1 parent
5d74846942
commit
4a9524cb57
2 files changed
+229
-315
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-row class="pt-2">
|
<v-row class="pt-2 mx-1">
|
||||||
<template v-if="isVoteCreated">
|
<template v-if="isVoteCreated">
|
||||||
<v-card class="text-center pa-8" flat>
|
<v-card class="text-center pa-8" flat>
|
||||||
<v-icon color="success" size="48">mdi-check-circle</v-icon>
|
<v-icon color="success" size="48">mdi-check-circle</v-icon>
|
||||||
@@ -8,309 +8,224 @@
|
|||||||
</v-card>
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div class="v-col">
|
<div class="v-col ">
|
||||||
<v-stepper v-model="step" editable>
|
<v-stepper v-model="step" editable>
|
||||||
<v-stepper-header>
|
<v-stepper-header>
|
||||||
<v-stepper-item :complete="step > 0" step="1">Основная информация</v-stepper-item>
|
<v-stepper-item :complete="step > 0" step="1">Основная информация</v-stepper-item>
|
||||||
<v-divider></v-divider>
|
<v-divider></v-divider>
|
||||||
<v-stepper-item :complete="step > 1" step="2">Создание опроса</v-stepper-item>
|
<v-stepper-item :complete="step > 1" step="2">Создание опроса</v-stepper-item>
|
||||||
<v-divider></v-divider>
|
<v-divider></v-divider>
|
||||||
<v-stepper-item :complete="step > 2" step="3">Подтверждение</v-stepper-item>
|
<v-stepper-item :complete="step > 2" step="3">Подтверждение</v-stepper-item>
|
||||||
</v-stepper-header>
|
</v-stepper-header>
|
||||||
|
|
||||||
<v-stepper-window>
|
<v-stepper-window class="">
|
||||||
<!-- Основная информация -->
|
<!-- Основная информация -->
|
||||||
<v-stepper-window-item step="1">
|
<v-stepper-window-item step="1">
|
||||||
<v-card flat>
|
<v-card flat>
|
||||||
<v-card-title>Основная информация</v-card-title>
|
<v-card-title>Основная информация</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-text-field
|
<v-text-field v-model="form.title" :rules="[rules.required]" label="Название голосования"
|
||||||
v-model="form.title"
|
variant="underlined"></v-text-field>
|
||||||
:rules="[rules.required]"
|
<v-textarea v-model="form.description" :rules="[rules.required]" label="Описание"
|
||||||
label="Название голосования"
|
variant="outlined"></v-textarea>
|
||||||
variant="underlined"
|
|
||||||
></v-text-field>
|
|
||||||
<v-textarea
|
|
||||||
v-model="form.description"
|
|
||||||
:rules="[rules.required]"
|
|
||||||
label="Описание"
|
|
||||||
variant="outlined"
|
|
||||||
></v-textarea>
|
|
||||||
<v-divider></v-divider>
|
|
||||||
<div class="pt-2">Дата и время:</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>
|
|
||||||
<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>
|
|
||||||
</v-card-text>
|
|
||||||
<v-card-actions>
|
|
||||||
<v-btn color="teal-darken-4" size="medium" @click="step = 1">Далее</v-btn>
|
|
||||||
</v-card-actions>
|
|
||||||
</v-card>
|
|
||||||
</v-stepper-window-item>
|
|
||||||
|
|
||||||
<!-- Создание опроса -->
|
|
||||||
<v-stepper-window-item step="2">
|
|
||||||
<v-card flat>
|
|
||||||
<v-card-title>Создание опроса</v-card-title>
|
|
||||||
<v-card-text>
|
|
||||||
<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="Картинка для вопроса"
|
|
||||||
outlined
|
|
||||||
></v-file-input>
|
|
||||||
<v-divider></v-divider>
|
<v-divider></v-divider>
|
||||||
<div>Настройки вопроса</div>
|
<div class="pt-2">Дата и время:</div>
|
||||||
<div class="v-row px-2">
|
<div class="d-flex justify-space-around">
|
||||||
|
<div class="d-flex ga-3 align-center">
|
||||||
<v-col class="align-self-center font-weight-bold">
|
<h6 class="text-subtitle-1 pt-2">начало:</h6>
|
||||||
Тип ответа
|
<date-select :datedefault="form.startDate" @returndate="returnstart" />
|
||||||
</v-col>
|
<v-select v-model="selectedTimeStart" :items="timeOptions" density="compact" variant="plain"
|
||||||
<v-col cols="3"
|
hide-details>
|
||||||
|
<template v-slot:prepend-inner>
|
||||||
>
|
<v-icon icon="mdi-timer" size="xsmall" color="red"></v-icon>
|
||||||
|
|
||||||
<v-select
|
|
||||||
density="compact"
|
|
||||||
v-model="question.settings.type"
|
|
||||||
:items="questionTypes"
|
|
||||||
label=""
|
|
||||||
hide-details
|
|
||||||
|
|
||||||
|
|
||||||
></v-select>
|
|
||||||
</v-col>
|
|
||||||
</div>
|
|
||||||
<div class="v-row">
|
|
||||||
<v-col class="align-self-center font-weight-bold">
|
|
||||||
Число возможных ответов
|
|
||||||
</v-col>
|
|
||||||
<v-col cols="2">
|
|
||||||
<v-text-field
|
|
||||||
density="compact"
|
|
||||||
v-model="question.settings.multiChoice"
|
|
||||||
:rules="[rules.required && question.settings.multiChoice > 0]"
|
|
||||||
hide-details
|
|
||||||
type="number"
|
|
||||||
min="1"
|
|
||||||
class="v-col-auto"
|
|
||||||
|
|
||||||
>
|
|
||||||
<template v-slot:prepend>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
</v-text-field>
|
|
||||||
</v-col>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<v-card-text>
|
|
||||||
<div v-if="question.settings.type === 'Ввести вручную'">
|
|
||||||
<div
|
|
||||||
v-for="(answer, index) in question.answers"
|
|
||||||
:key="index"
|
|
||||||
class="d-flex align-start mb-4"
|
|
||||||
>
|
|
||||||
<v-text-field
|
|
||||||
v-model="answer.text"
|
|
||||||
:label="'Ответ ' + (index + 1)"
|
|
||||||
:rules="[rules.required]"
|
|
||||||
class="mr-4"
|
|
||||||
outlined
|
|
||||||
></v-text-field>
|
|
||||||
<v-file-input
|
|
||||||
v-model="answer.image"
|
|
||||||
accept="image/*"
|
|
||||||
dense
|
|
||||||
hide-details
|
|
||||||
label="Картинка"
|
|
||||||
outlined
|
|
||||||
></v-file-input>
|
|
||||||
<v-btn color="error" @click="removeAnswer(index)">
|
|
||||||
<v-icon>mdi-delete</v-icon>
|
|
||||||
</v-btn>
|
|
||||||
</div>
|
|
||||||
<v-btn color="teal-darken-4" @click="addAnswer">Добавить ответ</v-btn>
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
<v-switch
|
|
||||||
color="teal-darken-4"
|
|
||||||
v-model="question.settings.onlyDep"
|
|
||||||
:label="`Голосование по отделам: ${question.settings.onlyDep ? 'да' : 'нет'}`"
|
|
||||||
hide-details
|
|
||||||
inset
|
|
||||||
></v-switch>
|
|
||||||
<v-switch
|
|
||||||
color="teal-darken-4"
|
|
||||||
v-model="question.settings.withoutDirector"
|
|
||||||
:label="`Без начальства : ${question.settings.withoutDirector ? 'да' : 'нет'}`"
|
|
||||||
hide-details
|
|
||||||
inset
|
|
||||||
></v-switch>
|
|
||||||
<v-autocomplete
|
|
||||||
clearable
|
|
||||||
v-model="question.selectedEmployees"
|
|
||||||
:items="allEmployees"
|
|
||||||
item-title="fio"
|
|
||||||
item-value="id"
|
|
||||||
label="Выберите сотрудников"
|
|
||||||
multiple
|
|
||||||
outlined
|
|
||||||
:value-comparator="(a, b) => a === b"
|
|
||||||
@update:model-value="onEmployeesChange"
|
|
||||||
>
|
|
||||||
<template #prepend-item>
|
|
||||||
<v-checkbox
|
|
||||||
v-model="isAllSelected"
|
|
||||||
label="Все"
|
|
||||||
@change="() => handleSelectAll(['all'])"
|
|
||||||
></v-checkbox>
|
|
||||||
</template>
|
</template>
|
||||||
</v-autocomplete>
|
</v-select>
|
||||||
<div
|
</div>
|
||||||
v-for="(person, index) in question.answers"
|
<div class="d-flex ga-3 align-center">
|
||||||
:key="person"
|
<h6 class="text-subtitle-1 pt-2">окончание:</h6>
|
||||||
class="d-flex align-center mb-4"
|
<date-select :datedefault="form.endDate" @returndate="returnend" />
|
||||||
>
|
<v-select v-model="selectedTimeEnd" :items="timeOptions" density="compact" outlined variant="plain"
|
||||||
<v-chip>{{ findEmployeeById(person.text)?.fio }}</v-chip>
|
hide-details>
|
||||||
<v-file-input
|
<template v-slot:prepend-inner>
|
||||||
v-model="person.image"
|
<v-icon icon="mdi-timer" size="xsmall" color="red"></v-icon>
|
||||||
accept="image/*"
|
</template>
|
||||||
class="ml-4"
|
</v-select>
|
||||||
dense
|
</div>
|
||||||
hide-details
|
</div>
|
||||||
label="Картинка"
|
</v-card-text>
|
||||||
outlined
|
<v-card-actions>
|
||||||
></v-file-input>
|
<v-btn color="teal-darken-4" size="medium" @click="step = 1">Далее</v-btn>
|
||||||
<v-btn color="error" @click="removeEmployee(index)">
|
</v-card-actions>
|
||||||
<v-icon>mdi-delete</v-icon>
|
</v-card>
|
||||||
</v-btn>
|
</v-stepper-window-item>
|
||||||
|
|
||||||
|
<!-- Создание опроса -->
|
||||||
|
<v-stepper-window-item step="2">
|
||||||
|
<v-card flat class="h-100 ">
|
||||||
|
<v-card-title>Создание опроса:</v-card-title>
|
||||||
|
<v-card-text>
|
||||||
|
<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">Настройки вопроса</div>
|
||||||
|
<div class="v-row ">
|
||||||
|
|
||||||
|
<v-col class="align-self-center font-weight-bold py-0">
|
||||||
|
Тип ответа
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="3" class="py-0">
|
||||||
|
|
||||||
|
<v-select density="compact" v-model="question.settings.choice" :items="questionTypes"
|
||||||
|
item-title="name" item-value="choice" label="" hide-details variant="outlined"></v-select>
|
||||||
|
<!-- choice -->
|
||||||
|
</v-col>
|
||||||
|
</div>
|
||||||
|
<div class="v-row">
|
||||||
|
<v-col class="align-self-center font-weight-bold">
|
||||||
|
Число возможных ответов
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="2" 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>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
</v-text-field>
|
||||||
|
</v-col>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<v-card-text class="px-0">
|
||||||
|
<div v-if="question.settings.choice === 'free'">
|
||||||
|
<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-btn>
|
||||||
|
</div>
|
||||||
|
<v-btn color="teal-darken-4" @click="addAnswer(index)">Добавить ответ</v-btn>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div v-else>
|
||||||
</v-card-text>
|
<div class="v-row">
|
||||||
</div>
|
<v-switch color="teal-darken-4" v-model="question.settings.onlyDep"
|
||||||
<v-btn color="teal-darken-4" @click="addQuestion">Добавить вопрос</v-btn>
|
:label="`Голосование по отделам: ${question.settings.onlyDep ? 'да ' : 'нет'}`" hide-details
|
||||||
</v-card-text>
|
class="v-col-auto"></v-switch>
|
||||||
<v-card-actions>
|
<v-switch color="teal-darken-4" v-model="question.settings.withoutDirector"
|
||||||
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
:label="`Без начальства : ${question.settings.withoutDirector ? 'да ' : 'нет'}`" hide-details
|
||||||
<v-btn color="teal-darken-4" size="medium" @click="step = 2">Далее</v-btn>
|
class="v-col-auto"></v-switch>
|
||||||
</v-card-actions>
|
|
||||||
</v-card>
|
|
||||||
</v-stepper-window-item>
|
|
||||||
|
|
||||||
<!-- Подтверждение -->
|
|
||||||
<v-stepper-window-item step="3">
|
|
||||||
<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 }}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div v-if="question.settings.type === 'Выбрать сотрудника' && question.answers.length">
|
|
||||||
<p><strong>Выбранные сотрудники:</strong></p>
|
|
||||||
<ul>
|
|
||||||
<li
|
|
||||||
v-for="employeeId in question.answers"
|
|
||||||
:key="employeeId"
|
|
||||||
>
|
|
||||||
{{ findEmployeeById(employeeId.text).fio }}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</v-card-text>
|
|
||||||
<v-card-actions>
|
|
||||||
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
|
||||||
<v-btn color="teal-darken-4" size="medium" @click="saveVoting">Сохранить</v-btn>
|
|
||||||
</v-card-actions>
|
|
||||||
<v-alert v-if="errorMessage" class="mb-4" type="error">
|
|
||||||
{{ errorMessage }}
|
|
||||||
</v-alert>
|
|
||||||
</v-card>
|
|
||||||
</v-stepper-window-item>
|
|
||||||
|
|
||||||
</v-stepper-window>
|
</div>
|
||||||
</v-stepper>
|
{{ question.selectedEmployees }}
|
||||||
</div>
|
<v-autocomplete clearable v-model="question.selectedEmployees" :items="allEmployees"
|
||||||
|
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)">
|
||||||
|
<template #prepend-item>
|
||||||
|
<v-checkbox :value="question.selectedEmployees.length==allEmployees.length" label="Все"
|
||||||
|
@change="() => handleSelectAll(question.selectedEmployees.length==allEmployees.length)"></v-checkbox>
|
||||||
|
</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>
|
||||||
|
<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)">
|
||||||
|
|
||||||
|
</v-btn>
|
||||||
|
</v-col>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</v-card-text>
|
||||||
|
</div>
|
||||||
|
<v-btn color="teal-darken-4" @click="addQuestion">Добавить вопрос</v-btn>
|
||||||
|
</v-card-text>
|
||||||
|
<v-card-actions>
|
||||||
|
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
||||||
|
<v-btn color="teal-darken-4" size="medium" @click="step = 2">Далее</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
|
</v-stepper-window-item>
|
||||||
|
|
||||||
|
<!-- Подтверждение -->
|
||||||
|
<v-stepper-window-item step="3">
|
||||||
|
<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 }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div v-if="question.settings.type === 'Выбрать сотрудника' && question.answers.length">
|
||||||
|
<p><strong>Выбранные сотрудники:</strong></p>
|
||||||
|
<ul>
|
||||||
|
<li v-for="employeeId in question.answers" :key="employeeId">
|
||||||
|
{{ findEmployeeById(employeeId.text).fio }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</v-card-text>
|
||||||
|
<v-card-actions>
|
||||||
|
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
||||||
|
<v-btn color="teal-darken-4" size="medium" @click="saveVoting">Сохранить</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
<v-alert v-if="errorMessage" class="mb-4" type="error">
|
||||||
|
{{ errorMessage }}
|
||||||
|
</v-alert>
|
||||||
|
</v-card>
|
||||||
|
</v-stepper-window-item>
|
||||||
|
|
||||||
|
</v-stepper-window>
|
||||||
|
</v-stepper>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</v-row>
|
</v-row>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {computed, ref, watch} from "vue";
|
import { computed, ref, watch } from "vue";
|
||||||
import {createVote, getEmployees} from "@/utils/axios-api";
|
import { createVote, getEmployees } from "@/utils/axios-api";
|
||||||
import DateSelect from "@/components/UI/date-select.vue";
|
import DateSelect from "@/components/UI/date-select.vue";
|
||||||
import {useAccountStore} from "@/store/AccountStore";
|
import { useAccountStore } from "@/store/AccountStore";
|
||||||
|
|
||||||
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);
|
||||||
@@ -328,7 +243,7 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const currentQuestionIndex = ref(0);
|
const currentQuestionIndex = ref(0);
|
||||||
const questionTypes = ["Ввести вручную", "Выбрать сотрудника"];
|
const questionTypes = [{ name: "Ввести вручную", choice: 'free' }, { name: "Выбрать сотрудника", choice: 'employee' }];
|
||||||
|
|
||||||
const groupedEmployees = ref([]);
|
const groupedEmployees = ref([]);
|
||||||
const allEmployees = computed(() => [
|
const allEmployees = computed(() => [
|
||||||
@@ -345,20 +260,18 @@ export default {
|
|||||||
const findEmployeeById = (id) =>
|
const findEmployeeById = (id) =>
|
||||||
groupedEmployees.value.find((employee) => employee.id === id) || {};
|
groupedEmployees.value.find((employee) => employee.id === id) || {};
|
||||||
|
|
||||||
const removeEmployee = (index) => {
|
|
||||||
currentQuestion.value.answers.splice(index, 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSelectAll = (selected) => {
|
const handleSelectAll = (selected) => {
|
||||||
if (selected.includes("all")) {
|
console.log(selected);
|
||||||
form.value.questions[currentQuestionIndex.value].answers = groupedEmployees.value.map((employee) => ({
|
// if (selected.includes("all")) {
|
||||||
text: employee.id,
|
// form.value.questions[currentQuestionIndex.value].answers = groupedEmployees.value.map((employee) => ({
|
||||||
image: null,
|
// text: employee.id,
|
||||||
}));
|
// image: null,
|
||||||
selectedEmployees.value = groupedEmployees.value.map(employee => employee.id);
|
// }));
|
||||||
} else {
|
// selectedEmployees.value = groupedEmployees.value.map(employee => employee.id);
|
||||||
form.value.questions[currentQuestionIndex.value].answers = selected.map((id) => ({ text: id, image: null }));
|
// } else {
|
||||||
}
|
// form.value.questions[currentQuestionIndex.value].answers = selected.map((id) => ({ text: id, image: null }));
|
||||||
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
const isAllSelected = computed(() => currentQuestion.value.answers.length === groupedEmployees.value.length);
|
const isAllSelected = computed(() => currentQuestion.value.answers.length === groupedEmployees.value.length);
|
||||||
@@ -366,7 +279,7 @@ export default {
|
|||||||
const addQuestion = () => {
|
const addQuestion = () => {
|
||||||
form.value.questions.push({
|
form.value.questions.push({
|
||||||
text: "",
|
text: "",
|
||||||
settings: { type: "Ввести вручную", multiChoice: 1, onlyDep: false, withoutDirector: false },
|
settings: { choice: "free", multiChoice: 1, onlyDep: false, withoutDirector: false },
|
||||||
image: null,
|
image: null,
|
||||||
answers: [],
|
answers: [],
|
||||||
selectedEmployees: []
|
selectedEmployees: []
|
||||||
@@ -381,16 +294,17 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const addAnswer = () => {
|
const addAnswer = (index) => {
|
||||||
if (currentQuestion.value) {
|
if (currentQuestion.value) {
|
||||||
form.value.questions[currentQuestionIndex.value].answers.push({ text: "", image: null });
|
form.value.questions[index].answers.push({ text: "", image: null });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeAnswer = (index) => {
|
const removeAnswer = (index,ind) => {
|
||||||
if (currentQuestion.value) {
|
// if (currentQuestion.value) {
|
||||||
currentQuestion.value.answers.splice(index, 1);
|
form.value.questions[index].answers.splice(ind, 1)
|
||||||
}
|
// currentQuestion.value.answers.splice(index, 1);
|
||||||
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
const errorMessage = ref("");
|
const errorMessage = ref("");
|
||||||
@@ -422,7 +336,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}`;
|
||||||
@@ -474,10 +388,11 @@ export default {
|
|||||||
form.value.endDate = dates
|
form.value.endDate = dates
|
||||||
}
|
}
|
||||||
|
|
||||||
// const selectedEmployees = ref([]);
|
const selectedEmployees = ref([]);
|
||||||
|
|
||||||
const onEmployeesChange = (selected) => {
|
const onEmployeesChange = (selected, index) => {
|
||||||
form.value.questions[currentQuestionIndex.value].answers = selected.map((id) => ({ text: id, image: null }));
|
|
||||||
|
form.value.questions[index].answers = selected.map((id) => ({ text: id, image: null }));
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -492,7 +407,6 @@ export default {
|
|||||||
addAnswer,
|
addAnswer,
|
||||||
removeAnswer,
|
removeAnswer,
|
||||||
findEmployeeById,
|
findEmployeeById,
|
||||||
removeEmployee,
|
|
||||||
saveVoting,
|
saveVoting,
|
||||||
isVoteCreated,
|
isVoteCreated,
|
||||||
resetForm,
|
resetForm,
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- Конструктор -->
|
<!-- Конструктор -->
|
||||||
<v-tabs-window-item value="constructor" class="">
|
<v-tabs-window-item value="constructor" class="h-100 overflow-auto">
|
||||||
<VoteConstructor @updating="updating" />
|
<VoteConstructor @updating="updating" />
|
||||||
</v-tabs-window-item>
|
</v-tabs-window-item>
|
||||||
<!-- </v-tabs-window> -->
|
<!-- </v-tabs-window> -->
|
||||||
|
|||||||
Reference in new issue
Block a user