import ngModule from '../module'; import Section from 'salix/components/section'; import './style.scss'; class Controller extends Section { showItemDescriptor(event, sale) { this.quicklinks = { btnThree: { icon: 'icon-transaction', state: `item.card.diary({ id: ${sale.item.id}, warehouseFk: ${this.ticket.warehouseFk}, lineFk: ${sale.id} })`, tooltip: 'Item diary' } }; this.$.itemDescriptor.show(event.target, sale.item.id); } showSaleTracking(sale) { this.saleId = sale.saleFk; this.$.saleTracking.show(); } showItemShelvingSale(sale) { this.saleId = sale.saleFk; this.$.itemShelvingSale.show(); } clickPreviousSelected(index) { const sale = this.sales[index]; if (!sale.isPreviousSelected) { sale.isPreviousSelected = true; this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false); } else { sale.isPreviousSelected = false; sale.isPrevious = false; this.saleTrackingDel(sale, 'PREVIOUS_PREPARATION'); } } clickPrevious(index) { const sale = this.sales[index]; if (!sale.isPrevious) { sale.isPrevious = true; sale.isPreviousSelected = true; this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', true); } else { sale.isPrevious = false; this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false); } } clickPrepared(index) { const sale = this.sales[index]; if (!sale.isPrepared) { sale.isPrepared = true; this.saleTrackingNew(sale, 'PREPARED', true); } else { sale.isPrepared = false; this.saleTrackingDel(sale, 'PREPARED'); } } clickControled(index) { const sale = this.sales[index]; if (!sale.isControled) { sale.isControled = true; this.saleTrackingNew(sale, 'CHECKED', true); } else { sale.isControled = false; this.saleTrackingDel(sale, 'CHECKED'); } } saleTrackingNew(sale, stateCode, isChecked) { const params = { saleFk: sale.saleFk, isChecked: isChecked, quantity: sale.quantity, stateCode: stateCode }; this.$http.post(`SaleTrackings/replace`, params).then(() => { this.vnApp.showSuccess(this.$t('Data saved!')); }); } saleTrackingDel(sale, stateCode) { const params = { saleFk: sale.saleFk, stateCode: stateCode }; this.$http.post(`SaleTrackings/delete`, params).then(() => { this.vnApp.showSuccess(this.$t('Data saved!')); }); } } ngModule.vnComponent('vnTicketSaleTracking', { template: require('./index.html'), controller: Controller, bindings: { ticket: '<', model: '