<template>
    <div class="module-main">
        <div class="module-box">
            <div class="main-box">
                <div class="module-title">
                    可视化轨迹展示
                </div>
                <div class="patrol">
                    <div class="patrol-box">
                        <div v-for="(item,index) in imgs" :key="index" class="list">
                            <div class="top-img">
                                <img :src="item.img" alt="">
                            </div>

                            <div class="patrol-title line1">
                                {{item.title}}
                            </div>
                        </div>
                    </div>
                    <div class="echarts">
                        <dv-scroll-board v-if="flag" :config="config" style="width:100%;height:100%" />
                    </div>
                </div>

            </div>
        </div>
    </div>
</template>

<script>
import Vue from 'vue';
import Component from 'vue-class-component';
import echarts from '@/common/components/echarts.vue';
import api from '../../api';

@Component({
    props: {
        data: {
            type: Object,
            default: null,
        },
    },
    components: {
        echarts,
    },
})
export default class smodule8 extends Vue {
    imgs = [];

    flag = false;

    config = {
        header: ['地点', '时间', '人员', '内容'],
        data: [],
        rowNum: 4,
        // index: true,
        // columnWidth: [80],
        align: ['center', 'center', 'center', 'center', 'center', 'center', 'center', 'center'],
        headerBGC: 'rgba(17, 43, 117, 0.5)',
        oddRowBGC: 'rgba(17, 43, 117, 0.5)',
        evenRowBGC: 'rgba(9, 32, 99, 0.5)',
    }

    created() {
        this.getPatrolRecord();

        setInterval(() => {
            this.getPatrolRecord();
        }, 1000 * 60);
    }

    getPatrolRecord() {
        api.getPatrolRecord().then((res) => {
            this.imgs = res.data.imgs;
            this.flag = false;
            this.$nextTick(() => {
                this.flag = true;
                this.config.data = res.data.lists;
            });
        }).catch(() => {}).finally(() => {
            this.flag = true;
        });
    }
}
</script>
<style lang="css">
    .line1 {
        overflow: hidden;
        text-overflow: ellipsis;
        display: box;
        display: -webkit-box;
        line-clamp: 1;
        box-orient: vertical;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        word-break: break-all;
    }
</style>
<style scoped lang="scss">
    *{
        box-sizing:border-box;
        color: #fff;
    }
    .text-right{
        text-align: right;
    }
    .pull-right{
        float: right !important;
    }
    .module-title{
        position: relative;
        height: 40px;
        line-height: 40px;
        font-size: 16px;
    }
    .module-title::before{
        content: '';
        position: absolute;
        z-index: 1;
        height: 8px;
        width: 72px;
        top: 32px;
        left: 0;
        background-image: url(../../images/smodule/org-title.png);
        background-size: 100% 100%;
    }
    .main-box{
        width: 100%;
        height: 100%;
        padding: 10px;
        position: relative;
        padding-top: 0;
    }

    .module-select{
        width: 80px;
        height: 20px;
        color: #A6D6FF;
        background-color: #061A3B;
        outline: none;
        border: 1px solid #A6D6FF;
        float: right;
        vertical-align: middle;
        margin-top: 15px;
        margin-right: 5px;
    }

    .echarts{
        width: auto;
        height: calc(100% - 90px);
        margin-top: 10px;
    }

    .patrol{
        padding: 10px;
        width: auto;
        height: calc(100% - 40px);

        .patrol-box{
            height: 90px;
            overflow: hidden;
            .list{
                height: 90px;
                width: 30%;
                margin-left: 3%;
                overflow: hidden;
                text-align: center;
                float: left;

                .top-img{
                    width: 100%;
                    height: 70px;
                    overflow: hidden;
                    img{
                        width: 100%;
                        height: 100%;
                    }
                }

                .patrol-title{
                    height: 20px;
                    line-height: 20px;
                    font-size: 12px;
                    background-color: rgba(69, 117, 230, 0.2);
                }
            }

        }
        .patrol-box:first-child{
            margin-left: 0;
        }
    }
</style>
