<template>
    <div class="module-main">
        <div class="module-box">
            <div class="main-box">
                <div class="module-title">
                    任务数据总览
                    <select v-model="mode" class="module-select" @change="updateData">
                        <option value="1">报修</option>
                        <option value="2">保洁</option>
                        <option value="3">运送</option>
                        <option value="4">应急</option>
                        <option value="5">陪护</option>
                    </select>
                </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 api from '../../api';

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

    flag = false;

    config = {
        header: [],
        data: [],
        rowNum: 2,
        // index: true,
        // columnWidth: [80],
        align: ['center', 'center', 'center', 'center', 'center', 'center', 'center', 'center'],
        headerBGC: 'rgba(17, 43, 117, 2.5)',
        oddRowBGC: 'rgba(17, 43, 117, 0.5)',
        evenRowBGC: 'rgba(9, 32, 99, 0.5)',
    }

    created() {
        this.updateData();
    }

    updateData() {
        if (this.timer) { // 清除定时器
            clearInterval(this.timer);
        }
        this.getTaskList();
        this.timer = setInterval(() => {
            this.getTaskList();
        }, 1000 * 60 * 1);
    }

    getTaskList() {
        api.getTaskList({
            mode: this.mode,
        }).then((res) => {
            this.flag = false;
            this.$nextTick(() => {
                this.config.header = res.data.header;
                this.config.data = res.data.data;
                this.flag = true;
            });
        }).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% - 50px);
        margin-top: 10px;
    }

</style>
