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

66 lines
1.6 KiB
JavaScript

import ngModule from '../module';
import Component from 'core/lib/component';
class Controller extends Component {
constructor($element, $, $httpParamSerializer) {
super($element, $);
this.$httpParamSerializer = $httpParamSerializer;
}
get zone() {
return this._zone;
}
set zone(value) {
this._zone = value;
if (!value) return;
this.getSummary();
this.getWarehouses();
}
getSummary() {
const params = {
filter: {
include: {
relation: 'agencyMode',
fields: ['name']
},
where: {
id: this.zone.id
}
}
};
const serializedParams = this.$httpParamSerializer(params);
this.$http.get(`Zones/findOne?${serializedParams}`).then(res => {
this.summary = res.data;
});
}
getWarehouses() {
const params = {
filter: {
include: {
relation: 'warehouse',
fields: ['name']
}
}
};
const serializedParams = this.$httpParamSerializer(params);
this.$http.get(`Zones/${this.zone.id}/warehouses?${serializedParams}`).then(res => {
this.zoneWarehouses = res.data;
});
}
}
Controller.$inject = ['$element', '$scope', '$httpParamSerializer'];
ngModule.component('vnZoneSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
zone: '<'
}
});