88 lines
2.1 KiB
JavaScript
88 lines
2.1 KiB
JavaScript
import ngModule from '../module';
|
|
import Summary from 'salix/components/summary';
|
|
import './style.scss';
|
|
|
|
class Controller extends Summary {
|
|
$onChanges() {
|
|
if (!this.client)
|
|
return;
|
|
|
|
this.$http.get(`Clients/${this.client.id}/summary`).then(res => {
|
|
if (res && res.data) {
|
|
this.summary = res.data;
|
|
|
|
if (res.data.classifications.length)
|
|
this.grade = res.data.classifications[0].insurances[0].grade;
|
|
|
|
this.summary.sumRisk = this.sumRisk();
|
|
}
|
|
});
|
|
}
|
|
get isEmployee() {
|
|
return this.aclService.hasAny(['employee']);
|
|
}
|
|
|
|
sumRisk() {
|
|
let total = 0;
|
|
this.summary.clientRisks.forEach(risk => {
|
|
total += risk.amount;
|
|
});
|
|
return total;
|
|
}
|
|
|
|
claimRate(priceIncreasing) {
|
|
if (priceIncreasing)
|
|
return priceIncreasing * 100;
|
|
}
|
|
|
|
claimingRate(rate) {
|
|
if (rate)
|
|
return rate * 100;
|
|
}
|
|
|
|
stateColor(ticket) {
|
|
if (ticket.alertLevelCode === 'OK')
|
|
return 'success';
|
|
else if (ticket.alertLevelCode === 'FREE')
|
|
return 'notice';
|
|
else if (ticket.alertLevel === 1)
|
|
return 'warning';
|
|
else if (ticket.alertLevel === 0)
|
|
return 'alert';
|
|
}
|
|
|
|
chipColor(date) {
|
|
const today = new Date();
|
|
today.setHours(0, 0, 0, 0);
|
|
|
|
const ticketShipped = new Date(date);
|
|
ticketShipped.setHours(0, 0, 0, 0);
|
|
|
|
const difference = today - ticketShipped;
|
|
|
|
if (difference == 0)
|
|
return 'warning';
|
|
if (difference < 0)
|
|
return 'success';
|
|
}
|
|
|
|
totalPriceColor(ticket) {
|
|
const total = parseInt(ticket.totalWithVat);
|
|
if (total > 0 && total < 50)
|
|
return 'warning';
|
|
}
|
|
|
|
preview(ticket) {
|
|
this.selectedTicket = ticket;
|
|
this.$.summary.show();
|
|
}
|
|
}
|
|
|
|
ngModule.vnComponent('vnClientSummary', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
client: '<'
|
|
}
|
|
});
|