2018-03-01 11:51:35 +00:00
|
|
|
import ngModule from '../module';
|
2018-03-27 13:06:22 +00:00
|
|
|
import './style.scss';
|
2018-03-01 11:51:35 +00:00
|
|
|
|
2018-03-15 13:36:09 +00:00
|
|
|
class Controller {
|
2018-03-01 13:48:02 +00:00
|
|
|
constructor($http) {
|
|
|
|
this.$http = $http;
|
|
|
|
}
|
2018-03-05 09:56:51 +00:00
|
|
|
|
2018-03-15 13:36:09 +00:00
|
|
|
$onChanges() {
|
2018-03-27 13:06:22 +00:00
|
|
|
if (!this.client)
|
2018-03-05 09:56:51 +00:00
|
|
|
return;
|
|
|
|
|
2018-03-27 13:06:22 +00:00
|
|
|
this.$http.get(`/client/api/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
|
|
|
});
|
|
|
|
}
|
2018-10-19 06:40:32 +00:00
|
|
|
|
|
|
|
sumRisk() {
|
|
|
|
let total = 0;
|
|
|
|
this.summary.clientRisks.forEach(risk => {
|
|
|
|
total += risk.amount;
|
|
|
|
});
|
|
|
|
return total;
|
|
|
|
}
|
2018-03-01 13:48:02 +00:00
|
|
|
}
|
2018-03-27 13:06:22 +00:00
|
|
|
|
2018-03-15 13:36:09 +00:00
|
|
|
Controller.$inject = ['$http'];
|
2018-03-01 13:48:02 +00:00
|
|
|
|
2018-03-01 11:51:35 +00:00
|
|
|
ngModule.component('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: '<'
|
|
|
|
}
|
|
|
|
});
|