<template>
    <div class="mainContainer">
        <div class="lt">
            <div class="cube">
                <Region :region-list="regionList"></Region>
            </div>
            <br>
            <div class="cube">
                <Detecter :region-list="regionList"></Detecter>
            </div>
            <br>
            <div class="cube">
                <Task></Task>
            </div>
        </div>
        <div class="md">
            <div class="cube">
                <signMap></signMap>
            </div>
            <br>
            <div class="cube">
                <WifiSign :wifi-rs="WifiRs"></WifiSign>
            </div>
            <br>
            <Scan :scan-rs="ScanRs"></Scan>
        </div>
        <div class="rt">
            <div class="cube">
                <BigRader :total-rs="totalRs"></BigRader>
            </div>
            <br>
            <transition name="el-zoom-in-center">
                <div class="cube">
                    <HistoryRecord :history-rs="historyRs"></HistoryRecord>
                </div>
            </transition>
            <transition name="el-zoom-in-center">
                <div class="cube">
                    <HistoryRecord :history-rs="historyRs"></HistoryRecord>
                </div>
            </transition>
        </div>
    </div>
</template>

<script>
    import signMap from '@/components/signMap.vue'
    import Region from '@/components/Region.vue'
    import Detecter from '@/components/Detecter.vue'
    import Task from '@/components/Task.vue'
    import WifiSign from '@/components/WifiSign.vue'
    import Scan from '@/components/Scan.vue'
    import HistoryRecord from '@/components/HistoryRecord.vue'
    import EquipInfo from '@/components/EquipInfo.vue'
    import runTimeRecord from '@/components/runTimeRecord.vue'
    import BigRader from '@/components/BigRader.vue'
    import {
        getLoftInfo,
        RegionDetInfolist,
    } from '../api/getApiRes.js'

    let qs = require('qs');
    export default {
        data() {
            return {
                WifiRs: [],
                ScanRs: [],
                historyRs: [],
                totalRs: [],
                equipRs: [],
                regionList: [],
            }
        },
        mounted() {
            this.init()
        },
        watch: {
            '$route': function (val) {
                if (val.path == '/') {
                    this.init()
                }
            },
        },
        methods: {
            init() {
                this.getDate()
            },
            getDate() {
                let that = this;
                let param = {
                    token: localStorage.token,
                };
                let postdata = qs.stringify(param);
                that.regionList = [];
                getLoftInfo(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        console.log(json);
                        that.regionList = json.Rs
                    } else {
                        that.$message.error(json.Memo);
                    }
                })
            },
            // Wifi柱状图信息传入探测器Id
            getDetectorWifixyInfolist(postdata) {
                let that = this;
                DetectorWifixyInfolist(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        that.WifiRs = json;
                    } else {
                        that.$message.error(json.Memo + '，错误代码：' + json.Code);
                    }
                })
            },
            ClickGetInfo(index) {

            }
        },
        components: {
            signMap,
            Region,
            Detecter,
            WifiSign,
            Scan,
            HistoryRecord,
            EquipInfo,
            runTimeRecord,
            Task,
            BigRader,
        }
    }
</script>

<style scoped>
    @import "../assets/css/cube.css";

    .mainContainer {
        width: 100%;
        overflow: hidden;
        display: block;
        margin: 0 auto;
    }

    .mainContainer .lt {
        width: 20%;
        float: left;
    }

    .mainContainer .md {
        width: 50%;
        float: left;
    }

    .mainContainer .rt {
        width: 30%;
        float: right;
    }
    .rt .cube {
        float: right;
    }

</style>
