codevdesign 0.0.78 → 0.0.80
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/composants/csqcImportCSV.vue +125 -0
- package/composants/csqcRecherche.vue +212 -206
- package/composants/csqcRechercheUtilisateur.vue +125 -0
- package/composants/csqcTable/csqcTable.vue +3 -2
- package/index.ts +2 -0
- package/locales/en.json +21 -0
- package/locales/fr.json +34 -13
- package/modeles/assurancesAssuranceGeneraleGrics.ts +10 -0
- package/modeles/assurancesAssurancePersonnelleGrics.ts +13 -0
- package/modeles/assurancesContratGrics.ts +14 -0
- package/modeles/assurancesDetailsPrimeReguliereGrics.ts +12 -0
- package/modeles/assurancesDonneesAssureurGrics.ts +13 -0
- package/modeles/assurancesEmployeGrics.ts +11 -0
- package/modeles/assurancesGrics.ts +14 -0
- package/modeles/assurancesRegimeAssuranceGrics.ts +9 -0
- package/modeles/assurancesRegimeBaseEmployeurGrics.ts +9 -0
- package/modeles/assurancesRegimeBaseGrics.ts +9 -0
- package/modeles/employeAdresseGrics.ts +13 -0
- package/modeles/employeAdressesPersonnellesGrics.ts +12 -0
- package/modeles/employeAffectationCorpsEmploiGrics.ts +9 -0
- package/modeles/employeBanquesCongeBanqueGrics.ts +9 -0
- package/modeles/employeBanquesCongeGrics.ts +14 -0
- package/modeles/employeBanquesCongeRegimeAbsenceGrics.ts +9 -0
- package/modeles/employeCourrielsPersonnels.ts +9 -0
- package/modeles/employeCourrielsProfessionnels.ts +9 -0
- package/modeles/employeEmploisCategorieGrics.ts +2 -2
- package/modeles/employeEmploisClasseGrics.ts +2 -2
- package/modeles/employeEmploisCorpsEmploiGrics.ts +2 -2
- package/modeles/employeEmploisEtatEmploiGrics.ts +2 -2
- package/modeles/employeEmploisGrics.ts +29 -29
- package/modeles/employeEmploisGroupePaieGrics.ts +2 -2
- package/modeles/employeEmploisLieuTravailPrincipalGrics.ts +3 -3
- package/modeles/employeEmploisLieuxTravailSecondairesGrics.ts +3 -3
- package/modeles/employeEmploisRegimeAbsenceGrics.ts +2 -2
- package/modeles/employeEmploisSecteurGrics.ts +2 -2
- package/modeles/employeEmploisStatutEngagementGrics.ts +2 -2
- package/modeles/employeExperienceEmploiGrics.ts +9 -0
- package/modeles/employeExperienceEmployeGrics.ts +12 -0
- package/modeles/employeExperienceExperiencesGrics.ts +11 -0
- package/modeles/employeExperienceExperiencesTotalesGrics.ts +15 -0
- package/modeles/employeExperienceGrics.ts +17 -0
- package/modeles/employeGrics.ts +31 -0
- package/modeles/employeMinsLsCodev.ts +10 -0
- package/modeles/employeTelephoneGrics.ts +12 -0
- package/modeles/employeTelephonesPersonnelsGrics.ts +11 -0
- package/modeles/employeTelephonesProfessionnelsGrics.ts +11 -0
- package/modeles/groupeCE.ts +6 -6
- package/modeles/groupeCEIntervalle.ts +6 -6
- package/modeles/historiquesAbsenceBanqueGrics.ts +9 -0
- package/modeles/historiquesAbsenceGrics.ts +21 -0
- package/modeles/historiquesAbsenceLieuTravailGrics.ts +9 -0
- package/modeles/historiquesAbsenceSousBanqueGrics.ts +9 -0
- package/modeles/motifsAbsenceBanque.ts +9 -0
- package/modeles/motifsAbsenceGrics.ts +17 -0
- package/modeles/motifsAbsenceRegimeAbsence.ts +9 -0
- package/modeles/motifsAbsenceSousMotifs.ts +9 -0
- package/modeles/motifsAbsenceTraitementBanques.ts +11 -0
- package/modeles/syndicat.ts +26 -0
- package/modeles/syndicatGroupeCe.ts +10 -0
- package/modeles/syndicatResponsable.ts +15 -0
- package/modeles/syndicatUnite.ts +10 -0
- package/modeles/typeTelephone.ts +12 -0
- package/modeles/unite.ts +23 -24
- package/modeles/utilisateur.ts +8 -8
- package/package.json +1 -1
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<v-btn
|
|
4
|
+
color="success"
|
|
5
|
+
variant="outlined"
|
|
6
|
+
:loading="chargement"
|
|
7
|
+
class="elevation-0"
|
|
8
|
+
@click="importCsv"
|
|
9
|
+
>
|
|
10
|
+
{{ boutonTexte }}
|
|
11
|
+
<template #append>
|
|
12
|
+
<v-icon icon="mdi-microsoft-excel"></v-icon>
|
|
13
|
+
</template>
|
|
14
|
+
</v-btn>
|
|
15
|
+
|
|
16
|
+
<input
|
|
17
|
+
ref="fileInput"
|
|
18
|
+
type="file"
|
|
19
|
+
accept=".csv"
|
|
20
|
+
style="display: none"
|
|
21
|
+
@change="handleFileUpload"
|
|
22
|
+
/>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
import { ref, computed } from 'vue'
|
|
28
|
+
import { useI18n } from 'vue-i18n'
|
|
29
|
+
|
|
30
|
+
// Props
|
|
31
|
+
const props = withDefaults(
|
|
32
|
+
defineProps<{
|
|
33
|
+
boutonTexte?: string
|
|
34
|
+
erreurTexte?: string
|
|
35
|
+
chargement?: boolean
|
|
36
|
+
}>(),
|
|
37
|
+
{
|
|
38
|
+
chargement: false, // défaut
|
|
39
|
+
},
|
|
40
|
+
)
|
|
41
|
+
const emit = defineEmits(['import', 'import-erreur'])
|
|
42
|
+
|
|
43
|
+
const { t } = useI18n()
|
|
44
|
+
|
|
45
|
+
const boutonTexte = computed(() => props.boutonTexte ?? t('csqc.bouton.importer'))
|
|
46
|
+
const erreurTexte = computed(() => props.erreurTexte ?? t('csqc.csqcImportCSV.erreur.lectureFichier'))
|
|
47
|
+
|
|
48
|
+
// Références
|
|
49
|
+
const fileInput = ref<HTMLInputElement | null>(null)
|
|
50
|
+
const csvFile = ref<File | null>(null)
|
|
51
|
+
|
|
52
|
+
// Méthodes
|
|
53
|
+
function importCsv() {
|
|
54
|
+
fileInput.value?.click()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function handleFileUpload(event: Event) {
|
|
58
|
+
const target = event.target as HTMLInputElement
|
|
59
|
+
const file = target.files?.[0]
|
|
60
|
+
|
|
61
|
+
if (file?.name.toLowerCase().endsWith('.csv')) {
|
|
62
|
+
csvFile.value = file
|
|
63
|
+
|
|
64
|
+
const reader = new FileReader()
|
|
65
|
+
|
|
66
|
+
reader.onload = () => {
|
|
67
|
+
try {
|
|
68
|
+
let text = reader.result as string
|
|
69
|
+
|
|
70
|
+
// Supprime BOM UTF-8 si présent
|
|
71
|
+
if (text.charCodeAt(0) === 0xfeff) {
|
|
72
|
+
text = text.slice(1)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const lignes = text
|
|
76
|
+
.trim()
|
|
77
|
+
.split(/\r?\n/)
|
|
78
|
+
.filter(row => row.trim() !== '') // ignore lignes vides
|
|
79
|
+
|
|
80
|
+
if (lignes.length === 0) {
|
|
81
|
+
emit('import-erreur', 'Le fichier CSV est vide.')
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Détection automatique du séparateur
|
|
86
|
+
const separateur = detecterSeparateur(lignes[0]!)
|
|
87
|
+
|
|
88
|
+
// Découpage des lignes
|
|
89
|
+
const data: string[][] = lignes.map(row => row.split(separateur).map(cell => cell.trim()))
|
|
90
|
+
|
|
91
|
+
emit('import', data)
|
|
92
|
+
} catch (error) {
|
|
93
|
+
emit('import-erreur', erreurTexte || t('csqc.csqcImportCSV.erreur.lectureFichier'))
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
reader.onerror = () => {
|
|
98
|
+
emit('import-erreur', t('csqc.csqcImportCSV.erreur.lectureFichier'))
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
reader.readAsText(file)
|
|
102
|
+
} else {
|
|
103
|
+
const message = erreurTexte || t('csqc.csqcImportCSV.erreur.erreur')
|
|
104
|
+
emit('import-erreur', message)
|
|
105
|
+
csvFile.value = null
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Fonction pour détecter le séparateur le plus probable
|
|
110
|
+
function detecterSeparateur(ligne: string): string {
|
|
111
|
+
const separateursTestés = [',', ';', '\t', '|']
|
|
112
|
+
let meilleurSeparateur = ','
|
|
113
|
+
let maxColonnes = 0
|
|
114
|
+
|
|
115
|
+
for (const sep of separateursTestés) {
|
|
116
|
+
const nb = ligne.split(sep).length
|
|
117
|
+
if (nb > maxColonnes) {
|
|
118
|
+
maxColonnes = nb
|
|
119
|
+
meilleurSeparateur = sep
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return meilleurSeparateur
|
|
124
|
+
}
|
|
125
|
+
</script>
|
|
@@ -1,206 +1,212 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<v-row
|
|
4
|
-
dense
|
|
5
|
-
class="pt-0 mt-0"
|
|
6
|
-
>
|
|
7
|
-
<v-col
|
|
8
|
-
cols="12"
|
|
9
|
-
sm="auto"
|
|
10
|
-
>
|
|
11
|
-
<slot name="recherche"></slot>
|
|
12
|
-
<v-text-field
|
|
13
|
-
v-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
</
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
margin-left:
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<v-row
|
|
4
|
+
dense
|
|
5
|
+
class="pt-0 mt-0"
|
|
6
|
+
>
|
|
7
|
+
<v-col
|
|
8
|
+
cols="12"
|
|
9
|
+
sm="auto"
|
|
10
|
+
>
|
|
11
|
+
<slot name="recherche"></slot>
|
|
12
|
+
<v-text-field
|
|
13
|
+
v-if="afficher"
|
|
14
|
+
v-model="rechercheLocale"
|
|
15
|
+
:label="rechercheTexte ? rechercheTexte : $t('csqc.label.recherche')"
|
|
16
|
+
single-line
|
|
17
|
+
density="compact"
|
|
18
|
+
hide-details
|
|
19
|
+
clearable
|
|
20
|
+
:rounded="0"
|
|
21
|
+
variant="outlined"
|
|
22
|
+
max-width="640"
|
|
23
|
+
min-width="500"
|
|
24
|
+
class="BarreRecherche"
|
|
25
|
+
:loading="chargement"
|
|
26
|
+
:disabled="chargement || desactiver"
|
|
27
|
+
>
|
|
28
|
+
<template #append>
|
|
29
|
+
<v-btn
|
|
30
|
+
class="BarreRechercheBackIcone"
|
|
31
|
+
:loading="chargement"
|
|
32
|
+
:disabled="chargement || desactiver"
|
|
33
|
+
>
|
|
34
|
+
<v-icon
|
|
35
|
+
class="BarreRechercheIcone"
|
|
36
|
+
icon="mdi-magnify"
|
|
37
|
+
/>
|
|
38
|
+
</v-btn>
|
|
39
|
+
</template>
|
|
40
|
+
</v-text-field>
|
|
41
|
+
</v-col>
|
|
42
|
+
<!-- Entre recherche et ajouté-->
|
|
43
|
+
<v-col
|
|
44
|
+
cols="12"
|
|
45
|
+
sm="auto"
|
|
46
|
+
class="pt-1 mt-0 pb-0 mb-0"
|
|
47
|
+
>
|
|
48
|
+
<slot name="milieu" />
|
|
49
|
+
</v-col>
|
|
50
|
+
|
|
51
|
+
<!-- Affichage des boutons et icônes-->
|
|
52
|
+
<v-col
|
|
53
|
+
cols="12"
|
|
54
|
+
sm="auto"
|
|
55
|
+
class="flex-grow-1 d-flex justify-end"
|
|
56
|
+
>
|
|
57
|
+
<slot name="droite" />
|
|
58
|
+
</v-col>
|
|
59
|
+
</v-row>
|
|
60
|
+
<v-row
|
|
61
|
+
dense
|
|
62
|
+
class="pt-0 mt-0"
|
|
63
|
+
>
|
|
64
|
+
<v-col
|
|
65
|
+
cols="12"
|
|
66
|
+
:lg="rechercheAvanceeLargeur"
|
|
67
|
+
>
|
|
68
|
+
<v-expansion-panels
|
|
69
|
+
v-if="rechercheAvancee"
|
|
70
|
+
static
|
|
71
|
+
:readonly="chargement || desactiver"
|
|
72
|
+
expand-icon=""
|
|
73
|
+
@update:model-value="onPanelChange"
|
|
74
|
+
>
|
|
75
|
+
<v-expansion-panel
|
|
76
|
+
flat
|
|
77
|
+
elevation="0"
|
|
78
|
+
>
|
|
79
|
+
<v-expansion-panel-title
|
|
80
|
+
style="color: #095797"
|
|
81
|
+
class="pl-0 ml-0"
|
|
82
|
+
><slot name="rechercheAvanceeTitre">
|
|
83
|
+
<span
|
|
84
|
+
style="text-decoration: underline"
|
|
85
|
+
v-html="rechercheAvanceeTexte ? rechercheAvanceeTexte : $t('csqc.label.rechercheAvanceeDefaut')"
|
|
86
|
+
></span>
|
|
87
|
+
<slot name="rechercheAvanceeApresTitre"></slot
|
|
88
|
+
></slot>
|
|
89
|
+
</v-expansion-panel-title>
|
|
90
|
+
<v-expansion-panel-text :style="rechercheAvanceeStyle">
|
|
91
|
+
<slot name="rechercheAvancee"></slot>
|
|
92
|
+
</v-expansion-panel-text>
|
|
93
|
+
</v-expansion-panel>
|
|
94
|
+
</v-expansion-panels>
|
|
95
|
+
</v-col>
|
|
96
|
+
</v-row>
|
|
97
|
+
</div>
|
|
98
|
+
</template>
|
|
99
|
+
|
|
100
|
+
<script lang="ts" setup>
|
|
101
|
+
import { ref, watch } from 'vue'
|
|
102
|
+
|
|
103
|
+
// Props
|
|
104
|
+
const props = defineProps({
|
|
105
|
+
afficher: {
|
|
106
|
+
type: Boolean,
|
|
107
|
+
required: false,
|
|
108
|
+
default: true,
|
|
109
|
+
},
|
|
110
|
+
rechercheTexte: {
|
|
111
|
+
type: String,
|
|
112
|
+
required: false,
|
|
113
|
+
default: '',
|
|
114
|
+
},
|
|
115
|
+
rechercheAvanceeTexte: {
|
|
116
|
+
type: String,
|
|
117
|
+
required: false,
|
|
118
|
+
default: '',
|
|
119
|
+
},
|
|
120
|
+
rechercheAvanceeLargeur: {
|
|
121
|
+
type: Number,
|
|
122
|
+
required: false,
|
|
123
|
+
default: 12,
|
|
124
|
+
},
|
|
125
|
+
chargement: {
|
|
126
|
+
type: Boolean,
|
|
127
|
+
required: false,
|
|
128
|
+
default: false,
|
|
129
|
+
},
|
|
130
|
+
desactiver: {
|
|
131
|
+
type: Boolean,
|
|
132
|
+
required: false,
|
|
133
|
+
default: false,
|
|
134
|
+
},
|
|
135
|
+
recherche: {
|
|
136
|
+
type: String,
|
|
137
|
+
required: false,
|
|
138
|
+
default: '',
|
|
139
|
+
},
|
|
140
|
+
rechercheAvancee: {
|
|
141
|
+
type: Boolean,
|
|
142
|
+
required: false,
|
|
143
|
+
default: false,
|
|
144
|
+
},
|
|
145
|
+
rechercheAvanceeStyle: {
|
|
146
|
+
type: String,
|
|
147
|
+
required: false,
|
|
148
|
+
default: '',
|
|
149
|
+
},
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
const emit = defineEmits<{
|
|
153
|
+
(e: 'update:recherche', recherche: string): void
|
|
154
|
+
(e: 'panneau:etat', isOpen: boolean): void // événement pour l'ouverture/fermeture du panneau
|
|
155
|
+
}>()
|
|
156
|
+
|
|
157
|
+
// Création d'une variable locale pour gérer la recherche
|
|
158
|
+
const rechercheLocale = ref(props.recherche)
|
|
159
|
+
|
|
160
|
+
// Surveiller les changements de la prop `recherche` et mettre à jour `rechercheLocale`
|
|
161
|
+
watch(
|
|
162
|
+
() => props.recherche,
|
|
163
|
+
nouvelleValeur => {
|
|
164
|
+
rechercheLocale.value = nouvelleValeur
|
|
165
|
+
},
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
// Émettre l'événement `update:recherche` chaque fois que l'utilisateur tape
|
|
169
|
+
watch(rechercheLocale, nouvelleValeur => {
|
|
170
|
+
emit('update:recherche', nouvelleValeur!)
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
// Fonction pour émettre l'événement d'ouverture/fermeture du panneau
|
|
174
|
+
const onPanelChange = (val: unknown) => {
|
|
175
|
+
if (typeof val === 'string' || typeof val === 'number' || val === null) {
|
|
176
|
+
const isOpen = val !== null && val !== ''
|
|
177
|
+
emit('panneau:etat', isOpen)
|
|
178
|
+
} else {
|
|
179
|
+
emit('panneau:etat', false)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
</script>
|
|
183
|
+
|
|
184
|
+
<style lang="css">
|
|
185
|
+
/* barre de recherche design QC*/
|
|
186
|
+
.BarreRecherche {
|
|
187
|
+
min-height: 40px;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.BarreRechercheBackIcone {
|
|
191
|
+
border-right: 1px solid #808a9d;
|
|
192
|
+
border-top: 1px solid #808a9d;
|
|
193
|
+
border-bottom: 1px solid #808a9d;
|
|
194
|
+
background-color: #095797 !important;
|
|
195
|
+
height: 40px !important;
|
|
196
|
+
width: 40px !important;
|
|
197
|
+
max-width: 40px !important;
|
|
198
|
+
min-width: 40px !important;
|
|
199
|
+
padding-right: 0 !important;
|
|
200
|
+
padding-left: 0 !important;
|
|
201
|
+
border-radius: 0;
|
|
202
|
+
margin-left: -16px;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/* icone loupe */
|
|
206
|
+
.BarreRechercheIcone {
|
|
207
|
+
font-size: 34px !important;
|
|
208
|
+
margin-left: 1px !important;
|
|
209
|
+
margin-top: 2px !important;
|
|
210
|
+
color: white !important;
|
|
211
|
+
}
|
|
212
|
+
</style>
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<v-autocomplete
|
|
4
|
+
v-model="selection"
|
|
5
|
+
v-model:search="search"
|
|
6
|
+
:items="items"
|
|
7
|
+
:loading="chargement"
|
|
8
|
+
density="compact"
|
|
9
|
+
:hide-no-data="!doitAfficherAucunResultat"
|
|
10
|
+
:no-data-text="$t('csqcRechercheUtilisateur.aucunResultat')"
|
|
11
|
+
:item-title="formatterUtilisateur"
|
|
12
|
+
item-value="id"
|
|
13
|
+
:placeholder="$t('csqcRechercheUtilisateur.placeholderRechercheUtilisateur')"
|
|
14
|
+
return-object
|
|
15
|
+
autofocus
|
|
16
|
+
auto-select-first
|
|
17
|
+
variant="outlined"
|
|
18
|
+
:rules="props.rules"
|
|
19
|
+
/>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script setup lang="ts">
|
|
24
|
+
import { ref, watch, computed, onMounted } from 'vue'
|
|
25
|
+
import type { EmployeMinsLsCodev } from '@/modeles/employeMinsLsCodev'
|
|
26
|
+
import appAxios from '@/outils/appAxios'
|
|
27
|
+
import { useI18n } from 'vue-i18n'
|
|
28
|
+
|
|
29
|
+
const props = defineProps<{
|
|
30
|
+
rules: ((value: string) => boolean | string)[]
|
|
31
|
+
matriculeDefaut?: string | null
|
|
32
|
+
}>()
|
|
33
|
+
|
|
34
|
+
const emit = defineEmits<{
|
|
35
|
+
(e: 'selection', value: string | null): void
|
|
36
|
+
(e: 'selectionPlus', utilisateur: EmployeMinsLsCodev | null): void
|
|
37
|
+
(e: 'erreur', message: string): void
|
|
38
|
+
}>()
|
|
39
|
+
|
|
40
|
+
const { t } = useI18n({ useScope: 'global' })
|
|
41
|
+
|
|
42
|
+
const selection = ref<EmployeMinsLsCodev | null>(null)
|
|
43
|
+
const utilisateurs = ref<EmployeMinsLsCodev[]>([])
|
|
44
|
+
const chargement = ref(false)
|
|
45
|
+
const search = ref<string>('')
|
|
46
|
+
const items = computed(() => utilisateurs.value)
|
|
47
|
+
const erreur = ref<string | null>(null)
|
|
48
|
+
|
|
49
|
+
const cache = ref<Record<string, EmployeMinsLsCodev[]>>({})
|
|
50
|
+
|
|
51
|
+
const estTermeValide = (terme?: string): boolean => !!terme && terme.length >= 4 && !terme.includes('(')
|
|
52
|
+
|
|
53
|
+
onMounted(async () => {
|
|
54
|
+
if (props.matriculeDefaut) {
|
|
55
|
+
await rechercherUtilisateurs(props.matriculeDefaut)
|
|
56
|
+
if (utilisateurs.value.length > 0) {
|
|
57
|
+
const utilisateur: EmployeMinsLsCodev | null =
|
|
58
|
+
utilisateurs.value.find(user => user.matricule == props.matriculeDefaut) ?? null
|
|
59
|
+
|
|
60
|
+
if (utilisateur) {
|
|
61
|
+
search.value = `${utilisateur.prenom} ${utilisateur.nom} (${utilisateur.matricule}), ${utilisateur.courrielProfessionnel}, ${utilisateur.nomLieuPrincipal}, ${utilisateur.corpsEmploiPrincipalDescription}`
|
|
62
|
+
selection.value = utilisateur
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const doitAfficherAucunResultat = computed(
|
|
69
|
+
() => estTermeValide(search.value) && !chargement.value && items.value.length === 0,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
const formatterUtilisateur = (item: EmployeMinsLsCodev): string => {
|
|
73
|
+
return `${item.prenom} ${item.nom} (${item.matricule}), ${item.courrielProfessionnel}, ${item.numeroLieuPrincipal}-${item.nomLieuPrincipal}, ${item.corpsEmploiPrincipal}-${item.corpsEmploiPrincipalDescription}`
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const rechercherUtilisateurs = async (terme?: string) => {
|
|
77
|
+
if (!estTermeValide(terme)) {
|
|
78
|
+
utilisateurs.value = []
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const termeLower = terme!.toLowerCase()
|
|
83
|
+
|
|
84
|
+
const cachedKey = Object.keys(cache.value)
|
|
85
|
+
.filter(k => termeLower.startsWith(k))
|
|
86
|
+
.sort((a, b) => b.length - a.length)[0]
|
|
87
|
+
|
|
88
|
+
if (cachedKey) {
|
|
89
|
+
utilisateurs.value = cache.value[cachedKey].filter(user =>
|
|
90
|
+
formatterUtilisateur(user).toLowerCase().includes(termeLower),
|
|
91
|
+
)
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
chargement.value = true
|
|
97
|
+
const reponse = await appAxios.getAxios().get<EmployeMinsLsCodev[]>(`Application/Utilisateurs/${terme}`)
|
|
98
|
+
const donnee = reponse.data ?? reponse // fallback si .data est absent
|
|
99
|
+
|
|
100
|
+
utilisateurs.value = donnee
|
|
101
|
+
cache.value[termeLower] = donnee
|
|
102
|
+
} catch (e: unknown) {
|
|
103
|
+
let message = t('csqcRechercheUtilisateur.erreur')
|
|
104
|
+
if (e instanceof Error) message = e.message
|
|
105
|
+
else if (typeof e === 'string') message = e
|
|
106
|
+
erreur.value = message
|
|
107
|
+
emit('erreur', message)
|
|
108
|
+
} finally {
|
|
109
|
+
chargement.value = false
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
watch(selection, utilisateur => {
|
|
114
|
+
emit('selection', utilisateur?.courrielProfessionnel ?? null)
|
|
115
|
+
emit('selectionPlus', utilisateur ?? null)
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
watch(
|
|
119
|
+
search,
|
|
120
|
+
terme => {
|
|
121
|
+
if (!chargement.value) rechercherUtilisateurs(terme)
|
|
122
|
+
},
|
|
123
|
+
{ immediate: false },
|
|
124
|
+
)
|
|
125
|
+
</script>
|