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

51 lines
1.4 KiB
JavaScript
Raw Normal View History

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