<template>
    <div>
        <el-dialog v-model="dialogVisible" draggable :title="title" width="1000">
            <el-descriptions :column="2" border>
                <el-descriptions-item label="监测点名称">
                    {{ list.lineName }}
                </el-descriptions-item>
                <el-descriptions-item label="接入母线">
                    {{ list.connectedBus }}
                </el-descriptions-item>
                <el-descriptions-item label="终端名称">
                    {{ list.monitoringTerminalName }}
                </el-descriptions-item>
                <el-descriptions-item label="变电站">
                    {{ list.powerSubstationName ||'/'}}
                </el-descriptions-item>
                <el-descriptions-item label="调试原因">
                    {{ list.reason }}
                </el-descriptions-item>

                <el-descriptions-item label="试运行状态">
                    <el-tag
                        :type='list.testRunState == 0 ? "primary" : list.testRunState == 1 ? "warning" : list.testRunState == 2 ? "success" : list.testRunState == 3 ? "danger" : "primary"'>{{
                            list.testRunState == 0 ? "待试运行" : list.testRunState == 1 ? "试运行中" : list.testRunState == 2
                                ? "试运行成功" : list.testRunState == 3 ? "试运行失败" : "待试运行" }}</el-tag>




                </el-descriptions-item>
                <el-descriptions-item label="试运行时间范围">
                    {{ list.testRunTime ||'/' }}
                </el-descriptions-item>
                <el-descriptions-item label="试运行评估问题">
                    {{ list.problemReason ||'/' }}
                </el-descriptions-item>
                <el-descriptions-item label="填报人">
                    {{ dictData.state.userList.filter(item => item.id == list.createBy)[0]?.name }}
                </el-descriptions-item>
                <el-descriptions-item label="整改意见">
                    {{ list.reformAdvice }}
                </el-descriptions-item>
                <el-descriptions-item label="采取的措施">
                    {{ list.takeStep }}
                </el-descriptions-item>
                <el-descriptions-item :span="2" label="处理成效报告">
                    <el-icon class="elView " v-if="list?.reportName && VITE_FLAG">
                        <View @click="openFile(list?.reportPath)" />
                    </el-icon>
                    <a class="aLoad" @click="download(list.keyName)" target="_blank">{{ list.reportName }}</a>
                </el-descriptions-item>


            </el-descriptions>

        </el-dialog>
    </div>
</template>
<script setup lang='ts'>
import { ref, reactive } from 'vue'
import { View } from '@element-plus/icons-vue'
import { getFileNameAndFilePath } from '@/api/system-boot/file'
import { useDictData } from '@/stores/dictData'
import {download} from '@/utils/fileDownLoad'
const dialogVisible = ref(false)
const title = ref('')
const list: any = ref({})
const dictData = useDictData()
const VITE_FLAG = import.meta.env.VITE_NAME == 'jibei'
const open = (row: any) => {
    list.value = {}
    title.value = row.title
    dialogVisible.value = true
    list.value = JSON.parse(JSON.stringify(row.row))
    getFileNameAndFilePath({ filePath: row.row.reportPath }).then(res => {
        list.value.keyName = res.data.name
        list.value.reportPath = res.data.url
        list.value.reportName = res.data.fileName
    })
}
const openFile = (name: any) => {
    window.open(window.location.origin + '/#/previewFile?/supervision/' + name)
}

defineExpose({ open })
</script>
<style lang="scss" scoped>
.elView {
    cursor: pointer;
    margin-right: 10px;
}
</style>
