salix/front/core/components/worker-autocomplete/index.js

41 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

import ngModule from '../../module';
import Autocomplete from '../autocomplete';
export default class WorkerAutocomplete extends Autocomplete {
constructor(...args) {
super(...args);
}
$onInit() {
2023-07-12 11:12:51 +00:00
super.$onInit();
let url = 'Workers/search';
if (this.departments) {
const parameter = encodeURIComponent(JSON.stringify(this.departments));
url = `Workers/search?departmentCodes=${parameter}`;
}
Object.assign(this, {
label: 'Worker',
2023-08-24 05:40:37 +00:00
url,
2023-06-08 11:12:30 +00:00
searchFunction: function({$search}) {
return {and: [
2023-07-12 11:12:51 +00:00
{'active': {neq: false}},
{or: [
2023-07-12 11:12:51 +00:00
{'name': $search},
{'nickname': {like: '%' + $search + '%'}},
{'code': {like: $search + '%'}}
]}
]};
},
});
}
}
ngModule.vnComponent('vnWorkerAutocomplete', {
slotTemplate: require('./index.html'),
controller: WorkerAutocomplete,
bindings: {
departments: '<?'
},
});