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

126 lines
3.6 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 {
constructor($element, $) {
super($element, $);
this.filter = {
include: [
{
relation: 'item'
2023-02-06 12:57:04 +00:00
},
{
2023-01-03 12:06:30 +00:00
relation: 'saleTracking',
scope: {
fields: ['isChecked']
}
2023-02-06 12:57:04 +00:00
},
{
relation: 'saleGroupDetail',
scope: {
fields: ['saleGroupFk'],
include: {
relation: 'saleGroup',
scope: {
fields: ['parkingFk'],
include: {
relation: 'parking',
scope: {
fields: ['code']
}
}
}
}
}
}
]
};
}
2023-01-03 12:06:30 +00:00
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 => {
2023-06-01 13:01:38 +00:00
res.data.forEach(salePreparing => {
const sale = this.sales.find(sale => salePreparing.saleFk === sale.id);
if (sale) sale.preparingList = salePreparing;
});
2023-01-03 12:06:30 +00:00
});
}
}
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.id;
this.$.saleTracking.show();
}
showItemShelvingSale(sale) {
this.saleId = sale.id;
this.$.itemShelvingSale.show();
}
2023-06-01 13:01:38 +00:00
clickPreviousSelected(index) {
const sale = this.sales[index];
if (!sale.preparingList.isPreviousSelected) {
this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false);
sale.preparingList.isPreviousSelected = true;
} else {
this.saleTrackingDel(sale, 'PREVIOUS_PREPARATION');
sale.preparingList.isPreviousSelected = false;
}
}
saleTrackingNew(sale, stateCode, isChecked) {
const params = {
saleFk: sale.id,
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.id,
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: {
2023-06-01 13:01:38 +00:00
ticket: '<',
model: '<?'
}
});