import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; export default class Client extends ModuleMain { async exprBuilder(param, value) { switch (param) { case 'search': return /^\d+$/.test(value) ? {id: value} : {or: [{name: {like: `%${value}%`}}, {socialName: {like: `%${value}%`}}]}; case 'phone': return { or: [ {phone: value}, {mobile: value} ] }; case 'zoneFk': await this.getPostCodesFromZone(value); console.log(this.postCodeIds); return {postcode: {inq: this.postCodeIds}}; case 'name': case 'socialName': case 'city': case 'email': return {[param]: {like: `%${value}%`}}; case 'id': case 'fi': case 'postcode': case 'provinceFk': case 'salesPersonFk': return {[param]: value}; } } async getPostCodesFromZone(zoneId) { const params = { zoneId: zoneId }; this.$http.get('Clients/getPostCodeFromZone', {params}) .then(res => { this.postCodeIds = res.data; }); } } ngModule.vnComponent('vnClient', { controller: Client, template: require('./index.html') });