github.com/benoitkugler/goacve@v0.0.0-20201217100549-151ce6e55dc8/server/frontend/bv/src/pages/espace_perso/components/fiche_sanitaire/Vaccins.vue (about) 1 <template> 2 <b-card header="Vaccinations" header-text-variant="fushia"> 3 <b-card-text> 4 Merci de joindre le 5 <b>scan des pages « vaccinations »</b> 6 du carnet de santé du participant. Seul le DTPolio est obligatoire pour 7 être accueilli en séjour de vacances. <br /> 8 <i> 9 Si le participant n’a pas les vaccins obligatoires, joindre un 10 certificat médical de contre-indication. Attention: le vaccin 11 anti-tétanique ne présente aucune contre-indication. 12 </i> 13 <needed-document 14 v-if="contrainteVaccin != null" 15 class="mt-2" 16 :controller="controller" 17 :contrainte="contrainteVaccin" 18 :documents="vaccins" 19 @changed="onChanged" 20 @upload="creeVaccin" 21 ></needed-document> 22 </b-card-text> 23 </b-card> 24 </template> 25 26 <script lang="ts"> 27 import Vue from "vue"; 28 import Component from "vue-class-component"; 29 30 import NeededDocument from "@/shared/NeededDocument.vue"; 31 import FormFile from "@/shared/FormFile.vue"; 32 33 import { C } from "../../logic/controller"; 34 import { PublicDocument, Time } from "@/shared/logic/types"; 35 import { ControllerDocument } from "@/shared/logic/controller"; 36 import { ValidEvent, ValidEventFile } from "@/shared/utils"; 37 38 const VaccinsProps = Vue.extend({ 39 props: { 40 idPersonneCrypted: String 41 } 42 }); 43 44 function compareDate(d1: Time, d2: Time) { 45 const dd1 = new Date(d1); 46 const dd2 = new Date(d2); 47 return dd1.valueOf() - dd2.valueOf(); 48 } 49 50 @Component({ 51 components: { NeededDocument, FormFile } 52 }) 53 export default class Vaccins extends VaccinsProps { 54 controller: ControllerDocument = C; 55 56 get contrainteVaccin() { 57 if (C.data.metas == null) return null; 58 return C.data.metas.contrainte_vaccin; 59 } 60 61 get vaccins(): PublicDocument[] { 62 const l = C.data.personnes[this.idPersonneCrypted].vaccins || []; 63 return l.sort((a, b) => 64 compareDate(a.date_heure_modif, b.date_heure_modif) 65 ); 66 } 67 68 onChanged(vaccins: PublicDocument[]) { 69 const pers = C.data.personnes[this.idPersonneCrypted]; 70 pers.vaccins = vaccins; 71 this.$set(C.data.personnes, this.idPersonneCrypted, pers); // VRC 72 } 73 74 async creeVaccin(event: ValidEventFile) { 75 const vaccins = await C.data.creeVaccin(event.file, this.idPersonneCrypted); 76 event.event.spinning = false; 77 if (vaccins === undefined || C.data == null) return; 78 const pers = (C.data.personnes || {})[this.idPersonneCrypted]; 79 pers.vaccins = vaccins; 80 this.$set(C.data.personnes || {}, this.idPersonneCrypted, pers); // VRC 81 C.notifications.success = { 82 title: "Vaccin ajouté", 83 message: "Le document a bien été ajouté. Merci !" 84 }; 85 } 86 } 87 </script> 88 89 <style scoped></style>