166 lines
4.4 KiB
JavaScript
166 lines
4.4 KiB
JavaScript
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: {
|
|
search: true,
|
|
},
|
|
columns: [
|
|
{
|
|
field: 'state',
|
|
searchable: false
|
|
},
|
|
{
|
|
field: 'tfState',
|
|
searchable: false
|
|
},
|
|
{
|
|
field: 'totalWithVat',
|
|
searchable: false
|
|
},
|
|
{
|
|
field: 'tfTotalWithVat',
|
|
searchable: false
|
|
},
|
|
{
|
|
field: 'destETD',
|
|
searchable: false
|
|
},
|
|
{
|
|
field: 'ipt',
|
|
autocomplete: {
|
|
url: 'ItemPackingTypes',
|
|
showField: 'description',
|
|
valueField: 'description'
|
|
}
|
|
},
|
|
{
|
|
field: 'tfIpt',
|
|
autocomplete: {
|
|
url: 'ItemPackingTypes',
|
|
showField: 'description',
|
|
valueField: 'description'
|
|
}
|
|
},
|
|
]
|
|
};
|
|
this.setDefaultFilter();
|
|
}
|
|
|
|
setDefaultFilter() {
|
|
const tomorrow = new Date();
|
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
|
|
this.filterParams = {
|
|
shipped: tomorrow,
|
|
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';
|
|
}
|
|
|
|
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) {
|
|
const total = parseInt(totalWithVat);
|
|
if (total > 0 && total < 50)
|
|
return 'warning';
|
|
}
|
|
|
|
get confirmationMessage() {
|
|
if (!this.$.model) return 0;
|
|
|
|
return this.$t(`Advance confirmation`, {
|
|
checked: this.checked.length
|
|
});
|
|
}
|
|
|
|
moveTicketsAdvance() {
|
|
let ticketsToAdvance = this.checked;
|
|
ticketsToAdvance.forEach(function(elem, index, arr) {
|
|
let aux = arr[index].ticketFuture;
|
|
arr[index].ticketFuture = arr[index].id;
|
|
arr[index].id = aux;
|
|
});
|
|
|
|
const params = { tickets: ticketsToAdvance };
|
|
return this.$http.post('Tickets/merge', params)
|
|
.then(() => {
|
|
this.$.model.refresh();
|
|
this.vnApp.showSuccess(this.$t('Success'));
|
|
});
|
|
}
|
|
|
|
exprBuilder(param, value) {
|
|
switch (param) {
|
|
case 'id':
|
|
return { 'id': value };
|
|
case 'ticketFuture':
|
|
return { 'ticketFuture': value };
|
|
case 'liters':
|
|
return { 'liters': value };
|
|
case 'lines':
|
|
return { 'lines': value };
|
|
case 'ipt':
|
|
return { 'ipt': value };
|
|
case 'tfIpt':
|
|
return { 'tfIpt': value };
|
|
case 'totalWithVat':
|
|
return { 'totalWithVat': value };
|
|
case 'tfTotalWithVat':
|
|
return { 'tfTotalWithVat': value };
|
|
case 'hasStock':
|
|
return { 'hasStock': value };
|
|
}
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$element', '$scope'];
|
|
|
|
ngModule.vnComponent('vnTicketAdvance', {
|
|
template: require('./index.html'),
|
|
controller: Controller
|
|
});
|