salix/modules/item/front/tax/index.js

50 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-02-23 12:04:44 +00:00
import ngModule from '../module';
export default class Controller {
constructor($stateParams, $http, $translate, $scope) {
this.$ = $scope;
2018-02-23 12:04:44 +00:00
this.$http = $http;
this.$stateParams = $stateParams;
this._ = $translate;
2018-08-09 11:13:50 +00:00
}
$onInit() {
this.getTaxes();
}
2018-02-23 12:04:44 +00:00
2018-08-09 11:13:50 +00:00
getTaxes() {
2018-02-23 12:04:44 +00:00
let filter = {
fields: ['id', 'countryFk', 'taxClassFk'],
include: [{
relation: 'country',
scope: {fields: ['country']}
}]
};
let url = `api/Items/${this.$stateParams.id}/taxes`;
this.$http.get(url, {params: {filter}}).then(json => {
2018-02-23 12:04:44 +00:00
this.taxes = json.data;
});
}
2018-02-23 12:04:44 +00:00
submit() {
let data = [];
for (let tax of this.taxes)
data.push({id: tax.id, taxClassFk: tax.taxClassFk});
this.$.watcher.check();
let url = `api/Items/updateTaxes`;
this.$http.post(url, data).then(() => {
this.$.watcher.notifySaved();
this.$.watcher.updateOriginalData();
});
2018-02-23 12:04:44 +00:00
}
}
Controller.$inject = ['$stateParams', '$http', '$translate', '$scope'];
2018-02-23 12:04:44 +00:00
ngModule.component('vnItemTax', {
template: require('./index.html'),
2018-08-09 11:13:50 +00:00
controller: Controller
2018-02-23 12:04:44 +00:00
});