mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
65 lines
1.7 KiB
TypeScript
65 lines
1.7 KiB
TypeScript
export default {
|
|
computed: {
|
|
employeesOptions() {
|
|
const selectedEmployees = [...this.masterTask.employees].map(employee => employee.id)
|
|
|
|
const employees = this.employees.filter(
|
|
(employee) => !selectedEmployees.includes(employee.id)
|
|
) || []
|
|
|
|
return employees.map((employee) => {
|
|
return {
|
|
key: employee.id,
|
|
value: `${employee.name} ${employee.surname}`,
|
|
}
|
|
})
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
onProjectSelected({ key }) {
|
|
const project = this.projects.find(project => project.id == key)
|
|
this.masterTask.project_code = project.code
|
|
this.masterTask.project_id = project.id
|
|
},
|
|
|
|
onMasterTaskSelected({ key }) {
|
|
const mastertask = this.mastertasks.find(masterTask => masterTask.id == key)
|
|
this.task.master_task = mastertask
|
|
this.task.project_code = mastertask.project_code
|
|
},
|
|
|
|
onEmployeeSelected({ key }) {
|
|
const employee = this.employees.find(employee => employee.id == key)
|
|
this.masterTask.employees.push(employee)
|
|
this.showAddEmployeeInput = false
|
|
},
|
|
|
|
onEmployeeDurationChanged() {
|
|
let totalDuration = 0
|
|
|
|
this.masterTask.employees = this.masterTask.employees.map(employee => {
|
|
if (typeof employee.duration == 'string') {
|
|
totalDuration += parseInt(employee.duration)
|
|
employee.duration = parseInt(employee.duration)
|
|
}
|
|
else if (typeof employee.duration == 'number') {
|
|
totalDuration += employee.duration
|
|
}
|
|
|
|
return employee
|
|
})
|
|
|
|
this.masterTask.duration = totalDuration
|
|
}
|
|
},
|
|
|
|
watch: {
|
|
'masterTask.team_id'(value, oldValue) {
|
|
if (!value || !oldValue) return
|
|
|
|
this.masterTask.team = this.teams.find(team => team.id == value)
|
|
this.masterTask.employees = this.masterTask.team.employees
|
|
}
|
|
}
|
|
} |