2018-03-01 11:51:35 +00:00
|
|
|
import ngModule from '../module';
|
2020-11-23 12:41:51 +00:00
|
|
|
import Summary from 'salix/components/summary';
|
2018-03-27 13:06:22 +00:00
|
|
|
import './style.scss';
|
2018-03-01 11:51:35 +00:00
|
|
|
|
2020-11-23 12:41:51 +00:00
|
|
|
class Controller extends Summary {
|
2021-06-18 14:07:13 +00:00
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
|
|
|
|
|
|
|
this.ticketFilter = {
|
2021-06-28 06:28:31 +00:00
|
|
|
include: [
|
|
|
|
{
|
|
|
|
relation: 'ticketState',
|
|
|
|
scope: {
|
|
|
|
fields: ['stateFk', 'code', 'alertLevel'],
|
|
|
|
include: {
|
|
|
|
relation: 'state'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'invoiceOut',
|
|
|
|
scope: {
|
|
|
|
fields: ['id']
|
2021-06-18 14:07:13 +00:00
|
|
|
}
|
2021-07-19 13:59:39 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'agencyMode',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
},
|
2021-06-28 06:28:31 +00:00
|
|
|
]
|
2021-06-18 14:07:13 +00:00
|
|
|
};
|
|
|
|
}
|
2021-06-28 06:48:35 +00:00
|
|
|
|
2021-08-12 11:55:10 +00:00
|
|
|
get client() {
|
|
|
|
return this._client;
|
|
|
|
}
|
|
|
|
|
|
|
|
set client(value) {
|
|
|
|
this._client = value;
|
|
|
|
if (value) {
|
|
|
|
this.loadData();
|
|
|
|
this.loadTickets();
|
|
|
|
}
|
|
|
|
}
|
2018-03-05 09:56:51 +00:00
|
|
|
|
2021-08-12 11:55:10 +00:00
|
|
|
loadData() {
|
2019-10-24 22:53:53 +00:00
|
|
|
this.$http.get(`Clients/${this.client.id}/summary`).then(res => {
|
2018-07-09 11:01:46 +00:00
|
|
|
if (res && res.data) {
|
2018-03-05 09:56:51 +00:00
|
|
|
this.summary = res.data;
|
2018-07-09 11:01:46 +00:00
|
|
|
|
|
|
|
if (res.data.classifications.length)
|
|
|
|
this.grade = res.data.classifications[0].insurances[0].grade;
|
2018-10-19 06:40:32 +00:00
|
|
|
|
|
|
|
this.summary.sumRisk = this.sumRisk();
|
2018-07-09 11:01:46 +00:00
|
|
|
}
|
2018-03-01 13:48:02 +00:00
|
|
|
});
|
|
|
|
}
|
2021-06-18 14:07:13 +00:00
|
|
|
|
2021-08-12 11:55:10 +00:00
|
|
|
loadTickets() {
|
|
|
|
this.$.$applyAsync(() => this.$.ticketsModel.refresh());
|
|
|
|
}
|
|
|
|
|
2021-01-12 06:39:12 +00:00
|
|
|
get isEmployee() {
|
|
|
|
return this.aclService.hasAny(['employee']);
|
|
|
|
}
|
2018-10-19 06:40:32 +00:00
|
|
|
|
|
|
|
sumRisk() {
|
|
|
|
let total = 0;
|
|
|
|
this.summary.clientRisks.forEach(risk => {
|
|
|
|
total += risk.amount;
|
|
|
|
});
|
|
|
|
return total;
|
|
|
|
}
|
2019-07-02 10:12:15 +00:00
|
|
|
|
|
|
|
claimRate(priceIncreasing) {
|
|
|
|
if (priceIncreasing)
|
|
|
|
return priceIncreasing * 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
claimingRate(rate) {
|
|
|
|
if (rate)
|
|
|
|
return rate * 100;
|
|
|
|
}
|
2021-06-16 07:43:07 +00:00
|
|
|
|
|
|
|
stateColor(ticket) {
|
2021-06-18 14:07:13 +00:00
|
|
|
const ticketState = ticket.ticketState;
|
|
|
|
|
2021-06-22 12:11:33 +00:00
|
|
|
if (!ticketState) return;
|
|
|
|
|
2021-06-18 14:07:13 +00:00
|
|
|
if (ticketState.code === 'OK')
|
2021-06-16 07:43:07 +00:00
|
|
|
return 'success';
|
2021-06-18 14:07:13 +00:00
|
|
|
else if (ticketState.code === 'FREE')
|
2021-06-16 07:43:07 +00:00
|
|
|
return 'notice';
|
2021-06-18 14:07:13 +00:00
|
|
|
else if (ticketState.alertLevel === 1)
|
2021-06-16 07:43:07 +00:00
|
|
|
return 'warning';
|
2021-06-18 14:07:13 +00:00
|
|
|
else if (ticketState.alertLevel === 0)
|
2021-06-16 07:43:07 +00:00
|
|
|
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();
|
|
|
|
}
|
2018-03-01 13:48:02 +00:00
|
|
|
}
|
2018-03-27 13:06:22 +00:00
|
|
|
|
2020-07-24 12:22:30 +00:00
|
|
|
ngModule.vnComponent('vnClientSummary', {
|
2018-05-23 12:26:51 +00:00
|
|
|
template: require('./index.html'),
|
2018-03-15 13:36:09 +00:00
|
|
|
controller: Controller,
|
2018-03-01 11:51:35 +00:00
|
|
|
bindings: {
|
|
|
|
client: '<'
|
|
|
|
}
|
|
|
|
});
|