import ngModule from '../module'; import Section from 'salix/components/section'; import './style.scss'; class Controller extends Section { constructor($element, $) { super($element, $); this.filter = { include: [ { relation: 'item' }, { relation: 'saleTracking', scope: { fields: ['isChecked'] } } ] }; } get sales() { return this._sales; } set sales(value) { this._sales = value; if (value) { const query = `Sales/${this.$params.id}/salePreparingList`; this.$http.get(query) .then(res => { this.salePreparingList = res.data; for (const salePreparing of this.salePreparingList) { for (const sale of this.sales) { if (salePreparing.saleFk == sale.id) sale.preparingList = salePreparing; } } }); } } showItemDescriptor(event, sale) { this.quicklinks = { btnThree: { icon: 'icon-transaction', state: `item.card.diary({ id: ${sale.itemFk}, warehouseFk: ${this.ticket.warehouseFk}, lineFk: ${sale.id} })`, tooltip: 'Item diary' } }; this.$.itemDescriptor.show(event.target, sale.itemFk); } chipHasSaleGroupDetail(hasSaleGroupDetail) { if (hasSaleGroupDetail) return 'pink'; else return 'message'; } chipIsPreviousSelected(isPreviousSelected) { if (isPreviousSelected) return 'notice'; else return 'message'; } chipIsPrevious(isPrevious) { if (isPrevious) return 'dark-notice'; else return 'message'; } chipIsPrepared(isPrepared) { if (isPrepared) return 'warning'; else return 'message'; } chipIsControled(isControled) { if (isControled) return 'yellow'; else return 'message'; } showSaleTracking(sale) { this.saleId = sale.id; this.$.saleTracking.show(); } showItemShelvingSale(sale) { this.saleId = sale.id; this.$.itemShelvingSale.show(); } } ngModule.vnComponent('vnTicketSaleTracking', { template: require('./index.html'), controller: Controller, bindings: { ticket: '<' } });