salix/modules/claim/front/card/index.js

49 lines
1.2 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']
}
}
}
]
};
}
2018-10-03 06:00:19 +00:00
$onInit() {
this.getCard();
}
getCard() {
2018-08-24 11:16:11 +00:00
let json = encodeURIComponent(JSON.stringify(this.filter));
let query = `/claim/api/Claims/${this.$state.params.id}?filter=${json}`;
this.$http.get(query).then(res => {
2018-12-14 11:56:21 +00:00
if (res.data)
2018-08-24 11:16:11 +00:00
this.claim = res.data;
});
}
2018-10-03 06:00:19 +00:00
2018-08-24 11:16:11 +00:00
reload() {
2018-10-03 06:00:19 +00:00
this.getCard();
2018-08-24 11:16:11 +00:00
}
}
Controller.$inject = ['$http', '$state'];
ngModule.component('vnClaimCard', {
template: require('./index.html'),
controller: Controller
});