WIP: 9b11987d7
feat: desaparecen los botones para las semanas que no tienen registros
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
bc542d8a40
commit
3051768781
|
@ -0,0 +1,3 @@
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES
|
||||||
|
('Time', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -14,6 +14,9 @@
|
||||||
"year": {
|
"year": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"month": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
"week": {
|
"week": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,97 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.date = initialDate;
|
this.date = initialDate;
|
||||||
|
|
||||||
|
const filterTime = {
|
||||||
|
fields: ['week'],
|
||||||
|
where: {
|
||||||
|
month: this.date.getMonth() + 1,
|
||||||
|
year: this.date.getFullYear()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.$http.get('Times', {filter: filterTime})
|
||||||
|
.then(res => {
|
||||||
|
const weeks = res.data.map(time => time.week);
|
||||||
|
const weekNumbersSet = new Set(weeks);
|
||||||
|
const weekNumbers = Array.from(weekNumbersSet);
|
||||||
|
|
||||||
|
const filter = {
|
||||||
|
where: {
|
||||||
|
workerFk: this.$params.id,
|
||||||
|
year: this.date.getFullYear(),
|
||||||
|
week: {inq: weekNumbers}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.$http.get('WorkerTimeControlMails', {filter})
|
||||||
|
.then(res => {
|
||||||
|
const workerTimeControlMails = res.data;
|
||||||
|
console.log(workerTimeControlMails);
|
||||||
|
for (const workerTimeControlMail of workerTimeControlMails) {
|
||||||
|
// const [data] = res.data;
|
||||||
|
// if (!data) {
|
||||||
|
// if (this.weekNumber == weekNumberValue) this.state = null;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
const state = workerTimeControlMail.state;
|
||||||
|
|
||||||
|
console.log(workerTimeControlMail.week, this.weekNumberValue);
|
||||||
|
if (workerTimeControlMail.week == this.weekNumberValue) {
|
||||||
|
this.state = state;
|
||||||
|
this.reason = workerTimeControlMail.reason;
|
||||||
|
}
|
||||||
|
if (state == 'CONFIRMED') {
|
||||||
|
this.weekNumberHTML.classList.add('confirmed');
|
||||||
|
this.weekNumberHTML.setAttribute('title', 'Conforme');
|
||||||
|
}
|
||||||
|
if (state == 'REVISE') {
|
||||||
|
this.weekNumberHTML.classList.add('revise');
|
||||||
|
this.weekNumberHTML.setAttribute('title', 'No conforme');
|
||||||
|
}
|
||||||
|
if (state == 'SENDED') {
|
||||||
|
this.weekNumberHTML.classList.add('sended');
|
||||||
|
this.weekNumberHTML.setAttribute('title', 'Pendiente');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// console.log(this.weekNumbers);
|
||||||
|
// const filter = {
|
||||||
|
// where: {
|
||||||
|
// workerFk: this.$params.id,
|
||||||
|
// year: this.date.getFullYear(),
|
||||||
|
// week: {inq: this.weekNumbers}
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// this.$http.get('WorkerTimeControlMails', {filter})
|
||||||
|
// .then(res => {
|
||||||
|
// console.log(res.data);
|
||||||
|
// // const [data] = res.data;
|
||||||
|
// // if (!data) {
|
||||||
|
// // if (this.weekNumber == weekNumberValue) this.state = null;
|
||||||
|
// // return;
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // const state = data.state;
|
||||||
|
// // if (this.weekNumber == weekNumberValue) {
|
||||||
|
// // this.state = state;
|
||||||
|
// // this.reason = data.reason;
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // if (state == 'CONFIRMED') {
|
||||||
|
// // weekNumber.classList.add('confirmed');
|
||||||
|
// // weekNumber.setAttribute('title', 'Conforme');
|
||||||
|
// // }
|
||||||
|
// // if (state == 'REVISE') {
|
||||||
|
// // weekNumber.classList.add('revise');
|
||||||
|
// // weekNumber.setAttribute('title', 'No conforme');
|
||||||
|
// // }
|
||||||
|
// // if (state == 'SENDED') {
|
||||||
|
// // weekNumber.classList.add('sended');
|
||||||
|
// // weekNumber.setAttribute('title', 'Pendiente');
|
||||||
|
// // }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
get isHr() {
|
get isHr() {
|
||||||
|
@ -314,7 +405,7 @@ class Controller extends Section {
|
||||||
const firstDayOfYear = new Date(tempDate.getFullYear(), 0, 1);
|
const firstDayOfYear = new Date(tempDate.getFullYear(), 0, 1);
|
||||||
const differenceInMilliseconds = firstDayOfWeek.getTime() - firstDayOfYear.getTime();
|
const differenceInMilliseconds = firstDayOfWeek.getTime() - firstDayOfYear.getTime();
|
||||||
const weekNumber = Math.floor(differenceInMilliseconds / (1000 * 60 * 60 * 24 * 7)) + 1;
|
const weekNumber = Math.floor(differenceInMilliseconds / (1000 * 60 * 60 * 24 * 7)) + 1;
|
||||||
return weekNumber - 1;
|
return weekNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
isSatisfied() {
|
isSatisfied() {
|
||||||
|
@ -363,43 +454,45 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
formatWeek($element) {
|
formatWeek($element) {
|
||||||
let weekNumber = $element.firstElementChild;
|
this.weekNumberHTML = $element.firstElementChild;
|
||||||
let weekNumberValue = $element.firstElementChild.innerHTML - 1;
|
console.log(this.weekNumberHTML);
|
||||||
const filter = {
|
this.weekNumberValue = $element.firstElementChild.innerHTML;
|
||||||
where: {
|
|
||||||
workerFk: this.$params.id,
|
|
||||||
year: this.date.getFullYear(),
|
|
||||||
week: weekNumberValue
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.$http.get('WorkerTimeControlMails', {filter})
|
// const filter = {
|
||||||
.then(res => {
|
// where: {
|
||||||
const [data] = res.data;
|
// workerFk: this.$params.id,
|
||||||
if (!data) {
|
// year: this.date.getFullYear(),
|
||||||
if (this.weekNumber == weekNumberValue) this.state = null;
|
// week: weekNumberValue
|
||||||
return;
|
// }
|
||||||
}
|
// };
|
||||||
|
|
||||||
const state = data.state;
|
// this.$http.get('WorkerTimeControlMails', {filter})
|
||||||
if (this.weekNumber == weekNumberValue) {
|
// .then(res => {
|
||||||
this.state = state;
|
// const [data] = res.data;
|
||||||
this.reason = data.reason;
|
// if (!data) {
|
||||||
}
|
// if (this.weekNumber == weekNumberValue) this.state = null;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
if (state == 'CONFIRMED') {
|
// const state = data.state;
|
||||||
weekNumber.classList.add('confirmed');
|
// if (this.weekNumber == weekNumberValue) {
|
||||||
weekNumber.setAttribute('title', 'Conforme');
|
// this.state = state;
|
||||||
}
|
// this.reason = data.reason;
|
||||||
if (state == 'REVISE') {
|
// }
|
||||||
weekNumber.classList.add('revise');
|
|
||||||
weekNumber.setAttribute('title', 'No conforme');
|
// if (state == 'CONFIRMED') {
|
||||||
}
|
// weekNumber.classList.add('confirmed');
|
||||||
if (state == 'SENDED') {
|
// weekNumber.setAttribute('title', 'Conforme');
|
||||||
weekNumber.classList.add('sended');
|
// }
|
||||||
weekNumber.setAttribute('title', 'Pendiente');
|
// if (state == 'REVISE') {
|
||||||
}
|
// weekNumber.classList.add('revise');
|
||||||
});
|
// weekNumber.setAttribute('title', 'No conforme');
|
||||||
|
// }
|
||||||
|
// if (state == 'SENDED') {
|
||||||
|
// weekNumber.classList.add('sended');
|
||||||
|
// weekNumber.setAttribute('title', 'Pendiente');
|
||||||
|
// }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
resendEmail() {
|
resendEmail() {
|
||||||
|
@ -407,7 +500,7 @@ class Controller extends Section {
|
||||||
const url = `${window.location.origin}/#!/worker/${this.worker.id}/time-control?timestamp=${timestamp}`;
|
const url = `${window.location.origin}/#!/worker/${this.worker.id}/time-control?timestamp=${timestamp}`;
|
||||||
const params = {
|
const params = {
|
||||||
recipient: this.worker.user.emailUser.email,
|
recipient: this.worker.user.emailUser.email,
|
||||||
week: this.weekNumber + 1,
|
week: this.weekNumber,
|
||||||
year: this.date.getFullYear(),
|
year: this.date.getFullYear(),
|
||||||
url: url,
|
url: url,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue