salix/modules/client/front/summary/index.js

48 lines
1.1 KiB
JavaScript

import ngModule from '../module';
import Section from 'salix/components/section';
import './style.scss';
class Controller extends Section {
$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();
}
});
}
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;
}
}
ngModule.vnComponent('vnClientSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
client: '<'
}
});