<template>
    <div class="default-main">
        <el-tabs v-model="activeName" type="border-card">
            <!-- <el-tab-pane label="概览" name="1"><overview v-if="activeName == '1'"/></el-tab-pane>
      <el-tab-pane label="技术监督管理" name="2"><technology  v-if="activeName == '2'"/></el-tab-pane> -->

            <el-tab-pane label="预警单列表" name="3" v-if="tabList.includes('3')">
                <earlyWarn :id="id" :businessKey="key" v-if="activeName == '3'" />
            </el-tab-pane>
            <el-tab-pane label="告警单列表" name="4" v-if="tabList.includes('4')">
                <alarm :id="id" :businessKey="key" v-if="activeName == '4'" />
            </el-tab-pane>
        </el-tabs>
    </div>
</template>

<script setup lang="ts">
import earlyWarn from './components/earlyWarn.vue'
import alarm from './components/alarm.vue'
import { ref } from 'vue'
import { useRoute } from 'vue-router'
import { mainHeight } from '@/utils/layout'
const route = useRoute()
const id = ref('')
const key = ref('')
// defineOptions({
//     name: 'supervision/supervision/manage'
// })
const tabList = ref(['3', '4'])
const activeName: any = ref('3')
onMounted(() => {

    let key = window.location.href.split('?')[0].slice(-1)
    const isNumber = /^\d$/.test(key)
    if (isNumber) {
      
        tabList.value = [key]
        activeName.value = key
    }
})

watch(
    () => route.query.t,
    async (newValue, oldValue) => {
        if (route.fullPath.includes('supervision/supervision/manage')) {
            let type = (route.query.type as string) || 'null'
            if (type == 'null') {
            } else if (type == '0' || type == '3') {
                activeName.value = '3'
            } else {
                activeName.value = '4'
            }
            id.value = (route.query.id as string) || 'null'
            key.value = (route.query.key as string) || 'null'
            id.value = id.value + '@' + route.query.t
        }
    },
    { deep: true, immediate: true }
)

const layout = mainHeight(63) as any
</script>

<style lang="scss" scoped>
.bars_w {
    width: 100%;
    height: 500px;
}

:deep(.el-tabs__content) {
    height: v-bind('layout.height');
    overflow-y: auto;
}
</style>
