try
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
949c73a465
commit
46f36e1de1
Binary file not shown.
|
@ -1,6 +1,9 @@
|
|||
/* eslint max-len: ["error", { "code": 180 }]*/
|
||||
const got = require('got');
|
||||
const axios = require('axios');
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
const FormData = require('form-data');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('download', {
|
||||
|
@ -89,6 +92,7 @@ module.exports = Self => {
|
|||
|
||||
// get dialog
|
||||
const dialogResponse = await got.get(`${docuwareUrl}/FileCabinets/${fileCabinetId}/dialogs`, options);
|
||||
console.log(`${docuwareUrl}/FileCabinets/${fileCabinetId}/dialogs`);
|
||||
const dialogJson = JSON.parse(dialogResponse.body).Dialog;
|
||||
const dialogId = dialogJson.find(dialogs => dialogs.DisplayName === 'find').Id;
|
||||
|
||||
|
@ -107,9 +111,48 @@ module.exports = Self => {
|
|||
}
|
||||
};
|
||||
|
||||
const stream = got.stream(downloadUri, downloadOptions);
|
||||
// const stream = got.stream(downloadUri, downloadOptions);
|
||||
|
||||
return [stream, contentType, fileName];
|
||||
const uploadUri = `${docuwareUrl}/FileCabinets/${fileCabinetId}/Documents?storeDialogId=1f665772-c936-4e13-aa2a-f209b1a7070e`;
|
||||
const form = new FormData();
|
||||
const file = await fs.readFile('back/methods/docuware/10.pdf');
|
||||
form.append('file', file, '10.pdf');
|
||||
const uploadOptions = {
|
||||
'headers': {
|
||||
'Cookie': cookie,
|
||||
}
|
||||
};
|
||||
|
||||
const fileData = {
|
||||
formData: {
|
||||
'document': {
|
||||
value: JSON.stringify({Fields: {}}),
|
||||
options: {
|
||||
filename: 'document.json',
|
||||
contentType: 'application/json',
|
||||
},
|
||||
},
|
||||
'file[]': {
|
||||
value: fs.createReadStream('back/methods/docuware/10.pdf'),
|
||||
options: {
|
||||
filename: '10.pdf',
|
||||
contentType: null
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Object.assign(uploadOptions, fileData);
|
||||
try {
|
||||
const upload = await axios.post(uploadUri, file, uploadOptions);
|
||||
console.log('UPLOAD FINISHED');
|
||||
} catch (e) {
|
||||
console.log('ERROR CATCHED:', e);
|
||||
console.log('ERROR CATCHED');
|
||||
return;
|
||||
}
|
||||
// return [stream, contentType, fileName];
|
||||
return;
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT')
|
||||
throw new UserError('The DOCUWARE PDF document does not exists');
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
Add turn
|
||||
</vn-item>
|
||||
<vn-item class="dropdown"
|
||||
vn-click-stop="showDeliveryNoteMenu.show($event, 'left')"
|
||||
vn-click-stop="showDeliveryNoteMenu.show($event, 'left'); $ctrl.hasDocuware()"
|
||||
translate>
|
||||
Show Delivery Note...
|
||||
<vn-menu vn-id="showDeliveryNoteMenu">
|
||||
|
@ -37,7 +37,7 @@
|
|||
href='api/Docuwares/{{$ctrl.ticket.id}}/download/deliveryClient/findTicket?access_token={{$ctrl.vnToken.token}}'
|
||||
target="_blank"
|
||||
translate>
|
||||
as PDF
|
||||
as PDF Docuware
|
||||
</a>
|
||||
<vn-item
|
||||
ng-if="!$ctrl.hasDocuwareFile"
|
||||
|
@ -64,6 +64,11 @@
|
|||
translate>
|
||||
Send PDF
|
||||
</vn-item>
|
||||
<vn-item
|
||||
ng-click="sendPdfConfirmation.show({email: $ctrl.ticket.client.email})"
|
||||
translate>
|
||||
Send PDF Docuware
|
||||
</vn-item>
|
||||
<vn-item
|
||||
ng-click="sendCsvConfirmation.show({email: $ctrl.ticket.client.email})"
|
||||
translate>
|
||||
|
|
|
@ -85,7 +85,6 @@ class Controller extends Section {
|
|||
.then(res => this.ticket = res.data)
|
||||
.then(() => {
|
||||
this.isTicketEditable();
|
||||
this.hasDocuware();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
Show Delivery Note...: Ver albarán...
|
||||
Send Delivery Note...: Enviar albarán...
|
||||
as PDF: como PDF
|
||||
as PDF Docuware: como PDF Docuware
|
||||
as CSV: como CSV
|
||||
as PDF without prices: como PDF sin precios
|
||||
Send PDF: Enviar PDF
|
||||
|
|
Loading…
Reference in New Issue