|
|
@@ -25,6 +25,7 @@ Sélecteur de dates
|
|
|
:dense="dense"
|
|
|
:single-line="singleLine"
|
|
|
v-on="on"
|
|
|
+ :error="error"
|
|
|
/>
|
|
|
</template>
|
|
|
<v-date-picker
|
|
|
@@ -42,6 +43,7 @@ Sélecteur de dates
|
|
|
import { defineComponent, watch, ref, useContext, onUnmounted, computed, Ref, ComputedRef } from '@nuxtjs/composition-api'
|
|
|
import { WatchStopHandle } from '@vue/composition-api'
|
|
|
import DatesUtils from '~/services/utils/datesUtils'
|
|
|
+import {$useError} from "~/use/form/useError";
|
|
|
|
|
|
export default defineComponent({
|
|
|
props: {
|
|
|
@@ -81,6 +83,7 @@ export default defineComponent({
|
|
|
const { data, field, range } = props
|
|
|
const { $moment } = useContext()
|
|
|
const dateUtils = new DatesUtils($moment)
|
|
|
+ const {error, onChange} = $useError(props.field, emit)
|
|
|
|
|
|
const datesParsed: Ref<Array<string>|string> = range ? ref(Array<string>()) : ref('')
|
|
|
|
|
|
@@ -99,7 +102,7 @@ export default defineComponent({
|
|
|
const unwatch: WatchStopHandle = watch(datesParsed, (newValue, oldValue) => {
|
|
|
if (newValue === oldValue) { return }
|
|
|
if (Array.isArray(newValue) && newValue.length < 2) { return }
|
|
|
- emit('update', Array.isArray(newValue) ? dateUtils.sortDate(newValue) : newValue, field)
|
|
|
+ onChange(Array.isArray(newValue) ? dateUtils.sortDate(newValue) : newValue)
|
|
|
})
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
@@ -110,7 +113,8 @@ export default defineComponent({
|
|
|
label_field: props.label ?? props.field,
|
|
|
datesParsed,
|
|
|
datesFormatted,
|
|
|
- dateOpen: ref(false)
|
|
|
+ dateOpen: ref(false),
|
|
|
+ error
|
|
|
}
|
|
|
}
|
|
|
})
|