<template>
    <EditorHome v-if="showEditor"></EditorHome>
</template>
<script lang="ts" setup>
import { inject, ref } from 'vue';
import EditorHome from './index.vue'
import { injectKeyTemplate } from "@/types/injectKey"
import { useSellTemplateStore, useScreenStore, useSlidesStore } from "@/store";
import { useRouter } from 'vue-router';
import ConfigService from '@/services/ConfigService';
import { ApiResult } from '@/configs/axios';

const router = useRouter()
const currentRoute = router.currentRoute.value
const params = currentRoute.params
const searchData = ref({} as any)
searchData.value = inject(injectKeyTemplate)

const showEditor = ref(false)
const initOpModify = async ()=>{
    const ConfigId = parseInt(params.configId.toString())
    try {
        const queryMsg = {ConfigId}
        const response = await ConfigService.triptemplateGetTripConfig(queryMsg);
        if (response.data.resultCode==ApiResult.SUCCESS && response.data.data) {
          let data = response.data.data
          if(data.TempId>0){
            useScreenStore().setIsModel(true)
            useScreenStore().setTempId(data.TempId)
            useScreenStore().setConfigId(ConfigId)
            useScreenStore().setModel(3)
            showEditor.value=true
            return
          }
        }
    } catch (error) { }
    const path = `/notfound`
    router.push({path})
}
initOpModify()
</script>