2018-06-04 07:48:32 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-17 13:43:46 +00:00
|
|
|
import Section from 'salix/components/section';
|
2018-06-04 07:48:32 +00:00
|
|
|
import './style.scss';
|
|
|
|
|
2020-03-17 13:43:46 +00:00
|
|
|
class Controller extends Section {
|
2020-05-06 16:42:50 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2018-09-18 11:34:11 +00:00
|
|
|
get item() {
|
|
|
|
return this._item;
|
2018-06-04 07:48:32 +00:00
|
|
|
}
|
2018-09-18 11:34:11 +00:00
|
|
|
|
2018-07-04 06:50:34 +00:00
|
|
|
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;
|
2018-09-18 11:34:11 +00:00
|
|
|
else if (value)
|
|
|
|
this.warehouseFk = value.itemType.warehouseFk;
|
2018-10-05 13:53:31 +00:00
|
|
|
|
2020-05-06 16:42:50 +00:00
|
|
|
if (this.$params.lineFk)
|
|
|
|
this.lineFk = this.$params.lineFk;
|
2018-09-18 11:34:11 +00:00
|
|
|
});
|
2018-07-04 06:50:34 +00:00
|
|
|
}
|
|
|
|
|
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-07-04 06:50:34 +00:00
|
|
|
|
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-07-04 06:50:34 +00:00
|
|
|
}
|
|
|
|
|
2018-09-06 13:08:02 +00:00
|
|
|
get warehouseFk() {
|
|
|
|
return this._warehouseFk;
|
2018-07-04 06:50:34 +00:00
|
|
|
}
|
|
|
|
|
2020-05-06 16:42:50 +00:00
|
|
|
scrollToLine(lineFk) {
|
|
|
|
const hashFk = this.lineFk || lineFk;
|
|
|
|
const hash = `vnItemDiary-${hashFk}`;
|
|
|
|
this.$location.hash(hash);
|
|
|
|
this.$anchorScroll();
|
2018-06-04 07:48:32 +00:00
|
|
|
}
|
2020-06-03 08:37:17 +00:00
|
|
|
|
|
|
|
showTicketDescriptor(event, sale) {
|
|
|
|
if (!sale.isTicket) return;
|
|
|
|
|
|
|
|
this.$.ticketDescriptor.show(event.target, sale.origin);
|
|
|
|
}
|
2018-06-04 07:48:32 +00:00
|
|
|
}
|
|
|
|
|
2020-05-06 16:42:50 +00:00
|
|
|
Controller.$inject = ['$element', '$scope', '$anchorScroll', '$location'];
|
|
|
|
|
2018-06-04 07:48:32 +00:00
|
|
|
ngModule.component('vnItemDiary', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
item: '<'
|
|
|
|
}
|
|
|
|
});
|