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;
|
2023-01-16 14:18:24 +00:00
|
|
|
let today = Date.vnNew();
|
2020-05-06 16:42:50 +00:00
|
|
|
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)
|
2022-10-10 10:23:40 +00:00
|
|
|
this.warehouseFk = this.vnConfig.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) {
|
2022-03-24 09:28:28 +00:00
|
|
|
this.$.$applyAsync(() => {
|
|
|
|
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
|
|
|
|
2020-10-27 11:02:49 +00:00
|
|
|
showDescriptor(event, sale) {
|
|
|
|
let descriptor = 'entryDescriptor';
|
|
|
|
if (sale.isTicket)
|
|
|
|
descriptor = 'ticketDescriptor';
|
2020-06-03 08:37:17 +00:00
|
|
|
|
2020-10-27 11:02:49 +00:00
|
|
|
this.$[descriptor].show(event.target, sale.origin);
|
2020-06-03 08:37:17 +00:00
|
|
|
}
|
2018-06-04 07:48:32 +00:00
|
|
|
}
|
|
|
|
|
2020-05-06 16:42:50 +00:00
|
|
|
Controller.$inject = ['$element', '$scope', '$anchorScroll', '$location'];
|
|
|
|
|
2020-07-24 12:22:30 +00:00
|
|
|
ngModule.vnComponent('vnItemDiary', {
|
2018-06-04 07:48:32 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
item: '<'
|
|
|
|
}
|
|
|
|
});
|