This commit is contained in:
parent
fcf7ac0ad7
commit
e13ecabddf
|
@ -0,0 +1,3 @@
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`)
|
||||||
|
VALUES
|
||||||
|
('Vehicle','getVehiclesSorted','WRITE','ALLOW','employee');
|
|
@ -0,0 +1,31 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('getVehiclesSorted', {
|
||||||
|
description: 'Sort the vehicles by a warehouse',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'warehouseFk',
|
||||||
|
type: 'number'
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: ['object'],
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/getVehiclesSorted`,
|
||||||
|
verb: `POST`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.getVehiclesSorted = async(ctx, options) => {
|
||||||
|
const args = ctx.args;
|
||||||
|
|
||||||
|
const vehicles = await Self.rawSql(`
|
||||||
|
SELECT v.id, v.numberPlate, w.name
|
||||||
|
FROM vehicle v
|
||||||
|
JOIN warehouse w ON w.id = v.warehouseFk
|
||||||
|
WHERE v.warehouseFk = ?
|
||||||
|
ORDER BY v.warehouseFk DESC, v.numberPlate ASC`, args.warehouseFk);
|
||||||
|
|
||||||
|
return [vehicles];
|
||||||
|
};
|
||||||
|
};
|
|
@ -1,3 +1,4 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('../methods/vehicle/currentWarehouse')(Self);
|
require('../methods/vehicle/currentWarehouse')(Self);
|
||||||
|
require('../methods/vehicle/getVehiclesSorted')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,16 +25,14 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
ng-model="$ctrl.route.vehicleFk"
|
ng-model="$ctrl.route.vehicleFk"
|
||||||
url="Vehicles"
|
data="$ctrl.vehicles"
|
||||||
fields="['warehouseFk']"
|
|
||||||
include="{relation: 'warehouse'}"
|
|
||||||
show-field="numberPlate"
|
show-field="numberPlate"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
label="Vehicle">
|
label="Vehicle">
|
||||||
<tpl-item>
|
<tpl-item>
|
||||||
{{numberPlate}} - {{warehouse.name}}
|
{{numberPlate}} - {{warehouse.name}}
|
||||||
</tpl-item>
|
</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-date-picker
|
<vn-date-picker
|
||||||
|
|
|
@ -7,6 +7,10 @@ class Controller extends Section {
|
||||||
this.card.reload()
|
this.card.reload()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
constructor($element, $) {
|
||||||
|
super($element, $);
|
||||||
|
this.$http.post(`Vehicles/getVehiclesSorted`, {params: {warehouseFk: 1}});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnRouteBasicData', {
|
ngModule.vnComponent('vnRouteBasicData', {
|
||||||
|
|
Loading…
Reference in New Issue