<template>
    <el-dialog title="上报历史" width="1400px" v-model="dialogVisible" @close="onClose">
        <el-table border :data="dataTable" style="width: 100%" v-loading="tableLoading"
            :header-cell-style="{ background: '#F6F6F6' }">
            <el-table-column :prop="item.prop" :label="item.label" v-for="(item, i) in tableColumn" :key="i">
                <template #default="{ row }" v-if="item.prop === 'total'">
                    {{ row.level1 * 1 + row.level2 * 1 }}
                </template>
            </el-table-column>
            <el-table-column align="center" label="操作" width="170">
                <template #default="{ row }">
                    <el-link type="primary" @click="onDetail(row)">查看</el-link>
                </template>
            </el-table-column>
        </el-table>
    </el-dialog>
    <DialogTable v-if="detailVisible" @close="detailVisible = false" :title="dialogTitle" :dict="props.dict"
        :item="item" :isEdit="false" />
</template>

<script setup>
import { onMounted, ref, reactive } from "vue"
import { getApi, postApi } from "@/api/tobAcco_api.js"
import * as MOSTY from "@/components/MyComponents/index"
import DialogTable from './DialogTable.vue'
import { ElMessage } from "element-plus"
const props = defineProps({
    item: Object,
    dict: Object
})
const emits = defineEmits(["close"]);
const dialogVisible = ref(true)
const detailVisible = ref(false)
const dialogTitle = ref("")
const item = ref({})
const dataTable = ref([])
const rowId = ref(null)
const query = ref({
    pageCurrent: 1,
    pageSize: 20,
})
const tableColumn = ref([
    { label: "企业名称", prop: "orgName" },
    { label: "上报次数", prop: "sbcs" },
    { label: "总数", prop: "total" },
    { label: "中度风险数量", prop: "level1" },
    { label: "高度风险数量", prop: "level2" },
    { label: "上报时间", prop: "gxTime" }
])
const tableLoading = ref(false)
const getDataList = () => {
    dataTable.value = []
    tableLoading.value = true
    postApi({ ...query.value, ...props.item }, "/mosty-jcgl/data/ops/getLsjlCountList").then(res => {
        if (res) {
            dataTable.value = res
            tableLoading.value = false
        }
    })
}
onMounted(() => {
    getDataList()
})
const onClose = () => {
    emits('close')
};
const onDetail = val => {
    detailVisible.value = true
    dialogTitle.value = `查看（${val.orgName}）`
    item.value.jtsj = Number(props.item.jtsj)
    item.value.year = Number(props.item.year)
    item.value.cs = val.sbcs
    item.value.orgcode = val.orgCode
}
</script>

<style lang="scss" scoped></style>