<!-- 解析列表 -->
<template>
    <el-dialog v-model="dialogVisible" title="解析列表" width="70%" draggable @closed="close">
        <TableHeader date-picker></TableHeader>
        <Table ref="tableRef" />
    </el-dialog>
</template>
<script lang="ts" setup>
import { ref, onMounted, provide, watch, onBeforeUnmount } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import { ArrowLeft } from '@element-plus/icons-vue'
const emit = defineEmits(['back'])
const dialogVisible = ref(false)
const height = ref(0)
height.value = window.innerHeight < 1080 ? 230 : 450

const tableStore: any = new TableStore({
    url: '',
    publicHeight: height.value,
    column: [
        { width: '60', type: 'checkbox', fixed: 'left' },
        { title: '序号', type: 'seq', width: 80 },
        { field: 'projectName', title: '工程名称', minWidth: 170 },
        { field: 'allCount', title: '数据总数(条)', minWidth: 170 },
        { field: 'successCount', title: '已入库总数(条)', minWidth: 170 },
        { field: 'startTime', title: '起始时间', minWidth: 170 },
        { field: 'endTime', title: '结束时间', minWidth: 170 },
        {
            title: '解析状态',
            field: 'status',
            width: 100,
            render: 'tag',
            custom: {
                0: 'warning',
                1: 'success',
                2: 'danger',
                3: 'primary'
            },
            replaceValue: {
                0: '未解析',
                1: '解析成功',
                2: '解析失败',
                3: '文件不存在'
            }
            // formatter: row => {
            //     return row.cellValue == 1 ? '未注册' : row.cellValue == 2 ? '注册' : '接入'
            // },
        },
        {
            title: '操作',
            width: '180',
            render: 'buttons',
            buttons: [
                {
                    name: 'edit',
                    title: '详情',
                    type: 'primary',
                    icon: 'el-icon-EditPen',
                    render: 'basicButton',
                    click: row => {
                        console.log(row.portableOfflLogList)
                    }
                }
            ]
        }
    ],
    loadCallback: () => {
        tableStore.table.data = []
    }
})
provide('tableStore', tableStore)
//返回
const handleBack = () => {
    emit('back')
}
const open = (val: any) => {
    dialogVisible.value = true
    tableStore.table.data = val
    setTimeout(() => {
        tableStore.index()
    }, 10)
}
const close = () => {
    dialogVisible.value = false
}
const updateViewportHeight = async () => {
    // height.value = window.innerHeight;
    height.value = window.innerHeight < 1080 ? 230 : 450
    tableStore.table.publicHeight = height.value
    // await tableStore.index()
}

onMounted(() => {
    updateViewportHeight() // 初始化视口高度
    window.addEventListener('resize', updateViewportHeight) // 监听窗口大小变化
})

onBeforeUnmount(() => {
    window.removeEventListener('resize', updateViewportHeight) // 移除监听
})
defineExpose({ open })
</script>
<style lang="scss" scoped>
::v-deep .el-dialog_body {
    overflow-y: hidden !important;
    .analysisTable {
        height: 400px !important;
    }
}
</style>
