refs #5066 metodo getVehiclesSorted
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Satorres 2023-04-19 15:09:52 +02:00
parent c69864aa3b
commit 365c209d9f
5 changed files with 23 additions and 16 deletions

View File

@ -22,7 +22,7 @@ describe('Route basic Data path', () => {
nextMonth.setMonth(nextMonth.getMonth() + 1); nextMonth.setMonth(nextMonth.getMonth() + 1);
await page.autocompleteSearch(selectors.routeBasicData.worker, 'adminBossNick'); await page.autocompleteSearch(selectors.routeBasicData.worker, 'adminBossNick');
await page.autocompleteSearch(selectors.routeBasicData.vehicle, '1111-IMK - Warehouse One'); await page.autocompleteSearch(selectors.routeBasicData.vehicle, '3333-BAT - Warehouse One');
await page.pickDate(selectors.routeBasicData.createdDate, nextMonth); await page.pickDate(selectors.routeBasicData.createdDate, nextMonth);
await page.clearInput(selectors.routeBasicData.kmStart); await page.clearInput(selectors.routeBasicData.kmStart);
await page.write(selectors.routeBasicData.kmStart, '1'); await page.write(selectors.routeBasicData.kmStart, '1');

View File

@ -275,5 +275,7 @@
"Insert a date range": "Inserte un rango de fechas", "Insert a date range": "Inserte un rango de fechas",
"Added observation": "{{user}} añadió esta observacion: {{text}}", "Added observation": "{{user}} añadió esta observacion: {{text}}",
"Comment added to client": "Observación añadida al cliente {{clientFk}}", "Comment added to client": "Observación añadida al cliente {{clientFk}}",
"Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen" "Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen",
"Valid priorities: 1,2,3": "Valid priorities: 1,2,3",
"No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº 2": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº 2"
} }

View File

@ -1,5 +1,5 @@
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('getVehiclesSorted', { Self.remoteMethod('getVehiclesSorted', {
description: 'Sort the vehicles by a warehouse', description: 'Sort the vehicles by a warehouse',
accessType: 'WRITE', accessType: 'WRITE',
accepts: [{ accepts: [{
@ -16,16 +16,13 @@ module.exports = Self => {
} }
}); });
Self.getVehiclesSorted = async(ctx, options) => { Self.getVehiclesSorted = async warehouseFk => {
const args = ctx.args;
const vehicles = await Self.rawSql(` const vehicles = await Self.rawSql(`
SELECT v.id, v.numberPlate, w.name SELECT v.id, v.numberPlate, w.name
FROM vehicle v FROM vehicle v
JOIN warehouse w ON w.id = v.warehouseFk JOIN warehouse w ON w.id = v.warehouseFk
WHERE v.warehouseFk = ? ORDER BY v.warehouseFk = ? DESC, v.numberPlate ASC`, [warehouseFk]);
ORDER BY v.warehouseFk DESC, v.numberPlate ASC`, args.warehouseFk);
return [vehicles]; return vehicles;
}; };
}; };

View File

@ -21,7 +21,6 @@
<div>{{name}} - {{nickname}}</div> <div>{{name}} - {{nickname}}</div>
</tpl-item> </tpl-item>
</vn-autocomplete> </vn-autocomplete>
{{$ctrl.route.vehicleFk}}
<vn-autocomplete <vn-autocomplete
vn-one vn-one
ng-model="$ctrl.route.vehicleFk" ng-model="$ctrl.route.vehicleFk"
@ -30,7 +29,7 @@
value-field="id" value-field="id"
label="Vehicle"> label="Vehicle">
<tpl-item> <tpl-item>
{{numberPlate}} - {{warehouse.name}} {{numberPlate}} - {{name}}
</tpl-item> </tpl-item>
</vn-autocomplete> </vn-autocomplete>
</vn-horizontal> </vn-horizontal>

View File

@ -9,7 +9,16 @@ class Controller extends Section {
} }
constructor($element, $) { constructor($element, $) {
super($element, $); super($element, $);
this.$http.post(`Vehicles/getVehiclesSorted`, {params: {warehouseFk: 1}}); this.$http.get(`UserConfigs/getUserConfig`)
.then(res => {
if (res && res.data) {
this.$http.post(`Vehicles/getVehiclesSorted`, {warehouseFk: res.data.warehouseFk})
.then(res => {
if (res && res.data)
this.vehicles = res.data;
});
}
});
} }
} }