<template>
    <div class="app-container">
        <!-- 返回按钮 -->
        <div class="back-container">
            <el-button type="default" size="small" @click="handleBack" class="back-btn">
                返回
            </el-button>
        </div>
        <div class="layout-container">
            <el-row :gutter="18">
                <el-col :span="4" class="left-col">
                    <LeftType :value="activeCategory" @change="handleCategoryChange"
                        :enterpriseId="enterpriseId" />
                </el-col>
                <el-col :span="20" class="right-col">
                    <RightTable :value="activeCategory" :enterpriseId="enterpriseId" />
                </el-col>
            </el-row>
        </div>
    </div>
</template>

<script>
import LeftType from './components/LeftType.vue'
import RightTable from './components/RightTable.vue'
import { encryptWithSM4, decryptWithSM4 } from '@/utils/sm'

export default {
    name: 'Technical',
    components: {
        LeftType,
        RightTable
    },
    data() {
        return {
            activeCategory: this.$route.query.checkedCategory ? decryptWithSM4(this.$route.query.checkedCategory) : null,
            enterpriseId: decryptWithSM4(this.$route.query.enterpriseId),
        }
    },
    methods: {
        handleCategoryChange(categoryId) {
            this.activeCategory = categoryId
        },
        // 返回上一页
        handleBack() {
            const obj = {
                path: "/enterpriseKnowledge/index",
                query: {
                    enterpriseId: encryptWithSM4(this.enterpriseId || '0'),
                }
            }
            this.$tab.closeOpenPage(obj)
        },
    }
}
</script>

<style scoped lang="scss">
.app-container {
    width: 100%;
    height: calc(100vh - 84px);
    overflow: hidden;
    background: linear-gradient(180deg, #F1F6FF 20%, #E5EFFF 100%);
}

.back-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 0 0 20px;
    margin-bottom: 20px;

    .back-btn {
        width: 98px;
        height: 36px;
        background: #FFFFFF;
        box-shadow: 0px 4px 8px 0px rgba(76, 76, 76, 0.2);
        border-radius: 4px;
        border: none;
        color: #666;
        font-size: 14px;
        transition: all 0.3s ease;

        &:hover {
            background: #f5f5f5;
            color: #409EFF;
            box-shadow: 0px 6px 12px 0px rgba(76, 76, 76, 0.3);
        }
    }
}

.layout-container {
    display: flex;
    height: 100%;
    width: 100%;
    justify-content: space-around;
}

.left-col {
    height: calc(100vh - 120px);
    padding-left: 0 !important;
}

.right-col {
    height: calc(100vh - 120px);
    padding-right: 0 !important;
}

.el-row {
  width: 100%;
  height: 100%;
}
.el-col {
  height: 100%;
}
</style>