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, $);
|
|
|
|
|
2023-01-16 14:18:24 +00:00
|
|
|
const date = Date.vnNew();
|
2022-03-21 10:32:26 +00:00
|
|
|
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)
|
2023-01-16 14:18:24 +00:00
|
|
|
from = Date.vnNew();
|
2022-03-21 10:32:26 +00:00
|
|
|
if (!to)
|
2023-01-16 14:18:24 +00:00
|
|
|
to = Date.vnNew();
|
2022-03-21 10:32:26 +00:00
|
|
|
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
|
|
|
});
|