<template>
    <div class="hc-analysis-os-vue hc-flex-center h-full">
        <div class="body">
            <div class="title mb-50px text-center text-30px font-bold">分析处理工具</div>
            <div v-loading="isLoading" class="row hc-flex">
                <div class="col hc-flex-center h-394px w-300px" @click="toPageOs('1')">
                    <img :src="png1" class="mb-50px mt-10px w-50%" alt="">
                    <div class="text mt-34px text-24px font-bold">数据分析处理工具</div>
                </div>
                <div class="col hc-flex-center h-394px w-300px" @click="toPageOs('2')">
                    <img :src="png2" class="mb-50px mt-10px w-50%" alt="">
                    <div class="text mt-34px text-center text-24px font-bold"> 高速公路<br>投资效益分析工具</div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { useAppStore } from '~src/store'
import { getHomeRouter, setRouterData } from '~store/user'

//图片文件
import png1 from '~ass/images/xmjszhzx.png'
import png2 from '~ass/images/jgxt.png'
//import png3 from '~ass/images/xtglxt.png'

//初始化
const router = useRouter()
const store = useAppStore()

//渲染完成
onMounted(() => {
    store.setOsType('')
})

//跳转页面
const isLoading = ref(false)
const toPageOs = async (type) => {
    isLoading.value = true
    store.setOsType(type)
    //数据分析处理工具
    if (type === '1') {
        const routerRes = await setRouterData()
        if (routerRes.length <= 0) {
            window?.$message?.error('您还没有权限')
            return
        }
        await getHomeRouter()
        setTimeout(() => {
            isLoading.value = false
            router.push({ name: store.home })
        }, 1000)
    }
    //高速公路模型分析工具
    if (type === '2') {
       
        const routerRes = await setRouterData(2)
        if (routerRes.length <= 0) {
            window?.$message?.error('您还没有权限')
            isLoading.value = false
            return
        }
             isLoading.value = false
            router.push({ name: 'index2' })
    }
    isLoading.value = false
}
</script>

<style scoped lang="scss">
@import "~src/styles/view/os";
</style>
