|
@@ -20,12 +20,13 @@
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
import type { PropType } from '@vue/runtime-core'
|
|
import type { PropType } from '@vue/runtime-core'
|
|
|
-import type { RouteLocationRaw } from '@intlify/vue-router-bridge'
|
|
|
|
|
import ApiModel from '~/models/ApiModel'
|
|
import ApiModel from '~/models/ApiModel'
|
|
|
import type { AnyJson } from '~/types/data'
|
|
import type { AnyJson } from '~/types/data'
|
|
|
import { SUBMIT_TYPE } from '~/types/enum/enums'
|
|
import { SUBMIT_TYPE } from '~/types/enum/enums'
|
|
|
import { useRoute } from 'vue-router'
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
+import type { RouteLocationRaw} from 'vue-router'
|
|
|
import { useEntityFetch } from '~/composables/data/useEntityFetch'
|
|
import { useEntityFetch } from '~/composables/data/useEntityFetch'
|
|
|
|
|
+import type {AsyncData} from "#app";
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
/**
|
|
/**
|
|
@@ -40,7 +41,7 @@ const props = defineProps({
|
|
|
* Si non renseigné, le component essaiera de l'extraire de la route actuelle
|
|
* Si non renseigné, le component essaiera de l'extraire de la route actuelle
|
|
|
*/
|
|
*/
|
|
|
id: {
|
|
id: {
|
|
|
- type: Number,
|
|
|
|
|
|
|
+ type: Number as PropType<number | null>,
|
|
|
required: false,
|
|
required: false,
|
|
|
default: null,
|
|
default: null,
|
|
|
},
|
|
},
|
|
@@ -48,7 +49,7 @@ const props = defineProps({
|
|
|
* Route de retour
|
|
* Route de retour
|
|
|
*/
|
|
*/
|
|
|
goBackRoute: {
|
|
goBackRoute: {
|
|
|
- type: Object as PropType<RouteLocationRaw>,
|
|
|
|
|
|
|
+ type: Object as PropType<RouteLocationRaw | null>,
|
|
|
required: false,
|
|
required: false,
|
|
|
default: null,
|
|
default: null,
|
|
|
},
|
|
},
|
|
@@ -77,7 +78,7 @@ const router = useRouter()
|
|
|
const entityId =
|
|
const entityId =
|
|
|
props.id !== null ? props.id : parseInt(route.params.id as string)
|
|
props.id !== null ? props.id : parseInt(route.params.id as string)
|
|
|
|
|
|
|
|
-const { data: entity, pending } = fetch(props.model, entityId)
|
|
|
|
|
|
|
+const { data: entity, pending } = fetch(props.model, entityId) as AsyncData<ApiModel, Error | null>
|
|
|
|
|
|
|
|
const submitActions = computed(() => {
|
|
const submitActions = computed(() => {
|
|
|
let actions: AnyJson = {}
|
|
let actions: AnyJson = {}
|