<template>
    <div class="sidebar">
        <div style="padding: 10px">
            <el-button
                size="small"
                type="default"
                icon="el-icon-plus"

            />
            <el-button
                size="small"
                type="default"
                icon="el-icon-minus"

            />
            <el-button
                size="small"
                type="default"
                icon="el-icon-edit-outline"

            />
        </div>
            <h4>建筑</h4>

        <div class="build-list">
            <div
                v-if="content.length"
                v-for="(item,index) in content"
                :key="item.BuildID"
                :class="{'floor-item':true,active:currentIndex  === index}"
                @click="changeBuild(index)"

            >
            <span>
            {{item.BuildLocalName || item.BuildName}}
            <el-badge
                v-if="item.Count > 0"
                class="mark"
                :value="item.Count"
            />
            </span>
            </div>
        </div>
        <addBuild
            :title="buildTitle"
            ref="addBuildDialog"
        />
    </div>

</template>

<script>
    import addBuild from "./addBuild";

    export default {
        name: "sidebar",
        props: ['content'],
        data() {
            return {
                currentIndex: 0,
                buildTitle: "添加建筑",

            }
        },
        components: {addBuild},
        created() {
            console.log(this.content)
        },
        methods: {
            changeBuild(index) {
                this.currentIndex = index
                this.$emit('currentBuild', index)
            }
        }
    }
</script>

<style scoped lang="less">
    .sidebar {
        h4 {
            padding-left: 10px;
            border-top: 1px solid #d9d9d9;
            border-bottom: 1px solid #d9d9d9;
            background: #d9d9d9;
            color: #2b2b2b;
            line-height: 44px;
        }
        .floor-item {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;

            span {
                margin-left: 10px;
            }
        }

        .build-list {
            line-height: 48px;

            .floor-item {
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;

                span {
                    margin-left: 10px;
                }
            }

            .floor-item.active,
            .floor-item:hover {
                background-color: #f5f7fa;
                color: #000;
            }
        }

    }
</style>
