#1860 refactorizar llamadas al servicio print
gitea/salix/1466-print_refactor There was a failure building this commit
Details
gitea/salix/1466-print_refactor There was a failure building this commit
Details
This commit is contained in:
parent
cac8cb6a6a
commit
23f6c8843d
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Serializes an object to a query params
|
||||
*
|
||||
* @param {Object} obj The params object
|
||||
* @return {String} Serialized params
|
||||
*/
|
||||
exports.httpParamSerializer = function(obj) {
|
||||
let query = '';
|
||||
for (let param in obj) {
|
||||
if (query != '')
|
||||
query += '&';
|
||||
query += `${param}=${obj[param]}`;
|
||||
}
|
||||
|
||||
return query;
|
||||
};
|
|
@ -35,7 +35,7 @@ class Controller {
|
|||
{
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['salesPersonFk', 'name'],
|
||||
fields: ['salesPersonFk', 'name', 'email'],
|
||||
include: {
|
||||
relation: 'salesPerson',
|
||||
scope: {
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
class Controller {
|
||||
constructor($scope, $state, $http, $translate, vnApp, aclService) {
|
||||
constructor($scope, $state, $http, $translate, vnApp, aclService, $httpParamSerializer) {
|
||||
this.$scope = $scope;
|
||||
this.$state = $state;
|
||||
this.$http = $http;
|
||||
this.$translate = $translate;
|
||||
this.vnApp = vnApp;
|
||||
this.aclService = aclService;
|
||||
this.$httpParamSerializer = $httpParamSerializer;
|
||||
this.moreOptions = [
|
||||
{callback: this.showPickupOrder, name: 'Show Pickup order'},
|
||||
{callback: this.confirmPickupOrder, name: 'Send Pickup order'},
|
||||
|
@ -60,7 +61,12 @@ class Controller {
|
|||
}
|
||||
|
||||
showPickupOrder() {
|
||||
let url = `report/rpt-claim-pickup-order?claimFk=${this.claim.id}`;
|
||||
const params = {
|
||||
clientId: this.claim.clientFk,
|
||||
claimId: this.claim.id
|
||||
};
|
||||
const serializedParams = this.$httpParamSerializer(params);
|
||||
let url = `api/report/claim-pickup-order?${serializedParams}`;
|
||||
window.open(url);
|
||||
}
|
||||
|
||||
|
@ -70,7 +76,14 @@ class Controller {
|
|||
|
||||
sendPickupOrder(response) {
|
||||
if (response === 'accept') {
|
||||
this.$http.post(`email/claim-pickup-order`, {claimFk: this.claim.id}).then(
|
||||
const params = {
|
||||
recipient: this.claim.client.email,
|
||||
clientId: this.claim.clientFk,
|
||||
claimId: this.claim.id
|
||||
};
|
||||
const serializedParams = this.$httpParamSerializer(params);
|
||||
const url = `email/claim-pickup-order?${serializedParams}`;
|
||||
this.$http.get(url).then(
|
||||
() => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
|
||||
);
|
||||
}
|
||||
|
@ -90,7 +103,7 @@ class Controller {
|
|||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp', 'aclService'];
|
||||
Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp', 'aclService', '$httpParamSerializer'];
|
||||
|
||||
ngModule.component('vnClaimDescriptor', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -2,6 +2,8 @@ let request = require('request-promise-native');
|
|||
let UserError = require('vn-loopback/util/user-error');
|
||||
let getFinalState = require('vn-loopback/util/hook').getFinalState;
|
||||
let isMultiple = require('vn-loopback/util/hook').isMultiple;
|
||||
const httpParamSerializer = require('vn-loopback/util/http').httpParamSerializer;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
module.exports = Self => {
|
||||
// Methods
|
||||
|
@ -239,15 +241,18 @@ module.exports = Self => {
|
|||
});
|
||||
}
|
||||
|
||||
const options = {
|
||||
method: 'POST',
|
||||
uri: 'http://127.0.0.1:3000/api/email/payment-update',
|
||||
body: {
|
||||
clientFk: instance.id
|
||||
},
|
||||
json: true
|
||||
// Send email to client
|
||||
|
||||
if (!instance.email) return;
|
||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||
const headers = loopBackContext.active.http.req.headers;
|
||||
const params = {
|
||||
clientId: instance.id,
|
||||
recipient: instance.email
|
||||
};
|
||||
await request(options);
|
||||
const serializedParams = httpParamSerializer(params);
|
||||
const query = `${headers.origin}/api/email/payment-update?${serializedParams}`;
|
||||
await request.get(query);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -44,5 +44,9 @@
|
|||
<vn-dialog
|
||||
vn-id="show-preview"
|
||||
on-open="$ctrl.onPreviewOpen()">
|
||||
<tpl-body></tpl-body>
|
||||
<tpl-body>
|
||||
<div class="loading">
|
||||
<vn-spinner enable="true"></vn-spinner>
|
||||
</div>
|
||||
</tpl-body>
|
||||
</vn-dialog>
|
||||
|
|
|
@ -2,13 +2,14 @@ import ngModule from '../../module';
|
|||
import './style.scss';
|
||||
|
||||
class Controller {
|
||||
constructor($scope, $state, $http, vnApp, $translate, $httpParamSerializer) {
|
||||
constructor($scope, $state, $http, vnApp, $translate, $httpParamSerializer, $window) {
|
||||
this.$scope = $scope;
|
||||
this.$state = $state;
|
||||
this.$stateParams = $state.params;
|
||||
this.$http = $http;
|
||||
this.vnApp = vnApp;
|
||||
this.$translate = $translate;
|
||||
this.$window = $window;
|
||||
this.$httpParamSerializer = $httpParamSerializer;
|
||||
this.clientSample = {
|
||||
clientFk: this.$stateParams.id
|
||||
|
@ -58,13 +59,12 @@ class Controller {
|
|||
const serializedParams = this.$httpParamSerializer(params);
|
||||
const query = `email/${sampleType.code}?${serializedParams}`;
|
||||
this.$http.get(query).then(res => {
|
||||
let dialog = this.$scope.showPreview.element;
|
||||
this.$scope.showPreview.show();
|
||||
let dialog = document.body.querySelector('div.vn-dialog');
|
||||
let body = dialog.querySelector('tpl-body');
|
||||
let scroll = dialog.querySelector('div:first-child');
|
||||
|
||||
body.innerHTML = res.data;
|
||||
this.$scope.showPreview.show();
|
||||
|
||||
scroll.scrollTop = 0;
|
||||
});
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class Controller {
|
|||
});
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate', '$httpParamSerializer'];
|
||||
Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate', '$httpParamSerializer', '$window'];
|
||||
|
||||
ngModule.component('vnClientSampleCreate', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -1,36 +1,38 @@
|
|||
vn-client-sample-create {
|
||||
vn-dialog {
|
||||
& > div {
|
||||
padding: 0 !important
|
||||
div.vn-dialog {
|
||||
& > div {
|
||||
padding: 0 !important
|
||||
}
|
||||
|
||||
tpl-body {
|
||||
min-width: 800px;
|
||||
|
||||
.container, .container h1 {
|
||||
font-family: "Roboto","Helvetica","Arial",sans-serif;
|
||||
font-size: 1em !important;
|
||||
|
||||
h1 {
|
||||
font-weight: bold;
|
||||
margin: auto
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 1em 0
|
||||
}
|
||||
|
||||
footer p {
|
||||
font-size: 10px !important;
|
||||
line-height: 10px
|
||||
}
|
||||
}
|
||||
|
||||
tpl-body {
|
||||
min-width: 800px;
|
||||
|
||||
.title h1 {
|
||||
font-size: 2em !important;
|
||||
margin: 0
|
||||
}
|
||||
|
||||
.container, .container h1 {
|
||||
font-family: "Roboto","Helvetica","Arial",sans-serif;
|
||||
font-size: 1em !important;
|
||||
|
||||
h1 {
|
||||
font-weight: bold;
|
||||
margin: auto
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 1em 0
|
||||
}
|
||||
|
||||
footer p {
|
||||
font-size: 10px !important;
|
||||
line-height: 10px
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.title h1 {
|
||||
font-size: 2em !important;
|
||||
margin: 0
|
||||
}
|
||||
.loading {
|
||||
text-align: center
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,24 @@ export default class Controller {
|
|||
scope: {
|
||||
fields: ['id', 'name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['userFk'],
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['id'],
|
||||
include: {
|
||||
relation: 'emailUser',
|
||||
scope: {
|
||||
fields: ['email']
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
class Controller {
|
||||
constructor($, $http, vnApp, $translate, aclService) {
|
||||
constructor($, $http, vnApp, $translate, aclService, $httpParamSerializer) {
|
||||
this.$http = $http;
|
||||
this.vnApp = vnApp;
|
||||
this.$translate = $translate;
|
||||
this.$ = $;
|
||||
this.aclService = aclService;
|
||||
this.$httpParamSerializer = $httpParamSerializer;
|
||||
this.moreOptions = [
|
||||
{callback: this.showRouteReport, name: 'Show route report'},
|
||||
{callback: this.sendRouteReport, name: 'Send route report'},
|
||||
|
@ -36,13 +37,26 @@ class Controller {
|
|||
}
|
||||
|
||||
showRouteReport() {
|
||||
let url = `report/rpt-route?routeFk=${this.route.id}`;
|
||||
const user = this.route.worker.user;
|
||||
const params = {
|
||||
clientId: user.id,
|
||||
routeId: this.route.id
|
||||
};
|
||||
const serializedParams = this.$httpParamSerializer(params);
|
||||
let url = `api/report/driver-route?${serializedParams}`;
|
||||
window.open(url);
|
||||
}
|
||||
|
||||
sendRouteReport() {
|
||||
let url = `email/driver-route?routeFk=${this.route.id}`;
|
||||
this.$http.post(url).then(() => {
|
||||
const user = this.route.worker.user;
|
||||
const params = {
|
||||
recipient: user.emailUser.email,
|
||||
clientId: user.id,
|
||||
routeId: this.route.id
|
||||
};
|
||||
const serializedParams = this.$httpParamSerializer(params);
|
||||
const url = `email/driver-route?${serializedParams}`;
|
||||
this.$http.get(url).then(() => {
|
||||
this.vnApp.showSuccess(this.$translate.instant('Report sent'));
|
||||
});
|
||||
}
|
||||
|
@ -62,7 +76,7 @@ class Controller {
|
|||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope', '$http', 'vnApp', '$translate', 'aclService'];
|
||||
Controller.$inject = ['$scope', '$http', 'vnApp', '$translate', 'aclService', '$httpParamSerializer'];
|
||||
|
||||
ngModule.component('vnRouteDescriptor', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -15,7 +15,15 @@ class Controller {
|
|||
{
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked', 'credit'],
|
||||
fields: [
|
||||
'salesPersonFk',
|
||||
'name',
|
||||
'isActive',
|
||||
'isFreezed',
|
||||
'isTaxDataChecked',
|
||||
'credit',
|
||||
'email'
|
||||
],
|
||||
include: {
|
||||
relation: 'salesPerson',
|
||||
scope: {
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
class Controller {
|
||||
constructor($state, $scope, $http, vnApp, $translate, aclService) {
|
||||
constructor($state, $scope, $http, vnApp, $translate, aclService, $httpParamSerializer) {
|
||||
this.$scope = $scope;
|
||||
this.$state = $state;
|
||||
this.$http = $http;
|
||||
this.vnApp = vnApp;
|
||||
this.$translate = $translate;
|
||||
this.$httpParamSerializer = $httpParamSerializer;
|
||||
this.aclService = aclService;
|
||||
this.moreOptions = [
|
||||
{name: 'Add turn', callback: this.showAddTurnDialog},
|
||||
|
@ -201,10 +202,29 @@ class Controller {
|
|||
}
|
||||
|
||||
showDeliveryNote() {
|
||||
let url = `report/rpt-delivery-note?ticketFk=${this.ticket.id}`;
|
||||
const params = {
|
||||
clientId: this.ticket.client.id,
|
||||
ticketId: this.ticket.id
|
||||
};
|
||||
const serializedParams = this.$httpParamSerializer(params);
|
||||
let url = `api/report/delivery-note?${serializedParams}`;
|
||||
window.open(url);
|
||||
}
|
||||
|
||||
sendDeliveryNote(response) {
|
||||
if (response === 'accept') {
|
||||
const params = {
|
||||
recipient: this.ticket.client.email,
|
||||
clientId: this.ticket.client.id,
|
||||
ticketId: this.ticket.id
|
||||
};
|
||||
const serializedParams = this.$httpParamSerializer(params);
|
||||
this.$http.get(`email/delivery-note?${serializedParams}`).then(
|
||||
() => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
showSMSDialog() {
|
||||
const address = this.ticket.address;
|
||||
this.newSMS = {
|
||||
|
@ -275,17 +295,9 @@ class Controller {
|
|||
confirmDeliveryNote() {
|
||||
this.$scope.confirmDeliveryNote.show();
|
||||
}
|
||||
|
||||
sendDeliveryNote(response) {
|
||||
if (response === 'accept') {
|
||||
this.$http.post(`email/delivery-note`, {ticketFk: this.ticket.id}).then(
|
||||
() => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$state', '$scope', '$http', 'vnApp', '$translate', 'aclService'];
|
||||
Controller.$inject = ['$state', '$scope', '$http', 'vnApp', '$translate', 'aclService', '$httpParamSerializer'];
|
||||
|
||||
ngModule.component('vnTicketDescriptor', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<html v-bind:lang="locale">
|
||||
<head>
|
||||
<title>{{ $t('subject') }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<section class="container">
|
||||
<!-- Header component -->
|
||||
<email-header :is-preview="isPreview" :locale="locale"></email-header>
|
||||
<email-header
|
||||
v-bind:is-preview="isPreview"
|
||||
v-bind:locale="locale">
|
||||
</email-header>
|
||||
<!-- End header component -->
|
||||
<section class="main">
|
||||
<!-- Title block -->
|
||||
|
@ -25,7 +28,10 @@
|
|||
</section>
|
||||
</section>
|
||||
<!-- Footer component -->
|
||||
<email-footer :is-preview="isPreview" :locale="locale"></email-footer>
|
||||
<email-footer
|
||||
v-bind:is-preview="isPreview"
|
||||
v-bind:locale="locale">
|
||||
</email-footer>
|
||||
<!-- End footer component -->
|
||||
</section>
|
||||
</body>
|
||||
|
|
|
@ -2,38 +2,21 @@ const Component = require(`${appPath}/core/component`);
|
|||
const emailHeader = new Component('email-header');
|
||||
const emailFooter = new Component('email-footer');
|
||||
const attachments = require('./attachments.json');
|
||||
const db = require(`${appPath}/core/database`);
|
||||
|
||||
module.exports = {
|
||||
name: 'claim-pickup-order',
|
||||
/* async serverPrefetch() {
|
||||
this.client = await this.fetchClient(this.clientId);
|
||||
},*/
|
||||
created() {
|
||||
if (this.locale)
|
||||
this.$i18n.locale = this.locale;
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
attachments
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
fetchClient(claimId) {
|
||||
return db.findOne(`
|
||||
SELECT
|
||||
c.id,
|
||||
u.lang locale,
|
||||
c.email recipient
|
||||
FROM claim cl
|
||||
JOIN client c ON c.id = cl.clientFk
|
||||
JOIN account.user u ON u.id = c.id
|
||||
WHERE cl.id = ?`, [claimId]);
|
||||
},
|
||||
},
|
||||
components: {
|
||||
'email-header': emailHeader.build(),
|
||||
'email-footer': emailFooter.build()
|
||||
},
|
||||
props: ['clientId', 'claimId', 'isPreview']
|
||||
props: {
|
||||
claimId: {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<html v-bind:lang="locale">
|
||||
<head>
|
||||
<title>{{ $t('subject') }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<section class="container">
|
||||
<!-- Header component -->
|
||||
<email-header :is-preview="isPreview" :locale="locale"></email-header>
|
||||
<email-header
|
||||
v-bind:is-preview="isPreview"
|
||||
v-bind:locale="locale">
|
||||
</email-header>
|
||||
<!-- End header component -->
|
||||
<section class="main">
|
||||
<!-- Title block -->
|
||||
|
@ -65,7 +68,10 @@
|
|||
</p>
|
||||
</section>
|
||||
<!-- Footer component -->
|
||||
<email-footer :is-preview="isPreview" :locale="locale"></email-footer>
|
||||
<email-footer
|
||||
v-bind:is-preview="isPreview"
|
||||
v-bind:locale="locale">
|
||||
</email-footer>
|
||||
<!-- End footer component -->
|
||||
</section>
|
||||
</body>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const db = require(`${appPath}/core/database`);
|
||||
const Component = require(`${appPath}/core/component`);
|
||||
const emailHeader = new Component('email-header');
|
||||
const emailFooter = new Component('email-footer');
|
||||
const db = require(`${appPath}/core/database`);
|
||||
|
||||
module.exports = {
|
||||
name: 'printer-setup',
|
||||
|
|
|
@ -60,7 +60,6 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
claimId: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ const reportFooter = new Component('report-footer');
|
|||
const db = require(`${appPath}/core/database`);
|
||||
|
||||
module.exports = {
|
||||
name: 'route',
|
||||
name: 'driver-route',
|
||||
async serverPrefetch() {
|
||||
this.route = await this.fetchRoute(this.routeId);
|
||||
this.tickets = await this.fetchTickets(this.routeId);
|
||||
|
@ -83,7 +83,6 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
routeId: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
}
|
|
@ -70,11 +70,9 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
itemId: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
warehouseId: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
labelNumber: {
|
||||
|
|
|
@ -77,11 +77,9 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
clientId: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
companyId: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
receiptId: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,11 +68,9 @@ const rptSepaCore = {
|
|||
},
|
||||
props: {
|
||||
clientId: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
companyId: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
routeId: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue