salix/modules/account/front/main/index.js

40 lines
1022 B
JavaScript

import ngModule from '../module';
import ModuleMain from 'salix/components/module-main';
export default class User extends ModuleMain {
constructor($element, $) {
super($element, $);
this.filter = {
fields: ['id', 'nickname', 'name', 'role'],
include: {
relation: 'role',
scope: {
fields: ['id', 'name']
}
}
};
}
exprBuilder(param, value) {
switch (param) {
case 'search':
return /^\d+$/.test(value)
? {id: value}
: {or: [
{name: {like: `%${value}%`}},
{nickname: {like: `%${value}%`}}
]};
case 'name':
case 'nickname':
return {[param]: {like: `%${value}%`}};
case 'roleFk':
return {[param]: value};
}
}
}
ngModule.vnComponent('vnUser', {
controller: User,
template: require('./index.html')
});