95 lines
2.3 KiB
JavaScript
95 lines
2.3 KiB
JavaScript
import ngModule from '../module';
|
|
import Section from 'salix/components/section';
|
|
import './style.scss';
|
|
|
|
class Controller extends Section {
|
|
constructor($element, $scope, $anchorScroll, $location) {
|
|
super($element, $scope);
|
|
this.$anchorScroll = $anchorScroll;
|
|
this.$location = $location;
|
|
let today = new Date();
|
|
today.setHours(0, 0, 0, 0);
|
|
this.today = today.toJSON();
|
|
}
|
|
|
|
get item() {
|
|
return this._item;
|
|
}
|
|
|
|
set item(value) {
|
|
this._item = value;
|
|
|
|
this.filter = {
|
|
where: {itemFk: this.$params.id}
|
|
};
|
|
|
|
this.$.$applyAsync(() => {
|
|
if (this.$params.warehouseFk)
|
|
this.warehouseFk = this.$params.warehouseFk;
|
|
else if (value)
|
|
this.warehouseFk = value.itemType.warehouseFk;
|
|
|
|
if (this.$params.lineFk)
|
|
this.lineFk = this.$params.lineFk;
|
|
});
|
|
}
|
|
|
|
set warehouseFk(value) {
|
|
if (value && value != this._warehouseFk) {
|
|
this._warehouseFk = value;
|
|
|
|
this.$state.go(this.$state.current.name, {
|
|
warehouseFk: value
|
|
});
|
|
|
|
this.filter.where.warehouseFk = value;
|
|
this.$.model.refresh();
|
|
}
|
|
}
|
|
|
|
get warehouseFk() {
|
|
return this._warehouseFk;
|
|
}
|
|
|
|
scrollToLine(lineFk) {
|
|
const hashFk = this.lineFk || lineFk;
|
|
const hash = `vnItemDiary-${hashFk}`;
|
|
this.$location.hash(hash);
|
|
this.$anchorScroll();
|
|
}
|
|
|
|
showDescriptor(event, sale) {
|
|
if (!sale.isTicket) return;
|
|
|
|
this.$.descriptor.ticketFk = sale.origin;
|
|
this.$.descriptor.parent = event.target;
|
|
this.$.descriptor.show();
|
|
|
|
event.preventDefault();
|
|
}
|
|
|
|
showClientDescriptor(event, sale) {
|
|
if (!sale.isTicket) return;
|
|
|
|
this.$.clientDescriptor.clientFk = sale.clientFk;
|
|
this.$.clientDescriptor.parent = event.target;
|
|
this.$.clientDescriptor.show();
|
|
|
|
event.preventDefault();
|
|
}
|
|
|
|
onDescriptorLoad() {
|
|
this.$.popover.relocate();
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$element', '$scope', '$anchorScroll', '$location'];
|
|
|
|
ngModule.component('vnItemDiary', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
item: '<'
|
|
}
|
|
});
|