92 lines
2.4 KiB
JavaScript
92 lines
2.4 KiB
JavaScript
import ngModule from '../module';
|
|
import Section from 'salix/components/section';
|
|
|
|
class Controller extends Section {
|
|
constructor($element, $) {
|
|
super($element, $);
|
|
|
|
this.smartTableOptions = {
|
|
activeButtons: {
|
|
search: true
|
|
},
|
|
columns: [
|
|
{
|
|
field: 'clientFk',
|
|
autocomplete: {
|
|
url: 'Clients',
|
|
showField: 'socialName',
|
|
valueField: 'socialName'
|
|
}
|
|
},
|
|
{
|
|
field: 'workerFk',
|
|
autocomplete: {
|
|
url: 'Workers/activeWithInheritedRole',
|
|
where: `{role: 'salesPerson'}`,
|
|
searchFunction: '{firstName: $search}',
|
|
showField: 'name',
|
|
valueField: 'id',
|
|
}
|
|
},
|
|
{
|
|
field: 'claimStateFk',
|
|
autocomplete: {
|
|
url: 'ClaimStates',
|
|
showField: 'description',
|
|
valueField: 'id',
|
|
}
|
|
},
|
|
{
|
|
field: 'created',
|
|
searchable: false
|
|
}
|
|
]
|
|
};
|
|
}
|
|
|
|
exprBuilder(param, value) {
|
|
switch (param) {
|
|
case 'clientFk':
|
|
return {['cl.socialName']: value};
|
|
case 'id':
|
|
case 'claimStateFk':
|
|
case 'priority':
|
|
return {[`cl.${param}`]: value};
|
|
case 'salesPersonFk':
|
|
case 'attenderFk':
|
|
return {'cl.workerFk': value};
|
|
case 'created':
|
|
value.setHours(0, 0, 0, 0);
|
|
to = new Date(value);
|
|
to.setHours(23, 59, 59, 999);
|
|
|
|
return {'cl.created': {between: [value, to]}};
|
|
}
|
|
}
|
|
|
|
stateColor(claim) {
|
|
switch (claim.description) {
|
|
case 'Pendiente':
|
|
return 'warning';
|
|
case 'Gestionado':
|
|
return 'notice';
|
|
case 'Resuelto':
|
|
return 'success';
|
|
}
|
|
}
|
|
|
|
preview(claim) {
|
|
this.claimSelected = claim;
|
|
this.$.summary.show();
|
|
}
|
|
|
|
reload() {
|
|
this.$.model.refresh();
|
|
}
|
|
}
|
|
|
|
ngModule.vnComponent('vnClaimIndex', {
|
|
template: require('./index.html'),
|
|
controller: Controller
|
|
});
|