codevdesign 0.0.92 → 0.0.94
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/csqcDate.vue +57 -56
- package/package.json +1 -1
package/composants/csqcDate.vue
CHANGED
|
@@ -1,56 +1,57 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<v-date-input
|
|
3
|
-
v-model="dateValeur"
|
|
4
|
-
v-bind="$attrs"
|
|
5
|
-
|
|
6
|
-
variant="outlined"
|
|
7
|
-
prepend-icon=""
|
|
8
|
-
prepend-inner-icon="$calendar"
|
|
9
|
-
density="comfortable"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<v-date-input
|
|
3
|
+
v-model="dateValeur"
|
|
4
|
+
v-bind="$attrs"
|
|
5
|
+
input-format="yyyy-MM-dd"
|
|
6
|
+
variant="outlined"
|
|
7
|
+
prepend-icon=""
|
|
8
|
+
prepend-inner-icon="$calendar"
|
|
9
|
+
density="comfortable"
|
|
10
|
+
@update:model-value="formatDate"
|
|
11
|
+
></v-date-input>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup lang="ts">
|
|
15
|
+
import { ref, watch } from 'vue'
|
|
16
|
+
import { VDateInput } from 'vuetify/labs/VDateInput'
|
|
17
|
+
|
|
18
|
+
const props = withDefaults(
|
|
19
|
+
defineProps<{
|
|
20
|
+
modelValue: string | Date | null
|
|
21
|
+
}>(),
|
|
22
|
+
{},
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const emit = defineEmits(['update:modelValue'])
|
|
26
|
+
const dateValeur = ref<Date | string | null>(props.modelValue)
|
|
27
|
+
|
|
28
|
+
const formatDate = (date: Date | string | null) => {
|
|
29
|
+
if (date == null) {
|
|
30
|
+
emit('update:modelValue', null)
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (typeof date === 'string') {
|
|
35
|
+
emit('update:modelValue', props.modelValue)
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//Transformer la date en string
|
|
40
|
+
const d = new Date(date)
|
|
41
|
+
const yyyy = d.getFullYear()
|
|
42
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0')
|
|
43
|
+
const dd = String(d.getDate()).padStart(2, '0')
|
|
44
|
+
const formatte = `${yyyy}-${mm}-${dd}`
|
|
45
|
+
dateValeur.value = formatte
|
|
46
|
+
|
|
47
|
+
emit('update:modelValue', dateValeur.value)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Synchronise les props externes avec l'état interne
|
|
51
|
+
watch(
|
|
52
|
+
() => props.modelValue,
|
|
53
|
+
nouvelle => {
|
|
54
|
+
dateValeur.value = nouvelle
|
|
55
|
+
},
|
|
56
|
+
)
|
|
57
|
+
</script>
|