переработка степпера v2

Надо на бэке убрать fakeid
This commit is contained in:
Vitaly committed 2023-09-07 17:08:31 +03:00
1 parent 94e0b59bd1
commit 70708c0b35
26 files changed
+1084 -2088

No files matched your search

@@ -1,501 +1,348 @@
<template>
<v-row>
<v-col lg=3 class="flex-col">
<v-row class="flex-grow-0">
<v-col >
<v-btn
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 h-0 ">
<v-col class="py-0 ">
<v-treeview
:active.sync="active"
:items="newproject.tasks"
class="pointer"
activatable
color="btns"
transition
return-object
>
<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-divider vertical/>
<v-col lg=9 class="flex-col">
<v-scroll-y-transition mode="out-in">
<v-row v-if="active.length==0">
<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
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 h-0 ">
<v-col>
<v-treeview
:active.sync="activework"
:items="active[0].task_work"
class="pointer"
activatable
color="btns"
open-on-click
transition
return-object
>
<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-divider vertical></v-divider>
<v-col class="flex-col">
<v-row class="overflow-auto h-0 ">
<v-col class="flex-col">
<v-row class="flex-grow-0">
<v-col>
<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"
<template>
<v-form ref="form" lazy-validation class=" d-flex pa-3 pt-0 flex-grow-1 flex-col overflow-auto overflow-x-hidden stepper"
style="height:100%"
>
<v-icon
left
x-small
>
mdi-minus
</v-icon>
{{activework.length?'Удалить работу':'Удалить задачу'}}
</v-btn>
</template>
<v-card>
<v-card-title class="text-h5">
{{activework.length?activework[0].name:active[0].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
:colora="'red accent-4'"
@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
v-model="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
v-model="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>
<v-row class="d-flex flex-grow-1 " style="height:100%">
<v-col class="flex-col justify-space-between">
<v-treeview
:active.sync="selection"
:items="newproject.tasks"
:selection-type="'leaf'"
item-key="fakeid"
hoverable
activatable
return-object
item-children="task_work"
open-all
></v-treeview>
<v-btn
@click="addtask"
>Добавить задачу</v-btn>
</v-col>
<v-divider vertical></v-divider>
<v-col
class="flex-col flex-grow-1 justify-space-between"
style="height:100%"
: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
class="d-flex flex-grow-1 flex-col" ref="selection">
<div class="d-flex flex-grow-1 flex-col"
<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="getprojectuniqueusers"
hide-no-data
item-text="text"
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">
v-for="node in selection"
:key="node.id"
>
<row-pirow title="Название:"
myclass="pt-3"
rowclass="px-1">
<template #leftcol>
<v-textarea
v-model="vmodeldescription"
v-model="node.longname"
auto-grow
rows=0
dense
flat
class="mt-0 pt-0 pb-2"
hide-details
></v-textarea>
/>
</template>
</row-pirow>
</v-col>
</row-pirow>
<row-pirow title="Короткое название:"
myclass="pt-2"
rowclass="px-1">
<template #leftcol>
<v-textarea
v-model="node.name"
auto-grow
rows=0
dense
flat
class="mt-0 pt-0 pb-2"
:rules="selection_rules.name"
></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(node.datestart)'
:rules="selection_rules.datestart"
v-bind="attrs"
v-on="on"
></v-text-field>
</template>
<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>
<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(node.dateend)'
:rules="selection_rules.datestart"
readonly
v-bind="attrs"
v-on="on"
></v-text-field>
</template>
<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>
</v-row>
</template>
</row-pirow>
<row-pirow title="Сложность:" class="mt-2" rowclass="px-1"
>
<template #leftcol>
<v-rating
v-model="node.difficult"
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="node.responsible"
:items="getprojectuniquePersons"
return-object
item-text="fullname"
item-value="id"
item-color="open_icons"
color="primaryicons"
:rules="selection_rules.responsible"
/>
</template>
</row-pirow>
<strong class="px-1">Описание:</strong>
<v-textarea
v-model="node.description"
no-resize
rows=10
solo
class="mt-0 pt-0 pb-2"
hide-details
></v-textarea>
</div>
<div class="d-felx flex-grow-0">
<div class="d-felx flex-row justify-space-around">
<v-btn
v-if="'task_work' in selection[0]"
@click="addwork"
>Добавить работу</v-btn>
<v-btn
class="white--text"
color="red "
@click="deltasksworks"
>Удалить {{'task_work' in selection[0]?"Задачу": "Работу" }}</v-btn>
</div>
</div>
</div>
</template>
</v-col>
</v-row>
</v-col>
</v-row>
</v-form>
</v-scroll-y-transition>
</v-col>
</v-row>
</template>
<script>
import { createNamespacedHelpers } from "vuex";
const projectstate = createNamespacedHelpers("projectstate");
import rowPirow from '@/components/carddetails/pattern/row-pirow.vue';
import formatDate from '@/utils/datepiker'
export default {
name:'step-four',
components: { rowPirow},
name:"step-four",
mixins:[formatDate],
components: { rowPirow },
props:{
newproject:{
type:Object,
default:()=>{}
}
newproject:{type:Object,
default:()=>{}}
},
data:()=>{
return{
dialogdelete: false,
active: [],
activework:[],
menudatestart: false,
menudateend: false,
return{
deletion: {
deltasks: [],
delworks: []
},
menudatestart: false,
menudateend: false,
selection:[],
selection_rules:{name:[ v => !!v || 'Обязательно для заполнения',],
datestart:[ v => !!v || 'Обязательно для заполнения',
// v => moment(v,"DD.MM.YYYY").isValid()==true || 'Что-то не то с датой',
],
responsible:[ v => !!v || 'Обязательно для заполнения',]
},
}
},
methods:{
newTask() {
this.newproject.tasks.push({id:-1-this.newproject.tasks.length,longname: "", name:`Новая задача - ${this.newproject.tasks.length+1}`, difficult:3, description: "", datestart: "", dateend: "", responsible: "", status: 1, task_work:[]})
},
deltasksworks() {
// let arr = []
// let delarr = []
// let selectid = ""
if(this.activework.length > 0){
this.active[0].task_work.splice(this.active[0].task_work.findIndex(e=>e.id==this.activework[0].id),1)
}
else{
this.newproject.tasks.splice(this.newproject.tasks.findIndex(e=>e.id==this.active[0].id),1)
this.active[0].task_work=[]
}
// ?
// (
// arr = this.selected.task_work,
// delarr = this.deletion.delworks,
// selectid = this.activework[0]
// ) :
// (
// arr = this.newproject.tasks,
// delarr = this.deletion.deltasks,
// selectid = this.selected.id
// )
// if (selectid >= 0) {
// delarr.push(selectid)
// }
// let delinx = arr.findIndex(e=>e.id==selectid)
// if(arr == this.selected.task_work) {
// this.activework = []
// }
// arr.splice(delinx, 1)
this.dialogdelete = false
console.log(`this.newproject.tasks`, this.deletion, this.newproject.tasks);
},
adddwork() {
this.active[0].task_work.push({id: -1-this.active[0].task_work.length, longname: "", name:`Новая работа - ${this.active[0].task_work.length+1}`, description: "", datestart: "", dateend: "", responsible: "", difficult:3})
},
},
computed:{
...projectstate.mapGetters(["getProject", "getprojectuniqueusers"]),
getprojectuniquePersons(){
let a =[...this.newproject.users]
let b = []
a.forEach(el=> {if( (el!=undefined && b.findIndex(e=>el.user.id===e.id)==-1))b.push(el.user)})
return b
},
},
methods:{
addtask() {
if (this.selection && !this.$refs.form.validate()){
return
}
let id = -1*(this.newproject.tasks.length)
this.newproject.tasks.push({fakeid:`t-${id}` ,id: id, longname: "", name:"Новая задача", description: "", datestart: null, dateend: null, responsible: null, task_work:[]})
this.selection= [this.newproject.tasks[this.newproject.tasks.length-1]]
},
addwork() {
if (this.selection && !this.$refs.form.validate()){
return
}
let id=-1*(this.selection[0].task_work.length)
this.selection[0].task_work.push({fakeid:`w-${id}` ,id: id,parent:{id: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]
this.selection=[this.selection[0].task_work[this.selection[0].task_work.length-1] ]
},
vmodelname: {
get () {
return this.activework.length > 0 ?this.activework[0].name:this.active[0].name
},
set (newval) {
if (this.activework.length > 0) {
this.activework[0].name = newval
}
else {
this.active[0].name = newval
}
}
},
deltasksworks() {
if (this.selection.length>0){
if('task_work' in this.selection[0]){
if (this.selection[0].id>0)this.deletion.deltasks.push(this.selection[0].id)
this.selection[0].task_work.forEach(e=>{if(e.id>0)this.deletion.delworks.push(e.id)});
this.newproject.tasks.splice(this.newproject.tasks.findIndex(e=>e.id==this.selection[0].id),1)
this.selection=[]
vmodellongname: {
get () {
return this.activework.length > 0?this.activework[0].longname:this.active[0].longname
},
set (newval) {
if (this.activework.length > 0) {
this.activework[0].longname = newval
}
else {
this.active[0].longname = newval
}
}
else{
if (this.selection[0].id>0)this.deletion.delworks.push(this.selection[0].id)
let taskind = this.newproject.tasks.findIndex(e=>e.id==this.selection[0].parent.id)
this.newproject.tasks[taskind].task_work.splice(this.newproject.tasks[taskind].task_work.findIndex(e=>e.id==this.selection[0].id),1)
this.selection=[]
}
},
this.newproject.deletion = this.deletion
}
// if (this.activework.length > 0){
// arr = this.selected.task_work,
// delarr = this.deletion.delworks,
// selectid = this.activework[0]
// }
// else{
// arr = this.newproject.tasks,
// delarr = this.deletion.deltasks,
// selectid = this.selected.id
// this.selected.task_work.forEach(e=>this.deletion.delworks.push(e.id));
// }
// if (selectid >= 0) {
// delarr.push(selectid)
// }
// let delinx = arr.findIndex(e=>e.id==selectid)
// if(arr == this.selected.task_work) {
// this.activework = []
// }
// arr.splice(delinx, 1)
// this.dialogdelete = false
// console.log(`this.newproject.tasks`, this.deletion, this.newproject.tasks);
},
findMinMaxdate(id,key){
if ("task_work" in this.selection[0]){
return this.newproject[key]
}
else{
vmodeldescription: {
get () {
return this.activework.length > 0?this.activework[0].description:this.active[0].description
},
set (newval) {
if (this.activework.length > 0) {
this.activework[0].description = newval
}
else {
this.active[0].description = newval
}
}
},
let elm=this.newproject.tasks.find(e=>e.id==this.selection[0].parent.id)
return elm[key]
}
vmodeldatestart: {
get () {
return this.activework.length > 0?this.activework[0].datestart:this.active[0].datestart
},
set (newval) {
if (this.activework.length > 0) {
this.activework[0].datestart = newval
}
else {
this.active[0].datestart = newval
}
}
},
vmodeldateend: {
get () {
return this.activework.length > 0?this.activework[0].dateend:this.active[0].dateend
},
set (newval) {
if (this.activework.length > 0) {
this.activework[0].dateend = newval
}
else {
this.active[0].dateend = newval
}
}
},
vmodelresponsible: {
get () {
return this.activework.length > 0?this.activework[0].responsible:this.active[0].responsible
},
set (newval) {
if (this.activework.length > 0) {
this.activework[0].responsible = newval
}
else {
this.active[0].responsible = newval
}
}
},
vmodeldifficult: {
get () {
return this.activework.length > 0?this.activework[0].difficult:this.active[0].difficult
},
set (newval) {
if (this.activework.length > 0) {
this.activework[0].difficult = newval
}
else {
this.active[0].difficult = newval
}
}
},
},
}
}