2018-01-25 13:14:58 +00:00
|
|
|
import ngModule from '../module';
|
2020-04-25 09:50:04 +00:00
|
|
|
import Descriptor from 'salix/components/descriptor';
|
2018-04-24 12:40:12 +00:00
|
|
|
import './style.scss';
|
2018-01-25 13:14:58 +00:00
|
|
|
|
2020-04-25 09:50:04 +00:00
|
|
|
class Controller extends Descriptor {
|
2020-04-30 10:48:52 +00:00
|
|
|
get item() {
|
|
|
|
return this.entity;
|
2018-11-12 12:12:25 +00:00
|
|
|
}
|
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
set item(value) {
|
|
|
|
this.entity = value;
|
2018-11-12 12:12:25 +00:00
|
|
|
}
|
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
get entity() {
|
|
|
|
return super.entity;
|
2018-11-12 12:12:25 +00:00
|
|
|
}
|
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
set entity(value) {
|
|
|
|
super.entity = value;
|
|
|
|
this.updateStock();
|
2019-02-18 12:31:57 +00:00
|
|
|
}
|
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
loadData() {
|
|
|
|
return this.getData(`Items/${this.id}/getCard`)
|
|
|
|
.then(res => this.entity = res.data);
|
2019-02-18 12:31:57 +00:00
|
|
|
}
|
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
updateStock() {
|
2019-02-18 06:57:15 +00:00
|
|
|
this.available = null;
|
|
|
|
this.visible = null;
|
2020-04-30 10:48:52 +00:00
|
|
|
if (!this.item) return;
|
2019-02-15 15:04:24 +00:00
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
const params = {
|
|
|
|
warehouseFk: this.item.itemType.warehouseFk
|
|
|
|
};
|
2018-11-12 12:12:25 +00:00
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
return this.$http.get(`Items/${this.id}/getVisibleAvailable`, {params})
|
|
|
|
.then(res => {
|
|
|
|
this.available = res.data.available;
|
|
|
|
this.visible = res.data.visible;
|
|
|
|
});
|
2018-08-01 10:15:09 +00:00
|
|
|
}
|
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
saveRegularize() {
|
|
|
|
const params = {
|
|
|
|
itemFk: this.id,
|
|
|
|
quantity: parseInt(this.quantity),
|
|
|
|
warehouseFk: this.warehouseFk
|
|
|
|
};
|
2018-11-12 12:12:25 +00:00
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
return this.$http.post(`Items/regularize`, params)
|
|
|
|
.then(() => {
|
|
|
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
|
|
|
this.updateStock();
|
2018-11-12 12:12:25 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
clearRegularizeDialog() {
|
|
|
|
this.warehouseFk = null;
|
|
|
|
this.quantity = null;
|
|
|
|
}
|
2018-08-01 10:15:09 +00:00
|
|
|
}
|
|
|
|
|
2020-04-25 09:50:04 +00:00
|
|
|
ngModule.vnComponent('vnItemDescriptor', {
|
2018-05-25 08:03:45 +00:00
|
|
|
template: require('./index.html'),
|
2018-08-01 10:15:09 +00:00
|
|
|
controller: Controller,
|
2018-01-25 13:14:58 +00:00
|
|
|
bindings: {
|
2020-04-25 09:50:04 +00:00
|
|
|
item: '<'
|
2018-01-25 13:14:58 +00:00
|
|
|
}
|
|
|
|
});
|