<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">
            </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>
    <DetailDialog  v-if="detailVisible" @close="detailVisible = false" :id="rowId" title="查看上报历史详情"/>
</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 DetailDialog from './dialog.vue'
import { ElMessage } from "element-plus"
const props = defineProps({
    item: Object,
})
const emits = defineEmits(["close"]);
const dialogVisible = ref(true)
const detailVisible = ref(false)
const dataTable = ref([])
const rowId = ref(null)
const query = ref({
    pageCurrent:1,
    pageSize:20,
})
const tableColumn = ref([
    { label: "企业名称", prop: "baOrgName" },
    { label: "上报次数", prop: "sbcs" },
    { label: "职业病确诊人数", prop: "occupationalDiseaseQty" },
    { label: "上报时间", prop: "gxTime" }
])
const tableLoading = ref(false)
const getDataList = () => {
    dataTable.value = []
    tableLoading.value = true
    postApi({...query.value,...props.item}, "/mosty-jcgl/data/occupational/getLsjlList").then(res => {
        if (res) {
            dataTable.value = res
            tableLoading.value = false
        }
    })
}
const onClose = () => {
  emits('close')
};
onMounted(() => {
    getDataList()
})
const onDetail = e => {
    detailVisible.value = true
    rowId.value = e.sourceId
}
</script>

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