salix/modules/item/front/descriptor/index.js

79 lines
1.8 KiB
JavaScript
Raw Normal View History

import ngModule from '../module';
import './style.scss';
class Controller {
2018-11-12 12:12:25 +00:00
constructor($state, $scope, $http, vnApp, $translate) {
this.$state = $state;
2018-11-12 12:12:25 +00:00
this.$scope = $scope;
this.$http = $http;
this.vnApp = vnApp;
this.$translate = $translate;
this.moreOptions = [
{callback: this.showRegularizeDialog, name: 'Regularize'}
];
}
set quantity(value) {
this._quantity = parseInt(value);
}
get quantity() {
return this._quantity;
}
set warehouseFk(value) {
this._warehouseFk = value;
}
get warehouseFk() {
if (!this._warehouseFk)
this._warehouseFk = parseInt(window.localStorage.localWarehouseFk);
return this._warehouseFk;
}
onMoreChange(callback) {
callback.call(this);
}
showRegularizeDialog() {
this.$scope.regularize.show();
}
set quicklinks(value = {}) {
2018-08-02 08:06:11 +00:00
this._quicklinks = Object.assign(value, this._quicklinks);
}
get quicklinks() {
return this._quicklinks;
}
2018-11-12 12:12:25 +00:00
saveRegularize(response) {
if (response == 'ACCEPT') {
this.$http.post(`/item/api/Items/regularize`, {
itemFk: this.item.id,
quantity: this.quantity,
warehouseFk: this.warehouseFk
}).then(res => {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
});
}
}
clearRegularizeDialog() {
this.warehouseFk = null;
this.quantity = null;
}
}
2018-11-12 12:12:25 +00:00
Controller.$inject = ['$state', '$scope', '$http', 'vnApp', '$translate'];
ngModule.component('vnItemDescriptor', {
template: require('./index.html'),
controller: Controller,
bindings: {
item: '<',
quicklinks: '<'
}
});