<template>
    <div class="module-main">
        <div class="module-box">
            <div class="main-box">
                <div class="module-title">
                    三级品控
                    <span class="pull-right">
                        <div class="subname" :class="{cur:type ==3}" @click="timeClick(3)">集团巡检</div>
                        <div class="subname" :class="{cur:type ==2}" @click="timeClick(2)">区域抽检</div>
                        <div class="subname" :class="{cur:type ==1}" @click="timeClick(1)">项目自检</div>
                    </span>
                </div>
                <div class="echarts">
                    <dv-scroll-board v-if="flag" :config="config" style="width:100%;height:100%" />
                </div>
            </div>
        </div>
    </div>
</template>

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

@Component({
    props: {
        data: {
            type: Object,
            default: null,
        },
    },
    components: {
        echarts,
    },

})
export default class smodule87 extends Vue {
    flag = false;

    type = 1;

    timeInfo = {}

    config = {
        header: [],
        data: [],
        rowNum: 2,
        // index: true,
        columnWidth: [40],
        align: ['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() {
        Bus.$on('dateTypeInfo', this.getDateInfo);
        this.threeTypeList();
        setInterval(() => {
            this.threeTypeList();
        }, 1000 * 60 * 5);
    }

    threeTypeList() {
        const dd = {
            type: this.type,
            dateType: this.timeInfo ? this.timeInfo.type : 0,
            date: this.timeInfo ? this.timeInfo.date : '',
        };

        api.threeTypeList(dd).then((res) => {
            this.flag = false;
            this.$nextTick(() => {
                this.config.header = res.data.header;
                this.config.data = res.data.list;
                this.flag = true;
            });
        }).catch(() => {}).finally(() => {
            this.flag = true;
        });
    }

    timeClick(e) {
        if (e === 1) {
            this.type = 1;
        } else if (e === 2) {
            this.type = 2;
        } else {
            this.type = 3;
        }
        this.threeTypeList();
    }

    getDateInfo(e) {
        this.timeInfo = e;
        this.threeTypeList();
    }
}
</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;
    }

    .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: 10px;
        margin-right: 5px;
    }

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

    .pull-right .subname{
        height: 30px;
        line-height: 30px;
        margin-top: 5px;
        padding: 0 0.5vw;
        text-align: center;
        font-size: 12px;
        color: #B1CDEF;
        background: #002862;
        border-radius: 2px;
        border: 1px solid #1B68A9;
        display: inline-block;
        float: right;
        margin-right: 0.2vw;
        cursor: pointer;
    }
    .pull-right .cur{
        color: #fff !important;
        background-image: url(../../images/smodule/cur-bg.png) !important;
        background-repeat: no-repeat;
        background-size: 100% 100%;
    }

</style>
