<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>
    <DialogTableylrq :title="dialogTitle" @close="dialogVisibles = false" :sbcs="currCs" :orgObj="orgObj"
        :params="props.params" v-if="dialogVisibles" />
</template>

<script setup>
import { onMounted, ref, reactive, getCurrentInstance } from "vue";
import { Delete, Edit, Search, Share, Upload } from '@element-plus/icons-vue'
import { getApi, postApi } from "@/api/tobAcco_api.js";
import * as MOSTY from "@/components/MyComponents/index";
import DialogTableylrq from '../DialogTableylrq.vue';
import { getItem } from "@/utils/storage";
import { ElMessage } from "element-plus";
const orgObj = ref({});
const { proxy } = getCurrentInstance();
const { D_BZ_GLLX } = proxy.$dict("D_BZ_GLLX");
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 currCs = ref(null)
const tableColumn = ref([
    { label: "上报次数", prop: "sbcs" },
    { label: '企业名称', prop: 'orgname' },
    { label: "压力容器总数", prop: "count" },
    { label: "Ⅰ类压力容器数量", prop: "count1" },
    { label: "Ⅱ类压力容器数量", prop: "count2" },
    { label: "Ⅲ类压力容器数量", prop: "count3" },
    { 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/perves/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>
