Skip to content

Commit

Permalink
feat(rup): adjuntar archivos email
Browse files Browse the repository at this point in the history
  • Loading branch information
negro89 authored and juuliotero committed Oct 7, 2020
1 parent 8755c26 commit 9d8a9cd
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,35 @@ export class RUPAccionesEnvioInformeComponent {
}
}

getAbsoluteUrl(url) {
if (url.toLowerCase().startsWith('http')) {
return url;
} else {
return window.location.protocol + url;
}
}

getAdjuntos(registro?) {
let adjuntos = [];
let registros;
if (registro) {
registros = registro.relacionadoCon;
} else {
registros = this.prestacion.ejecucion.registros;
}
registros.forEach(reg => {
if (reg.concepto.conceptId === '1921000013108') {
reg.valor.documentos.forEach(doc => {
if (doc.selected) {
doc.url = this.getAbsoluteUrl(doc.url);
adjuntos.push(doc);
}
});
}
});
return adjuntos;
}

openModalEmails() {
this.showModalEmails = true;
}
Expand All @@ -100,10 +129,13 @@ export class RUPAccionesEnvioInformeComponent {
const datos: any = {
idPrestacion: this.prestacion.id,
email: email,
idOrganizacion: this.auth.organizacion.id,
idOrganizacion: this.auth.organizacion.id
};
if (this.registro) {
datos.adjuntos = this.getAdjuntos(this.registro);
datos.idRegistro = this.registro.id;
} else {
datos.adjuntos = this.getAdjuntos();
}
this.servicioDocumentos.enviarInformeRUP(datos).subscribe(
result => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class AdjuntarDocumentoComponent extends RUPComponent implements OnInit {
timeout = null;
errorExt = false;
uploadValid = true;
emailDocs = [];

// fotos: { file?: any, ext: string, id?: any, descripcion?: ISnomedConcept, fecha?: Date }[] = [];
lightbox = false;
Expand Down Expand Up @@ -64,6 +65,13 @@ export class AdjuntarDocumentoComponent extends RUPComponent implements OnInit {
this.snomedService.getQuery({ expression: '^4681000013102' }).subscribe(result => {
this.descendientesInformeClinico = result;
});

// for (let i = 0; i < this.registro.valor.documentos.length; i++) {
// this.emailDocs[i] = true;
// }
this.registro.valor.documentos.forEach(doc => {
doc.selected = true;
});
}

onValidate() {
Expand All @@ -82,6 +90,10 @@ export class AdjuntarDocumentoComponent extends RUPComponent implements OnInit {
this.readThis($event.target);
}

get showSelectDoc() {
let last = this.prestacion.estados.length - 1;
return this.prestacion.estados[last].tipo === 'validada';
}

readThis(inputValue: any): void {
let ext = this.fileExtension(inputValue.value);
Expand Down
16 changes: 10 additions & 6 deletions src/app/modules/rup/components/elementos/adjuntarDocumento.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<th>Tipo de Documento</th>
<th>Fecha</th>
<th></th>
<th>Enviar por mail</th>
</tr>
</thead>
<tbody>
Expand All @@ -43,27 +44,30 @@
</a>
</div>
<br>
<p class="text-center small">
{{ doc.ext }}
</p>
</td>
<td>
<plex-select *ngIf="!soloValores && descendientesInformeClinico.length"
[(ngModel)]="doc.descripcion" name="select{{i}}" idField="term"
labelField="term" [data]="descendientesInformeClinico">
</plex-select>
<span *ngIf="soloValores && doc.descripcion">{{doc.descripcion.term}}</span>
<span
*ngIf="soloValores">{{doc.descripcion? doc.descripcion.term: 'No indica tipo de documento'}}</span>
</td>
<td>
<plex-datetime *ngIf="!soloValores" type="date" [(ngModel)]="doc.fecha"
name="fecha{{i}}" [max]="hoy">
</plex-datetime>
<span *ngIf="soloValores && doc.fecha">{{doc.fecha | fecha}}</span>
<span
*ngIf="soloValores">{{doc.fecha? (doc.fecha | fecha) : 'No indica fecha'}}</span>
</td>
<td>
<plex-button *ngIf="!soloValores" icon="delete" type="danger"
(click)="imageRemoved(doc)" title="Borrar documento"></plex-button>
</td>
<td>
<plex-bool *ngIf="showSelectDoc" class="pr-4" [(ngModel)]="doc.selected"
name="doc-{{i}}" type="slide"></plex-bool>
</td>
</tr>
</tbody>
</table>
Expand All @@ -90,4 +94,4 @@

<plex-badge *ngIf="!uploadValid" type="danger float-right">
No se adjunto ningun archivo
</plex-badge>
</plex-badge>

0 comments on commit 9d8a9cd

Please sign in to comment.