codevdesign 0.0.47 → 0.0.49
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/README.md +117 -117
- package/composants/csqcAide.vue +2 -2
- package/composants/csqcAlerteErreur.vue +86 -86
- package/composants/csqcChaise/chaiseConteneur.vue +330 -330
- package/composants/csqcChaise/chaiseItem.vue +53 -53
- package/composants/csqcConfirmation.vue +74 -74
- package/composants/csqcDialogue.vue +3 -4
- package/composants/csqcEntete.vue +127 -127
- package/composants/csqcOptionSwitch.vue +2 -2
- package/composants/csqcRecherche.vue +5 -2
- package/composants/csqcSnackbar.vue +1 -2
- package/composants/csqcTable/csqcTable.vue +2 -2
- package/composants/csqcTable/csqcTableExportExcel.vue +4 -4
- package/composants/csqcTexteBilingue.vue +13 -13
- package/composants/csqcTiroir.vue +1 -2
- package/composants/gabarit/csqcMenu.vue +7 -5
- package/composants/gabarit/pivEntete.vue +9 -6
- package/composants/gabarit/pivPiedPage.vue +70 -70
- package/composants/validateurs.ts +183 -181
- package/index.ts +68 -68
- package/modeles/apiReponse.ts +12 -12
- package/modeles/composants/datatableColonne.ts +14 -14
- package/modeles/composants/snackbar.ts +18 -18
- package/modeles/data.ts +24 -24
- package/modeles/droitIntervention.ts +14 -14
- package/modeles/groupeCE.ts +23 -23
- package/modeles/groupeCEIntervalle.ts +24 -24
- package/modeles/intervention.ts +35 -35
- package/modeles/notificationGabaritDefaut.ts +10 -10
- package/modeles/response.ts +12 -12
- package/modeles/role.ts +31 -31
- package/modeles/roleMin.ts +12 -12
- package/modeles/unite.ts +41 -41
- package/modeles/utilisateur.ts +32 -32
- package/package.json +1 -1
|
@@ -1,330 +1,330 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="pa-2 mt-2 mb-1 mr-1">
|
|
3
|
-
<!--on affiche une div avec les infos de préférences si le user a déjà au moins une préférence, au moins une unité et si activerDiv est à true.-->
|
|
4
|
-
<div v-if="preferences && unites && unites.length > 0 && activerDivPreferences">
|
|
5
|
-
<v-card
|
|
6
|
-
width="375"
|
|
7
|
-
outlined
|
|
8
|
-
>
|
|
9
|
-
<v-card-text
|
|
10
|
-
flat
|
|
11
|
-
class="pt-0 mt-0"
|
|
12
|
-
>
|
|
13
|
-
<v-progress-linear
|
|
14
|
-
v-if="chargementEnCours"
|
|
15
|
-
indeterminate
|
|
16
|
-
/>
|
|
17
|
-
<div
|
|
18
|
-
v-if="!chargementEnCours"
|
|
19
|
-
class="pt-2"
|
|
20
|
-
>
|
|
21
|
-
<div class="text-overline text-h6 mb-2">{{ texteTitre }}</div>
|
|
22
|
-
<!-- <div v-if="existePreference == false">
|
|
23
|
-
Cliquer sur modifier ou lors de la soumission, vous pourrez sélectionner vos préférences de suivi.
|
|
24
|
-
</div>-->
|
|
25
|
-
<div>
|
|
26
|
-
<v-list-item
|
|
27
|
-
v-for="uniteId in Object.keys(dictChaisesReleve).map(Number)"
|
|
28
|
-
:key="uniteId"
|
|
29
|
-
class="mb-1"
|
|
30
|
-
>
|
|
31
|
-
<chaiseItem
|
|
32
|
-
:uniteId="uniteId"
|
|
33
|
-
:preferences="preferences"
|
|
34
|
-
:dictChaisesReleve="dictChaisesReleve"
|
|
35
|
-
:unites="unites"
|
|
36
|
-
/>
|
|
37
|
-
</v-list-item>
|
|
38
|
-
</div>
|
|
39
|
-
</div>
|
|
40
|
-
</v-card-text>
|
|
41
|
-
<v-card-actions>
|
|
42
|
-
<div class="flex-grow-1"></div>
|
|
43
|
-
<v-btn
|
|
44
|
-
v-if="chargementEnCours == false"
|
|
45
|
-
rounded
|
|
46
|
-
outlined
|
|
47
|
-
small
|
|
48
|
-
@click.stop="modifier"
|
|
49
|
-
>{{ $t('csqc.bouton.modifier') }}</v-btn
|
|
50
|
-
>
|
|
51
|
-
</v-card-actions>
|
|
52
|
-
</v-card>
|
|
53
|
-
</div>
|
|
54
|
-
|
|
55
|
-
<v-dialog
|
|
56
|
-
max-width="largeur"
|
|
57
|
-
:fullscreen="display.name.value == 'xs'"
|
|
58
|
-
v-model="visible"
|
|
59
|
-
@click:outside="annuler"
|
|
60
|
-
@keydown.esc="annuler"
|
|
61
|
-
>
|
|
62
|
-
<v-card :class="['pa-0', display.name.value != 'xs' ? 'v-card-color-solid' : 'v-card-color-solid-xs']">
|
|
63
|
-
<v-container :class="display.name.value == 'xs' ? 'pl-1 pr-3' : ''">
|
|
64
|
-
<h3 class="pb-3 pl-2">{{ texteTitre }}</h3>
|
|
65
|
-
<hr class="pl-2" />
|
|
66
|
-
<v-card-text flat>
|
|
67
|
-
<i>{{ info }}</i>
|
|
68
|
-
<v-progress-linear
|
|
69
|
-
v-if="chargementEnCours"
|
|
70
|
-
indeterminate
|
|
71
|
-
/>
|
|
72
|
-
<div
|
|
73
|
-
v-if="!chargementEnCours"
|
|
74
|
-
class="pt-4"
|
|
75
|
-
>
|
|
76
|
-
<v-row v-if="toutesUnitesPreferencesSelectionnees === false">
|
|
77
|
-
<v-col cols="12">
|
|
78
|
-
<v-alert
|
|
79
|
-
dismissible
|
|
80
|
-
v-model="afficherErreur"
|
|
81
|
-
type="error"
|
|
82
|
-
>{{ $t('csqc.message.chaiseSelectionToutes') }}</v-alert
|
|
83
|
-
>
|
|
84
|
-
</v-col>
|
|
85
|
-
</v-row>
|
|
86
|
-
<v-row>
|
|
87
|
-
<v-col
|
|
88
|
-
cols="12"
|
|
89
|
-
sm="4"
|
|
90
|
-
md="3"
|
|
91
|
-
v-for="uniteId in Object.keys(dictChaisesReleve).map(Number)"
|
|
92
|
-
:key="uniteId"
|
|
93
|
-
>
|
|
94
|
-
<label>{{ getUnite(uniteId)?.nom || '' }}</label>
|
|
95
|
-
<br />
|
|
96
|
-
<v-radio-group v-model="selection[uniteId]">
|
|
97
|
-
<v-radio
|
|
98
|
-
v-for="chaise in dictChaisesReleve[uniteId]"
|
|
99
|
-
:key="chaise.id"
|
|
100
|
-
:label="chaise.nom"
|
|
101
|
-
:value="chaise.id"
|
|
102
|
-
></v-radio>
|
|
103
|
-
</v-radio-group>
|
|
104
|
-
</v-col>
|
|
105
|
-
</v-row>
|
|
106
|
-
</div>
|
|
107
|
-
</v-card-text>
|
|
108
|
-
</v-container>
|
|
109
|
-
|
|
110
|
-
<v-card-actions>
|
|
111
|
-
<div class="flex-grow-1"></div>
|
|
112
|
-
<v-btn
|
|
113
|
-
color="primary"
|
|
114
|
-
outlined
|
|
115
|
-
@click.stop="annuler"
|
|
116
|
-
>Annuler</v-btn
|
|
117
|
-
>
|
|
118
|
-
<v-btn
|
|
119
|
-
color="primary"
|
|
120
|
-
@click.stop="ok"
|
|
121
|
-
>Ok</v-btn
|
|
122
|
-
>
|
|
123
|
-
</v-card-actions>
|
|
124
|
-
</v-card>
|
|
125
|
-
</v-dialog>
|
|
126
|
-
</div>
|
|
127
|
-
</template>
|
|
128
|
-
|
|
129
|
-
<script lang="ts" setup>
|
|
130
|
-
import { ref, computed,
|
|
131
|
-
import axios from '@/outils/appAxios.ts'
|
|
132
|
-
import chaiseItem from './chaiseItem.vue'
|
|
133
|
-
import { useDisplay } from 'vuetify'
|
|
134
|
-
const display = useDisplay()
|
|
135
|
-
|
|
136
|
-
// Définition des props
|
|
137
|
-
const props = defineProps<{
|
|
138
|
-
activerDivPreferences: boolean
|
|
139
|
-
typeintervenant: string
|
|
140
|
-
demandeid: string
|
|
141
|
-
formulaireid: string
|
|
142
|
-
urlbase: string
|
|
143
|
-
titre?: string
|
|
144
|
-
texteinfo?: string
|
|
145
|
-
largeur?: number
|
|
146
|
-
}>()
|
|
147
|
-
|
|
148
|
-
// Définition des emits
|
|
149
|
-
const emit = defineEmits<{
|
|
150
|
-
(event: 'annuler'): void
|
|
151
|
-
(event: 'confirmer'): void
|
|
152
|
-
}>()
|
|
153
|
-
|
|
154
|
-
// Variables réactives
|
|
155
|
-
const visible = ref(false)
|
|
156
|
-
const chargementEnCours = ref(false)
|
|
157
|
-
const afficherErreur = ref(false)
|
|
158
|
-
const unites = ref<Array<{ id: number; nom: string }>>([])
|
|
159
|
-
const preferences = ref<Array<{ uniteId: number; chaiseId: number }>>([])
|
|
160
|
-
const dictChaisesReleve = ref<Record<number, Array<{ id: number; nom: string }>>>({})
|
|
161
|
-
const selection = ref<Record<number, number>>({})
|
|
162
|
-
const modeModifier = ref(false)
|
|
163
|
-
|
|
164
|
-
// Méthodes
|
|
165
|
-
const soumettre = async () => {
|
|
166
|
-
modeModifier.value = false
|
|
167
|
-
await ouvrir()
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const ouvrir = async () => {
|
|
171
|
-
// Mode sans les divs
|
|
172
|
-
if (props.activerDivPreferences === false) {
|
|
173
|
-
await chargementPreferences()
|
|
174
|
-
visible.value = true
|
|
175
|
-
return
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Mode avec div, mais il manque une sélection
|
|
179
|
-
if (!toutesUnitesPreferencesSelectionnees.value) {
|
|
180
|
-
visible.value = true
|
|
181
|
-
return
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Tout est beau
|
|
185
|
-
await ok()
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const definitionSelectionDepart = () => {
|
|
189
|
-
for (let uniteId in dictChaisesReleve.value) {
|
|
190
|
-
const chaises = dictChaisesReleve.value[uniteId]
|
|
191
|
-
const uniteIdNum = Number(uniteId) // Convert to number
|
|
192
|
-
|
|
193
|
-
const pref = preferences.value.find(
|
|
194
|
-
pref => pref.uniteId === uniteIdNum && chaises.some(chaise => chaise.id === pref.chaiseId),
|
|
195
|
-
)
|
|
196
|
-
|
|
197
|
-
const chaiseIdDefaut = pref?.chaiseId ?? (chaises.length === 1 ? chaises[0].id : -1)
|
|
198
|
-
selection.value[uniteIdNum] = chaiseIdDefaut // Ensure key consistency
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
const estPrefere = (uniteId: number, chaiseId: number) => {
|
|
202
|
-
return preferences.value.some(x => x.uniteId === uniteId && x.chaiseId === chaiseId)
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
const annuler = () => {
|
|
206
|
-
visible.value = false
|
|
207
|
-
modeModifier.value = false
|
|
208
|
-
emit('annuler')
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const getUnite = (uniteId: number) => {
|
|
212
|
-
return unites.value.find(x => x.id === uniteId)
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const modifier = () => {
|
|
216
|
-
modeModifier.value = true
|
|
217
|
-
visible.value = true
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const ok = async () => {
|
|
221
|
-
await sauvegarder()
|
|
222
|
-
if (toutesUnitesPreferencesSelectionnees.value) {
|
|
223
|
-
if (!modeModifier.value) {
|
|
224
|
-
emit('confirmer')
|
|
225
|
-
}
|
|
226
|
-
visible.value = false
|
|
227
|
-
modeModifier.value = false
|
|
228
|
-
} else {
|
|
229
|
-
afficherErreur.value = true
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
const sauvegarder = async () => {
|
|
234
|
-
for (let uniteId in dictChaisesReleve.value) {
|
|
235
|
-
const chaiseId = selection.value[uniteId]
|
|
236
|
-
if (chaiseId <= 0) {
|
|
237
|
-
continue
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// Cibler l'ancienne préférence reliée à une des chaises de cette unité
|
|
241
|
-
let prefIndexDeUnite = -1
|
|
242
|
-
for (let i = 0; i < dictChaisesReleve.value[uniteId].length; i++) {
|
|
243
|
-
prefIndexDeUnite = preferences.value.findIndex(p => p.chaiseId === dictChaisesReleve.value[uniteId][i].id)
|
|
244
|
-
if (prefIndexDeUnite >= 0) {
|
|
245
|
-
break
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
try {
|
|
250
|
-
const response = await axios
|
|
251
|
-
.getAxios()
|
|
252
|
-
.put(
|
|
253
|
-
`${props.urlbase}/api/ComposantUI/Preferences/${props.formulaireid}/Unite/${uniteId}/Chaise/${chaiseId}/TypeIntervenant/${props.typeintervenant}`,
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
const itemRecu = response.data // Extract the actual data
|
|
257
|
-
|
|
258
|
-
// Écraser l'ancienne sélection
|
|
259
|
-
if (prefIndexDeUnite >= 0) {
|
|
260
|
-
preferences.value[prefIndexDeUnite] = itemRecu
|
|
261
|
-
} else {
|
|
262
|
-
preferences.value = [itemRecu]
|
|
263
|
-
}
|
|
264
|
-
} catch (e) {
|
|
265
|
-
console.error(e)
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
const chargementPreferences = async () => {
|
|
271
|
-
chargementEnCours.value = true
|
|
272
|
-
// Ramasse les infos des chaises par unité
|
|
273
|
-
dictChaisesReleve.value = await axios
|
|
274
|
-
.getAxios()
|
|
275
|
-
.get(`${props.urlbase}/api/ComposantUI/ReleveDe/${props.typeintervenant}/Demande/${props.demandeid}`)
|
|
276
|
-
|
|
277
|
-
// Ramasse les préférences de l'usager
|
|
278
|
-
preferences.value = await axios
|
|
279
|
-
.getAxios()
|
|
280
|
-
.get(
|
|
281
|
-
`${props.urlbase}/api/ComposantUI/Preferences/${props.formulaireid}/TypeIntervenant/${props.typeintervenant}`,
|
|
282
|
-
)
|
|
283
|
-
definitionSelectionDepart()
|
|
284
|
-
|
|
285
|
-
await sauvegarder() // Immédiatement on sauvegarde pour les choix uniques.
|
|
286
|
-
|
|
287
|
-
chargementEnCours.value = false
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const texteTitre = computed(() => {
|
|
291
|
-
return props.titre || ''
|
|
292
|
-
})
|
|
293
|
-
|
|
294
|
-
const info = computed(() => {
|
|
295
|
-
return props.texteinfo || ''
|
|
296
|
-
})
|
|
297
|
-
|
|
298
|
-
const existePreference = computed(() => {
|
|
299
|
-
for (let uniteId in dictChaisesReleve.value) {
|
|
300
|
-
for (let i = 0; i < dictChaisesReleve.value[uniteId].length; i++) {
|
|
301
|
-
if (preferences.value.some(p => p.chaiseId === dictChaisesReleve.value[uniteId][i].id)) {
|
|
302
|
-
return true
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
return false
|
|
307
|
-
})
|
|
308
|
-
|
|
309
|
-
const toutesUnitesPreferencesSelectionnees = computed(() => {
|
|
310
|
-
for (let uniteId in dictChaisesReleve.value) {
|
|
311
|
-
let uniteOk = false
|
|
312
|
-
for (let i = 0; i < dictChaisesReleve.value[uniteId].length; i++) {
|
|
313
|
-
if (preferences.value.some(p => p.chaiseId === dictChaisesReleve.value[uniteId][i].id)) {
|
|
314
|
-
uniteOk = true
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
if (!uniteOk) return false
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
return true // Toutes les unités ont été sélectionnées
|
|
322
|
-
})
|
|
323
|
-
|
|
324
|
-
onMounted(async () => {
|
|
325
|
-
chargementEnCours.value = true
|
|
326
|
-
// Ramasse les unités de l'usager
|
|
327
|
-
unites.value = await axios.getAxios().get(`${props.urlbase}/api/ComposantUI/Unites`)
|
|
328
|
-
chargementPreferences()
|
|
329
|
-
})
|
|
330
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="pa-2 mt-2 mb-1 mr-1">
|
|
3
|
+
<!--on affiche une div avec les infos de préférences si le user a déjà au moins une préférence, au moins une unité et si activerDiv est à true.-->
|
|
4
|
+
<div v-if="preferences && unites && unites.length > 0 && activerDivPreferences">
|
|
5
|
+
<v-card
|
|
6
|
+
width="375"
|
|
7
|
+
outlined
|
|
8
|
+
>
|
|
9
|
+
<v-card-text
|
|
10
|
+
flat
|
|
11
|
+
class="pt-0 mt-0"
|
|
12
|
+
>
|
|
13
|
+
<v-progress-linear
|
|
14
|
+
v-if="chargementEnCours"
|
|
15
|
+
indeterminate
|
|
16
|
+
/>
|
|
17
|
+
<div
|
|
18
|
+
v-if="!chargementEnCours"
|
|
19
|
+
class="pt-2"
|
|
20
|
+
>
|
|
21
|
+
<div class="text-overline text-h6 mb-2">{{ texteTitre }}</div>
|
|
22
|
+
<!-- <div v-if="existePreference == false">
|
|
23
|
+
Cliquer sur modifier ou lors de la soumission, vous pourrez sélectionner vos préférences de suivi.
|
|
24
|
+
</div>-->
|
|
25
|
+
<div>
|
|
26
|
+
<v-list-item
|
|
27
|
+
v-for="uniteId in Object.keys(dictChaisesReleve).map(Number)"
|
|
28
|
+
:key="uniteId"
|
|
29
|
+
class="mb-1"
|
|
30
|
+
>
|
|
31
|
+
<chaiseItem
|
|
32
|
+
:uniteId="uniteId"
|
|
33
|
+
:preferences="preferences"
|
|
34
|
+
:dictChaisesReleve="dictChaisesReleve"
|
|
35
|
+
:unites="unites"
|
|
36
|
+
/>
|
|
37
|
+
</v-list-item>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</v-card-text>
|
|
41
|
+
<v-card-actions>
|
|
42
|
+
<div class="flex-grow-1"></div>
|
|
43
|
+
<v-btn
|
|
44
|
+
v-if="chargementEnCours == false"
|
|
45
|
+
rounded
|
|
46
|
+
outlined
|
|
47
|
+
small
|
|
48
|
+
@click.stop="modifier"
|
|
49
|
+
>{{ $t('csqc.bouton.modifier') }}</v-btn
|
|
50
|
+
>
|
|
51
|
+
</v-card-actions>
|
|
52
|
+
</v-card>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<v-dialog
|
|
56
|
+
max-width="largeur"
|
|
57
|
+
:fullscreen="display.name.value == 'xs'"
|
|
58
|
+
v-model="visible"
|
|
59
|
+
@click:outside="annuler"
|
|
60
|
+
@keydown.esc="annuler"
|
|
61
|
+
>
|
|
62
|
+
<v-card :class="['pa-0', display.name.value != 'xs' ? 'v-card-color-solid' : 'v-card-color-solid-xs']">
|
|
63
|
+
<v-container :class="display.name.value == 'xs' ? 'pl-1 pr-3' : ''">
|
|
64
|
+
<h3 class="pb-3 pl-2">{{ texteTitre }}</h3>
|
|
65
|
+
<hr class="pl-2" />
|
|
66
|
+
<v-card-text flat>
|
|
67
|
+
<i>{{ info }}</i>
|
|
68
|
+
<v-progress-linear
|
|
69
|
+
v-if="chargementEnCours"
|
|
70
|
+
indeterminate
|
|
71
|
+
/>
|
|
72
|
+
<div
|
|
73
|
+
v-if="!chargementEnCours"
|
|
74
|
+
class="pt-4"
|
|
75
|
+
>
|
|
76
|
+
<v-row v-if="toutesUnitesPreferencesSelectionnees === false">
|
|
77
|
+
<v-col cols="12">
|
|
78
|
+
<v-alert
|
|
79
|
+
dismissible
|
|
80
|
+
v-model="afficherErreur"
|
|
81
|
+
type="error"
|
|
82
|
+
>{{ $t('csqc.message.chaiseSelectionToutes') }}</v-alert
|
|
83
|
+
>
|
|
84
|
+
</v-col>
|
|
85
|
+
</v-row>
|
|
86
|
+
<v-row>
|
|
87
|
+
<v-col
|
|
88
|
+
cols="12"
|
|
89
|
+
sm="4"
|
|
90
|
+
md="3"
|
|
91
|
+
v-for="uniteId in Object.keys(dictChaisesReleve).map(Number)"
|
|
92
|
+
:key="uniteId"
|
|
93
|
+
>
|
|
94
|
+
<label>{{ getUnite(uniteId)?.nom || '' }}</label>
|
|
95
|
+
<br />
|
|
96
|
+
<v-radio-group v-model="selection[uniteId]">
|
|
97
|
+
<v-radio
|
|
98
|
+
v-for="chaise in dictChaisesReleve[uniteId]"
|
|
99
|
+
:key="chaise.id"
|
|
100
|
+
:label="chaise.nom"
|
|
101
|
+
:value="chaise.id"
|
|
102
|
+
></v-radio>
|
|
103
|
+
</v-radio-group>
|
|
104
|
+
</v-col>
|
|
105
|
+
</v-row>
|
|
106
|
+
</div>
|
|
107
|
+
</v-card-text>
|
|
108
|
+
</v-container>
|
|
109
|
+
|
|
110
|
+
<v-card-actions>
|
|
111
|
+
<div class="flex-grow-1"></div>
|
|
112
|
+
<v-btn
|
|
113
|
+
color="primary"
|
|
114
|
+
outlined
|
|
115
|
+
@click.stop="annuler"
|
|
116
|
+
>Annuler</v-btn
|
|
117
|
+
>
|
|
118
|
+
<v-btn
|
|
119
|
+
color="primary"
|
|
120
|
+
@click.stop="ok"
|
|
121
|
+
>Ok</v-btn
|
|
122
|
+
>
|
|
123
|
+
</v-card-actions>
|
|
124
|
+
</v-card>
|
|
125
|
+
</v-dialog>
|
|
126
|
+
</div>
|
|
127
|
+
</template>
|
|
128
|
+
|
|
129
|
+
<script lang="ts" setup>
|
|
130
|
+
import { ref, computed, onMounted } from 'vue'
|
|
131
|
+
import axios from '@/outils/appAxios.ts'
|
|
132
|
+
import chaiseItem from './chaiseItem.vue'
|
|
133
|
+
import { useDisplay } from 'vuetify'
|
|
134
|
+
const display = useDisplay()
|
|
135
|
+
|
|
136
|
+
// Définition des props
|
|
137
|
+
const props = defineProps<{
|
|
138
|
+
activerDivPreferences: boolean
|
|
139
|
+
typeintervenant: string
|
|
140
|
+
demandeid: string
|
|
141
|
+
formulaireid: string
|
|
142
|
+
urlbase: string
|
|
143
|
+
titre?: string
|
|
144
|
+
texteinfo?: string
|
|
145
|
+
largeur?: number
|
|
146
|
+
}>()
|
|
147
|
+
|
|
148
|
+
// Définition des emits
|
|
149
|
+
const emit = defineEmits<{
|
|
150
|
+
(event: 'annuler'): void
|
|
151
|
+
(event: 'confirmer'): void
|
|
152
|
+
}>()
|
|
153
|
+
|
|
154
|
+
// Variables réactives
|
|
155
|
+
const visible = ref(false)
|
|
156
|
+
const chargementEnCours = ref(false)
|
|
157
|
+
const afficherErreur = ref(false)
|
|
158
|
+
const unites = ref<Array<{ id: number; nom: string }>>([])
|
|
159
|
+
const preferences = ref<Array<{ uniteId: number; chaiseId: number }>>([])
|
|
160
|
+
const dictChaisesReleve = ref<Record<number, Array<{ id: number; nom: string }>>>({})
|
|
161
|
+
const selection = ref<Record<number, number>>({})
|
|
162
|
+
const modeModifier = ref(false)
|
|
163
|
+
|
|
164
|
+
// Méthodes
|
|
165
|
+
const soumettre = async () => {
|
|
166
|
+
modeModifier.value = false
|
|
167
|
+
await ouvrir()
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const ouvrir = async () => {
|
|
171
|
+
// Mode sans les divs
|
|
172
|
+
if (props.activerDivPreferences === false) {
|
|
173
|
+
await chargementPreferences()
|
|
174
|
+
visible.value = true
|
|
175
|
+
return
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Mode avec div, mais il manque une sélection
|
|
179
|
+
if (!toutesUnitesPreferencesSelectionnees.value) {
|
|
180
|
+
visible.value = true
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Tout est beau
|
|
185
|
+
await ok()
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const definitionSelectionDepart = () => {
|
|
189
|
+
for (let uniteId in dictChaisesReleve.value) {
|
|
190
|
+
const chaises = dictChaisesReleve.value[uniteId]
|
|
191
|
+
const uniteIdNum = Number(uniteId) // Convert to number
|
|
192
|
+
|
|
193
|
+
const pref = preferences.value.find(
|
|
194
|
+
pref => pref.uniteId === uniteIdNum && chaises.some(chaise => chaise.id === pref.chaiseId),
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
const chaiseIdDefaut = pref?.chaiseId ?? (chaises.length === 1 ? chaises[0].id : -1)
|
|
198
|
+
selection.value[uniteIdNum] = chaiseIdDefaut // Ensure key consistency
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const estPrefere = (uniteId: number, chaiseId: number) => {
|
|
202
|
+
return preferences.value.some(x => x.uniteId === uniteId && x.chaiseId === chaiseId)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const annuler = () => {
|
|
206
|
+
visible.value = false
|
|
207
|
+
modeModifier.value = false
|
|
208
|
+
emit('annuler')
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const getUnite = (uniteId: number) => {
|
|
212
|
+
return unites.value.find(x => x.id === uniteId)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const modifier = () => {
|
|
216
|
+
modeModifier.value = true
|
|
217
|
+
visible.value = true
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const ok = async () => {
|
|
221
|
+
await sauvegarder()
|
|
222
|
+
if (toutesUnitesPreferencesSelectionnees.value) {
|
|
223
|
+
if (!modeModifier.value) {
|
|
224
|
+
emit('confirmer')
|
|
225
|
+
}
|
|
226
|
+
visible.value = false
|
|
227
|
+
modeModifier.value = false
|
|
228
|
+
} else {
|
|
229
|
+
afficherErreur.value = true
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const sauvegarder = async () => {
|
|
234
|
+
for (let uniteId in dictChaisesReleve.value) {
|
|
235
|
+
const chaiseId = selection.value[uniteId]
|
|
236
|
+
if (chaiseId <= 0) {
|
|
237
|
+
continue
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Cibler l'ancienne préférence reliée à une des chaises de cette unité
|
|
241
|
+
let prefIndexDeUnite = -1
|
|
242
|
+
for (let i = 0; i < dictChaisesReleve.value[uniteId].length; i++) {
|
|
243
|
+
prefIndexDeUnite = preferences.value.findIndex(p => p.chaiseId === dictChaisesReleve.value[uniteId][i].id)
|
|
244
|
+
if (prefIndexDeUnite >= 0) {
|
|
245
|
+
break
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
try {
|
|
250
|
+
const response = await axios
|
|
251
|
+
.getAxios()
|
|
252
|
+
.put(
|
|
253
|
+
`${props.urlbase}/api/ComposantUI/Preferences/${props.formulaireid}/Unite/${uniteId}/Chaise/${chaiseId}/TypeIntervenant/${props.typeintervenant}`,
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
const itemRecu = response.data // Extract the actual data
|
|
257
|
+
|
|
258
|
+
// Écraser l'ancienne sélection
|
|
259
|
+
if (prefIndexDeUnite >= 0) {
|
|
260
|
+
preferences.value[prefIndexDeUnite] = itemRecu
|
|
261
|
+
} else {
|
|
262
|
+
preferences.value = [itemRecu]
|
|
263
|
+
}
|
|
264
|
+
} catch (e) {
|
|
265
|
+
console.error(e)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const chargementPreferences = async () => {
|
|
271
|
+
chargementEnCours.value = true
|
|
272
|
+
// Ramasse les infos des chaises par unité
|
|
273
|
+
dictChaisesReleve.value = await axios
|
|
274
|
+
.getAxios()
|
|
275
|
+
.get(`${props.urlbase}/api/ComposantUI/ReleveDe/${props.typeintervenant}/Demande/${props.demandeid}`)
|
|
276
|
+
|
|
277
|
+
// Ramasse les préférences de l'usager
|
|
278
|
+
preferences.value = await axios
|
|
279
|
+
.getAxios()
|
|
280
|
+
.get(
|
|
281
|
+
`${props.urlbase}/api/ComposantUI/Preferences/${props.formulaireid}/TypeIntervenant/${props.typeintervenant}`,
|
|
282
|
+
)
|
|
283
|
+
definitionSelectionDepart()
|
|
284
|
+
|
|
285
|
+
await sauvegarder() // Immédiatement on sauvegarde pour les choix uniques.
|
|
286
|
+
|
|
287
|
+
chargementEnCours.value = false
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const texteTitre = computed(() => {
|
|
291
|
+
return props.titre || ''
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
const info = computed(() => {
|
|
295
|
+
return props.texteinfo || ''
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
const existePreference = computed(() => {
|
|
299
|
+
for (let uniteId in dictChaisesReleve.value) {
|
|
300
|
+
for (let i = 0; i < dictChaisesReleve.value[uniteId].length; i++) {
|
|
301
|
+
if (preferences.value.some(p => p.chaiseId === dictChaisesReleve.value[uniteId][i].id)) {
|
|
302
|
+
return true
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return false
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
const toutesUnitesPreferencesSelectionnees = computed(() => {
|
|
310
|
+
for (let uniteId in dictChaisesReleve.value) {
|
|
311
|
+
let uniteOk = false
|
|
312
|
+
for (let i = 0; i < dictChaisesReleve.value[uniteId].length; i++) {
|
|
313
|
+
if (preferences.value.some(p => p.chaiseId === dictChaisesReleve.value[uniteId][i].id)) {
|
|
314
|
+
uniteOk = true
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (!uniteOk) return false
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return true // Toutes les unités ont été sélectionnées
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
onMounted(async () => {
|
|
325
|
+
chargementEnCours.value = true
|
|
326
|
+
// Ramasse les unités de l'usager
|
|
327
|
+
unites.value = await axios.getAxios().get(`${props.urlbase}/api/ComposantUI/Unites`)
|
|
328
|
+
chargementPreferences()
|
|
329
|
+
})
|
|
330
|
+
</script>
|