<template>
    <div class="gasReportInspect">
        <customHeader>报表管理中心</customHeader>
        <div class="content">
            <div class="left-box">
                <!-- 左侧树菜单 -->
                <div class="card-toggle">
                    <div :class="gasType == 'gasDayNight' ? 'card-item1' : 'card-item'"
                        @click="handlerToggle('gasDayNight')">夜班</div>
                    <div :class="gasType == 'gasDayEarly' ? 'card-item1' : 'card-item'"
                        @click="handlerToggle('gasDayEarly')">早班</div>
                    <div :class="gasType == 'gasDayNoon' ? 'card-item1' : 'card-item'"
                        @click="handlerToggle('gasDayNoon')">中班</div>
                </div>
                <div v-if="listArr.length != 0" class="card-file">
                    <fileSystem :selected="selected" :list="listArr" :draggable="true" @on-click="onClick">
                        <template #icon="{ item }">
                            <template v-if="item.isFolder">
                                <SvgIcon v-if="item.isexpanded" size="18" name="file-open" />
                                <SvgIcon v-else size="18" name="file-close" />
                            </template>
                            <treeIcon class="iconfont" :title="item.title" v-else />
                        </template>
                    </fileSystem>
                </div>

            </div>
            <div class="right-box">
                <a-table :columns="columnsType" size="small" :data-source="tableData" :scroll="{ y: 700 }"
                    class="tableW" :pagination="pagination"></a-table>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref, nextTick, reactive, onMounted } from 'vue';
import customHeader from '/@/components/vent/customHeader.vue';
import fileSystem from './comment/common/cameraTree.vue';
import { SvgIcon } from '/@/components/Icon';
import treeIcon from './comment/common/Icon/treeIcon.vue';
import { columnsType, pagination } from './gasReportInspect.data';
import { queryReportData } from './gasReportInspect.api';


let gasType = ref('gasDayNight')
//左侧菜单列表
let listArr = reactive<any[]>([]);
//lxh 当前选中树节点
let selected = reactive<any>({
    id: null,
    pid: null,
    title: '',
    isFolder: false,
});
let tableData = ref<any[]>([])
let handlerToggle = (param) => {
    gasType.value = param
    pagination.current = 1
    getTreeList(gasType.value)
}
//获取左侧菜单树
async function getTreeList(param) {
    listArr.length = 0
    const res = await queryReportData({ type: param })
    console.log(res, '早中晚----------------')
    if (res) {
        listArr.push({
            id: res.id,
            pid: null,
            title: res.fileName,
            isFolder: true,
        })
        tableData.value = JSON.parse(res.content)
        // pagination.total = Math.ceil(tableData.value.length / pagination.pageSize)
    }

}
//点击目录
function onClick(node) {
    selected.id = node.id;
    selected.pid = node.pid;
    selected.title = node.title;
    selected.isFolder = node.isFolder;
    selected.ppid = node.ppid
};

onMounted(() => {
    getTreeList(gasType.value)
})
</script>

<style lang="less" scoped>
.gasReportInspect {
    width: 100%;
    height: 100%;
    padding: 80px 10px 15px 10px;
    box-sizing: border-box;
    position: relative;
    .content {
        width: 100%;
        height: calc(100% - 30px);
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
        position: relative;

        // z-index: 999;
        .left-box {
            width: 15%;
            height: 100%;
            padding: 20px;
            border: 1px solid #99e8ff66;
            background: #27546e1a;
            box-shadow: 0px 0px 20px 7px rgba(145, 233, 254, 0.7) inset;
            -moz-box-shadow: 0px 0px 20px 7px rgba(145, 233, 254, 0.7) inset;
            -webkit-box-shadow: 0px 0px 50px 1px rgb(149 235 255 / 5%) inset;
            overflow-y: auto;

            .card-toggle {
                height: 30px;
                display: flex;
                justify-content: space-between;
                align-items: center;
                margin-bottom: 10px;
                color: #fff;

                .card-item {
                    width: calc(33.3% - 5px);
                    height: 100%;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    background: #1a5b7f;
                    border-radius: 5px;
                    cursor: pointer;
                }

                .card-item1 {
                    width: calc(33.3% - 5px);
                    height: 100%;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    background: #5dd8f7;
                    border-radius: 5px;
                    cursor: pointer;
                }
            }

            .card-file {
                height: calc(100% - 40px);
                overflow-y: auto;
            }

            // lxh
            .iconfont {
                color: #fff;
                font-size: 12px;
                margin-left: 5px;
            }
        }

        .right-box {
            width: 85%;
            height: 100%;
            padding: 0px 0px 0px 15px;
            box-sizing: border-box;
        }
    }
}
</style>