2018-07-03 13:00:33 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-18 07:35:59 +00:00
|
|
|
import Section from 'salix/components/section';
|
2022-12-28 11:16:23 +00:00
|
|
|
import './style.scss';
|
2018-07-03 13:00:33 +00:00
|
|
|
|
2022-12-28 11:16:23 +00:00
|
|
|
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',
|
2022-12-28 11:16:23 +00:00
|
|
|
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']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-12-28 11:16:23 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
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
|
|
|
});
|
|
|
|
}
|
2022-12-28 11:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
showItemDescriptor(event, sale) {
|
|
|
|
this.quicklinks = {
|
|
|
|
btnThree: {
|
|
|
|
icon: 'icon-transaction',
|
|
|
|
state: `item.card.diary({
|
2023-01-20 11:37:41 +00:00
|
|
|
id: ${sale.item.id},
|
2022-12-28 11:16:23 +00:00
|
|
|
warehouseFk: ${this.ticket.warehouseFk},
|
|
|
|
lineFk: ${sale.id}
|
|
|
|
})`,
|
|
|
|
tooltip: 'Item diary'
|
|
|
|
}
|
|
|
|
};
|
2023-01-20 11:37:41 +00:00
|
|
|
this.$.itemDescriptor.show(event.target, sale.item.id);
|
2022-12-28 11:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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!'));
|
|
|
|
});
|
|
|
|
}
|
2022-12-28 11:16:23 +00:00
|
|
|
}
|
2018-07-03 13:00:33 +00:00
|
|
|
|
2020-07-24 12:22:30 +00:00
|
|
|
ngModule.vnComponent('vnTicketSaleTracking', {
|
2018-07-03 13:00:33 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
2023-06-01 13:01:38 +00:00
|
|
|
ticket: '<',
|
|
|
|
model: '<?'
|
2022-12-28 11:16:23 +00:00
|
|
|
}
|
2018-07-03 13:00:33 +00:00
|
|
|
});
|