97 lines
2.4 KiB
JavaScript
97 lines
2.4 KiB
JavaScript
import ngModule from '../../module';
|
|
import Section from 'salix/components/section';
|
|
|
|
export default class Controller extends Section {
|
|
constructor($element, $) {
|
|
super($element, $);
|
|
|
|
const date = new Date();
|
|
this.dateFrom = date;
|
|
this.dateTo = date;
|
|
this.filter = {
|
|
where: {
|
|
'v.stamp': {
|
|
between: this.dateRange()
|
|
}
|
|
}
|
|
};
|
|
|
|
this.smartTableOptions = {
|
|
activeButtons: {
|
|
search: true
|
|
},
|
|
columns: [
|
|
{
|
|
field: 'clientFk',
|
|
autocomplete: {
|
|
url: 'Clients',
|
|
showField: 'name',
|
|
valueField: 'id'
|
|
}
|
|
},
|
|
{
|
|
field: 'salesPersonFk',
|
|
autocomplete: {
|
|
url: 'Workers/activeWithInheritedRole',
|
|
where: `{role: 'salesPerson'}`,
|
|
searchFunction: '{firstName: $search}',
|
|
showField: 'nickname',
|
|
valueField: 'id',
|
|
}
|
|
},
|
|
{
|
|
field: 'dated',
|
|
searchable: false
|
|
},
|
|
{
|
|
field: 'hour',
|
|
searchable: false
|
|
}
|
|
]
|
|
};
|
|
}
|
|
|
|
exprBuilder(param, value) {
|
|
switch (param) {
|
|
case 'clientFk':
|
|
return {[`c.id`]: value};
|
|
case 'salesPersonFk':
|
|
return {[`c.${param}`]: value};
|
|
}
|
|
}
|
|
|
|
dateRange() {
|
|
let from = this.dateFrom;
|
|
let to = this.dateTo;
|
|
if (!from)
|
|
from = new Date();
|
|
if (!to)
|
|
to = new Date();
|
|
const minHour = new Date(from);
|
|
minHour.setHours(0, 0, 0, 0);
|
|
const maxHour = new Date(to);
|
|
maxHour.setHours(23, 59, 59, 59);
|
|
|
|
return [minHour, maxHour];
|
|
}
|
|
|
|
addFilterDate() {
|
|
this.$.model.filter = {
|
|
where: {
|
|
'v.stamp': {
|
|
between: this.dateRange()
|
|
}
|
|
}
|
|
};
|
|
this.$.model.refresh();
|
|
}
|
|
}
|
|
|
|
ngModule.vnComponent('vnMonitorSalesClients', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
require: {
|
|
main: '^vnMonitorIndex'
|
|
}
|
|
});
|