sigo-package 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/programados/procesos/parteDiario/generarParteDiarioPDF.js +204 -0
- package/lib/programados/procesos/parteDiario/generarParteDiarioPDF.js.map +1 -0
- package/lib/programados/procesos/parteDiario/index.js +14 -154
- package/lib/programados/procesos/parteDiario/index.js.map +1 -1
- package/lib/programados/procesos/parteDiario/trabajo.js +1649 -0
- package/lib/programados/procesos/parteDiario/trabajo.js.map +1 -0
- package/lib/types/programados/procesos/parteDiario/generarParteDiarioPDF.d.ts +4 -0
- package/lib/types/programados/procesos/parteDiario/index.d.ts +1 -3
- package/lib/types/programados/procesos/parteDiario/trabajo.d.ts +2 -0
- package/package.json +4 -4
- package/lib/programados/procesos/parteDiario/downloadFiles.js +0 -14
- package/lib/programados/procesos/parteDiario/downloadFiles.js.map +0 -1
- package/lib/programados/procesos/parteDiario/obtenerDatosValorizaciones.js +0 -8
- package/lib/programados/procesos/parteDiario/obtenerDatosValorizaciones.js.map +0 -1
- package/lib/programados/procesos/parteDiario/obtenerParteDiario.js +0 -10
- package/lib/programados/procesos/parteDiario/obtenerParteDiario.js.map +0 -1
- package/lib/types/programados/procesos/parteDiario/downloadFiles.d.ts +0 -3
- package/lib/types/programados/procesos/parteDiario/obtenerDatosValorizaciones.d.ts +0 -3
- package/lib/types/programados/procesos/parteDiario/obtenerParteDiario.d.ts +0 -3
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.generarParteDiarioPDF = void 0;
|
|
27
|
+
const shared_1 = require("../../../shared");
|
|
28
|
+
const shared_2 = require("../shared");
|
|
29
|
+
const pdf = __importStar(require("html-pdf"));
|
|
30
|
+
const generarParteDiarioPDF = async (trabajo, dia, enviroments) => {
|
|
31
|
+
const parteDiario = obtenerParteDiario(trabajo, dia);
|
|
32
|
+
// console.log(parteDiario)
|
|
33
|
+
if (!parteDiario)
|
|
34
|
+
return null;
|
|
35
|
+
let valorizaciones = obtenerDatosValorizaciones(trabajo, parteDiario);
|
|
36
|
+
const styles = `
|
|
37
|
+
<style>
|
|
38
|
+
table {
|
|
39
|
+
width: 100%;
|
|
40
|
+
}
|
|
41
|
+
table, th{
|
|
42
|
+
border-collapse: collapse;
|
|
43
|
+
}
|
|
44
|
+
table, th, td {
|
|
45
|
+
padding: 4px;
|
|
46
|
+
border-collapse: collapse;
|
|
47
|
+
}
|
|
48
|
+
th, td {
|
|
49
|
+
text-align: left;
|
|
50
|
+
}
|
|
51
|
+
th {
|
|
52
|
+
background-color: #2980ba;
|
|
53
|
+
color: white;
|
|
54
|
+
}
|
|
55
|
+
.tituloPersonal {
|
|
56
|
+
text-align: center;
|
|
57
|
+
background-color: #17a185;
|
|
58
|
+
}
|
|
59
|
+
.img-container {
|
|
60
|
+
width: 100%;
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-direction: column;
|
|
63
|
+
align-items: center;
|
|
64
|
+
}
|
|
65
|
+
.card-fotos {
|
|
66
|
+
width: 250px;
|
|
67
|
+
margin-bottom: 10px
|
|
68
|
+
}
|
|
69
|
+
.img-container img {
|
|
70
|
+
width: 100%;
|
|
71
|
+
height: auto;
|
|
72
|
+
}
|
|
73
|
+
</style>
|
|
74
|
+
`;
|
|
75
|
+
//#region Personal
|
|
76
|
+
let tablePersonal = `<table>`;
|
|
77
|
+
tablePersonal += '<tr><th class="tituloPersonal" colspan="4">Personal</th></tr>';
|
|
78
|
+
tablePersonal += '<tr><th>Identificación</th><th>Apellidos</th><th>Nombres</th><th>Cargo</th></tr>';
|
|
79
|
+
parteDiario.Lider.Cargo = 'LIDER';
|
|
80
|
+
parteDiario.Personal.unshift(parteDiario.Lider);
|
|
81
|
+
parteDiario.Personal.length ? parteDiario.Personal.forEach(item => {
|
|
82
|
+
tablePersonal += `<tr><td>${item.Identificacion}</td><td>${item.Apellidos}</td><td>${item.Nombres}</td><td>${item.Cargo}</td></tr>`;
|
|
83
|
+
}) : tablePersonal += `<tr><td colspan="4">Sin Personal</td></tr>`;
|
|
84
|
+
tablePersonal += '</table>';
|
|
85
|
+
//#endregion Personal
|
|
86
|
+
//#region Fotos
|
|
87
|
+
const fotos = await downloadFiles(parteDiario, enviroments);
|
|
88
|
+
for (const foto of parteDiario.Fotos_SST) {
|
|
89
|
+
const exist = fotos.find(e => e.FileName === foto.Foto.img);
|
|
90
|
+
if (exist && typeof exist.Archivo === 'string')
|
|
91
|
+
foto.Foto.File = exist.Archivo;
|
|
92
|
+
}
|
|
93
|
+
let fotosContent = `
|
|
94
|
+
<div class="img-container">
|
|
95
|
+
`;
|
|
96
|
+
parteDiario.Fotos_SST.length ? parteDiario.Fotos_SST.forEach(item => {
|
|
97
|
+
fotosContent += `<div class="card-fotos"><p>${item.Titulo} (${item.Descripcion})</p><img src="${item.Foto.File}" alt="${item.Titulo}"></div>`;
|
|
98
|
+
}) : fotosContent += `<p>Sin Fotos</p>`;
|
|
99
|
+
fotosContent += `</div>`;
|
|
100
|
+
//#endregion Fotos
|
|
101
|
+
//#region Valorizaciones
|
|
102
|
+
let tableValorizaciones = `<table>`;
|
|
103
|
+
tableValorizaciones += '<tr><th class="tituloPersonal" colspan="4">Valorizaciones</th></tr>';
|
|
104
|
+
tableValorizaciones += `<tr>
|
|
105
|
+
<th>Cod. MO</th>
|
|
106
|
+
<th>Descripción MO</th>
|
|
107
|
+
<th>Cantidad</th>
|
|
108
|
+
<th>Estado</th>
|
|
109
|
+
</tr>`;
|
|
110
|
+
valorizaciones.length ? valorizaciones.forEach(item => {
|
|
111
|
+
tableValorizaciones += `<tr><td>${item.DetalleChile.ManoObra.Codigo}</td><td>${item.DetalleChile.ManoObra.Nombre}</td><td>${item.Cantidad}</td><td>${item.Ultimo_Estado_Interno.Descripcion}</td></tr>`;
|
|
112
|
+
}) : tableValorizaciones += `<tr><td colspan="4">Sin Valorizaciones</td></tr>`;
|
|
113
|
+
tableValorizaciones += '</table>';
|
|
114
|
+
//#endregion Valorizaciones
|
|
115
|
+
//#region Materiales
|
|
116
|
+
let tableMateriales = `<table>`;
|
|
117
|
+
tableMateriales += '<tr><th class="tituloPersonal" colspan="4">Materiales</th></tr>';
|
|
118
|
+
tableMateriales += `<tr>
|
|
119
|
+
<th>Cod.</th>
|
|
120
|
+
<th>Descripción MO</th>
|
|
121
|
+
<th>Cantidad</th>
|
|
122
|
+
<th>Tipo</th>
|
|
123
|
+
</tr>`;
|
|
124
|
+
valorizaciones.length ? valorizaciones.forEach(item => {
|
|
125
|
+
item.MaterialesUtilizados.filter(e => e.Estado.ID_Estado === 1).forEach(mat => {
|
|
126
|
+
tableMateriales += `<tr><td>${mat.Codigo}</td><td>${mat.Descripcion}</td><td>${mat.Cantidad}</td><td>Instalado</td></tr>`;
|
|
127
|
+
});
|
|
128
|
+
item.MaterialesRetirados.filter(e => e.Estado.ID_Estado === 1).forEach(mat => {
|
|
129
|
+
tableMateriales += `<tr><td>${mat.Codigo}</td><td>${mat.Descripcion}</td><td>${mat.Cantidad}</td><td>Retirado</td></tr>`;
|
|
130
|
+
});
|
|
131
|
+
if (!item.MaterialesUtilizados.length && !item.MaterialesRetirados)
|
|
132
|
+
tableMateriales += `<tr><td colspan="4">Sin Materiales</td></tr>`;
|
|
133
|
+
}) : tableMateriales += `<tr><td colspan="4">Sin Materiales</td></tr>`;
|
|
134
|
+
tableMateriales += '</table>';
|
|
135
|
+
//#endregion Materiales
|
|
136
|
+
const content = `
|
|
137
|
+
<html>
|
|
138
|
+
<body>
|
|
139
|
+
${styles}
|
|
140
|
+
<div style="display: flex; justify-content: center;">
|
|
141
|
+
<h3>PARTE DIARIO</h3>
|
|
142
|
+
</div>
|
|
143
|
+
<div>
|
|
144
|
+
<p>Fecha: ${parteDiario.Fecha.toLocaleString()}</h1>
|
|
145
|
+
<p>Estado: <span style="color: ${parteDiario.UltimoEstadoInterno.Color}">${parteDiario.UltimoEstadoInterno.Descripcion}</span></p>
|
|
146
|
+
<p>Novedad: ${parteDiario.Novedad}</p>
|
|
147
|
+
</div>
|
|
148
|
+
${tablePersonal}
|
|
149
|
+
<br>
|
|
150
|
+
${fotosContent}
|
|
151
|
+
<br>
|
|
152
|
+
${tableValorizaciones}
|
|
153
|
+
<br>
|
|
154
|
+
${tableMateriales}
|
|
155
|
+
</table>
|
|
156
|
+
</body>
|
|
157
|
+
</html>
|
|
158
|
+
`;
|
|
159
|
+
const options = {
|
|
160
|
+
format: 'A4', border: {
|
|
161
|
+
top: '2cm',
|
|
162
|
+
right: '2.5cm',
|
|
163
|
+
bottom: '2cm',
|
|
164
|
+
left: '2.5cm'
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
return new Promise((resolve, reject) => {
|
|
168
|
+
pdf.create(content, options).toBuffer((err, buffer) => {
|
|
169
|
+
if (err) {
|
|
170
|
+
console.log(err);
|
|
171
|
+
resolve(null);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
// fs.writeFileSync('./documento.pdf', buffer)
|
|
175
|
+
resolve(buffer);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
exports.generarParteDiarioPDF = generarParteDiarioPDF;
|
|
181
|
+
const downloadFiles = async (parteDiario, { PATH_API_FILE, Pass_Auth_FILE, User_Auth_FILE, user_API_FILE }) => {
|
|
182
|
+
const fotosPromises = parteDiario.Fotos_SST
|
|
183
|
+
.filter(foto => foto.Foto.Estado.ID_Estado === 1)
|
|
184
|
+
.map(foto => shared_1.FTPService.getFileToServer(foto.Foto.img, 2, { Pass_Auth_FILE, PATH_API_FILE, User_Auth_FILE, user_API_FILE }));
|
|
185
|
+
const response = await Promise.all(fotosPromises);
|
|
186
|
+
const filteredResponse = response.filter(item => typeof item !== 'string');
|
|
187
|
+
return filteredResponse;
|
|
188
|
+
};
|
|
189
|
+
const obtenerParteDiario = (trabajo, dia) => {
|
|
190
|
+
const parteDiario = trabajo.PartesDiarios.find(e => (0, shared_2.CompararFechas)(e.Fecha, new Date(dia)));
|
|
191
|
+
return parteDiario ? parteDiario : null;
|
|
192
|
+
};
|
|
193
|
+
const obtenerDatosValorizaciones = (trabajo, parteDiario) => {
|
|
194
|
+
return trabajo.Ultima_PreLiquidacion.Valorizacion.filter(e => parteDiario.Valorizaciones.some(el => el === e.ID_Valorizacion));
|
|
195
|
+
};
|
|
196
|
+
// generarParteDiarioPDF(trabajo, new Date("2023-10-17T16:45:45.182Z"), {
|
|
197
|
+
// PATH_API_FILE: 'https://cobraperu.com.pe:8010/api/MASTERQA/Master/File',
|
|
198
|
+
// user_API_FILE: 'sistema.sigo.qa',
|
|
199
|
+
// User_Auth_FILE: 'user.sigo',
|
|
200
|
+
// Pass_Auth_FILE: 'gr8p0C0br4!!\$'
|
|
201
|
+
// }).then((res) => {
|
|
202
|
+
// console.log(res);
|
|
203
|
+
// })
|
|
204
|
+
//# sourceMappingURL=generarParteDiarioPDF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generarParteDiarioPDF.js","sourceRoot":"","sources":["../../../../src/programados/procesos/parteDiario/generarParteDiarioPDF.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA0E;AAG1E,sCAA0C;AAE1C,8CAA+B;AAGxB,MAAM,qBAAqB,GAAG,KAAK,EAAE,OAAsB,EAAE,GAAS,EAAE,WAA8B,EAA0B,EAAE;IAErI,MAAM,WAAW,GAAG,kBAAkB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACpD,2BAA2B;IAC3B,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAA;IAC7B,IAAI,cAAc,GAAG,0BAA0B,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;IAErE,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsCd,CAAA;IACD,kBAAkB;IAClB,IAAI,aAAa,GAAG,SAAS,CAAA;IAC7B,aAAa,IAAI,+DAA+D,CAAA;IAChF,aAAa,IAAI,kFAAkF,CAAA;IACnG,WAAW,CAAC,KAAK,CAAC,KAAK,GAAG,OAAO,CAAA;IACjC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IAC/C,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC9D,aAAa,IAAI,WAAW,IAAI,CAAC,cAAc,YAAY,IAAI,CAAC,SAAS,YAAY,IAAI,CAAC,OAAO,YAAY,IAAI,CAAC,K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 = require("./obtenerParteDiario");
|
|
9
|
-
const obtenerDatosValorizaciones_1 = require("./obtenerDatosValorizaciones");
|
|
10
|
-
const downloadFiles_1 = require("./downloadFiles");
|
|
11
|
-
const generarParteDiarioPDF = async (trabajo, dia, enviroments) => {
|
|
12
|
-
const parteDiario = (0, obtenerParteDiario_1.obtenerParteDiario)(trabajo, dia);
|
|
13
|
-
// console.log(parteDiario)
|
|
14
|
-
if (!parteDiario)
|
|
15
|
-
return null;
|
|
16
|
-
let valorizaciones = (0, obtenerDatosValorizaciones_1.obtenerDatosValorizaciones)(trabajo, parteDiario);
|
|
17
|
-
const browser = await puppeteer_1.default.launch();
|
|
18
|
-
const page = await browser.newPage();
|
|
19
|
-
const styles = `
|
|
20
|
-
<style>
|
|
21
|
-
table {
|
|
22
|
-
width: 100%;
|
|
23
|
-
}
|
|
24
|
-
table, th{
|
|
25
|
-
border-collapse: collapse;
|
|
26
|
-
}
|
|
27
|
-
table, th, td {
|
|
28
|
-
padding: 4px;
|
|
29
|
-
border-collapse: collapse;
|
|
30
|
-
}
|
|
31
|
-
th, td {
|
|
32
|
-
text-align: left;
|
|
33
|
-
}
|
|
34
|
-
th {
|
|
35
|
-
background-color: #2980ba;
|
|
36
|
-
color: white;
|
|
37
|
-
}
|
|
38
|
-
.tituloPersonal {
|
|
39
|
-
text-align: center;
|
|
40
|
-
background-color: #17a185;
|
|
41
|
-
}
|
|
42
|
-
.img-container {
|
|
43
|
-
width: 100%;
|
|
44
|
-
display: flex;
|
|
45
|
-
flex-direction: column;
|
|
46
|
-
align-items: center;
|
|
47
|
-
}
|
|
48
|
-
.card-fotos {
|
|
49
|
-
width: 250px;
|
|
50
|
-
margin-bottom: 10px
|
|
51
|
-
}
|
|
52
|
-
.img-container img {
|
|
53
|
-
width: 100%;
|
|
54
|
-
height: auto;
|
|
55
|
-
}
|
|
56
|
-
</style>
|
|
57
|
-
`;
|
|
58
|
-
//#region Personal
|
|
59
|
-
let tablePersonal = `<table>`;
|
|
60
|
-
tablePersonal += '<tr><th class="tituloPersonal" colspan="4">Personal</th></tr>';
|
|
61
|
-
tablePersonal += '<tr><th>Identificación</th><th>Apellidos</th><th>Nombres</th><th>Cargo</th></tr>';
|
|
62
|
-
parteDiario.Lider.Cargo = 'LIDER';
|
|
63
|
-
parteDiario.Personal.unshift(parteDiario.Lider);
|
|
64
|
-
parteDiario.Personal.length ? parteDiario.Personal.forEach(item => {
|
|
65
|
-
tablePersonal += `<tr><td>${item.Identificacion}</td><td>${item.Apellidos}</td><td>${item.Nombres}</td><td>${item.Cargo}</td></tr>`;
|
|
66
|
-
}) : tablePersonal += `<tr><td colspan="4">Sin Personal</td></tr>`;
|
|
67
|
-
tablePersonal += '</table>';
|
|
68
|
-
//#endregion Personal
|
|
69
|
-
//#region Fotos
|
|
70
|
-
const fotos = await (0, downloadFiles_1.downloadFilesParteDiario)(parteDiario, enviroments);
|
|
71
|
-
for (const foto of parteDiario.Fotos_SST) {
|
|
72
|
-
const exist = fotos.find(e => e.FileName === foto.Foto.img);
|
|
73
|
-
if (exist && typeof exist.Archivo === 'string')
|
|
74
|
-
foto.Foto.File = exist.Archivo;
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
75
7
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
//#endregion Fotos
|
|
84
|
-
//#region Valorizaciones
|
|
85
|
-
let tableValorizaciones = `<table>`;
|
|
86
|
-
tableValorizaciones += '<tr><th class="tituloPersonal" colspan="4">Valorizaciones</th></tr>';
|
|
87
|
-
tableValorizaciones += `<tr>
|
|
88
|
-
<th>Cod. MO</th>
|
|
89
|
-
<th>Descripción MO</th>
|
|
90
|
-
<th>Cantidad</th>
|
|
91
|
-
<th>Estado</th>
|
|
92
|
-
</tr>`;
|
|
93
|
-
valorizaciones.length ? valorizaciones.forEach(item => {
|
|
94
|
-
tableValorizaciones += `<tr><td>${item.DetalleChile.ManoObra.Codigo}</td><td>${item.DetalleChile.ManoObra.Nombre}</td><td>${item.Cantidad}</td><td>${item.Ultimo_Estado_Interno.Descripcion}</td></tr>`;
|
|
95
|
-
}) : tableValorizaciones += `<tr><td colspan="4">Sin Valorizaciones</td></tr>`;
|
|
96
|
-
tableValorizaciones += '</table>';
|
|
97
|
-
//#endregion Valorizaciones
|
|
98
|
-
//#region Materiales
|
|
99
|
-
let tableMateriales = `<table>`;
|
|
100
|
-
tableMateriales += '<tr><th class="tituloPersonal" colspan="4">Materiales</th></tr>';
|
|
101
|
-
tableMateriales += `<tr>
|
|
102
|
-
<th>Cod.</th>
|
|
103
|
-
<th>Descripción MO</th>
|
|
104
|
-
<th>Cantidad</th>
|
|
105
|
-
<th>Tipo</th>
|
|
106
|
-
</tr>`;
|
|
107
|
-
valorizaciones.length ? valorizaciones.forEach(item => {
|
|
108
|
-
item.MaterialesUtilizados.filter(e => e.Estado.ID_Estado === 1).forEach(mat => {
|
|
109
|
-
tableMateriales += `<tr><td>${mat.Codigo}</td><td>${mat.Descripcion}</td><td>${mat.Cantidad}</td><td>Instalado</td></tr>`;
|
|
110
|
-
});
|
|
111
|
-
item.MaterialesRetirados.filter(e => e.Estado.ID_Estado === 1).forEach(mat => {
|
|
112
|
-
tableMateriales += `<tr><td>${mat.Codigo}</td><td>${mat.Descripcion}</td><td>${mat.Cantidad}</td><td>Retirado</td></tr>`;
|
|
113
|
-
});
|
|
114
|
-
if (!item.MaterialesUtilizados.length && !item.MaterialesRetirados)
|
|
115
|
-
tableMateriales += `<tr><td colspan="4">Sin Materiales</td></tr>`;
|
|
116
|
-
}) : tableMateriales += `<tr><td colspan="4">Sin Materiales</td></tr>`;
|
|
117
|
-
tableMateriales += '</table>';
|
|
118
|
-
//#endregion Materiales
|
|
119
|
-
const content = `
|
|
120
|
-
<html>
|
|
121
|
-
<body>
|
|
122
|
-
${styles}
|
|
123
|
-
<div style="display: flex; justify-content: center;">
|
|
124
|
-
<h3>PARTE DIARIO</h3>
|
|
125
|
-
</div>
|
|
126
|
-
<div>
|
|
127
|
-
<p>Fecha: ${parteDiario.Fecha.toLocaleString()}</h1>
|
|
128
|
-
<p>Estado: <span style="color: ${parteDiario.UltimoEstadoInterno.Color}">${parteDiario.UltimoEstadoInterno.Descripcion}</span></p>
|
|
129
|
-
<p>Novedad: ${parteDiario.Novedad}</p>
|
|
130
|
-
</div>
|
|
131
|
-
${tablePersonal}
|
|
132
|
-
<br>
|
|
133
|
-
${fotosContent}
|
|
134
|
-
<br>
|
|
135
|
-
${tableValorizaciones}
|
|
136
|
-
<br>
|
|
137
|
-
${tableMateriales}
|
|
138
|
-
</table>
|
|
139
|
-
</body>
|
|
140
|
-
</html>
|
|
141
|
-
`;
|
|
142
|
-
await page.setContent(content);
|
|
143
|
-
const pdfBuffer = await page.pdf({
|
|
144
|
-
format: 'A4',
|
|
145
|
-
margin: {
|
|
146
|
-
top: '2cm',
|
|
147
|
-
right: '2.5cm',
|
|
148
|
-
bottom: '2cm',
|
|
149
|
-
left: '2.5cm'
|
|
150
|
-
},
|
|
151
|
-
printBackground: true
|
|
152
|
-
});
|
|
153
|
-
const pdfBase64 = pdfBuffer.toString('base64');
|
|
154
|
-
await browser.close();
|
|
155
|
-
return `data:application/pdf;base64,${pdfBase64}`;
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
156
15
|
};
|
|
157
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./generarParteDiarioPDF"), exports);
|
|
158
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/programados/procesos/parteDiario/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/programados/procesos/parteDiario/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAuC"}
|