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"
[dataSource]="data"
[includeWeekend]="true"
[resources]="resources"
[taskFields]="taskSettings"
[resourceFields]="resourceFields"

View File

@ -1,6 +1,7 @@
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { GanttComponent } from '@syncfusion/ej2-angular-gantt';
import { MAT_DATE_FORMATS } from '@angular/material/core';
import * as moment from 'moment';
export const MY_DATE_FORMATS = {
parse: {
@ -38,43 +39,37 @@ export class PlanTimeBarComponent implements OnInit {
public toolbar: any[] = [];
public timelineSettings: object = {};
constructor() { }
constructor() {
}
ngOnInit(): void {
this.splitterSettings = this.inputData[0];
this.projectStartDate = this.inputData[1];
this.projectEndDate = this.inputData[2];
this.labelSettings = {
taskLabel: '${taskData.planzeit} H'
taskLabel: '${taskData.planzeit}'
}
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(
{
TaskID: '02', TaskName: "Woche 2", StartDate: new Date ('01.10.2023'), Duration: 7, planzeit: 4,
resources: [{resourceId: this.resources[0].resourceId},], Progress: 0, work: 0, isRes: false
});
this.data.push(
{
TaskID: '03', TaskName: "Woche 3", StartDate: new Date ('01.18.2023'), Duration: 7, planzeit: 7,
resources: [{resourceId: this.resources[0].resourceId},], Progress: 0, work: 0, isRes: false
});
let calendarWeeks = this.getCalendarWeeks(this.projectStartDate , this.projectEndDate);
// Ausgabe der Kalenderwochen
calendarWeeks.forEach((week, index) => {
console.log(`Kalenderwoche ${index + 1}: ${week.start} - ${week.end}`);
this.data.push(
{
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 = {
bottomTier: {
@ -87,8 +82,8 @@ export class PlanTimeBarComponent implements OnInit {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
endDate: 'EndDate',
progress: 'Progress',
dependency: 'Predecessor',
resourceInfo: 'resources',
@ -114,9 +109,27 @@ export class PlanTimeBarComponent implements OnInit {
// Calculate full weeks to nearest Thursday
let weekNo = Math.ceil(( ( (d - yearStart) / 86400000) + 1)/7);
// 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;
}
}