import ngModule from '../module'; import Descriptor from 'salix/components/descriptor'; import './style.scss'; class Controller extends Descriptor { get item() { return this.entity; } set item(value) { this.entity = value; } get entity() { return super.entity; } set entity(value) { super.entity = value; this.updateStock(); } loadData() { return this.getData(`Items/${this.id}/getCard`) .then(res => this.entity = res.data); } updateStock() { this.available = null; this.visible = null; if (!this.item) return; const params = { warehouseFk: this.item.itemType.warehouseFk, dated: this.dated }; return this.$http.get(`Items/${this.id}/getVisibleAvailable`, {params}) .then(res => { this.available = res.data.available; this.visible = res.data.visible; }); } saveRegularize() { const params = { itemFk: this.id, quantity: parseInt(this.quantity), warehouseFk: this.warehouseFk }; return this.$http.post(`Items/regularize`, params) .then(() => { this.vnApp.showSuccess(this.$t('Data saved!')); this.updateStock(); }); } clearRegularizeDialog() { this.warehouseFk = null; this.quantity = null; } onCloneAccept() { this.$http.post(`Items/${this.item.id}/clone`) .then(res => this.$state.go('item.card.tags', {id: res.data.id})); } } ngModule.vnComponent('vnItemDescriptor', { template: require('./index.html'), controller: Controller, bindings: { item: '<', dated: '<' } });