<template>
    <div>
        <el-form :inline="true" class="demo-form-inline">
            <el-form-item>
                <Area @click="handleNodeClick" ref="area"></Area>
            </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="qualityevaluationData.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 tableHeaderQualityevaluation">
                        <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="qualityevaluationData.length"
                    class="mt10"
                ></el-pagination>
            </el-col>
        </el-row>
    </div>
</template>

<script>
import { dicData } from '@/assets/commjs/dictypeData'
import Area from '@/views/components/Area/Area.vue'
import Timeinterval from './Timeslot.vue'
import { getRMpDevEvaluateDetailList } from '@/api/Management-operation/mochaITOM'
export default {
    props: ['faMsg'],
    components: { Area, Timeinterval },

    data() {
        return {
            kai: true,
            start: '',
            end: '',
            id: JSON.parse(window.sessionStorage.getItem('Info')).deptId,
            edata: [],
            vh: '',
            height: null,
            isLoading: false,
            manufacturer: '', // 生产厂家
            //生产厂家数据
            manufacturerData: [],

            tableHeaderQualityevaluation: [
                { prop: 'orgName', label: '单位' },
                { prop: 'devCount', label: '在运终端数量	' },
                // { prop: 'dataDate', label: '日期' },
                { prop: 'assessment', label: '综合评价	' },
                { prop: 'devDataRate', label: '终端数据完整率	(%)' },
                { prop: 'devEffectiveRate', label: '终端有效接入率	(%)' },
                { prop: 'devTargetRate', label: '终端指标完整率(%)	' }
            ],
            qualityevaluationData: [],
            device: '',
            currentPage: 1, // 当前页码
            total: 20, // 总条数
            pageSize: 18 // 每页的数据条数
        }
    },

    mounted() {
        this.manufacturerData = dicData('Dev_Manufacturers', [], 1)

        this.qualityevaluation()
        this.setHeight()
        window.addEventListener('resize', this.setHeight)
    },
    beforeDestroy() {
        window.removeEventListener('resize', this.setHeight)
    },
    methods: {
        setHeight() {
            this.device = window.devicePixelRatio
            this.height = window.sessionStorage.getItem('appheight') - 215
        },
        time(val) {
            ;(this.start = val[0]), (this.end = val[1])
            this.type = val[2]
        },
        //获取主网运行指标统计数据
        qualityevaluation() {
            this.isLoading = true
            getRMpDevEvaluateDetailList({
                manufactureIds: '',
                searchType: 1,
                startTime: this.start,
                endTime: this.end,
                id: this.id,
                deviceModel: '',
                type: this.type
            }).then(res => {
                this.isLoading = false
                this.qualityevaluationData = res.data
            })
        },
        // 切换选项
        handleNodeClick(data) {
            this.id = data.id
        },
        //每页条数改变时触发 选择一页显示多少行
        handleSizeChange(val) {
            this.pageSize = val
            this.qualityevaluation()
        },
        //当前页改变时触发 跳转其他页
        handleCurrentChange(val) {
            this.currentPage = val
            this.qualityevaluation()
        },
        //查询
        researchFn() {
            this.qualityevaluation()
        },
        //重置
        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>
