2022-11-14 13:30:35 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
import Section from 'salix/components/section';
|
2023-01-31 13:20:08 +00:00
|
|
|
import './style.scss';
|
2022-11-14 13:30:35 +00:00
|
|
|
|
|
|
|
export default class Controller extends Section {
|
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
|
|
|
this.$checkAll = false;
|
|
|
|
|
|
|
|
this.smartTableOptions = {
|
|
|
|
activeButtons: {
|
|
|
|
search: true,
|
|
|
|
},
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
field: 'state',
|
|
|
|
searchable: false
|
|
|
|
},
|
|
|
|
{
|
2022-12-20 10:36:58 +00:00
|
|
|
field: 'futureState',
|
2022-11-14 13:30:35 +00:00
|
|
|
searchable: false
|
|
|
|
},
|
2022-11-15 14:30:00 +00:00
|
|
|
{
|
|
|
|
field: 'totalWithVat',
|
|
|
|
searchable: false
|
|
|
|
},
|
|
|
|
{
|
2022-12-20 10:36:58 +00:00
|
|
|
field: 'futureTotalWithVat',
|
2022-11-15 14:30:00 +00:00
|
|
|
searchable: false
|
|
|
|
},
|
2022-11-16 09:57:15 +00:00
|
|
|
{
|
2022-12-20 10:36:37 +00:00
|
|
|
field: 'shipped',
|
|
|
|
searchable: false
|
|
|
|
},
|
|
|
|
{
|
2022-12-20 10:36:58 +00:00
|
|
|
field: 'futureShipped',
|
2022-11-16 09:57:15 +00:00
|
|
|
searchable: false
|
|
|
|
},
|
2022-11-14 13:30:35 +00:00
|
|
|
{
|
|
|
|
field: 'ipt',
|
|
|
|
autocomplete: {
|
|
|
|
url: 'ItemPackingTypes',
|
2023-01-17 07:54:26 +00:00
|
|
|
where: `{isActive: true}`,
|
2022-11-14 13:30:35 +00:00
|
|
|
showField: 'description',
|
2022-12-20 10:36:37 +00:00
|
|
|
valueField: 'code'
|
2022-11-14 13:30:35 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2022-12-20 10:36:58 +00:00
|
|
|
field: 'futureIpt',
|
2022-11-14 13:30:35 +00:00
|
|
|
autocomplete: {
|
|
|
|
url: 'ItemPackingTypes',
|
2023-01-17 07:54:26 +00:00
|
|
|
where: `{isActive: true}`,
|
2022-11-14 13:30:35 +00:00
|
|
|
showField: 'description',
|
2022-12-20 10:36:37 +00:00
|
|
|
valueField: 'code'
|
2022-11-14 13:30:35 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
]
|
|
|
|
};
|
2022-12-20 10:36:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$postLink() {
|
2022-11-16 09:57:15 +00:00
|
|
|
this.setDefaultFilter();
|
|
|
|
}
|
|
|
|
|
|
|
|
setDefaultFilter() {
|
2022-12-20 10:36:37 +00:00
|
|
|
let today = new Date();
|
|
|
|
const tomorrow = new Date(today);
|
2022-11-16 09:57:15 +00:00
|
|
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
2023-02-08 12:47:35 +00:00
|
|
|
this.$http.get(`UserConfigs/getUserConfig`)
|
|
|
|
.then(res => {
|
|
|
|
this.filterParams = {
|
|
|
|
dateFuture: tomorrow,
|
|
|
|
dateToAdvance: today,
|
|
|
|
warehouseFk: res.data.warehouseFk
|
|
|
|
};
|
|
|
|
this.$.model.addFilter({}, this.filterParams);
|
|
|
|
});
|
2022-11-14 13:30:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
compareDate(date) {
|
|
|
|
let today = new Date();
|
|
|
|
today.setHours(0, 0, 0, 0);
|
|
|
|
let timeTicket = new Date(date);
|
|
|
|
timeTicket.setHours(0, 0, 0, 0);
|
|
|
|
|
|
|
|
let comparation = today - timeTicket;
|
|
|
|
|
|
|
|
if (comparation == 0)
|
|
|
|
return 'warning';
|
|
|
|
if (comparation < 0)
|
|
|
|
return 'success';
|
|
|
|
}
|
|
|
|
|
|
|
|
get checked() {
|
|
|
|
const tickets = this.$.model.data || [];
|
|
|
|
const checkedLines = [];
|
|
|
|
for (let ticket of tickets) {
|
|
|
|
if (ticket.checked)
|
|
|
|
checkedLines.push(ticket);
|
|
|
|
}
|
|
|
|
|
|
|
|
return checkedLines;
|
|
|
|
}
|
|
|
|
|
|
|
|
stateColor(state) {
|
|
|
|
if (state === 'OK')
|
|
|
|
return 'success';
|
|
|
|
else if (state === 'Libre')
|
|
|
|
return 'notice';
|
|
|
|
}
|
|
|
|
|
|
|
|
dateRange(value) {
|
|
|
|
const minHour = new Date(value);
|
|
|
|
minHour.setHours(0, 0, 0, 0);
|
|
|
|
const maxHour = new Date(value);
|
|
|
|
maxHour.setHours(23, 59, 59, 59);
|
|
|
|
|
|
|
|
return [minHour, maxHour];
|
|
|
|
}
|
|
|
|
|
|
|
|
totalPriceColor(totalWithVat) {
|
2023-02-10 07:46:54 +00:00
|
|
|
return this.isLessThan50(totalWithVat) ? 'warning' : '';
|
|
|
|
}
|
|
|
|
|
|
|
|
totalPriceTitle(totalWithVat) {
|
|
|
|
return this.isLessThan50(totalWithVat) ? 'Less than 50€' : '';
|
|
|
|
}
|
|
|
|
|
|
|
|
isLessThan50(totalWithVat) {
|
|
|
|
return (parseInt(totalWithVat) > 0 && parseInt(totalWithVat) < 50);
|
2022-11-14 13:30:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get confirmationMessage() {
|
|
|
|
if (!this.$.model) return 0;
|
|
|
|
|
|
|
|
return this.$t(`Advance confirmation`, {
|
|
|
|
checked: this.checked.length
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-02-10 07:46:54 +00:00
|
|
|
agencies(futureAgency, agency) {
|
|
|
|
return this.$t(`Origin agency`, {agency: futureAgency}) +
|
|
|
|
'\n' + this.$t(`Destination agency`, {agency: agency});
|
|
|
|
}
|
|
|
|
|
2022-11-14 13:30:35 +00:00
|
|
|
moveTicketsAdvance() {
|
2022-12-20 10:36:58 +00:00
|
|
|
let ticketsToMove = [];
|
|
|
|
this.checked.forEach(ticket => {
|
|
|
|
ticketsToMove.push({
|
|
|
|
originId: ticket.futureId,
|
|
|
|
destinationId: ticket.id,
|
|
|
|
originShipped: ticket.futureShipped,
|
|
|
|
destinationShipped: ticket.shipped,
|
|
|
|
workerFk: ticket.workerFk
|
|
|
|
});
|
2022-11-29 09:29:18 +00:00
|
|
|
});
|
2022-12-20 10:36:58 +00:00
|
|
|
const params = {tickets: ticketsToMove};
|
2022-11-14 13:30:35 +00:00
|
|
|
return this.$http.post('Tickets/merge', params)
|
|
|
|
.then(() => {
|
|
|
|
this.$.model.refresh();
|
|
|
|
this.vnApp.showSuccess(this.$t('Success'));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
exprBuilder(param, value) {
|
|
|
|
switch (param) {
|
2022-11-29 09:29:18 +00:00
|
|
|
case 'id':
|
|
|
|
return {'id': value};
|
2022-12-20 10:36:58 +00:00
|
|
|
case 'futureId':
|
|
|
|
return {'futureId': value};
|
2022-11-29 09:29:18 +00:00
|
|
|
case 'liters':
|
|
|
|
return {'liters': value};
|
|
|
|
case 'lines':
|
|
|
|
return {'lines': value};
|
2023-01-31 14:09:16 +00:00
|
|
|
case 'futureLiters':
|
|
|
|
return {'futureLiters': value};
|
|
|
|
case 'futureLines':
|
|
|
|
return {'futureLines': value};
|
2022-11-29 09:29:18 +00:00
|
|
|
case 'ipt':
|
2023-02-10 07:46:54 +00:00
|
|
|
return {or:
|
|
|
|
[
|
|
|
|
{'ipt': {like: `%${value}%`}},
|
|
|
|
{'ipt': null}
|
|
|
|
]
|
|
|
|
};
|
2022-12-20 10:36:58 +00:00
|
|
|
case 'futureIpt':
|
2023-02-10 07:46:54 +00:00
|
|
|
return {or:
|
|
|
|
[
|
|
|
|
{'futureIpt': {like: `%${value}%`}},
|
|
|
|
{'futureIpt': null}
|
|
|
|
]
|
|
|
|
};
|
2022-11-29 09:29:18 +00:00
|
|
|
case 'totalWithVat':
|
|
|
|
return {'totalWithVat': value};
|
2022-12-20 10:36:58 +00:00
|
|
|
case 'futureTotalWithVat':
|
|
|
|
return {'futureTotalWithVat': value};
|
2022-11-29 09:29:18 +00:00
|
|
|
case 'hasStock':
|
|
|
|
return {'hasStock': value};
|
2022-11-14 13:30:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Controller.$inject = ['$element', '$scope'];
|
|
|
|
|
|
|
|
ngModule.vnComponent('vnTicketAdvance', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
|
|
|
});
|