39 lines
897 B
JavaScript
39 lines
897 B
JavaScript
|
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
|
||
|
});
|