This commit is contained in:
Nukeap committed 2025-01-22 10:10:02 +03:00
1 parent d38e3721b6
commit 2647be0a77
1 file changed
+47 -24
@@ -123,10 +123,21 @@
</div>
<div v-else>
<div class="v-row">
<v-switch color="teal-darken-4" v-model="question.settings.onlyDep"
<!-- <v-switch color="teal-darken-4" v-model="question.settings.onlyDep"
indeterminate
:label="`Голосование по отделам: ${question.settings.onlyDep ? 'да ' : 'нет'}`" hide-details
class="v-col-auto"></v-switch>
<v-switch color="teal-darken-4" v-model="question.settings.withoutDirector"
class="v-col-auto"></v-switch> -->
<v-radio-group inline label="Голосование по отделам:" v-model="question.settings.onlyDep">
<v-radio v-for="x in onlyDepdict" :key="x.name" :label="x.name" :value=x.value></v-radio>
</v-radio-group>
<v-switch color="teal-darken-4" v-model="question.settings.withoutDirector"
:label="`Без начальства : ${question.settings.withoutDirector ? 'да ' : 'нет'}`" hide-details
class="v-col-auto"></v-switch>
@@ -136,13 +147,13 @@
<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)=>console.log (selected, index)"
@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="Все"
@@ -152,7 +163,8 @@
<template #item="data">
<template v-if="typeof data.item.raw !== 'object'">
<v-list-group class='px-2' v-text="data.item.raw"></v-list-group>
<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
@@ -200,7 +212,7 @@
<v-file-input v-model="person.image" accept="image/*" dense hide-details label="Картинка"
variant="outlined" density="compact"></v-file-input>
<v-btn class="ms-1" color="error" icon="mdi-delete" size="small"
@click="removeAnswer(index,ind)">
@click="question.selectedEmployees.splice(ind,1); removeAnswer(index,ind)">
</v-btn>
</v-col>
@@ -223,23 +235,31 @@
<v-card flat>
<v-card-title>Подтверждение</v-card-title>
<v-card-text>
<p><strong>Название:</strong> {{ form.title }}</p>
<p><strong>Описание:</strong> {{ form.description }}</p>
<p><strong>Дата начала:</strong> {{ form.startDate.toLocaleDateString() }}</p>
<p><strong>Дата окончания:</strong> {{ form.endDate.toLocaleDateString() }}</p>
<p><strong>Вопросы:</strong></p>
<ul>
<li v-for="(question, index) in form.questions" :key="index" class="mb-4">
<p><strong>Вопрос {{ index + 1 }}:</strong> {{ question.text }} ({{ question.type }})</p>
<div v-if="question.settings.type === 'Ввести вручную' && question.answers.length">
<p><strong>Варианты ответов:</strong></p>
<ul>
<li v-for="(answer, answerIndex) in question.answers" :key="answerIndex">
{{ answer.text }}
<p><v-icon size="xsmall" :class="form.title===null||form.title.length==0?'':'opacity-0'" color='red' icon="mdi-alert"/><strong class="px-2">Название:</strong> {{ form.title }}</p>
<p><v-icon size="xsmall" :class="form.description===null||form.description.length==0?'':'opacity-0'" color='red' icon="mdi-alert"/><strong class="px-2">Описание:</strong> {{ form.description }}</p>
<p><strong class="px-2">Дата начала:</strong> {{ form.startDate.toLocaleDateString() }}</p>
<p><strong class="px-2">Дата окончания:</strong> {{ form.endDate.toLocaleDateString() }}</p>
<p><strong class="px-2">Вопросы:</strong></p>
<v-card v-for="(question, index) in form.questions" :key="index" class="mb-4 pa-3">
<div class="pa-2">
<p><strong>Вопрос {{ index + 1 }}:</strong> {{ question.text }} ({{ question.type }})</p>
<div v-if="question.settings.choice === 'free' && question.answers.length">
<p><strong>Варианты ответов:</strong></p>
<ul>
<li v-for="(answer, answerIndex) in question.answers" :key="answerIndex">
{{ answer.text }}
</li>
</ul>
</div>
<div v-if="question.settings.type === 'Выбрать сотрудника' && question.answers.length">
<div v-if="question.settings.choice === 'employee' && question.answers.length">
<div>Количество допустимых ответов: {{ question.settings.multiChoice }}</div>
<div class="">Голосование по отделам: {{ onlyDepdict.find(e=>e.value===question.settings.onlyDep).name}}</div>
<p><strong>Выбранные сотрудники:</strong></p>
<ul>
<li v-for="employeeId in question.answers" :key="employeeId">
@@ -247,8 +267,9 @@
</li>
</ul>
</div>
</li>
</ul>
</div>
</v-card>
</v-card-text>
<v-card-actions>
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
@@ -339,7 +360,7 @@ export default {
const addQuestion = () => {
form.value.questions.push({
text: "",
settings: { choice: "free", multiChoice: 1, onlyDep: false, withoutDirector: false },
settings: { choice: "free", multiChoice: 1, onlyDep: null, withoutDirector: false },
image: null,
answers: [],
selectedEmployees: []
@@ -463,7 +484,9 @@ export default {
}
};
const onlyDepdict = [{name:'За любого сотрудника' ,value:null},{name:"Кроме своего отдела" ,value:false}, {name:"Только за свой отдел" ,value:true}]
return {
onlyDepdict,
allEmployeesgroupedbydep,
onEmployeesChange,
returnend,