<template>
    <div>
        <el-dialog v-model="dialogVisible" draggable :title="title" width="1000">
            <el-descriptions :column="2" border>
                <el-descriptions-item label="用户名称">
                    {{ list.userName }}
                </el-descriptions-item>
                <el-descriptions-item label="用户编号">
                    {{ list.userNumber }}
                </el-descriptions-item>
                <el-descriptions-item label="负责单位">
                    {{ list.dutyOrgName }}
                </el-descriptions-item>
                <el-descriptions-item label="稳态指标">
                    {{ list.steadyIndicator }}
                </el-descriptions-item>
                <el-descriptions-item label="暂态指标">
                    {{ list.transientIndicators }}
                </el-descriptions-item>
                <el-descriptions-item label="监测点名称">
                    {{ list.monitorName || '/' }}
                </el-descriptions-item>
                <el-descriptions-item label="是否实现监测">
                    <el-tag :type='list.detectionFlag == 0 ? "warning" : "primary"'>{{ list.detectionFlag == 0 ? "否" :
                        "是" }}</el-tag>




                </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.complaintText }}
                </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="1" label="处理成效报告">
                <el-icon class="elView " v-if="list?.reportName " >
                    <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 { useDictData } from '@/stores/dictData'
import { getFileNameAndFilePath } from '@/api/system-boot/file'
import {download} from '@/utils/fileDownLoad'
const dialogVisible = ref(false)
const title = ref('')
const dictData = useDictData()
const list: any = ref({})

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?' + name)
}

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