salix/modules/ticket/front/future/index.js

148 lines
3.7 KiB
JavaScript
Raw Normal View History

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,
},
columns: [{
2022-11-08 14:56:58 +00:00
field: 'problems',
searchable: false
},
{
2022-11-08 14:56:58 +00:00
field: 'originETD',
searchable: false
},
{
2022-11-08 14:56:58 +00:00
field: 'destETD',
searchable: false
2022-11-10 14:54:00 +00:00
},
{
field: 'state',
searchable: false
},
{
field: 'tfState',
searchable: false
},
{
field: 'ipt',
autocomplete: {
url: 'ItemPackingTypes',
showField: 'description',
valueField: 'code'
}
},
{
field: 'tfIpt',
autocomplete: {
url: 'ItemPackingTypes',
showField: 'description',
valueField: 'code'
}
},
]
};
2022-11-16 10:10:00 +00:00
this.setDefaultFilter();
}
setDefaultFilter() {
const today = new Date();
this.filterParams = {
originDated: today,
futureDated: today,
linesMax: '9999',
litersMax: '9999',
warehouseFk: 1
};
}
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;
}
stateColor(state) {
if (state === 'OK')
return 'success';
2022-11-10 14:54:00 +00:00
else if (state === 'Libre')
return 'notice';
}
2022-11-08 14:56:58 +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() {
let params = { tickets: this.checked };
return this.$http.post('Tickets/merge', params)
.then(() => {
this.$.model.refresh();
this.vnApp.showSuccess(this.$t('Success'));
});
}
2022-11-10 14:54:00 +00:00
exprBuilder(param, value) {
switch (param) {
case 'id':
return { 'id': value };
case 'ticketFuture':
return { 'ticketFuture': value };
case 'litersMax':
return { 'liters': value };
case 'linesMax':
return { 'lines': value };
case 'ipt':
return { 'ipt': value };
case 'tfIpt':
return { 'tfIpt': value };
}
}
}
2022-11-08 14:56:58 +00:00
Controller.$inject = ['$element', '$scope'];
ngModule.vnComponent('vnTicketFuture', {
template: require('./index.html'),
controller: Controller
});