<template>
    <!-- <div :class="showDatePicker || showSelect? 'homeMobeilMask': ''">
    </div> -->
    <div class="reportConpanyPage">
        <van-nav-bar title="单位考评报告" />
        <div class="mobeilVant">
            <div class="mobeilTop">
                <div class="topLeft">
                    <!-- <van-icon name="star" size="20" /> -->
                    <img :src="logoImg" alt="">
                    <span>全业务域考评系统</span>
                </div>
                <div class="topRight">
                    <span>系统导航</span>
                    <!-- <van-icon name="wap-nav"  size="23" /> -->
                    <img :src="daohangImg" alt="" @click="chooseMenu">
                </div>
            </div>
            <div class="reportConpanyMain">
                <div class="mainSeach">
                    <div class="seachFrom" @click="showPopup">
                        <span>搜索栏</span>
                    </div>
                    <van-popup v-model:show="showVanPopup" position="top">
                        <div class="vanForm">
                            <van-form>
                                <van-field
                                v-model="form.company"
                                label="单位名称"
                                placeholder="单位名称"
                                />
                                <van-field
                                    v-model="form.binSection"
                                    is-link
                                    readonly
                                    label="选择板块"
                                    placeholder="点击选择板块"
                                    @click="showSelect = true"
                                    />
                                <van-popup v-model:show="showSelect" position="bottom">
                                    <van-picker
                                        :columns="columnSection"
                                        @confirm="selectConfirm"
                                        @cancel="showSelect = false"
                                    />
                                </van-popup>
                                <van-field
                                    v-model="form.year"
                                    is-link
                                    readonly
                                    name="datePicker"
                                    label="时间选择"
                                    placeholder="点击选择年度与季度"
                                    @click="showDatePicker = true"
                                    />
                                <van-popup v-model:show="showDatePicker" position="bottom">
                                    <van-date-picker
                                        title="年度/季度"
                                        :columns-type="['year', 'month']"
                                        :filter="filterPicker"
                                        @confirm="confirmFn"
                                        @cancel="cancelpickerFn"
                                        />
                                </van-popup>
                                <div style="margin: 16px;">
                                    <van-button round block type="primary" native-type="submit">
                                    提交
                                    </van-button>
                                </div>
                            </van-form>
                        </div>
                    </van-popup>
                </div>
                <div class="mainModel">
                    <el-table :data="mobeilReportData" style="width: 100%">
                    <el-table-column type="index" label="序号" align="center"></el-table-column>
                    <el-table-column label="报告名称" prop="evaluateReportName" width="330" />
                    <el-table-column label="业务属性" prop="binSectionName" width="150" />
                    <el-table-column label="考评周期">
                        <template #default="scope">
                            <span v-if="scope.row.checkCycle === 'YDKP'" style="font-size: 12px;">月度考评</span>
                            <span v-else-if="scope.row.checkCycle === 'JDKP'" style="font-size: 12px;">季度考评</span>
                            <span v-else style="font-size: 12px;">年度考评</span>
                        </template>
                    </el-table-column>
                    <el-table-column label="年度" prop="year" />
                    <el-table-column label="月度/季度" prop="month" align="center" />
                    <el-table-column label="业务简述" prop="des" width="200" />
                </el-table>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import logoImg from '../assets/mobeilImg/logo.png'
import daohangImg from '../assets/mobeilImg/daohang.png'
import dateImg from '../assets/mobeilImg/date.png'
import sortImg from '../assets/mobeilImg/sort.png'
import seachImg from '../assets/mobeilImg/seach.png'
import cup1 from '../assets/getwayImg/cup1.png'
import cup2 from '../assets/getwayImg/cup2.png'
import cup3 from '../assets/getwayImg/cup3.png'
import topImg from '../assets/getwayImg/topNew.png'
import botImg from '../assets/getwayImg/botNew.png'
import cenImg from '../assets/getwayImg/cenNew.png'

import {apiGetEvalReportList} from '../api/api'
export default {
    data() {
        return {
            logoImg: logoImg,
            daohangImg: daohangImg,
            dateImg: dateImg,
            sortImg: sortImg,
            seachImg: seachImg,
            topImg: topImg,
            botImg: botImg,
            cenImg: cenImg,
            showDatePicker: false,
            showSelect: false,
            showVanPopup: false,
            form: {
                company: '',
                binSection: '',
                year: '',
                season: ''
            },
            binSection: 'HD',
            mobeilReportData: [],
            columnSection: [],
            datePickerData: []
        }
    },
    created() {
        this.getReportData()
        this.columnSection = [
            { text: '火电', value: 'HD' },
            { text: '水电', value: 'SD' },
            { text: '新能源', value: 'XNYFG' },
            { text: '海外业务', value: 'GJYW' },
            { text: '煤电一体化', value: 'MDYTH' }
        ]
        
    },
    methods: {
        // 获取考评报告数据
        getReportData() {
            let that = this
            that.mobeilReportData = []
            let params = {
                pageNum: 1,
                pageSize: 500,
                binSection: '',
                checkCycle: '',
                year: '',
                month: ''
            }
            apiGetEvalReportList(params).then(datas =>{
                if (datas && datas.data) {
                    that.mobeilReportData = datas.data.records
                }
            })
        },
        showPopup() {
            this.showVanPopup = true
        },
        filterPicker(type, options) {
            if (type === 'month') {
                return options.filter((option) => Number(option.value) < 5);
            }
            return options;
        },
        chooseMenu() {
            this.$router.push({ path: "/menu"})
        },
        changeSelect() {
            this.showSelect = true
        },
        confirmFn(val) {
            debugger
            this.form.year = val.selectedValues[0]+'年'+val.selectedValues[1]+'季度'
            this.datePickerData = val.selectedValues
            this.cancelpickerFn()
        },
        selectConfirm(val) {
            this.form.binSection =  val.selectedValues[0]
            this.binSection = val.selectedValues[0]
            if (this.binSection === 'HD') {
                this.form.binSection = '火电'
            } else if (this.binSection === 'SD') {
                this.form.binSection = '水电'
            } else if (this.binSection === 'XNYFG') {
                this.form.binSection = '新能源'
            } else if (this.binSection === 'GJYW') {
                this.form.binSection = '海外业务'
            } else if (this.binSection === 'MDYTH') {
                this.form.binSection = '煤电一体化'
            }
            this.cancelSelect()
        },
        cancelpickerFn() {
            this.showDatePicker = false
        },
        cancelSelect() {
            this.showSelect = false
        }
    }
}
</script>

<style lang="less">
.homeMobeilMask{
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 111;
}
.reportConpanyPage {
    background-color: #184FB4;
    .van-nav-bar{
        width: 100%;
        background-color: #184FB4;
        color: #fff;
        position: fixed;
        top: 0;
        z-index: 111111;
        .van-nav-bar__content{
            .van-nav-bar__left{
                .van-nav-bar__text{
                    color: #fff;
                }
            }
        }
    }
    .mobeilVant{
        height: 100%;
        margin-top: 45px;
        border-radius: 10px 10px 0 0;
        background-color: #fff;
        .mobeilTop{
            height: 60px;
            display: flex;
            justify-content: space-around;
            .topLeft{
                display: flex;
                img{
                    width: 24px;
                    height: 28px;
                    position: relative;
                    top: 18px;
                    left: -10px;
                }
                span{
                    font-family: MicrosoftYaHei;
                    font-weight: 600;
                    font-size: 16px;
                    color: #444950;
                    line-height: 60px;
                }
            }
            .topRight{
                display: flex;
                img{
                    width: 22px;
                    height: 18px;
                    position: relative;
                    top: 21px;
                    left: 5px;
                }
                span{
                    font-family: MicrosoftYaHei;
                    font-weight: 400;
                    font-size: 14px;
                    color: #545960;
                    line-height: 60px;
                    margin-right: 5px;
                }
            }
        }
        .reportConpanyMain{
            // height: 50px;
            background-color: #ededf5;
            padding: 17px 20px;
            width: calc(100% - 40px);
            .mainSeach{
                display: flex;
                // justify-content: space-between;
                .seachFrom{
                    width: 100%;
                    height: 40px;
                    background: #184FB4;
                    border-radius: 5px;
                    margin-bottom: 15px;
                    text-align: center;
                    span{
                        display: inline-block;
                        color: #fff;
                        line-height: 40px;
                    }
                }
                .vanForm{
                    margin-top: 60px;
                }
            }
            .mainModel{
                background: #fff;
                border-radius: 5px;
                padding: 5px 0;
                .el-table{
                    .el-table__header-wrapper{
                        .el-table__header{
                            tr{
                                .cell{
                                    line-height: 18px !important;
                                }
                            }
                        }
                    }
                    .el-table__body-wrapper{
                        .el-table__body{
                            tr{
                                .cell{
                                    img{
                                        width: 20px;
                                        height: 20px;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
</style>