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-03-17 13:43:46 +00:00
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
2018-11-12 12:12:25 +00:00
|
|
|
this.moreOptions = [
|
2019-02-13 08:49:41 +00:00
|
|
|
{callback: this.showRegularizeDialog, name: 'Regularize stock'}
|
2018-11-12 12:12:25 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
set quantity(value) {
|
|
|
|
this._quantity = parseInt(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
get quantity() {
|
|
|
|
return this._quantity;
|
|
|
|
}
|
|
|
|
|
|
|
|
set warehouseFk(value) {
|
2019-02-13 08:49:41 +00:00
|
|
|
if (value)
|
|
|
|
this._warehouseFk = value;
|
2018-11-12 12:12:25 +00:00
|
|
|
}
|
|
|
|
get warehouseFk() {
|
|
|
|
if (!this._warehouseFk)
|
2019-10-09 22:47:29 +00:00
|
|
|
this._warehouseFk = this.vnConfig.warehouseFk;
|
2018-11-12 12:12:25 +00:00
|
|
|
|
|
|
|
return this._warehouseFk;
|
|
|
|
}
|
|
|
|
|
2019-02-15 15:04:24 +00:00
|
|
|
set item(value) {
|
2019-02-18 06:57:15 +00:00
|
|
|
this._item = value;
|
2019-02-20 10:30:55 +00:00
|
|
|
if (value && value.itemType && value.itemType.warehouseFk)
|
|
|
|
this.updateStock(value.itemType.warehouseFk);
|
2019-02-18 12:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get item() {
|
|
|
|
return this._item;
|
|
|
|
}
|
|
|
|
|
2019-02-20 10:30:55 +00:00
|
|
|
updateStock(warehouseFk) {
|
2019-02-18 06:57:15 +00:00
|
|
|
this.available = null;
|
|
|
|
this.visible = null;
|
2019-02-18 12:31:57 +00:00
|
|
|
if (this._item && this._item.id) {
|
|
|
|
let options = {
|
2019-02-18 06:57:15 +00:00
|
|
|
params: {
|
2019-02-20 10:30:55 +00:00
|
|
|
warehouseFk: warehouseFk
|
2019-02-18 06:57:15 +00:00
|
|
|
}
|
|
|
|
};
|
2019-10-24 22:53:53 +00:00
|
|
|
this.$http.get(`Items/${this._item.id}/getVisibleAvailable`, options).then(response => {
|
2019-02-18 12:31:57 +00:00
|
|
|
this.available = response.data.available;
|
|
|
|
this.visible = response.data.visible;
|
|
|
|
});
|
2019-02-18 06:57:15 +00:00
|
|
|
}
|
2019-02-15 15:04:24 +00:00
|
|
|
}
|
|
|
|
|
2018-11-12 12:12:25 +00:00
|
|
|
onMoreChange(callback) {
|
|
|
|
callback.call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
showRegularizeDialog() {
|
2020-03-17 13:43:46 +00:00
|
|
|
this.$.regularize.show();
|
2018-08-01 10:15:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set quicklinks(value = {}) {
|
2018-08-02 08:06:11 +00:00
|
|
|
this._quicklinks = Object.assign(value, this._quicklinks);
|
2018-08-01 10:15:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get quicklinks() {
|
|
|
|
return this._quicklinks;
|
|
|
|
}
|
2018-11-12 12:12:25 +00:00
|
|
|
|
|
|
|
saveRegularize(response) {
|
2019-10-30 15:57:14 +00:00
|
|
|
if (response == 'accept') {
|
2019-10-24 22:53:53 +00:00
|
|
|
this.$http.post(`Items/regularize`, {
|
2018-11-12 12:12:25 +00:00
|
|
|
itemFk: this.item.id,
|
|
|
|
quantity: this.quantity,
|
|
|
|
warehouseFk: this.warehouseFk
|
|
|
|
}).then(res => {
|
|
|
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
2019-02-20 10:30:55 +00:00
|
|
|
this.updateStock(this.item.itemType.warehouseFk);
|
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
|
|
|
}
|
|
|
|
});
|