2022-11-07 14:55:17 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
import Section from 'salix/components/section';
|
|
|
|
|
|
|
|
export default class Controller extends Section {
|
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
|
|
|
this.$checkAll = false;
|
|
|
|
|
|
|
|
this.smartTableOptions = {
|
|
|
|
activeButtons: {
|
2022-11-10 14:54:00 +00:00
|
|
|
search: true,
|
2022-11-07 14:55:17 +00:00
|
|
|
},
|
|
|
|
columns: [{
|
2022-12-20 08:54:28 +00:00
|
|
|
field: 'totalProblems',
|
|
|
|
searchable: false,
|
2022-11-07 14:55:17 +00:00
|
|
|
},
|
|
|
|
{
|
2022-12-14 11:17:12 +00:00
|
|
|
field: 'shipped',
|
2022-11-07 14:55:17 +00:00
|
|
|
searchable: false
|
|
|
|
},
|
|
|
|
{
|
2022-12-20 08:54:28 +00:00
|
|
|
field: 'futureShipped',
|
2022-11-07 14:55:17 +00:00
|
|
|
searchable: false
|
2022-11-10 14:54:00 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'state',
|
|
|
|
searchable: false
|
|
|
|
},
|
|
|
|
{
|
2022-12-20 08:54:28 +00:00
|
|
|
field: 'futureState',
|
2022-11-10 14:54:00 +00:00
|
|
|
searchable: false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'ipt',
|
|
|
|
autocomplete: {
|
|
|
|
url: 'ItemPackingTypes',
|
2023-01-17 07:54:26 +00:00
|
|
|
where: `{isActive: true}`,
|
2022-11-10 14:54:00 +00:00
|
|
|
showField: 'description',
|
2022-12-16 12:42:23 +00:00
|
|
|
valueField: 'code'
|
2022-11-10 14:54:00 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2022-12-20 08:54:28 +00:00
|
|
|
field: 'futureIpt',
|
2022-11-10 14:54:00 +00:00
|
|
|
autocomplete: {
|
|
|
|
url: 'ItemPackingTypes',
|
2023-01-17 07:54:26 +00:00
|
|
|
where: `{isActive: true}`,
|
2022-11-10 14:54:00 +00:00
|
|
|
showField: 'description',
|
2022-12-16 12:42:23 +00:00
|
|
|
valueField: 'code'
|
2022-11-10 14:54:00 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
]
|
2022-11-07 14:55:17 +00:00
|
|
|
};
|
2022-12-20 08:54:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$postLink() {
|
2022-11-16 10:10:00 +00:00
|
|
|
this.setDefaultFilter();
|
|
|
|
}
|
|
|
|
|
|
|
|
setDefaultFilter() {
|
|
|
|
const today = new Date();
|
|
|
|
|
|
|
|
this.filterParams = {
|
|
|
|
originDated: today,
|
|
|
|
futureDated: today,
|
2022-12-14 11:17:12 +00:00
|
|
|
warehouseFk: this.vnConfig.warehouseFk
|
2022-11-16 10:10:00 +00:00
|
|
|
};
|
2022-12-20 08:54:28 +00:00
|
|
|
this.$.model.applyFilter(null, this.filterParams);
|
2022-11-07 14:55:17 +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';
|
|
|
|
}
|
|
|
|
|
2022-11-08 14:56:58 +00:00
|
|
|
get checked() {
|
|
|
|
const tickets = this.$.model.data || [];
|
|
|
|
const checkedLines = [];
|
|
|
|
for (let ticket of tickets) {
|
|
|
|
if (ticket.checked)
|
|
|
|
checkedLines.push(ticket);
|
|
|
|
}
|
|
|
|
|
|
|
|
return checkedLines;
|
|
|
|
}
|
|
|
|
|
2022-11-07 14:55:17 +00:00
|
|
|
stateColor(state) {
|
|
|
|
if (state === 'OK')
|
|
|
|
return 'success';
|
2022-11-10 14:54:00 +00:00
|
|
|
else if (state === 'Libre')
|
2022-11-07 14:55:17 +00:00
|
|
|
return 'notice';
|
|
|
|
}
|
2022-11-08 14:56:58 +00:00
|
|
|
|
2022-11-07 14:55:17 +00:00
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
2022-11-08 14:56:58 +00:00
|
|
|
get confirmationMessage() {
|
|
|
|
if (!this.$.model) return 0;
|
|
|
|
|
|
|
|
return this.$t(`Move confirmation`, {
|
|
|
|
checked: this.checked.length
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
moveTicketsFuture() {
|
2022-12-20 08:54:28 +00:00
|
|
|
let ticketsToMove = [];
|
|
|
|
this.checked.forEach(ticket => {
|
|
|
|
ticketsToMove.push({
|
|
|
|
originId: ticket.id,
|
|
|
|
destinationId: ticket.futureId,
|
|
|
|
originShipped: ticket.shipped,
|
|
|
|
destinationShipped: ticket.futureShipped,
|
|
|
|
workerFk: ticket.workerFk
|
|
|
|
});
|
|
|
|
});
|
|
|
|
let params = {tickets: ticketsToMove};
|
2022-11-08 14:56:58 +00:00
|
|
|
return this.$http.post('Tickets/merge', params)
|
|
|
|
.then(() => {
|
|
|
|
this.$.model.refresh();
|
|
|
|
this.vnApp.showSuccess(this.$t('Success'));
|
|
|
|
});
|
2022-11-07 14:55:17 +00:00
|
|
|
}
|
2022-11-10 14:54:00 +00:00
|
|
|
|
|
|
|
exprBuilder(param, value) {
|
|
|
|
switch (param) {
|
2022-12-14 11:17:12 +00:00
|
|
|
case 'id':
|
|
|
|
return {'id': value};
|
2022-12-20 08:54:28 +00:00
|
|
|
case 'futureId':
|
|
|
|
return {'futureId': value};
|
2022-12-14 11:17:12 +00:00
|
|
|
case 'liters':
|
|
|
|
return {'liters': value};
|
|
|
|
case 'lines':
|
|
|
|
return {'lines': value};
|
|
|
|
case 'ipt':
|
|
|
|
return {'ipt': value};
|
2022-12-20 08:54:28 +00:00
|
|
|
case 'futureIpt':
|
|
|
|
return {'futureIpt': value};
|
2022-11-10 14:54:00 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-07 14:55:17 +00:00
|
|
|
}
|
|
|
|
|
2022-11-08 14:56:58 +00:00
|
|
|
Controller.$inject = ['$element', '$scope'];
|
|
|
|
|
2022-11-07 14:55:17 +00:00
|
|
|
ngModule.vnComponent('vnTicketFuture', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
|
|
|
});
|