77 lines
1.9 KiB
JavaScript
77 lines
1.9 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();
|
|
}
|
|
|
|
showTicketDescriptor(event, sale) {
|
|
if (!sale.isTicket) return;
|
|
|
|
this.$.ticketDescriptor.show(event.target, sale.origin);
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$element', '$scope', '$anchorScroll', '$location'];
|
|
|
|
ngModule.vnComponent('vnItemDiary', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
item: '<'
|
|
}
|
|
});
|