feat(client_search-panel): add zone and province
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
43fcd0c473
commit
ade5e9256d
|
@ -0,0 +1,38 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getPostCodeFromZone', {
|
||||
description: 'CHANGEEEEEEEEEEEEEEE',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'zoneId',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'zone id'
|
||||
}],
|
||||
returns: {
|
||||
type: 'number',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getPostCodeFromZone`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getPostCodeFromZone = async(zoneId, options) => {
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const query = `
|
||||
SELECT p.code
|
||||
FROM postCode p
|
||||
JOIN zoneIncluded z ON z.geoFk = p.geoFk
|
||||
WHERE z.zoneFk = ?`;
|
||||
const postCodes = await Self.rawSql(query, [zoneId], myOptions);
|
||||
const postCodeIds = [];
|
||||
postCodes.map(postCode => postCodeIds.push(postCode.code));
|
||||
console.log(postCodeIds);
|
||||
return postCodeIds;
|
||||
};
|
||||
};
|
|
@ -30,6 +30,7 @@ module.exports = Self => {
|
|||
require('../methods/client/consumption')(Self);
|
||||
require('../methods/client/createReceipt')(Self);
|
||||
require('../methods/client/updatePortfolio')(Self);
|
||||
require('../methods/client/getPostCodeFromZone')(Self);
|
||||
|
||||
// Validations
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import ngModule from '../module';
|
|||
import ModuleMain from 'salix/components/module-main';
|
||||
|
||||
export default class Client extends ModuleMain {
|
||||
exprBuilder(param, value) {
|
||||
async exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
|
@ -15,6 +15,10 @@ export default class Client extends ModuleMain {
|
|||
{mobile: value}
|
||||
]
|
||||
};
|
||||
case 'zoneFk':
|
||||
await this.getPostCodesFromZone(value);
|
||||
console.log(this.postCodeIds);
|
||||
return {postcode: {inq: this.postCodeIds}};
|
||||
case 'name':
|
||||
case 'socialName':
|
||||
case 'city':
|
||||
|
@ -23,10 +27,21 @@ export default class Client extends ModuleMain {
|
|||
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', {
|
||||
|
|
|
@ -50,6 +50,22 @@
|
|||
ng-model="filter.postcode">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
ng-model="filter.provinceFk"
|
||||
url="Provinces"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
label="Province">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
ng-model="filter.zoneFk"
|
||||
url="Zones"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
label="Zone">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
|
|
|
@ -26,5 +26,17 @@
|
|||
"sons": {
|
||||
"type": "Number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"zoneIncluded": {
|
||||
"type": "hasMany",
|
||||
"model": "Zone",
|
||||
"foreignKey": "geoFk"
|
||||
},
|
||||
"postcode": {
|
||||
"type": "hasMany",
|
||||
"model": "PostCode",
|
||||
"foreignKey": "geoFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -48,6 +48,11 @@
|
|||
"model": "AgencyMode",
|
||||
"foreignKey": "agencyModeFk"
|
||||
},
|
||||
"geo": {
|
||||
"type": "belongsTo",
|
||||
"model": "ZoneGeo",
|
||||
"foreignKey": "geoFk"
|
||||
},
|
||||
"events": {
|
||||
"type": "hasMany",
|
||||
"model": "ZoneEvent",
|
||||
|
@ -67,6 +72,11 @@
|
|||
"type": "hasMany",
|
||||
"model": "ZoneClosure",
|
||||
"foreignKey": "zoneFk"
|
||||
},
|
||||
"provinces": {
|
||||
"type": "hasMany",
|
||||
"model": "Province",
|
||||
"foreignKey": "zoneFk"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue