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-11-27 12:10:39 +00:00
|
|
|
constructor($element, $, $rootScope) {
|
|
|
|
super($element, $);
|
|
|
|
this.$rootScope = $rootScope;
|
|
|
|
}
|
|
|
|
|
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 = {
|
2020-05-26 08:37:52 +00:00
|
|
|
warehouseFk: this.item.itemType.warehouseFk,
|
|
|
|
dated: this.dated
|
2020-04-30 10:48:52 +00:00
|
|
|
};
|
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;
|
|
|
|
}
|
2020-05-13 15:51:27 +00:00
|
|
|
|
|
|
|
onCloneAccept() {
|
|
|
|
this.$http.post(`Items/${this.item.id}/clone`)
|
|
|
|
.then(res => this.$state.go('item.card.tags', {id: res.data.id}));
|
|
|
|
}
|
2020-11-27 12:10:39 +00:00
|
|
|
|
|
|
|
onUploadResponse() {
|
|
|
|
const timestamp = new Date().getTime();
|
|
|
|
const src = this.$rootScope.imagePath('catalog', '200x200', this.item.id);
|
|
|
|
const zoomSrc = this.$rootScope.imagePath('catalog', '1600x900', this.item.id);
|
|
|
|
const newSrc = `${src}&t=${timestamp}`;
|
|
|
|
const newZoomSrc = `${zoomSrc}&t=${timestamp}`;
|
|
|
|
|
|
|
|
this.$.photo.setAttribute('src', newSrc);
|
|
|
|
this.$.photo.setAttribute('zoom-image', newZoomSrc);
|
|
|
|
}
|
2018-08-01 10:15:09 +00:00
|
|
|
}
|
|
|
|
|
2020-11-27 12:10:39 +00:00
|
|
|
Controller.$inject = ['$element', '$scope', '$rootScope'];
|
|
|
|
|
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-05-26 08:37:52 +00:00
|
|
|
item: '<',
|
2020-11-27 12:10:39 +00:00
|
|
|
dated: '<',
|
|
|
|
cardReload: '&'
|
2018-01-25 13:14:58 +00:00
|
|
|
}
|
|
|
|
});
|