salix/client/claim/src/card/index.js

48 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-08-24 11:16:11 +00:00
import ngModule from '../module';
class Controller {
constructor($http, $state) {
this.$http = $http;
this.$state = $state;
this.filter = {
include: [
{relation: 'worker', scope: {fields: ['name', 'firstName']}},
{relation: 'claimState', scope: {fields: ['id', 'description']}},
{
relation: 'client',
scope: {
fields: ['salesPersonFk', 'name'],
include: {
relation: 'salesPerson',
fields: ['firstName', 'name']
}
}
}
]
};
}
getClaim() {
let json = encodeURIComponent(JSON.stringify(this.filter));
let query = `/claim/api/Claims/${this.$state.params.id}?filter=${json}`;
this.$http.get(query).then(res => {
if (res.data) {
this.claim = res.data;
}
});
}
$onInit() {
this.getClaim();
}
reload() {
this.getClaim();
}
}
Controller.$inject = ['$http', '$state'];
ngModule.component('vnClaimCard', {
template: require('./index.html'),
controller: Controller
});