<template>
    <div>
        <el-form :inline="true" class="demo-form-inline">
            <el-form-item label="终端厂家:">
                <el-select v-model="manufacturer" placeholder="请选择终端厂家">
                    <el-option
                        v-for="item in manufacturerData"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id"
                    ></el-option>
                </el-select>
            </el-form-item>

            <el-form-item>
                <Timeinterval @time="time"></Timeinterval>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" class="ml10" icon="el-icon-search" @click="researchFn">查询</el-button>
                <!-- <el-button type="primary" icon="el-icon-refresh" @click="Reset">重置</el-button> -->
            </el-form-item>
        </el-form>

        <el-row>
            <el-col :span="24">
                <el-table
                    stripe
                    :data="typeclassificationData.slice((currentPage - 1) * pageSize, currentPage * pageSize)"
                    :height="height"
                    border
                    style="width: 100%"
                    v-loading="isLoading"
                    header-cell-class-name="table_header"
                >
                    <template v-for="(item, index) in tableHeaderTypeclassification">
                        <el-table-column
                            align="center"
                            :prop="item.prop"
                            :label="item.label"
                            :key="index"
                            :min-width="item.width"
                        ></el-table-column>
                    </template>
                </el-table>
                <!-- <el-pagination  background
                align="right"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :page-sizes="[20,30,40,50,100]"
                :page-size="pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="typeclassificationData.length"
                class="mt10"
            >
            </el-pagination> -->
            </el-col>
            <el-col :span="24" :style="`height:${vh}`">
                <TypeEcharts ref="TypeEcharts" :fa-msg1="typeclassificationData"></TypeEcharts>
            </el-col>
        </el-row>
    </div>
</template>

<script>
import Timeinterval from './Timeslot.vue'
import { dicData } from '@/assets/commjs/dictypeData'
import TypeEcharts from './echarts/TypeEcharts.vue'
import { getRMpDevEvaluateDetailList } from '@/api/Management-operation/mochaITOM'
export default {
    props: ['faMsg'],
    components: { Timeinterval, TypeEcharts },
    data() {
        return {
            kai: true,
            start: '',
            end: '',
            id: JSON.parse(window.sessionStorage.getItem('Info')).deptId,
            vh: '',
            height: null,
            isLoading: false,
            manufacturer: '', // 生产厂家
            //生产厂家数据
            manufacturerData: [],
            tableHeaderTypeclassification: [
                { prop: 'manufactureId', label: '厂家名称' },
                // { prop: 'dataDate', label: '日期' },
                { prop: 'devDataRate', label: '终端数据完整率(%)' },
                { prop: 'devTargetRate', label: '终端指标完整率		(%)' },
                { prop: 'devEffectiveRate', label: '终端有效接入率	(%)' },
                { prop: 'assessment', label: '综合评价' }
            ],
            typeclassificationData: [],
            device: '',
            currentPage: 1, // 当前页码
            total: 20, // 总条数
            pageSize: 18 // 每页的数据条数
        }
    },
    created() {
        this.manufacturerData = dicData('Dev_Manufacturers', [], 1)
    },
    mounted() {
        this.typeclassification()
        this.setHeight()
        window.addEventListener('resize', this.setHeight)
    },
    beforeDestroy() {
        window.removeEventListener('resize', this.setHeight)
    },
    methods: {
        setHeight() {
            this.height = (window.sessionStorage.getItem('appheight') - 280) / 2
            this.vh = window.sessionStorage.getItem('appheight') / 2 - 35 + 'px'
        },
        time(val) {
            ;(this.start = val[0]), (this.end = val[1])
            this.type = val[2]
        },
        //获取主网运行指标统计数据
        typeclassification() {
            this.isLoading = true
            getRMpDevEvaluateDetailList({
                manufactureIds: this.manufacturer,
                searchType: 2,
                startTime: this.start,
                endTime: this.end,
                id: this.id,
                deviceModel: '',
                type: this.type
            }).then(res => {
                this.isLoading = false

                res.data.forEach(e => {
                    this.manufacturerData.forEach(i => {
                        if (i.id == e.manufactureId) {
                            e.manufactureId = i.name
                        }
                    })
                })
                this.typeclassificationData = res.data
            })
        },
        // 切换选项
        handleNodeClick(data) {
            // console.log(data);
        },
        //每页条数改变时触发 选择一页显示多少行
        handleSizeChange(val) {
            this.pageSize = val
            this.typeclassification()
        },
        //当前页改变时触发 跳转其他页
        handleCurrentChange(val) {
            this.currentPage = val
            this.typeclassification()
        },
        //查询
        researchFn() {
            this.typeclassification()
            this.$refs.TypeEcharts.province()
        },
        //重置
        Reset() {
            // this.$refs.area.form.valueTitle='全国'
            this.$refs.interval.intervald = 1
            this.manufacturer = 0
        }
    }
}
</script>
<style lang="less" scoped>
@import url('../../../../../styles/comStyle.less');
</style>
