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

42 lines
1.0 KiB
JavaScript
Raw Normal View History

import ngModule from '../module';
import Section from 'salix/components/section';
export default class Controller extends Section {
$onInit() {
this.getTaxes();
}
getTaxes() {
let filter = {
fields: ['id', 'countryFk', 'taxClassFk'],
include: [{
relation: 'country',
scope: {fields: ['name']}
}]
};
let url = `Items/${this.$params.id}/taxes`;
this.$http.get(url, {params: {filter}}).then(json => {
this.taxes = json.data;
});
}
submit() {
let data = [];
for (let tax of this.taxes)
data.push({id: tax.id, taxClassFk: tax.taxClassFk});
this.$.watcher.check();
let url = `Items/updateTaxes`;
this.$http.post(url, data).then(() => {
this.$.watcher.notifySaved();
this.$.watcher.updateOriginalData();
});
}
}
ngModule.vnComponent('vnItemTax', {
template: require('./index.html'),
controller: Controller
});