salix/modules/monitor/front/index/clients/index.js

97 lines
2.4 KiB
JavaScript
Raw Normal View History

2021-05-11 07:43:15 +00:00
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
}
]
};
}
2021-05-11 07:43:15 +00:00
exprBuilder(param, value) {
switch (param) {
case 'clientFk':
return {[`c.id`]: value};
2021-05-11 07:43:15 +00:00
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);
2021-05-11 07:43:15 +00:00
minHour.setHours(0, 0, 0, 0);
const maxHour = new Date(to);
2021-05-11 07:43:15 +00:00
maxHour.setHours(23, 59, 59, 59);
return [minHour, maxHour];
}
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
});