Merge pull request '3683-feat(monito_clients): smart-table and filter by date' (#904) from 3683-monitor_clients into dev
gitea/salix/pipeline/head Build queued...
Details
gitea/salix/pipeline/head Build queued...
Details
Reviewed-on: #904 Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
commit
f74c80cf21
|
@ -40,7 +40,8 @@ module.exports = Self => {
|
||||||
IFNULL(sc.workerSubstitute, c.salesPersonFk) AS salesPersonFk,
|
IFNULL(sc.workerSubstitute, c.salesPersonFk) AS salesPersonFk,
|
||||||
c.id AS clientFk,
|
c.id AS clientFk,
|
||||||
c.name AS clientName,
|
c.name AS clientName,
|
||||||
s.lastUpdate AS dated,
|
TIME(v.stamp) AS hour,
|
||||||
|
DATE(v.stamp) AS dated,
|
||||||
wtc.workerFk
|
wtc.workerFk
|
||||||
FROM hedera.userSession s
|
FROM hedera.userSession s
|
||||||
JOIN hedera.visitUser v ON v.id = s.userVisitFk
|
JOIN hedera.visitUser v ON v.id = s.userVisitFk
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
vn-id="model"
|
vn-id="model"
|
||||||
url="SalesMonitors/clientsFilter"
|
url="SalesMonitors/clientsFilter"
|
||||||
limit="6"
|
limit="6"
|
||||||
order="dated DESC"
|
filter="$ctrl.filter"
|
||||||
|
order="dated DESC, hour DESC"
|
||||||
auto-load="true">
|
auto-load="true">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-horizontal class="header">
|
<vn-horizontal class="header">
|
||||||
|
@ -15,54 +16,81 @@
|
||||||
vn-tooltip="Minimize/Maximize"
|
vn-tooltip="Minimize/Maximize"
|
||||||
ng-click="$ctrl.main.toggle()">
|
ng-click="$ctrl.main.toggle()">
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
<vn-icon
|
|
||||||
icon="refresh"
|
|
||||||
vn-tooltip="Refresh"
|
|
||||||
ng-click="model.refresh()">
|
|
||||||
</vn-icon>
|
|
||||||
</vn-none>
|
</vn-none>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-card vn-id="card">
|
<vn-card vn-id="card">
|
||||||
<vn-table model="model" class="scrollable sm">
|
<smart-table
|
||||||
<vn-thead>
|
model="model"
|
||||||
<vn-tr>
|
options="$ctrl.smartTableOptions"
|
||||||
<vn-th field="dated">Hour</vn-th>
|
expr-builder="$ctrl.exprBuilder(param, value)"
|
||||||
<vn-th field="salesPersonFk" class="expendable">Salesperson</vn-th>
|
class="scrollable sm">
|
||||||
<vn-th field="clientFk">Client</vn-th>
|
<slot-actions>
|
||||||
</vn-tr>
|
<vn-horizontal>
|
||||||
</vn-thead>
|
<vn-date-picker
|
||||||
<vn-tbody>
|
class="vn-pa-xs"
|
||||||
<vn-tr ng-repeat="visit in model.data">
|
label="From"
|
||||||
<vn-td shrink-date>
|
ng-model="$ctrl.dateFrom"
|
||||||
|
on-change="$ctrl.addFilterDate()">
|
||||||
|
</vn-date-picker>
|
||||||
|
<vn-date-picker
|
||||||
|
class="vn-pa-xs"
|
||||||
|
label="To"
|
||||||
|
ng-model="$ctrl.dateTo"
|
||||||
|
on-change="$ctrl.addFilterDate()">
|
||||||
|
</vn-date-picker>
|
||||||
|
</vn-horizontal>
|
||||||
|
</slot-actions>
|
||||||
|
<slot-table>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th field="dated">
|
||||||
|
<span translate>Date</span>
|
||||||
|
</th>
|
||||||
|
<th field="hour">
|
||||||
|
<span translate>Hour</span>
|
||||||
|
</th>
|
||||||
|
<th field="salesPersonFk" class="expendable">
|
||||||
|
<span translate>Salesperson</span>
|
||||||
|
</th>
|
||||||
|
<th field="clientFk">
|
||||||
|
<span translate>Client</span>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr ng-repeat="visit in model.data">
|
||||||
|
<td shrink-date>
|
||||||
<span class="chip">
|
<span class="chip">
|
||||||
{{::visit.dated | date: 'HH:mm'}}
|
{{::visit.dated | date:'dd/MM/yy'}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td class="shrink expendable">
|
<td shrink-date>
|
||||||
|
<span class="chip">
|
||||||
|
{{::visit.hour | date: 'HH:mm'}}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="shrink expendable">
|
||||||
<span
|
<span
|
||||||
title="{{::visit.salesPerson}}"
|
title="{{::visit.salesPerson}}"
|
||||||
vn-click-stop="workerDescriptor.show($event, visit.salesPersonFk)"
|
vn-click-stop="workerDescriptor.show($event, visit.salesPersonFk)"
|
||||||
class="link">
|
class="link">
|
||||||
{{::visit.salesPerson | dashIfEmpty}}
|
{{::visit.salesPerson | dashIfEmpty}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td>
|
<td>
|
||||||
<span
|
<span
|
||||||
title="{{::visit.clientName}}"
|
title="{{::visit.clientName}}"
|
||||||
vn-click-stop="clientDescriptor.show($event, visit.clientFk)"
|
vn-click-stop="clientDescriptor.show($event, visit.clientFk)"
|
||||||
class="link">
|
class="link">
|
||||||
{{::visit.clientName}}
|
{{::visit.clientName}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</td>
|
||||||
</vn-tr>
|
</tr>
|
||||||
</vn-tbody>
|
</tbody>
|
||||||
</vn-table>
|
<table>
|
||||||
<vn-pagination
|
<slot-table>
|
||||||
model="model"
|
</smart-table>
|
||||||
class="vn-pt-xs"
|
|
||||||
scroll-selector="vn-monitor-sales-clients vn-table"
|
|
||||||
scroll-offset="100">
|
|
||||||
</vn-pagination>
|
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-worker-descriptor-popover
|
<vn-worker-descriptor-popover
|
||||||
vn-id="workerDescriptor">
|
vn-id="workerDescriptor">
|
||||||
|
@ -70,32 +98,3 @@
|
||||||
<vn-client-descriptor-popover
|
<vn-client-descriptor-popover
|
||||||
vn-id="clientDescriptor">
|
vn-id="clientDescriptor">
|
||||||
</vn-client-descriptor-popover>
|
</vn-client-descriptor-popover>
|
||||||
<vn-contextmenu vn-id="contextmenu" targets="['vn-monitor-sales-clients vn-table']" model="model"
|
|
||||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
|
||||||
<slot-menu>
|
|
||||||
<vn-item translate
|
|
||||||
ng-if="contextmenu.isFilterAllowed()"
|
|
||||||
ng-click="contextmenu.filterBySelection()">
|
|
||||||
Filter by selection
|
|
||||||
</vn-item>
|
|
||||||
<vn-item translate
|
|
||||||
ng-if="contextmenu.isFilterAllowed()"
|
|
||||||
ng-click="contextmenu.excludeSelection()">
|
|
||||||
Exclude selection
|
|
||||||
</vn-item>
|
|
||||||
<vn-item translate
|
|
||||||
ng-if="contextmenu.isFilterAllowed()"
|
|
||||||
ng-click="contextmenu.removeFilter()">
|
|
||||||
Remove filter
|
|
||||||
</vn-item>
|
|
||||||
<vn-item translate
|
|
||||||
ng-click="contextmenu.removeAllFilters()">
|
|
||||||
Remove all filters
|
|
||||||
</vn-item>
|
|
||||||
<vn-item translate
|
|
||||||
ng-if="contextmenu.isActionAllowed()"
|
|
||||||
ng-click="contextmenu.copyValue()">
|
|
||||||
Copy value
|
|
||||||
</vn-item>
|
|
||||||
</slot-menu>
|
|
||||||
</vn-contextmenu>
|
|
|
@ -2,26 +2,89 @@ import ngModule from '../../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
export default class Controller extends 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) {
|
exprBuilder(param, value) {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case 'dated':
|
|
||||||
return {'s.lastUpdate': {
|
|
||||||
between: this.dateRange(value)}
|
|
||||||
};
|
|
||||||
case 'clientFk':
|
case 'clientFk':
|
||||||
|
return {[`c.id`]: value};
|
||||||
case 'salesPersonFk':
|
case 'salesPersonFk':
|
||||||
return {[`c.${param}`]: value};
|
return {[`c.${param}`]: value};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dateRange(value) {
|
dateRange() {
|
||||||
const minHour = new Date(value);
|
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);
|
minHour.setHours(0, 0, 0, 0);
|
||||||
const maxHour = new Date(value);
|
const maxHour = new Date(to);
|
||||||
maxHour.setHours(23, 59, 59, 59);
|
maxHour.setHours(23, 59, 59, 59);
|
||||||
|
|
||||||
return [minHour, maxHour];
|
return [minHour, maxHour];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addFilterDate() {
|
||||||
|
this.$.model.filter = {
|
||||||
|
where: {
|
||||||
|
'v.stamp': {
|
||||||
|
between: this.dateRange()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.$.model.refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnMonitorSalesClients', {
|
ngModule.vnComponent('vnMonitorSalesClients', {
|
||||||
|
|
Loading…
Reference in New Issue