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

97 lines
2.4 KiB
JavaScript
Raw Permalink 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, $);
2023-01-16 14:18:24 +00:00
const date = Date.vnNew();
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)
2023-01-16 14:18:24 +00:00
from = Date.vnNew();
if (!to)
2023-01-16 14:18:24 +00:00
to = Date.vnNew();
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
});