106 lines
2.7 KiB
JavaScript
106 lines
2.7 KiB
JavaScript
|
import ngModule from '../../module';
|
||
|
import Section from 'salix/components/section';
|
||
|
import './style.scss';
|
||
|
|
||
|
export default class Controller extends Section {
|
||
|
constructor($element, $) {
|
||
|
super($element, $);
|
||
|
|
||
|
this.filterParams = this.fetchParams({
|
||
|
scopeDays: 1
|
||
|
});
|
||
|
}
|
||
|
|
||
|
fetchParams($params) {
|
||
|
if (!Object.entries($params).length)
|
||
|
$params.scopeDays = 1;
|
||
|
|
||
|
if (typeof $params.scopeDays === 'number') {
|
||
|
const from = new Date();
|
||
|
from.setHours(0, 0, 0, 0);
|
||
|
|
||
|
const to = new Date(from.getTime());
|
||
|
to.setDate(to.getDate() + $params.scopeDays);
|
||
|
to.setHours(23, 59, 59, 999);
|
||
|
|
||
|
Object.assign($params, {from, to});
|
||
|
}
|
||
|
|
||
|
return $params;
|
||
|
}
|
||
|
|
||
|
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';
|
||
|
}
|
||
|
|
||
|
stateColor(ticket) {
|
||
|
if (ticket.alertLevelCode === 'OK')
|
||
|
return 'success';
|
||
|
else if (ticket.alertLevelCode === 'FREE')
|
||
|
return 'notice';
|
||
|
else if (ticket.alertLevel === 1)
|
||
|
return 'warning';
|
||
|
else if (ticket.alertLevel === 0)
|
||
|
return 'alert';
|
||
|
}
|
||
|
|
||
|
totalPriceColor(ticket) {
|
||
|
const total = parseInt(ticket.totalWithVat);
|
||
|
if (total > 0 && total < 50)
|
||
|
return 'warning';
|
||
|
}
|
||
|
|
||
|
exprBuilder(param, value) {
|
||
|
switch (param) {
|
||
|
case 'stateFk':
|
||
|
return {'ts.stateFk': value};
|
||
|
case 'salesPersonFk':
|
||
|
return {'c.salesPersonFk': value};
|
||
|
case 'provinceFk':
|
||
|
return {'a.provinceFk': value};
|
||
|
case 'hour':
|
||
|
return {'z.hour': value};
|
||
|
case 'shipped':
|
||
|
return {'t.shipped': {
|
||
|
between: this.dateRange(value)}
|
||
|
};
|
||
|
case 'id':
|
||
|
case 'refFk':
|
||
|
case 'zoneFk':
|
||
|
case 'nickname':
|
||
|
case 'agencyModeFk':
|
||
|
case 'warehouseFk':
|
||
|
return {[`t.${param}`]: value};
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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];
|
||
|
}
|
||
|
|
||
|
preview(ticket) {
|
||
|
this.selectedTicket = ticket;
|
||
|
this.$.summary.show();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
ngModule.vnComponent('vnMonitorSalesTickets', {
|
||
|
template: require('./index.html'),
|
||
|
controller: Controller
|
||
|
});
|