SummenPlanzeit/inProgress

main
manueltauber 2023-06-13 14:54:57 +02:00
parent df0365502d
commit c5d9c5f549
2 changed files with 41 additions and 27 deletions

View File

@ -1,6 +1,7 @@
<ejs-gantt #ganttObject id="ganttDefaultSum" <ejs-gantt #ganttObject id="ganttDefaultSum"
[dataSource]="data" [dataSource]="data"
[includeWeekend]="true"
[resources]="resources" [resources]="resources"
[taskFields]="taskSettings" [taskFields]="taskSettings"
[resourceFields]="resourceFields" [resourceFields]="resourceFields"

View File

@ -1,6 +1,7 @@
import { Component, Input, OnInit, ViewChild } from '@angular/core'; import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { GanttComponent } from '@syncfusion/ej2-angular-gantt'; import { GanttComponent } from '@syncfusion/ej2-angular-gantt';
import { MAT_DATE_FORMATS } from '@angular/material/core'; import { MAT_DATE_FORMATS } from '@angular/material/core';
import * as moment from 'moment';
export const MY_DATE_FORMATS = { export const MY_DATE_FORMATS = {
parse: { parse: {
@ -38,43 +39,37 @@ export class PlanTimeBarComponent implements OnInit {
public toolbar: any[] = []; public toolbar: any[] = [];
public timelineSettings: object = {}; public timelineSettings: object = {};
constructor() { } constructor() {
}
ngOnInit(): void { ngOnInit(): void {
this.splitterSettings = this.inputData[0]; this.splitterSettings = this.inputData[0];
this.projectStartDate = this.inputData[1]; this.projectStartDate = this.inputData[1];
this.projectEndDate = this.inputData[2]; this.projectEndDate = this.inputData[2];
this.labelSettings = { this.labelSettings = {
taskLabel: '${taskData.planzeit} H' taskLabel: '${taskData.planzeit}'
} }
this.resources = [{resourceId: 1, resourceName: 'Planzeit Summen pro Woche'}]; this.resources = [{resourceId: 1, resourceName: 'Planzeit Summen pro Woche'}];
this.data.push(
{
TaskID: '01', TaskName: "Woche 1", StartDate: new Date ('01.02.2023'), Duration: 7, planzeit: 1,
resources: [{resourceId: this.resources[0].resourceId},], Progress: 0, work: 0, isRes: false
});
this.data.push( let calendarWeeks = this.getCalendarWeeks(this.projectStartDate , this.projectEndDate);
{
TaskID: '02', TaskName: "Woche 2", StartDate: new Date ('01.10.2023'), Duration: 7, planzeit: 4, // Ausgabe der Kalenderwochen
resources: [{resourceId: this.resources[0].resourceId},], Progress: 0, work: 0, isRes: false calendarWeeks.forEach((week, index) => {
}); console.log(`Kalenderwoche ${index + 1}: ${week.start} - ${week.end}`);
this.data.push(
{
TaskID: '03', TaskName: "Woche 3", StartDate: new Date ('01.18.2023'), Duration: 7, planzeit: 7, this.data.push(
resources: [{resourceId: this.resources[0].resourceId},], Progress: 0, work: 0, isRes: false {
}); TaskID: '' + this.getWeekNumber(new Date(calendarWeeks[index].start.toISOString())), index , TaskName: "Woche " + this.getWeekNumber(new Date(calendarWeeks[index].start.toISOString())), StartDate: calendarWeeks[index].start.toISOString(),EndDate: calendarWeeks[index].end.toISOString() , planzeit: 1,
resources: [{resourceId: this.resources[0].resourceId},], Progress: 0, work: 0, isRes: false
});
});
this.data.push(
{
TaskID: '04', TaskName: "Woche 4", StartDate: new Date ('01.26.2023'), Duration: 7, planzeit: 11,
resources: [{resourceId: this.resources[0].resourceId},], Progress: 0, work: 0, isRes: false
});
console.log(this.getWeekNumber(new Date()));
this.timelineSettings = { this.timelineSettings = {
bottomTier: { bottomTier: {
@ -87,8 +82,8 @@ export class PlanTimeBarComponent implements OnInit {
id: 'TaskID', id: 'TaskID',
name: 'TaskName', name: 'TaskName',
startDate: 'StartDate', startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration', duration: 'Duration',
endDate: 'EndDate',
progress: 'Progress', progress: 'Progress',
dependency: 'Predecessor', dependency: 'Predecessor',
resourceInfo: 'resources', resourceInfo: 'resources',
@ -114,9 +109,27 @@ export class PlanTimeBarComponent implements OnInit {
// Calculate full weeks to nearest Thursday // Calculate full weeks to nearest Thursday
let weekNo = Math.ceil(( ( (d - yearStart) / 86400000) + 1)/7); let weekNo = Math.ceil(( ( (d - yearStart) / 86400000) + 1)/7);
// Return array of year and week number // Return array of year and week number
return [d.getUTCFullYear(), weekNo]; return '' + d.getUTCFullYear() + weekNo;
} }
calculate getCalendarWeeks(startDate: Date, endDate: Date): { start: Date, end: Date }[] {
const weeks: { start: Date, end: Date }[] = [];
let currentDate = moment(startDate).startOf('isoWeek');
let endMoment = moment(endDate).startOf('isoWeek');
while (currentDate.isSameOrBefore(endMoment)) {
let startOfWeek = currentDate.clone().toDate();
let endOfWeek = currentDate.clone().add(6, 'days').toDate();
weeks.push({ start: startOfWeek, end: endOfWeek });
currentDate = currentDate.add(7, 'days');
}
return weeks;
}
} }