Валидация степпера

Валидация степпера создания и обновления проектов. v.1
This commit is contained in:
Vitaly committed 2023-09-06 17:02:44 +03:00
1 parent 5b414bc4da
commit 94e0b59bd1
1 file changed
+57 -343
+57 -343
View File
@@ -259,7 +259,7 @@
<v-row style="height:100%">
<v-col class="flex-col justify-space-between">
<v-treeview
:active.sync="selection[0]"
:active.sync="selection"
:items="newproject.tasks"
:selection-type="'independent'"
hoverable
@@ -267,6 +267,7 @@
return-object
item-children="task_work"
open-all
></v-treeview>
<v-btn
@click="addtask"
@@ -274,18 +275,24 @@
</v-col>
<v-divider vertical></v-divider>
<v-col
class="flex-col justify-space-between"
class="flex-col flex-grow-1 justify-space-between"
:class="!selection.length?'justify-space-around':'justify-space-between'"
cols="6"
>
<template v-if="!selection.length">
Ничего не выбрано
<div class="align-self-center "> Ничего не выбрано</div>
</template>
<template v-else>
<div>
<div
v-for="node in selection"
:key="node.id"
>
<template
v-else>
<v-form
lazy-validation
class="d-flex flex-grow-1 flex-col" ref="selection">
<div class="d-flex flex-grow-1 flex-col"
v-for="node in selection"
:key="node.id"
>
<row-pirow title="Название:"
myclass="pt-3"
rowclass="px-1">
@@ -297,7 +304,8 @@
dense
flat
class="mt-0 pt-0 pb-2"
hide-details
/>
</template>
@@ -313,7 +321,7 @@
dense
flat
class="mt-0 pt-0 pb-2"
hide-details
:rules="selection_rules.name"
></v-textarea>
</template>
</row-pirow>
@@ -321,6 +329,7 @@
<template #leftcol>
<v-row class="flex-grow-0">
<v-col class="py-0">
<v-menu
v-model="menudatestart"
:close-on-content-click="false"
@@ -332,9 +341,9 @@
<template v-slot:activator="{ on, attrs }">
<v-text-field
:value ='formatDate(node.datestart)'
:rules="selection_rules.datestart"
readonly
v-bind="attrs"
v-on="on"
></v-text-field>
@@ -342,6 +351,9 @@
<v-date-picker
v-model="node.datestart"
@input="menudatestart = false"
:min="findMinMaxdate(node.id, 'datestart')"
:max="findMinMaxdate(node.id,'dateend')"
></v-date-picker>
</v-menu>
</v-col>
@@ -366,6 +378,8 @@
<v-date-picker
v-model="node.dateend"
@input="menudateend = false"
:min="findMinMaxdate(node.id, 'datestart')"
:max="findMinMaxdate(node.id,'dateend')"
></v-date-picker>
</v-menu>
</v-col>
@@ -402,9 +416,10 @@
return-object
item-text="fullname"
item-value="id"
hide-details
item-color="open_icons"
color="primaryicons"
:rules="selection_rules.responsible"
/>
</template>
</row-pirow>
@@ -423,12 +438,13 @@
></v-textarea>
</template>
</row-pirow>
</div>
</div>
<v-btn
v-if="'task_work' in selection[0]"
@click="addwork"
>Добавить работу</v-btn>
</div>
</v-form>
</template>
</v-col>
</v-row>
@@ -445,331 +461,6 @@
<!--<v-row
style="height:100%">
<v-col lg=3 class="flex-col">
<v-row class="flex-grow-0">
<v-col >
<v-btn
class="mx-2"
tile
color="btns"
small
block
@click="newTask"
outlined
>
<v-icon
left
x-small
>
mdi-plus
</v-icon>
Добавить задачу
</v-btn>
</v-col>
</v-row>
<v-row class="overflow-auto flex-grow-1">
<v-col class="py-0 " style="align-items:baseline">
<v-treeview
:active.sync="active"
:items="newproject.tasks"
:open.sync="open"
activatable
color="btns"
open-on-click
transition
>
<template v-slot:prepend="{ item }">
<v-icon v-if="!item.children">
mdi-calendar-edit-outline
</v-icon>
</template>
</v-treeview>
</v-col>
</v-row>
</v-col>
<v-col lg=9 class="flex-col">
<v-scroll-y-transition mode="out-in">
<v-row v-if="!selected">
<v-col
class="text-h6 grey--text text-center align-self-center text--lighten-1 font-weight-light">
Задача не выбрана
</v-col>
</v-row>
<v-row
v-else
:key="selected.id"
flat
>
<v-col lg=4 class="flex-col">
<v-row class="flex-grow-0">
<v-col>
<v-btn
tile
color="btns"
small
block
@click="adddwork"
outlined
>
<v-icon
left
x-small
>
mdi-plus
</v-icon>
Добавить работу
</v-btn>
</v-col>
</v-row>
<v-row >
<v-col class="py-0 flex-col">
<v-row class="overflow-auto">
<v-col>
<v-treeview
:active.sync="activework"
:items="selected.task_work"
:open.sync="openwork"
activatable
color="btns"
open-on-click
transition
>
<template v-slot:prepend="{ item }">
<v-icon v-if="!item.children">
mdi-archive-edit
</v-icon>
</template>
</v-treeview>
</v-col>
</v-row>
</v-col>
</v-row>
</v-col>
<v-col class="flex-col">
<v-row class="overflow-auto">
<v-col class="flex-col">
<v-row class="flex-grow-0">
<v-col class="mx-2">
<v-dialog
v-model="dialogdelete"
persistent
max-width="500"
>
<template v-slot:activator="{ on, attrs }">
<v-btn
tile
color="btns"
small
block
outlined
v-bind="attrs"
v-on="on"
>
<v-icon
left
x-small
>
mdi-minus
</v-icon>
{{activework.length?'Удалить работу':'Удалить задачу'}}
</v-btn>
</template>
<v-card>
<v-card-title class="text-h5">
{{activework.length?workselected.name:selected.name}}
</v-card-title>
<v-card-text>
Вы уверены что хотите удалить {{activework.length?'работу':'задачу'}}
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<BtnsOut
@click="dialogdelete = false"
title = "Отмена"
:height= 30
:width= 120
/>
<BtnsOut
@click="deltasksworks"
title = "Удалить"
:height= 30
:width= 120
/>
</v-card-actions>
</v-card>
</v-dialog>
</v-col>
</v-row>
<row-pirow title="Название:"
myclass="pt-3"
rowclass="px-1">
<template #leftcol>
<v-textarea
v-model="vmodellongname"
auto-grow
rows=0
dense
flat
class="mt-0 pt-0 pb-2"
hide-details
/>
</template>
</row-pirow>
<row-pirow title="Короткое название:"
myclass="pt-2"
rowclass="px-1">
<template #leftcol>
<v-textarea
v-model="vmodelname"
auto-grow
rows=0
dense
flat
class="mt-0 pt-0 pb-2"
hide-details
></v-textarea>
</template>
</row-pirow>
<row-pirow title="Период:" myclass="pt-3" rowclass="px-1">
<template #leftcol>
<v-row class="flex-grow-0">
<v-col class="py-0">
<v-menu
v-model="menudatestart"
:close-on-content-click="false"
:nudge-right="40"
transition="scale-transition"
offset-y
min-width="auto"
>
<template v-slot:activator="{ on, attrs }">
<v-text-field
:value ='formatDate(vmodeldatestart)'
readonly
v-bind="attrs"
v-on="on"
></v-text-field>
</template>
<v-date-picker
v-model="vmodeldatestart"
@input="menudatestart = false"
></v-date-picker>
</v-menu>
</v-col>
<v-col class="py-0">
<v-menu
v-model="menudateend"
:close-on-content-click="false"
:nudge-right="40"
transition="scale-transition"
offset-y
min-width="auto"
>
<template v-slot:activator="{ on, attrs }">
<v-text-field
:value ='formatDate(vmodeldateend)'
readonly
v-bind="attrs"
v-on="on"
></v-text-field>
</template>
<v-date-picker
v-model="vmodeldateend"
@input="menudateend = false"
></v-date-picker>
</v-menu>
</v-col>
</v-row>
</template>
</row-pirow>
<row-pirow title="Сложность проекта:" class="mt-2" rowclass="px-1"
>
<template #leftcol>
<v-rating
v-model="vmodeldifficult"
class=" ml-n3 star"
color="warning"
empty-icon="mdi-star-outline"
full-icon="mdi-star"
half-icon="mdi-star-half-full"
hover
length="5"
size="16"
/>
</template>
</row-pirow>
<row-pirow title="Ответсвенный:" rowclass="px-1"
class="pt-2">
<template #leftcol>
<v-autocomplete
dense
class="inputext pointer mt-n1 iconsh font-weight-medium"
v-model="vmodelresponsible"
:items="getprojectuniquePersons"
return-object
item-text="fullname"
item-value="id"
hide-details
item-color="open_icons"
color="primaryicons"
/>
</template>
</row-pirow>
<row-pirow title="Описание:" rowclass="px-1"
class="pt-2"
myclass="pt-3">
<template #leftcol>
<v-textarea
v-model="vmodeldescription"
auto-grow
rows=0
dense
flat
class="mt-0 pt-0 pb-2"
hide-details
></v-textarea>
</template>
</row-pirow>
</v-col>
</v-row>
</v-col>
</v-row>
</v-scroll-y-transition>
</v-col>
</v-row> -->
</template>
@@ -877,7 +568,7 @@
</template>
<script>
import moment from "moment";
import rowPirow from '@/components/carddetails/pattern/row-pirow.vue';
import RolesSingle from '@/components/assignments/UI/roles-single.vue';
import rolesMany from '@/components/assignments/UI/roles-many.vue';
@@ -956,6 +647,14 @@ data: () => ({
},
selection:[],
selection_rules:{name:[ v => !!v || 'Обязательно для заполнения',],
datestart:[ v => !!v || 'Обязательно для заполнения',
// v => moment(v,"DD.MM.YYYY").isValid()==true || 'Что-то не то с датой',
],
responsible:[ v => !!v || 'Обязательно для заполнения',]
},
selectedItem:0,
menudatestart: false,
menudateend: false,
@@ -996,6 +695,18 @@ data: () => ({
methods: {
findMinMaxdate(id,key){
if ("task_work" in this.selection[0]){
return this.getProject[key]
}
else{
let elm=this.newproject.tasks.find(e=>e.id==this.selection[0].parent)
return elm[key]
}
},
formatDate (date) {
try {
@@ -1081,13 +792,16 @@ formatDate (date) {
},
addtask() {
this.newproject.tasks.push({id: -1*(this.newproject.tasks.length), longname: "", name:"Новая задача", description: "", datestart: "", dateend: "", responsible: "", task_work:[]})
if (this.selection && !this.$refs.selection.validate()){
return
}
this.newproject.tasks.push({id: -1*(this.newproject.tasks.length), longname: "", name:"Новая задача", description: "", datestart: null, dateend: null, responsible: null, task_work:[]})
this.selection[0]=this.newproject.tasks[this.newproject.tasks.length-1]
},
addwork() {
console.log(this.selection);
this.selection[0].task_work.push({id: -1*(this.selection[0].task_work.length), longname: "", name:"Новая работа", description: "", datestart: "", dateend: "", responsible: ""})
this.selection[0].task_work.push({id: -1*(this.selection[0].task_work.length),parent:this.selection[0].id, longname: "", name:"Новая работа", description: "", datestart: "", dateend: "", responsible: ""})
this.selection[0]= this.selection[0].task_work[this.selection[0].task_work.length-1]
},