43 lines
943 B
JavaScript
43 lines
943 B
JavaScript
import ngModule from '../module';
|
|
import './style.scss';
|
|
|
|
class Controller {
|
|
constructor($http) {
|
|
this.$http = $http;
|
|
}
|
|
|
|
$onChanges() {
|
|
if (!this.client)
|
|
return;
|
|
|
|
this.$http.get(`/client/api/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();
|
|
}
|
|
});
|
|
}
|
|
|
|
sumRisk() {
|
|
let total = 0;
|
|
this.summary.clientRisks.forEach(risk => {
|
|
total += risk.amount;
|
|
});
|
|
return total;
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$http'];
|
|
|
|
ngModule.component('vnClientSummary', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
client: '<'
|
|
}
|
|
});
|