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

90 lines
2.2 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;
2023-01-16 14:18:24 +00:00
let today = Date.vnNew();
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)
2022-10-10 10:23:40 +00:00
this.warehouseFk = this.vnConfig.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;
this.card.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) {
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();
});
}
2020-06-03 08:37:17 +00:00
showDescriptor(event, sale) {
let descriptor = 'entryDescriptor';
if (sale.isTicket)
descriptor = 'ticketDescriptor';
2020-06-03 08:37:17 +00:00
this.$[descriptor].show(event.target, sale.origin);
2020-06-03 08:37:17 +00:00
}
$onDestroy() {
if (this.$state.getCurrentPath()[2].state.name === 'item')
this.card.reload();
}
}
Controller.$inject = ['$element', '$scope', '$anchorScroll', '$location'];
ngModule.vnComponent('vnItemDiary', {
template: require('./index.html'),
controller: Controller,
bindings: {
item: '<'
},
require: {
card: '?^vnItemCard'
}
});