refs #6276 saleTrackingDel
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
3333c83702
commit
d5f09c2f75
|
@ -4,4 +4,5 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp
|
|||
('ExpeditionPallet', 'getPallet', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('MachineWorker','updateInTime','WRITE','ALLOW','ROLE','employee'),
|
||||
('MachineWorker','add','READ','ALLOW','ROLE','employee'),
|
||||
('MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','employee');
|
||||
('MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','employee'),
|
||||
('SaleTracking','deleteTracking','WRITE','ALLOW','ROLE','employee');
|
|
@ -10,12 +10,12 @@ module.exports = Self => {
|
|||
description: 'The sale id'
|
||||
},
|
||||
{
|
||||
arg: 'stateCode',
|
||||
type: 'string'
|
||||
}
|
||||
arg: 'stateCodes',
|
||||
type: ['string']
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
type: 'boolean',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
|
@ -24,7 +24,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.delete = async(saleFk, stateCode, options) => {
|
||||
Self.delete = async(saleFk, stateCodes, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
@ -38,20 +38,24 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
try {
|
||||
if (stateCode === 'PREPARED') {
|
||||
const itemShelvingSales = await models.ItemShelvingSale.find({where: {saleFk: saleFk}}, myOptions);
|
||||
for (let itemShelvingSale of itemShelvingSales)
|
||||
await itemShelvingSale.destroy(myOptions);
|
||||
}
|
||||
const itemShelvingSales = await models.ItemShelvingSale.find({where: {saleFk: saleFk}}, myOptions);
|
||||
|
||||
const state = await models.State.findOne({
|
||||
where: {code: stateCode}
|
||||
for (let itemShelvingSale of itemShelvingSales)
|
||||
await itemShelvingSale.destroy(myOptions);
|
||||
|
||||
const states = await models.State.find({
|
||||
fields: ['id'],
|
||||
where: {
|
||||
code: {inq: stateCodes}
|
||||
}
|
||||
}, myOptions);
|
||||
|
||||
const stateIds = states.map(state => state.id);
|
||||
|
||||
const filter = {
|
||||
where: {
|
||||
saleFk: saleFk,
|
||||
stateFk: state.id
|
||||
stateFk: {inq: stateIds}
|
||||
}
|
||||
};
|
||||
const saleTrackings = await models.SaleTracking.find(filter, myOptions);
|
||||
|
|
|
@ -100,7 +100,7 @@ class Controller extends Section {
|
|||
saleTrackingDel(sale, stateCode) {
|
||||
const params = {
|
||||
saleFk: sale.saleFk,
|
||||
stateCode: stateCode
|
||||
stateCodes: [stateCode]
|
||||
};
|
||||
this.$http.post(`SaleTrackings/delete`, params).then(() => {
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
|
|
Loading…
Reference in New Issue