2021-05-11 07:43:15 +00:00
|
|
|
import ngModule from '../../module';
|
|
|
|
import Section from 'salix/components/section';
|
|
|
|
|
|
|
|
export default class Controller extends Section {
|
2022-03-21 10:32:26 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-11 07:43:15 +00:00
|
|
|
exprBuilder(param, value) {
|
|
|
|
switch (param) {
|
|
|
|
case 'clientFk':
|
2022-03-21 10:32:26 +00:00
|
|
|
return {[`c.id`]: value};
|
2021-05-11 07:43:15 +00:00
|
|
|
case 'salesPersonFk':
|
|
|
|
return {[`c.${param}`]: value};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-21 10:32:26 +00:00
|
|
|
dateRange() {
|
|
|
|
let from = this.dateFrom;
|
|
|
|
let to = this.dateTo;
|
|
|
|
if (!from)
|
|
|
|
from = new Date();
|
|
|
|
if (!to)
|
|
|
|
to = new Date();
|
|
|
|
const minHour = new Date(from);
|
2021-05-11 07:43:15 +00:00
|
|
|
minHour.setHours(0, 0, 0, 0);
|
2022-03-21 10:32:26 +00:00
|
|
|
const maxHour = new Date(to);
|
2021-05-11 07:43:15 +00:00
|
|
|
maxHour.setHours(23, 59, 59, 59);
|
|
|
|
|
|
|
|
return [minHour, maxHour];
|
|
|
|
}
|
2022-03-21 10:32:26 +00:00
|
|
|
|
|
|
|
addFilterDate() {
|
|
|
|
this.$.model.filter = {
|
|
|
|
where: {
|
|
|
|
'v.stamp': {
|
|
|
|
between: this.dateRange()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
this.$.model.refresh();
|
|
|
|
}
|
2021-05-11 07:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.vnComponent('vnMonitorSalesClients', {
|
|
|
|
template: require('./index.html'),
|
2021-06-15 11:48:42 +00:00
|
|
|
controller: Controller,
|
|
|
|
require: {
|
|
|
|
main: '^vnMonitorIndex'
|
|
|
|
}
|
2021-05-11 07:43:15 +00:00
|
|
|
});
|