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 }]*/
|
/* eslint max-len: ["error", { "code": 180 }]*/
|
||||||
const got = require('got');
|
const got = require('got');
|
||||||
|
const axios = require('axios');
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
const FormData = require('form-data');
|
||||||
|
const fs = require('fs-extra');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('download', {
|
Self.remoteMethodCtx('download', {
|
||||||
|
@ -89,6 +92,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
// get dialog
|
// get dialog
|
||||||
const dialogResponse = await got.get(`${docuwareUrl}/FileCabinets/${fileCabinetId}/dialogs`, options);
|
const dialogResponse = await got.get(`${docuwareUrl}/FileCabinets/${fileCabinetId}/dialogs`, options);
|
||||||
|
console.log(`${docuwareUrl}/FileCabinets/${fileCabinetId}/dialogs`);
|
||||||
const dialogJson = JSON.parse(dialogResponse.body).Dialog;
|
const dialogJson = JSON.parse(dialogResponse.body).Dialog;
|
||||||
const dialogId = dialogJson.find(dialogs => dialogs.DisplayName === 'find').Id;
|
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) {
|
} catch (error) {
|
||||||
if (error.code === 'ENOENT')
|
if (error.code === 'ENOENT')
|
||||||
throw new UserError('The DOCUWARE PDF document does not exists');
|
throw new UserError('The DOCUWARE PDF document does not exists');
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
Add turn
|
Add turn
|
||||||
</vn-item>
|
</vn-item>
|
||||||
<vn-item class="dropdown"
|
<vn-item class="dropdown"
|
||||||
vn-click-stop="showDeliveryNoteMenu.show($event, 'left')"
|
vn-click-stop="showDeliveryNoteMenu.show($event, 'left'); $ctrl.hasDocuware()"
|
||||||
translate>
|
translate>
|
||||||
Show Delivery Note...
|
Show Delivery Note...
|
||||||
<vn-menu vn-id="showDeliveryNoteMenu">
|
<vn-menu vn-id="showDeliveryNoteMenu">
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
href='api/Docuwares/{{$ctrl.ticket.id}}/download/deliveryClient/findTicket?access_token={{$ctrl.vnToken.token}}'
|
href='api/Docuwares/{{$ctrl.ticket.id}}/download/deliveryClient/findTicket?access_token={{$ctrl.vnToken.token}}'
|
||||||
target="_blank"
|
target="_blank"
|
||||||
translate>
|
translate>
|
||||||
as PDF
|
as PDF Docuware
|
||||||
</a>
|
</a>
|
||||||
<vn-item
|
<vn-item
|
||||||
ng-if="!$ctrl.hasDocuwareFile"
|
ng-if="!$ctrl.hasDocuwareFile"
|
||||||
|
@ -64,6 +64,11 @@
|
||||||
translate>
|
translate>
|
||||||
Send PDF
|
Send PDF
|
||||||
</vn-item>
|
</vn-item>
|
||||||
|
<vn-item
|
||||||
|
ng-click="sendPdfConfirmation.show({email: $ctrl.ticket.client.email})"
|
||||||
|
translate>
|
||||||
|
Send PDF Docuware
|
||||||
|
</vn-item>
|
||||||
<vn-item
|
<vn-item
|
||||||
ng-click="sendCsvConfirmation.show({email: $ctrl.ticket.client.email})"
|
ng-click="sendCsvConfirmation.show({email: $ctrl.ticket.client.email})"
|
||||||
translate>
|
translate>
|
||||||
|
|
|
@ -85,7 +85,6 @@ class Controller extends Section {
|
||||||
.then(res => this.ticket = res.data)
|
.then(res => this.ticket = res.data)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.isTicketEditable();
|
this.isTicketEditable();
|
||||||
this.hasDocuware();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
Show Delivery Note...: Ver albarán...
|
Show Delivery Note...: Ver albarán...
|
||||||
Send Delivery Note...: Enviar albarán...
|
Send Delivery Note...: Enviar albarán...
|
||||||
as PDF: como PDF
|
as PDF: como PDF
|
||||||
|
as PDF Docuware: como PDF Docuware
|
||||||
as CSV: como CSV
|
as CSV: como CSV
|
||||||
as PDF without prices: como PDF sin precios
|
as PDF without prices: como PDF sin precios
|
||||||
Send PDF: Enviar PDF
|
Send PDF: Enviar PDF
|
||||||
|
|
Loading…
Reference in New Issue