<template>
    <el-dialog :title="props.title" width="95%" v-model="dialoglsjl" @close="onClose">
        <el-table border :data="dataTable" style="width: 100%; margin-bottom: 10px" v-loading="tableLoading"
            :header-cell-style="{ background: '#F6F6F6' }" height="50vh">
            <el-table-column v-for="(item, index) in tableColumn" :prop="item.prop" :label="item.label" :key="index" />
            <el-table-column label="操作" width="170" fixed="right">
                <template #default='{ row }'>
                    <el-link type="primary" @click='seetable(row)'>详情 </el-link>
                </template>
            </el-table-column>
        </el-table>
    </el-dialog>
    <DialogTablegl :title="dialogTitle" @close="dialogVisibles = false" :sbcs="currCs" :orgCode="currId"
        :params="props.params" :orgObj="orgObj" v-if="dialogVisibles" />
</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 DialogTablegl from '../DialogTablegl.vue';
const orgObj = ref({});
const props = defineProps({
    title: {
        type: String,
        default: ''
    },
    params: {
        type: Object,
        default: () => { }
    },
    orgObj: Object,
});
const emits = defineEmits(["close"]);
const dialoglsjl = ref(true);
const dialogVisibles = ref(false);
const dialogTitle = ref('')
const currId = ref(null);
const currCs = ref(null)
const tableColumn = ref([
    { label: "上报次数", prop: "sbcs" },
    { label: "锅炉总数", prop: "count" },
    { label: "燃煤锅炉数量", prop: "countRm" },
    { label: "燃油锅炉数量", prop: "countRy" },
    { label: "燃气锅炉数量", prop: "countRq" },
    { label: "油气两用锅炉数量", prop: "countYq" },
    { label: "电锅炉数量", prop: "countDgl" },
    { label: "其他类型锅炉数量", prop: "countQt" },
    { label: "上报时间", prop: "gxTime" },
])
const dataTable = ref([])
const querySelect = reactive({
    year: props.params.year,
    half: props.params.half,
    orgcode: props.orgObj.orgcode
})
const tableLoading = ref(false);
onMounted(() => {
    getDataList();
});

// 获取表格数据
const getDataList = () => {
    tableLoading.value = true;
    getApi(querySelect, "/mosty-jcgl/data/epsemBoiler/getHistoryList").then((res) => {
        if (res) {
            dataTable.value = res;
        }
    }).finally(() => {
        tableLoading.value = false;
    });
};
function seetable(row) {

    orgObj.value.orgcode = row.orgcode
    orgObj.value.orgname = row.orgname
    currCs.value = row.sbcs
    dialogTitle.value = `特种设备-锅炉列表（${row.orgname}）`;
    dialogVisibles.value = true;
}
function dialogClose() {
    dialogVisibles.value = false;
}


// 关闭弹窗
const onClose = () => {
    emits('close')
};


</script>

<style lang="scss" scoped>
.content {
    .topper {
        display: flex;

        .sub-le {
            flex: 1;
            padding: 15px 15px 5px 15px;
            border-right: 1px solid #ebeef5;
        }
    }

    .bottom {
        padding: 0 15px 10px 15px;
    }
}
</style>
