71 lines
1.6 KiB
JavaScript
71 lines
1.6 KiB
JavaScript
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
|
|
};
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
ngModule.vnComponent('vnItemDescriptor', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
item: '<'
|
|
}
|
|
});
|