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

77 lines
1.9 KiB
JavaScript
Raw Normal View History

import ngModule from '../module';
2020-03-17 13:43:46 +00:00
import Section from 'salix/components/section';
import './style.scss';
2020-03-17 13:43:46 +00:00
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;
2018-09-06 13:08:02 +00:00
this.filter = {
2020-03-17 13:43:46 +00:00
where: {itemFk: this.$params.id}
2018-09-06 13:08:02 +00:00
};
2020-03-17 13:43:46 +00:00
this.$.$applyAsync(() => {
if (this.$params.warehouseFk)
this.warehouseFk = this.$params.warehouseFk;
else if (value)
this.warehouseFk = value.itemType.warehouseFk;
2018-10-05 13:53:31 +00:00
if (this.$params.lineFk)
this.lineFk = this.$params.lineFk;
});
}
2018-09-06 13:08:02 +00:00
set warehouseFk(value) {
2018-11-14 10:17:33 +00:00
if (value && value != this._warehouseFk) {
this._warehouseFk = value;
2018-09-06 13:08:02 +00:00
2018-11-14 10:17:33 +00:00
this.$state.go(this.$state.current.name, {
warehouseFk: value
});
2018-11-14 10:17:33 +00:00
this.filter.where.warehouseFk = value;
2020-03-17 13:43:46 +00:00
this.$.model.refresh();
2018-11-14 10:17:33 +00:00
}
}
2018-09-06 13:08:02 +00:00
get warehouseFk() {
return this._warehouseFk;
}
scrollToLine(lineFk) {
const hashFk = this.lineFk || lineFk;
const hash = `vnItemDiary-${hashFk}`;
this.$location.hash(hash);
this.$anchorScroll();
}
2020-06-03 08:37:17 +00:00
showTicketDescriptor(event, sale) {
if (!sale.isTicket) return;
this.$.ticketDescriptor.show(event.target, sale.origin);
}
}
Controller.$inject = ['$element', '$scope', '$anchorScroll', '$location'];
ngModule.component('vnItemDiary', {
template: require('./index.html'),
controller: Controller,
bindings: {
item: '<'
}
});