codevdesign 1.0.34 → 1.0.36

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.
Files changed (105) hide show
  1. package/assets/csqc.css +259 -0
  2. package/composants/csqcAide.vue +55 -0
  3. package/composants/csqcAlerteErreur.vue +87 -0
  4. package/composants/csqcChaise/chaiseConteneur.vue +367 -0
  5. package/composants/csqcChaise/chaiseItem.vue +54 -0
  6. package/composants/csqcCodeBudgetaireGenerique.vue +336 -0
  7. package/composants/csqcConfirmation.vue +75 -0
  8. package/composants/csqcDate.vue +57 -0
  9. package/composants/csqcDialogue.vue +118 -0
  10. package/composants/csqcEditeurTexteRiche.vue +380 -0
  11. package/composants/csqcEntete.vue +163 -0
  12. package/composants/csqcImportCSV.vue +125 -0
  13. package/composants/csqcModaleSaisie.vue +95 -0
  14. package/composants/csqcOptionSwitch.vue +120 -0
  15. package/composants/csqcRecherche.vue +213 -0
  16. package/composants/csqcRechercheUtilisateur.vue +197 -0
  17. package/composants/csqcSnackbar.vue +88 -0
  18. package/composants/csqcTable/csqcTable.vue +383 -0
  19. package/composants/csqcTable/csqcTableExportExcel.vue +58 -0
  20. package/composants/csqcTable/csqcTableModaleChoixColonnes.vue +586 -0
  21. package/composants/csqcTexteBilingue.vue +175 -0
  22. package/composants/csqcTiroir.vue +156 -0
  23. package/composants/gabarit/csqcMenu.vue +281 -0
  24. package/composants/gabarit/pivEntete.vue +205 -0
  25. package/composants/gabarit/pivPiedPage.vue +70 -0
  26. package/composants/gabarit/vueDefault.vue +5 -0
  27. package/composants/validateurs.ts +183 -0
  28. package/enums/choixLangue.ts +10 -0
  29. package/index.ts +75 -0
  30. package/locales/en.json +100 -0
  31. package/locales/fr.json +101 -0
  32. package/modeles/apiReponse.ts +12 -0
  33. package/modeles/assurancesAssuranceGeneraleGrics.ts +10 -0
  34. package/modeles/assurancesAssurancePersonnelleGrics.ts +13 -0
  35. package/modeles/assurancesContratGrics.ts +14 -0
  36. package/modeles/assurancesDetailsPrimeReguliereGrics.ts +12 -0
  37. package/modeles/assurancesDonneesAssureurGrics.ts +13 -0
  38. package/modeles/assurancesEmployeGrics.ts +11 -0
  39. package/modeles/assurancesGrics.ts +14 -0
  40. package/modeles/assurancesRegimeAssuranceGrics.ts +9 -0
  41. package/modeles/assurancesRegimeBaseEmployeurGrics.ts +9 -0
  42. package/modeles/assurancesRegimeBaseGrics.ts +9 -0
  43. package/modeles/composants/csqcMenuModele.ts +18 -0
  44. package/modeles/composants/datatableColonne.ts +31 -0
  45. package/modeles/composants/snackbar.ts +18 -0
  46. package/modeles/data.ts +24 -0
  47. package/modeles/droitIntervention.ts +14 -0
  48. package/modeles/employeAdresseGrics.ts +13 -0
  49. package/modeles/employeAdressesPersonnellesGrics.ts +12 -0
  50. package/modeles/employeAffectationCorpsEmploiGrics.ts +9 -0
  51. package/modeles/employeBanquesCongeBanqueGrics.ts +9 -0
  52. package/modeles/employeBanquesCongeGrics.ts +14 -0
  53. package/modeles/employeBanquesCongeRegimeAbsenceGrics.ts +9 -0
  54. package/modeles/employeCourrielsPersonnels.ts +9 -0
  55. package/modeles/employeCourrielsProfessionnels.ts +9 -0
  56. package/modeles/employeEmploisCategorieGrics.ts +9 -0
  57. package/modeles/employeEmploisClasseGrics.ts +9 -0
  58. package/modeles/employeEmploisCorpsEmploiGrics.ts +9 -0
  59. package/modeles/employeEmploisEtatEmploiGrics.ts +9 -0
  60. package/modeles/employeEmploisGrics.ts +37 -0
  61. package/modeles/employeEmploisGroupePaieGrics.ts +9 -0
  62. package/modeles/employeEmploisLieuTravailPrincipalGrics.ts +10 -0
  63. package/modeles/employeEmploisLieuxTravailSecondairesGrics.ts +10 -0
  64. package/modeles/employeEmploisRegimeAbsenceGrics.ts +9 -0
  65. package/modeles/employeEmploisSecteurGrics.ts +9 -0
  66. package/modeles/employeEmploisStatutEngagementGrics.ts +9 -0
  67. package/modeles/employeExperienceEmploiGrics.ts +9 -0
  68. package/modeles/employeExperienceEmployeGrics.ts +12 -0
  69. package/modeles/employeExperienceExperiencesGrics.ts +11 -0
  70. package/modeles/employeExperienceExperiencesTotalesGrics.ts +15 -0
  71. package/modeles/employeExperienceGrics.ts +17 -0
  72. package/modeles/employeGrics.ts +31 -0
  73. package/modeles/employeMinsLsCodev.ts +10 -0
  74. package/modeles/employeTelephoneGrics.ts +12 -0
  75. package/modeles/employeTelephonesPersonnelsGrics.ts +11 -0
  76. package/modeles/employeTelephonesProfessionnelsGrics.ts +11 -0
  77. package/modeles/groupeCE.ts +14 -0
  78. package/modeles/groupeCEIntervalle.ts +13 -0
  79. package/modeles/historiquesAbsenceBanqueGrics.ts +9 -0
  80. package/modeles/historiquesAbsenceGrics.ts +21 -0
  81. package/modeles/historiquesAbsenceLieuTravailGrics.ts +9 -0
  82. package/modeles/historiquesAbsenceSousBanqueGrics.ts +9 -0
  83. package/modeles/intervention.ts +35 -0
  84. package/modeles/motifsAbsenceBanque.ts +9 -0
  85. package/modeles/motifsAbsenceGrics.ts +17 -0
  86. package/modeles/motifsAbsenceRegimeAbsence.ts +9 -0
  87. package/modeles/motifsAbsenceSousMotifs.ts +9 -0
  88. package/modeles/motifsAbsenceTraitementBanques.ts +11 -0
  89. package/modeles/notificationGabaritDefaut.ts +10 -0
  90. package/modeles/response.ts +12 -0
  91. package/modeles/role.ts +31 -0
  92. package/modeles/roleMin.ts +12 -0
  93. package/modeles/syndicat.ts +26 -0
  94. package/modeles/syndicatGroupeCe.ts +10 -0
  95. package/modeles/syndicatResponsable.ts +15 -0
  96. package/modeles/syndicatUnite.ts +10 -0
  97. package/modeles/typeEnseignement.ts +14 -0
  98. package/modeles/typeTelephone.ts +12 -0
  99. package/modeles/unite.ts +23 -0
  100. package/modeles/uniteTypeEnseignement.ts +12 -0
  101. package/modeles/utilisateur.ts +15 -0
  102. package/outils/appAxios.ts +116 -0
  103. package/outils/csqcOutils.ts +366 -0
  104. package/outils/rafraichisseurToken.ts +187 -0
  105. package/package.json +6 -12
@@ -0,0 +1,380 @@
1
+ <template>
2
+ <div class="editor">
3
+ <Editor
4
+ v-if="editorReady"
5
+ v-bind="$attrs"
6
+ v-model="editorValue"
7
+ :init="initOptions"
8
+ :disabled="desactiver"
9
+ license-key="gpl"
10
+ @blur="onBlur"
11
+ @keydown="onUserActivity"
12
+ @change="onUserActivity"
13
+ />
14
+ </div>
15
+ </template>
16
+
17
+ <script setup lang="ts">
18
+ /* eslint-disable @typescript-eslint/no-explicit-any */
19
+
20
+ import { computed, ref, watch, nextTick } from 'vue'
21
+ import Editor from '@tinymce/tinymce-vue'
22
+ import type { Editor as TinyMCEEditor } from 'tinymce'
23
+
24
+ // Core / skins / thème
25
+ import 'tinymce/tinymce.js'
26
+ import 'tinymce/icons/default/icons.min.js'
27
+ import 'tinymce/themes/silver/theme.min.js'
28
+ import 'tinymce/models/dom/model.min.js'
29
+ import 'tinymce/skins/ui/oxide/skin.js'
30
+ import 'tinymce/skins/ui/oxide/content.js'
31
+ import 'tinymce/skins/content/default/content.js'
32
+
33
+ // Langue
34
+ import 'tinymce-i18n/langs7/fr_FR'
35
+
36
+ // Plugins
37
+ import 'tinymce/plugins/autoresize/plugin.min.js'
38
+ import 'tinymce/plugins/advlist/plugin.min.js'
39
+ import 'tinymce/plugins/lists/plugin.min.js'
40
+ import 'tinymce/plugins/link/plugin.min.js'
41
+ import 'tinymce/plugins/autolink/plugin.min.js'
42
+ import 'tinymce/plugins/fullscreen/plugin.min.js'
43
+ import 'tinymce/plugins/table/plugin.min.js'
44
+ import 'tinymce/plugins/image/plugin.min.js'
45
+ import 'tinymce/plugins/code/plugin.min.js'
46
+
47
+ const openLink = (url?: string | null, target?: string | null) => {
48
+ if (!url) return
49
+ if (import.meta.env.MODE !== 'development') {
50
+ if (target && target !== '_blank') {
51
+ document.location.href = url
52
+ return
53
+ }
54
+ window.open(url, target || '_blank', 'noopener,noreferrer')
55
+ }
56
+ }
57
+
58
+ type PluginsProp = string | string[]
59
+ type ToolbarProp = string | string[]
60
+
61
+ interface Props {
62
+ modelValue?: string
63
+ langue?: string
64
+ interdireRedimension?: boolean
65
+ desactiver?: boolean
66
+ plugins?: PluginsProp // optionnel
67
+ autoriserImage?: boolean
68
+ imageTailleMaximale?: number
69
+ cacherBarreMenu?: boolean
70
+ cacherBarreOutils?: boolean
71
+ toolbar?: ToolbarProp // optionnel
72
+ }
73
+
74
+ const props = withDefaults(defineProps<Props>(), {
75
+ modelValue: '',
76
+ langue: 'fr_FR',
77
+ interdireRedimension: false,
78
+ desactiver: false,
79
+ plugins: 'autoresize table image link fullscreen advlist lists autolink code',
80
+ autoriserImage: false,
81
+ imageTailleMaximale: 5,
82
+ cacherBarreMenu: false,
83
+ cacherBarreOutils: false,
84
+ toolbar:
85
+ 'print | bold italic underline strikethrough | fontsizeselect | forecolor backcolor | ' +
86
+ 'alignleft aligncenter alignright alignjustify | bullist numlist | ' +
87
+ 'image | link | outdent indent blockquote | undo redo | fullscreen | removeformat | table | code',
88
+ })
89
+
90
+ const emit = defineEmits<{
91
+ (e: 'update:modelValue', value: string): void
92
+ (e: 'blur'): void
93
+ }>()
94
+
95
+ const editorReady = ref(true)
96
+ const editorValue = ref<string>(props.modelValue)
97
+ const _editor = ref<TinyMCEEditor | null>(null)
98
+ const _reinitPending = ref(false)
99
+ const _reinitLock = ref(false)
100
+
101
+ const imageTailleMaxMo = computed<number>(() => {
102
+ const n = Number(props.imageTailleMaximale)
103
+ if (!Number.isFinite(n)) return 5
104
+ return Math.min(100, Math.max(0, n))
105
+ })
106
+
107
+ const normalizeToolbar = (tb: string): string => {
108
+ const trimmed = (tb || '').trim()
109
+ return trimmed && trimmed !== '|' ? trimmed : 'undo redo'
110
+ }
111
+
112
+ const toolbarEffective = computed<string | false>(() => {
113
+ if (props.cacherBarreOutils) return false
114
+
115
+ const raw = Array.isArray(props.toolbar) ? props.toolbar.join(' | ') : props.toolbar
116
+ if (props.autoriserImage) return normalizeToolbar(raw)
117
+
118
+ const sansImage = raw
119
+ .replace(/\bimage\b/g, '')
120
+ .replace(/\s*\|\s*/g, ' | ')
121
+ .replace(/(\s*\|\s*){2,}/g, ' | ')
122
+ .replace(/^\s*\|\s*|\s*\|\s*$/g, '')
123
+ .replace(/\s{2,}/g, ' ')
124
+ .trim()
125
+
126
+ return normalizeToolbar(sansImage)
127
+ })
128
+
129
+ const pluginsEffective = computed<string>(() => {
130
+ const list = (Array.isArray(props.plugins) ? props.plugins : props.plugins.split(/\s+/))
131
+ .map(p => p.trim())
132
+ .filter(Boolean)
133
+
134
+ const filtered = !props.autoriserImage ? list.filter(p => p !== 'image') : list
135
+ return filtered.join(' ')
136
+ })
137
+
138
+ const initOptions = computed<any>(() => {
139
+ const opts: any = {
140
+ autolink: !props.desactiver,
141
+ autoresize: true,
142
+ automatic_uploads: props.autoriserImage,
143
+ branding: false,
144
+ browser_spellcheck: true,
145
+ content_css: 'default',
146
+ deprecation_warnings: false,
147
+ highlight_on_focus: false,
148
+ image_dimensions: true,
149
+ language: props.langue === 'en' ? 'en_US' : 'fr_FR',
150
+ license_key: 'gpl',
151
+ menubar: !props.cacherBarreMenu,
152
+ object_resizing: true,
153
+ paste_data_images: props.autoriserImage,
154
+ plugins: pluginsEffective.value,
155
+ promotion: false,
156
+ readonly: props.desactiver,
157
+ resize: !props.interdireRedimension,
158
+ resize_img_proportional: props.autoriserImage,
159
+ skin_url: 'default',
160
+ statusbar: props.cacherBarreOutils === false,
161
+ theme_advanced_resizing: true,
162
+ theme_advanced_resizing_use_cookie: false,
163
+ toolbar: toolbarEffective.value,
164
+ ...(props.autoriserImage ? { file_picker_types: 'image' } : {}),
165
+
166
+ setup: (editor: TinyMCEEditor) => {
167
+ _editor.value = editor
168
+
169
+ editor.on('init', () => {
170
+ // init ok
171
+ })
172
+
173
+ // liens cliquables
174
+ editor.on('click', (e: any) => {
175
+ const a = e.target?.closest?.('a')
176
+ if (!a) return
177
+ const href = a.getAttribute('href')
178
+ const target = a.getAttribute('target')
179
+ if (href) {
180
+ e.preventDefault()
181
+ openLink(href, target)
182
+ }
183
+ })
184
+
185
+ editor.on('keydown', (e: KeyboardEvent) => {
186
+ if (e.key !== 'Enter') return
187
+ const node = editor.selection?.getNode?.()
188
+ const a = (node as any)?.closest?.('a')
189
+ if (a) {
190
+ e.preventDefault()
191
+ openLink(a.getAttribute('href'), a.getAttribute('target'))
192
+ }
193
+ })
194
+
195
+ // Si images interdites
196
+ if (!props.autoriserImage) {
197
+ const removeImagesFromDom = () => {
198
+ const body = editor.getBody()
199
+ if (!body) return
200
+ body.querySelectorAll('img').forEach(img => img.remove())
201
+ }
202
+
203
+ // collage
204
+ editor.on('paste', (e: any) => {
205
+ const dt: DataTransfer | null = e.clipboardData || e.originalEvent?.clipboardData || null
206
+ if (!dt) return
207
+
208
+ const items = Array.from(dt.items || [])
209
+ const hasImage = items.some(item => item.kind === 'file' && item.type && item.type.startsWith('image/'))
210
+
211
+ if (hasImage) {
212
+ const text = dt.getData('text/plain')
213
+ if (!text) {
214
+ e.preventDefault()
215
+ return
216
+ }
217
+
218
+ e.preventDefault()
219
+ editor.insertContent(editor.dom.encode(text))
220
+ }
221
+
222
+ setTimeout(removeImagesFromDom, 0)
223
+ })
224
+
225
+ // drag & drop
226
+ editor.on('drop', (e: DragEvent) => {
227
+ const dt = e.dataTransfer
228
+ if (!dt) return
229
+ const hasImageFile = Array.from(dt.items || []).some(
230
+ i => i.kind === 'file' && i.type && i.type.startsWith('image/'),
231
+ )
232
+ if (hasImageFile) {
233
+ e.preventDefault()
234
+ return
235
+ }
236
+ setTimeout(removeImagesFromDom, 0)
237
+ })
238
+
239
+ editor.on('input', removeImagesFromDom)
240
+ editor.on('SetContent', removeImagesFromDom)
241
+ }
242
+ },
243
+ }
244
+
245
+ if (!props.autoriserImage) {
246
+ opts.paste_data_images = false
247
+ opts.invalid_elements = 'img'
248
+ opts.images_upload_handler = (_blobInfo: any, _success: any, failure: (msg: string) => void) => {
249
+ failure('Les images sont désactivées dans cet éditeur.')
250
+ }
251
+ }
252
+
253
+ if (props.autoriserImage) {
254
+ opts.file_picker_callback = (cb: (url: string, meta?: any) => void) => {
255
+ const input = document.createElement('input')
256
+ input.type = 'file'
257
+ input.accept = 'image/*'
258
+ input.onchange = () => {
259
+ const file = input.files?.[0]
260
+ if (!file) return
261
+
262
+ const reader = new FileReader()
263
+ reader.onload = () => {
264
+ const base64 = String(reader.result).split(',')[1]
265
+ const editor = _editor.value as any
266
+ const blobCache = editor?.editorUpload?.blobCache
267
+ if (!blobCache) return
268
+
269
+ const id = 'blobid' + Date.now()
270
+ const blobInfo = blobCache.create(id, file, base64)
271
+ const imageSize = blobInfo.blob().size / 1_000_000
272
+ if (imageSize > imageTailleMaxMo.value) {
273
+ alert('Fichier trop volumineux > ' + imageTailleMaxMo.value + ' Mo')
274
+ return
275
+ }
276
+ blobCache.add(blobInfo)
277
+ cb(blobInfo.blobUri(), { title: file.name })
278
+ }
279
+ reader.readAsDataURL(file)
280
+ }
281
+ input.click()
282
+ }
283
+ }
284
+
285
+ return opts
286
+ })
287
+
288
+ // --- v-model sync ---
289
+ watch(
290
+ () => props.modelValue,
291
+ v => {
292
+ if (v !== editorValue.value) {
293
+ editorValue.value = v
294
+ }
295
+ },
296
+ )
297
+
298
+ watch(
299
+ () => editorValue.value,
300
+ v => {
301
+ if (v !== props.modelValue) {
302
+ emit('update:modelValue', v)
303
+ }
304
+ },
305
+ )
306
+
307
+ // --- Re-montage TinyMCE si props importantes changent ---
308
+ const scheduleReinit = () => {
309
+ if (_reinitPending.value) return
310
+ _reinitPending.value = true
311
+ queueMicrotask(async () => {
312
+ _reinitPending.value = false
313
+ await reinitEditor()
314
+ })
315
+ }
316
+
317
+ const reinitEditor = async () => {
318
+ if (_reinitLock.value) return
319
+ _reinitLock.value = true
320
+ try {
321
+ const ed = _editor.value as any
322
+ if (ed && typeof ed.remove === 'function') {
323
+ try {
324
+ ed.remove()
325
+ } catch (e) {
326
+ console.warn('[Editeur] editor.remove erreur', e)
327
+ }
328
+ }
329
+ _editor.value = null
330
+ editorReady.value = false
331
+ await nextTick()
332
+ editorReady.value = true
333
+ await nextTick()
334
+ } finally {
335
+ _reinitLock.value = false
336
+ }
337
+ }
338
+
339
+ watch(
340
+ () => [
341
+ props.autoriserImage,
342
+ props.interdireRedimension,
343
+ props.toolbar,
344
+ props.imageTailleMaximale,
345
+ props.plugins,
346
+ props.cacherBarreOutils,
347
+ props.cacherBarreMenu,
348
+ ],
349
+ () => {
350
+ scheduleReinit()
351
+ },
352
+ { deep: true },
353
+ )
354
+
355
+ const onBlur = () => {
356
+ if (!props.desactiver) emit('blur')
357
+ }
358
+
359
+ const onUserActivity = () => {
360
+ // hook pour autosave / "user is typing" si besoin
361
+ }
362
+
363
+ const insererAuCurseur = (texte: string) => {
364
+ const ed = _editor.value
365
+ if (!ed) return
366
+ ed.focus()
367
+ ;(ed as any).insertContent(texte)
368
+ }
369
+
370
+ // (optionnel) expose si tu veux appeler `insererAuCurseur` depuis le parent
371
+ defineExpose({
372
+ insererAuCurseur,
373
+ })
374
+ </script>
375
+
376
+ <style scoped>
377
+ .editor a {
378
+ cursor: pointer !important;
379
+ }
380
+ </style>
@@ -0,0 +1,163 @@
1
+ <template>
2
+ <v-app-bar
3
+ :color="barreCouleur"
4
+ class="px-0 mx-0"
5
+ :style="{
6
+ position: 'sticky',
7
+ // variables CSS pour les couleurs dynamiques
8
+ '--entete-texte': texteCouleur,
9
+ '--entete-icone': iconeCouleur,
10
+ }"
11
+ height="82px"
12
+ >
13
+ <v-row
14
+ class="pt-2"
15
+ @resize="controlAffichage"
16
+ >
17
+ <v-col
18
+ :cols="titreCol"
19
+ class="pr-0 mr-0 pl-5"
20
+ >
21
+ <v-toolbar-title class="titre">
22
+ <!-- Barre de retour -->
23
+ <slot name="retour">
24
+ <v-icon
25
+ v-if="retour"
26
+ size="large"
27
+ start
28
+ :color="iconeCouleur"
29
+ icon="mdi-arrow-left-thin"
30
+ @click="retournerMenu"
31
+ />
32
+ </slot>
33
+
34
+ <div class="titre-bloc">
35
+ <!-- Titre -->
36
+ <slot name="titre">
37
+ <span class="pl-3 titre-texte">{{ props.titre }}</span>
38
+ </slot>
39
+
40
+ <!-- État -->
41
+ <slot name="etat">
42
+ <span
43
+ v-if="monEtat?.afficher"
44
+ class="pl-10"
45
+ >
46
+ <v-btn
47
+ size="small"
48
+ :color="monEtat.couleur"
49
+ variant="tonal"
50
+ >
51
+ {{ monEtat.texte }}
52
+ </v-btn>
53
+ </span>
54
+ </slot>
55
+
56
+ <!-- État secondaire -->
57
+ <slot name="etatSecondaire">
58
+ <span
59
+ v-if="monEtatSecondaire?.afficher"
60
+ class="pl-3"
61
+ >
62
+ <v-btn
63
+ size="small"
64
+ :color="monEtatSecondaire.couleur"
65
+ variant="tonal"
66
+ >
67
+ {{ monEtatSecondaire.texte }}
68
+ </v-btn>
69
+ </span>
70
+ </slot>
71
+
72
+ <!-- Sous-titre -->
73
+ <slot name="soustitre">
74
+ <span class="pl-3 soustitre-texte">{{ props.soustitre }}</span>
75
+ </slot>
76
+ </div>
77
+ </v-toolbar-title>
78
+ </v-col>
79
+ </v-row>
80
+
81
+ <!-- Barre en bas -->
82
+ <div style="position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background-color: #808a9d" />
83
+ </v-app-bar>
84
+ </template>
85
+
86
+ <script setup lang="ts">
87
+ import { useRouter } from 'vue-router'
88
+ import { ref, computed } from 'vue'
89
+
90
+ interface EnteteEtat {
91
+ afficher: boolean
92
+ couleur: string
93
+ texte: string
94
+ }
95
+
96
+ interface EnteteEtatSecondaire {
97
+ afficher: boolean
98
+ couleur: string
99
+ texte: string
100
+ }
101
+
102
+ const router = useRouter()
103
+
104
+ const props = defineProps<{
105
+ titre: string
106
+ soustitre?: string
107
+ retour?: string
108
+ etat?: EnteteEtat
109
+ couleur?: string // couleur de la barre (Vuetify color/hex)
110
+ couleurTexte?: string
111
+ couleurIcone?: string
112
+ etatSecondaire?: EnteteEtatSecondaire
113
+ }>()
114
+
115
+ const titreCol = ref(12)
116
+
117
+ // Fallbacks (tes valeurs actuelles)
118
+ const barreCouleur = computed(() => props.couleur ?? 'white')
119
+ const texteCouleur = computed(() => props.couleurTexte ?? '#223654')
120
+ const iconeCouleur = computed(() => props.couleurIcone ?? 'grisMoyen') // peut être un nom de couleur Vuetify ou un hex
121
+
122
+ const monEtat = computed<EnteteEtat>(() => props.etat ?? { afficher: false, couleur: 'primary', texte: 'test' })
123
+ const monEtatSecondaire = computed<EnteteEtatSecondaire>(
124
+ () => props.etatSecondaire ?? { afficher: false, couleur: 'primary', texte: 'test' },
125
+ )
126
+
127
+ function retournerMenu() {
128
+ if (props.retour) router.push({ name: props.retour })
129
+ }
130
+ function controlAffichage() {
131
+ /* logique resize */
132
+ }
133
+ </script>
134
+
135
+ <style scoped>
136
+ .titre {
137
+ font-size: 1.85rem;
138
+ font-weight: bold;
139
+ margin-bottom: 15px;
140
+ }
141
+ .titre-texte {
142
+ color: var(--entete-texte, #223654);
143
+ }
144
+ .soustitre-texte {
145
+ display: block;
146
+ font-size: 1rem;
147
+ font-weight: normal;
148
+ color: var(--entete-texte, #223654);
149
+ }
150
+ .titre-bloc {
151
+ display: inline-block;
152
+ vertical-align: middle;
153
+ padding-left: 12px;
154
+ }
155
+ /* Couleur de l’icône (retour) + hover */
156
+ .v-icon {
157
+ color: var(--entete-icone, #6b7280); /* grisMoyen approx si hex */
158
+ }
159
+ .v-icon:hover {
160
+ /* tu peux garder une couleur fixe ou calculer une teinte plus foncée si besoin */
161
+ filter: brightness(0.85);
162
+ }
163
+ </style>
@@ -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>