salix/modules/worker/front/index/index.js

39 lines
897 B
JavaScript
Raw Normal View History

2019-01-28 15:24:45 +00:00
import ngModule from '../module';
export default class Controller {
constructor($) {
Object.assign(this, {
$,
selectedWorker: null
});
}
exprBuilder(param, value) {
switch (param) {
case 'search':
return /^\d+$/.test(value)
? {id: value}
: {name: {like: `%${value}%`}};
case 'name':
return {[param]: {like: `%${value}%`}};
case 'id':
return {[param]: value};
}
}
preview(event, worker) {
if (event.defaultPrevented) return;
event.preventDefault();
this.selectedWorker = worker;
this.$.preview.show();
event.stopImmediatePropagation();
}
}
Controller.$inject = ['$scope'];
ngModule.component('vnWorkerIndex', {
template: require('./index.html'),
controller: Controller
});