salix/modules/ticket/front/sale-tracking/index.js

164 lines
4.8 KiB
JavaScript
Raw Normal View History

import ngModule from '../module';
2020-03-18 07:35:59 +00:00
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();
}
2023-06-01 13:01:38 +00:00
clickSaleGroupDetail(index) {
const sale = this.sales[index];
2023-07-21 10:20:06 +00:00
if (!sale.saleGroupDetailFk) return;
return this.$http.delete(`SaleGroupDetails/${sale.saleGroupDetailFk}`)
.then(() => {
sale.hasSaleGroupDetail = false;
this.vnApp.showSuccess(this.$t('Data saved!'));
});
}
2023-06-01 13:01:38 +00:00
clickPreviousSelected(index) {
const sale = this.sales[index];
if (!sale.isPreviousSelected) {
this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false);
sale.isPreviousSelected = true;
2023-06-01 13:01:38 +00:00
} else {
this.saleTrackingDel(sale, 'PREVIOUS_PREPARATION');
sale.isPreviousSelected = false;
sale.isPrevious = false;
}
}
clickPrevious(index) {
const sale = this.sales[index];
if (!sale.isPrevious) {
this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', true);
sale.isPrevious = true;
sale.isPreviousSelected = true;
} else {
this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false);
sale.isPrevious = false;
}
}
clickPrepared(index) {
const sale = this.sales[index];
if (!sale.isPrepared) {
this.saleTrackingNew(sale, 'PREPARED', true);
sale.isPrepared = true;
} else {
this.saleTrackingDel(sale, 'PREPARED');
sale.isPrepared = false;
}
}
clickControled(index) {
const sale = this.sales[index];
if (!sale.isControled) {
this.saleTrackingNew(sale, 'CHECKED', true);
sale.isControled = true;
} else {
this.saleTrackingDel(sale, 'CHECKED');
sale.isControled = false;
2023-06-01 13:01:38 +00:00
}
}
saleTrackingNew(sale, stateCode, isChecked) {
const params = {
saleFk: sale.saleFk,
2023-06-01 13:01:38 +00:00
isChecked: isChecked,
quantity: sale.quantity,
stateCode: stateCode
};
this.$http.post(`SaleTrackings/new`, params).then(() => {
2023-06-01 13:01:38 +00:00
this.vnApp.showSuccess(this.$t('Data saved!'));
});
}
saleTrackingDel(sale, stateCode) {
const params = {
saleFk: sale.saleFk,
2023-06-01 13:01:38 +00:00
stateCode: stateCode
};
this.$http.post(`SaleTrackings/delete`, params).then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
});
}
updateQuantity(itemShelvingSale) {
const params = {
quantity: itemShelvingSale.quantity
};
this.$http.patch(`ItemShelvingSales/${itemShelvingSale.id}`, params)
.then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
});
}
2023-06-06 10:15:39 +00:00
async updateShelving(itemShelvingSale) {
const params = {
shelvingFk: itemShelvingSale.shelvingFk
};
2023-06-06 10:15:39 +00:00
const res = await this.$http.patch(`ItemShelvings/${itemShelvingSale.itemShelvingFk}`, params);
2023-06-06 10:15:39 +00:00
const filter = {
fields: ['parkingFk'],
where: {
code: res.data.shelvingFk
}
};
this.$http.get(`Shelvings/findOne`, {filter})
.then(res => {
itemShelvingSale.parkingFk = res.data.parkingFk;
this.vnApp.showSuccess(this.$t('Data saved!'));
});
}
2023-06-06 10:15:39 +00:00
async updateParking(itemShelvingSale) {
const filter = {
fields: ['id'],
where: {
code: itemShelvingSale.shelvingFk
}
};
2023-06-06 10:15:39 +00:00
const res = await this.$http.get(`Shelvings/findOne`, {filter});
const params = {
parkingFk: itemShelvingSale.parkingFk
};
this.$http.patch(`Shelvings/${res.data.id}`, params)
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
}
}
ngModule.vnComponent('vnTicketSaleTracking', {
template: require('./index.html'),
controller: Controller,
bindings: {
2023-06-01 13:01:38 +00:00
ticket: '<',
model: '<?'
}
});