2018-02-23 12:04:44 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-17 13:43:46 +00:00
|
|
|
import Section from 'salix/components/section';
|
2018-02-23 12:04:44 +00:00
|
|
|
|
2020-03-17 13:43:46 +00:00
|
|
|
export default class Controller extends Section {
|
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',
|
2024-06-11 12:15:10 +00:00
|
|
|
scope: {fields: ['name']}
|
2018-02-23 12:04:44 +00:00
|
|
|
}]
|
|
|
|
};
|
|
|
|
|
2020-03-17 13:43:46 +00:00
|
|
|
let url = `Items/${this.$params.id}/taxes`;
|
2019-10-08 15:27:27 +00:00
|
|
|
this.$http.get(url, {params: {filter}}).then(json => {
|
2018-02-23 12:04:44 +00:00
|
|
|
this.taxes = json.data;
|
|
|
|
});
|
|
|
|
}
|
2018-05-31 09:52:39 +00:00
|
|
|
|
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});
|
|
|
|
|
2019-10-08 15:27:27 +00:00
|
|
|
this.$.watcher.check();
|
2019-10-24 22:53:53 +00:00
|
|
|
let url = `Items/updateTaxes`;
|
2019-10-08 15:27:27 +00:00
|
|
|
this.$http.post(url, data).then(() => {
|
|
|
|
this.$.watcher.notifySaved();
|
|
|
|
this.$.watcher.updateOriginalData();
|
|
|
|
});
|
2018-02-23 12:04:44 +00:00
|
|
|
}
|
|
|
|
}
|
2018-05-25 08:03:45 +00:00
|
|
|
|
2020-07-24 12:22:30 +00:00
|
|
|
ngModule.vnComponent('vnItemTax', {
|
2018-05-25 08:03:45 +00:00
|
|
|
template: require('./index.html'),
|
2018-08-09 11:13:50 +00:00
|
|
|
controller: Controller
|
2018-02-23 12:04:44 +00:00
|
|
|
});
|