add new row
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
644c24fa3b
commit
a32f7b5ef1
|
@ -2457,12 +2457,6 @@ INSERT INTO `bs`.`defaulter` (`clientFk`, `amount`, `created`, `defaulterSinced`
|
|||
(1107, 500, CURDATE(), CURDATE()),
|
||||
(1109, 500, CURDATE(), CURDATE());
|
||||
|
||||
INSERT INTO `vn`.`agencyTerm` (`agencyFk`, `minimumPackages`, `kmPrice`, `packagePrice`, `routePrice`, `minimumKm`, `minimumM3`, `m3Price`)
|
||||
VALUES
|
||||
(1, 0, 0.00, 0.00, NULL, 0, 0.00, 0),
|
||||
(3, 0, 0.00, 3.05, NULL, 0, 0.00, 0),
|
||||
(2, 60, 0.00, 0.00, NULL, 0, 5.00, 33);
|
||||
|
||||
UPDATE `vn`.`agency`
|
||||
SET `supplierFk`=1
|
||||
WHERE `id`=1;
|
||||
|
@ -2505,4 +2499,4 @@ INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackage
|
|||
(2, 1, 60, 0.00, 0.00, NULL, 0, 5.00, 33),
|
||||
(3, 2, 0, 15.00, 0.00, NULL, 0, 0.00, 0),
|
||||
(4, 2, 0, 20.00, 0.00, NULL, 0, 0.00, 0),
|
||||
(5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0);
|
||||
(5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0);
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('freeAgencies', {
|
||||
description: 'Returns a list of agencies without a supplier assigned',
|
||||
accepts: [{
|
||||
arg: 'filter',
|
||||
type: 'object',
|
||||
description: `Filter defining where, order, offset, and limit - must be a JSON-encoded string`
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/freeAgencies`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.freeAgencies = async(filter, options) => {
|
||||
const conn = Self.dataSource.connector;
|
||||
const where = {'sat.supplierFk': null};
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
filter = mergeFilters(filter, {where});
|
||||
|
||||
let stmt = new ParameterizedSQL(
|
||||
`SELECT a.name, a.id
|
||||
FROM agency a
|
||||
LEFT JOIN supplierAgencyTerm sat ON sat.agencyFk = a.id`,
|
||||
null, myOptions);
|
||||
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
|
||||
return conn.executeStmt(stmt);
|
||||
};
|
||||
};
|
|
@ -36,6 +36,13 @@
|
|||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"agency": {
|
||||
"type": "belongsTo",
|
||||
"model": "Agency",
|
||||
"foreignKey": "agencyFk"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "EXECUTE",
|
||||
|
|
|
@ -7,6 +7,7 @@ module.exports = Self => {
|
|||
require('../methods/supplier/getSummary')(Self);
|
||||
require('../methods/supplier/updateFiscalData')(Self);
|
||||
require('../methods/supplier/consumption')(Self);
|
||||
require('../methods/supplier/freeAgencies')(Self);
|
||||
|
||||
Self.validatesPresenceOf('name', {
|
||||
message: 'The social name cannot be empty'
|
||||
|
|
|
@ -8,14 +8,13 @@
|
|||
</vn-watcher>
|
||||
<vn-crud-model
|
||||
auto-load="true"
|
||||
url="Agencies"
|
||||
filter="$ctrl.filter"
|
||||
url="Suppliers/freeAgencies"
|
||||
data="$ctrl.agencies">
|
||||
</vn-crud-model>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-id="agency" vn-one
|
||||
<vn-autocomplete vn-one
|
||||
label="Agency"
|
||||
ng-model="$ctrl.supplierAgencyTerm.agencyFk"
|
||||
data="$ctrl.agencies"
|
||||
|
|
|
@ -8,21 +8,6 @@ export default class Controller extends Section {
|
|||
this.supplierAgencyTerm = {
|
||||
supplierFk: this.$params.id
|
||||
};
|
||||
|
||||
this.filter = {
|
||||
include: {
|
||||
relation: 'supplierAgencyTerm',
|
||||
scope: {
|
||||
where: {
|
||||
supplierFk: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
console.log(this);
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
url="SupplierAgencyTerms"
|
||||
link="{supplierFk: $ctrl.$params.id}"
|
||||
primary-key="agencyFk"
|
||||
filter="$ctrl.filter"
|
||||
data="$ctrl.supplierAgencyTerms"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
|
@ -14,15 +15,13 @@
|
|||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-lg">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal ng-repeat="supplierAgencyTerm in $ctrl.supplierAgencyTerms">
|
||||
<vn-autocomplete
|
||||
<vn-textfield
|
||||
disabled="true"
|
||||
vn-id="agency"
|
||||
label="Agency"
|
||||
ng-model="supplierAgencyTerm.agencyFk"
|
||||
url="Agencies"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
ng-model="supplierAgencyTerm.agency.name"
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
</vn-textfield>
|
||||
<vn-input-number
|
||||
type="number"
|
||||
label="Minimum M3"
|
||||
|
|
|
@ -2,6 +2,18 @@ import ngModule from '../../module';
|
|||
import Section from 'salix/components/section';
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.filter = {
|
||||
include:
|
||||
{relation: 'agency',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
add() {
|
||||
this.$.model.insert({});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue