<template>
    <!-- 设备设施 -->
    <div id='equipment'>
        <div class='eq-top'>
            <span class='eq-system' v-for='(item,index) in system' :class='item.id==systemId?"isActive":""' :key='index' @click='tabSyatem(item)'>
                <img :src='item.id==systemId?item.icon1:item.icon' />
                {{item.name}}
            </span>
        </div>
        <div class='eq-bottom'>
            <div class='eq-left'>
                <ul v-for='(eve,index) in everySystem' :key='"o"+index'>
                    <li class='li-style' :class='{"is-active": eve.id}' @click='dialogVisible(eve)'>
                        <span class='circle'></span>
                        <span class='hanzi'>{{eve.label}}</span>
                    </li>
                </ul>
            </div>
            <div class='eq-right'>
                <div class='eq-right-bottom'>
                    <div class='title-box'>
                        <div class='eq-title'>
                            <span>{{floorInfo.code}}</span>
                        </div>
                    </div>
                    <div class='eq-content'>
                        <div class='legend-boxs'>
                            <Legend :systemName='systemName' :floors='floorsArr' type='1' :editTips='`编辑${floorInfo.code}层${systemName}平面图`'></Legend>
                        </div>
                        <floorMap ref='floorMap' :id='"equip"' :loadName='loadName' :type='"system"'></floorMap>
                        <!--  -->
                        <div class='additional-box' v-if='fqPic.length>0'>
                            <div class='additional' @click='additionalColl'>
                                <img src='../../assets/imgs/bg.png' alt />
                            </div>
                            <el-collapse-transition>
                                <div v-if='show' class='add-img'>
                                    <img :src='fqPic[0].url' alt />
                                </div>
                            </el-collapse-transition>
                        </div>
                    </div>
                    <floor-list v-if='floorsArr.length>0' :floorsArr='floorsArr' @emitFloor='emitFloor' id='system'></floor-list>
                </div>
            </div>
        </div>
        <eq-dialog ref='dialog' :systemName='systemName' :smsxt='smsxt' @emitCount='emitCount'></eq-dialog>
    </div>
</template>

<script>
import floorList from '@/components/floorList.vue'
import floorMap from '@/components/floorMap/index.vue'
import eqDialog from './eqDialog'
import editList from '@/components/edit.vue'
import { system } from '@/utils/plugins/components.js'
import { queryPic, queryBrand } from '@/api/public.js'
import { mapGetters } from 'vuex'

export default {
    data() {
        return {
            system,
            everySystem: [],
            systemId: 1,
            categoryId: 'GDXT',
            systemName: '供电系统',
            floorInfo: {
                gname: 'f1',
                code: 'F1'
            },
            smsxt: '1001',
            dialogInfo: {},
            brand: [], //品牌
            manufacturer: [],
            show: true,
            fqPic: [],
            loadName: '',
            type: '',
            objCount: []
        }
    },
    components: { floorList, eqDialog, floorMap, editList },
    methods: {
        query() {
            let data = {
                plazaId: '1000423'
            }
            let postParams = []
            queryBrand({ data, postParams }).then(res => {
                console.log(res)
            })
        },
        // 查询tab页
        tabSyatem(item) {
            this.systemId = item.id
            this.everySystem = item.children
            this.systemName = item.name
            this.smsxt = item.smsxt
            this.$cookie.set('categoryId', item.categoryId, 3)
            this.$refs.floorMap.init(this.floorInfo.gname)
            this.querySmsxt()
        },
        querySmsxt() {
            // 目前消防和弱电下面有特殊的数据表格
            if (this.smsxt == '1003' || this.smsxt == '1004') {
                this.queryTable(this.smsxt)
            }
        },
        //判断有没有原理图，如果没有则不出现系统原理图列表li
        emitCount(objCount) {
            this.objCount = objCount
        },
        emitFloor(item) {
            this.floorInfo = item
            this.$refs.floorMap.init(this.floorInfo.gname)
            this.init()
            this.querySmsxt()
        },
        dialogVisible(eve) {
            this.$refs.dialog.showModal(eve)
        },
        additionalColl() {
            this.show = !this.show
        },
        // 查询附加数据图片
        queryTable(system) {
            this.fqPic = []
            let picFloor = this.$cookie.get('floorNow')
            let getParams = {
                module: '1003',
                floor: picFloor,
                system: system,
                plazaId: this.plazaId
            }
            queryPic({ getParams }).then(res => {
                console.log('附加数据', res)
                this.fqPic = res.data
                console.log(this.fqPic)
            })
        },
        init() {
            this.loadName = `设备设施-${this.systemName}-${this.floorInfo.code}`
        },
        // 从设备设施进入的机房
        queryType(val) {
            this.type = val
        }
    },
    mounted() {
        if (this.$route.query.smsxt) {
            this.smsxt = this.$route.query.smsxt
            this.system.forEach(el => {
                if (el.smsxt == this.smsxt) {
                    this.everySystem = el.children
                    this.systemName = el.name
                    this.systemId = el.id
                }
            })
        }
        this.everySystem = this.system[0].children
        this.init()
        this.$refs.floorMap.init(this.floorInfo.gname)
        this.query()
    },
    computed: {
        ...mapGetters(['floorsArr', 'plazaId'])
    }
}
</script>
<style lang="less" scoped>
#equipment {
    background: rgba(242, 245, 247, 1);
    display: flex;
    flex: 1;
    overflow: hidden;
    color: #1f2429;
    .eq-top {
        margin-left: 260px;
        padding-top: 24px;
        position: fixed;
        z-index: 3;
        min-width: 1300px;
        .eq-system {
            padding: 12px 20px;
            background: #fff;
            font-size: 16px;
            cursor: pointer;
            img {
                width: 16px;
                height: 16px;
                margin-right: 4px;
                margin-bottom: 3px;
            }
        }
        .isActive {
            color: #025baa;
            font-weight: bolder;
            background: linear-gradient(360deg, rgba(2, 91, 170, 0.1) 0%, rgba(2, 91, 170, 0) 100%);
        }
    }
    .eq-bottom {
        display: flex;
        flex: 1;
        .eq-left {
            position: fixed;
            z-index: 2;
            width: 260px;
            padding-top: 100px;
            color: #646c73;
            font-size: 14px;
            height: 100%;
            background: rgba(242, 245, 247, 1);
        }
        .li-style {
            margin-left: 28px;
            // padding: 9px 6px;
            cursor: pointer;
            .circle {
                width: 6px;
                height: 6px;
                background: linear-gradient(180deg, rgba(54, 156, 247, 0.6) 0%, rgba(2, 91, 170, 0.6) 100%);
                border-radius: 50%;
                display: inline-block;
                margin-right: 10px;
            }
            .hanzi {
                padding: 10px 0 10px 6px;
                width: 200px;
                display: inline-block;
                &:hover {
                    color: rgba(2, 91, 170, 1);
                    background: linear-gradient(270deg, rgba(199, 217, 234, 0) 0%, rgba(199, 217, 234, 1) 100%);
                }
            }
        }

        .eq-right {
            flex: 1;
            .eq-right-bottom {
                display: flex;
                flex: 1;
                height: 100%;
                .title-box {
                    position: fixed;
                    z-index: 2;
                    top: 146px;
                    left: 260px;
                    display: flex;
                    img {
                        margin-top: -5px;
                    }
                    .eq-title {
                        width: 140px;
                        height: 32px;
                        background: linear-gradient(270deg, rgba(199, 217, 234, 0) 0%, rgba(199, 217, 234, 1) 100%);
                        box-shadow: -6px 2px 8px 0px rgba(31, 36, 41, 0.1);
                        color: #025baa;
                        font-size: 16px;
                        &::before {
                            width: 2px;
                            height: 16px;
                            background: rgba(2, 91, 170, 1);
                            display: inline-block;
                            content: '';
                            margin-right: 10px;
                            margin-top: 8px;
                        }
                    }
                }
                .eq-content {
                    flex: 1;
                    .legend-boxs {
                        position: fixed;
                        z-index: 9;
                        right: 32px;
                        top: 160px;
                    }
                    .additional-box {
                        position: relative;
                        .additional {
                            width: 44px;
                            height: 44px;
                            background: rgba(255, 255, 255, 1);
                            box-shadow: 0px 2px 15px 0px rgba(31, 36, 41, 0.08);
                            border-radius: 2px;
                            position: fixed;
                            right: 32px;
                            top: 471px;
                            z-index: 2;
                            display: flex;
                            justify-content: center;
                            align-items: center;
                            cursor: pointer;
                            img {
                                width: 20px;
                                height: 20px;
                            }
                        }
                        .add-img {
                            width: 560px;
                            height: 325px;
                            background: #ffffff;
                            -webkit-box-shadow: 0px 2px 8px 0px rgba(31, 36, 41, 0.06);
                            box-shadow: 0px 2px 8px 0px rgba(31, 36, 41, 0.06);
                            border-radius: 2px;
                            border: 1px solid #e4e5e7;
                            position: absolute;
                            right: 77px;
                            bottom: 421px;
                            z-index: 2;
                            img {
                                width: 100%;
                                height: 100%;
                            }
                        }
                    }
                }
            }
        }
    }
}
</style>
<style lang="less">
.el-table {
    th {
        background: rgba(248, 249, 250, 1);
        font-size: 12px;
        padding: 8px 0;
        color: #646a73;
    }
    td {
        font-size: 14px;
        color: #1f2429;
        padding: 8px 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}
</style>
