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 => {
|
||||
require('../methods/vehicle/currentWarehouse')(Self);
|
||||
require('../methods/vehicle/getVehiclesSorted')(Self);
|
||||
};
|
||||
|
|
|
@ -25,16 +25,14 @@
|
|||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="$ctrl.route.vehicleFk"
|
||||
url="Vehicles"
|
||||
fields="['warehouseFk']"
|
||||
include="{relation: 'warehouse'}"
|
||||
data="$ctrl.vehicles"
|
||||
show-field="numberPlate"
|
||||
value-field="id"
|
||||
label="Vehicle">
|
||||
<tpl-item>
|
||||
{{numberPlate}} - {{warehouse.name}}
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-date-picker
|
||||
|
|
|
@ -7,6 +7,10 @@ class Controller extends Section {
|
|||
this.card.reload()
|
||||
);
|
||||
}
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.$http.post(`Vehicles/getVehiclesSorted`, {params: {warehouseFk: 1}});
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnRouteBasicData', {
|
||||
|
|
Loading…
Reference in New Issue