refactor component

This commit is contained in:
Christian Seyfferth 2021-03-11 23:21:16 +01:00
parent 06aca83636
commit bddbb24bfe

34
app.js
View File

@ -196,7 +196,6 @@ var app = new Vue({
twelveHour: false, twelveHour: false,
} }
}, },
workbook: null,
}, },
watch: { watch: {
shifts: { shifts: {
@ -308,11 +307,16 @@ var app = new Vue({
// in der Zeitspalte stehen mehrere Uhrzeiten. // in der Zeitspalte stehen mehrere Uhrzeiten.
let tempTimes = element.Zeit.toString().split(' + '); let tempTimes = element.Zeit.toString().split(' + ');
tempTimes.forEach(function(time) { tempTimes.forEach(function(time) {
times.push(moment(time, 'HH:mm')); let mom = moment(time, 'HH:mm');
times.push([mom.hour(), mom.minute()]);
}) })
} else { } else {
// übrliches Format if (element.Zeit) {
times.push(element.Zeit ? moment(element.Zeit) : day); let mom = moment(element.Zeit);
times.push([mom.hour(), mom.minute()]);
} else {
times.push([0,0]);
}
} }
if (element.hasOwnProperty('Bemerkung')) { if (element.hasOwnProperty('Bemerkung')) {
if (element.Bemerkung.toString().search(/\d\d:\d\d\s/) >= 0) { if (element.Bemerkung.toString().search(/\d\d:\d\d\s/) >= 0) {
@ -324,9 +328,6 @@ var app = new Vue({
beschreibung: '', beschreibung: '',
name: element.Bemerkung.toString().replace(/\d\d:\d\d\s/, '').trim() name: element.Bemerkung.toString().replace(/\d\d:\d\d\s/, '').trim()
} }
if (!termin.datum.isDST()) {
termin.datum.add(1, 'hours')
}
vm.addShift(new Shift(termin)); vm.addShift(new Shift(termin));
beschreibung = ''; beschreibung = '';
} else { } else {
@ -342,14 +343,11 @@ var app = new Vue({
times.forEach(time => { times.forEach(time => {
var termin = { var termin = {
datum: day.clone().hour(time.hour()).minute(time.minute()), datum: day.clone().hour(time[0]).minute(time[1]),
art: art, art: art,
beschreibung: beschreibung, beschreibung: beschreibung,
name: name name: name
} }
if (!termin.datum.isDST()) {
termin.datum.add(1, 'hours')
}
vm.addShift(new Shift(termin)); vm.addShift(new Shift(termin));
}); });
@ -357,6 +355,20 @@ var app = new Vue({
}); });
}, },
changeTime: function (hours) {
let temp = this.shifts;
this.shifts = [];
temp.forEach(shift => {
shift.updateBeginn(hours);
this.addShift(shift);
});
},
updateBeginn: function (shift, hours) {
shift.updateBeginn(hours);
this.shifts.splice(this.shifts.indexOf(shift), 1, shift);
},
parseForStuttgart: function (dp) { parseForStuttgart: function (dp) {
var arr = XLSX.utils.sheet_to_json(dp, { var arr = XLSX.utils.sheet_to_json(dp, {
header: "A", header: "A",