<template>
    <div class="evaluationReport">
        <div class="evaluationReportBtn">
            <div class="collectSeach" :style="$utils.collectSeachSty()">
                <div class="exceed">
                    <span class="exceedSpan">考评周期：</span>
                    <!-- <el-input v-model="restype" placeholder="请输入业务类别"></el-input> -->
                    <el-select v-model="rescycle" placeholder="请选择考评周期">
                        <el-option
                        v-for="item in periodData"
                        :key="item.keyValue"
                        :label="item.keyName"
                        :value="item.keyValue">
                        </el-option>
                    </el-select>
                </div>
                <div class="exceed">
                    <span class="exceedSpan">业务属性：</span>
                    <!-- <el-input v-model="resDes" placeholder="请输入业务简述"></el-input> -->
                    <el-select v-model="resbinSection" placeholder="请选择业务属性" :disabled="isDetail">
                        <el-option
                        v-for="item in moduleData"
                        :key="item.id"
                        :label="item.sectionName"
                        :value="item.id">
                        </el-option>
                    </el-select>
                </div>
                <div class="exceed">
                    <span class="exceedSpan">考评时间：</span>
                    <el-date-picker v-model="resAnnual"  value-format="YYYY-MM" type="month" placeholder="选择时间" />
                </div>
                <seachs @handleSeach="getSeachData" @handleRest="resetSeach"></seachs>
            </div>
            <div class="PeriodBtn">
                <!-- <btns
                :showImport="false"
                :showExport="false"
                :showSave="false"
                :showAdd="false"
                :showDelete="false"
                :disDelete="changeDateSelect.length === 0"
                @handleExport="exportDataMsg"
                ></btns> -->
            </div>
            <div class="evaluationReportTableData">
                <el-table :data="evaluationReportData" style="width: 100%" @select="rowClick" @select-all="rowClick" @row-dblclick="getDetail">
                    <el-table-column type="selection" label="操作" align="center"></el-table-column>
                    <el-table-column label="报告名称" prop="evaluateReportName" width="330" />
                    <el-table-column label="业务属性" prop="binSectionName" />
                    <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" />
                    <el-table-column label="业务简述" prop="des" />
                    <el-table-column label="操作">
                        <template #default="scope">
                            <p class="indicitem" @click="getDetail(scope.row)">详情</p>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="page.currentPage"
                    :page-size="page.pagesize"
                    layout="total, prev, pager, next, jumper"
                    :total="page.total">
                </el-pagination>
            </div>
        </div>
        <evaluation-report-table ref="reportTable"></evaluation-report-table>
    </div>
</template>

<script>
import btns from '../elbuttonS.vue'
import seachs from '../seachGroup.vue'
import ExcelJS from 'exceljs'
import fileSave from 'file-saver'
import evaluationReportTable from './evaluationReportTable.vue'
import {apiGetEvalReportList, apiGetdatadictionaryList, apiGetbinsectionList} from '../../api/api'
export default {
    components: {
        btns,
        evaluationReportTable,
        seachs
    },
    data() {
        return {
            rescycle: '',
            resbinSection: '',
            resAnnual: '',
            periodData: [],
            moduleData: [],
            changeDateSelect: [],
            evaluationReportData:[],
            page:{
                pagesize: 12,
                currentPage: 1,
                total: 0
            }
        }
    },
    created() {
        this.getevaluStartList()
        this.getPeriodData()
        this.getBinSectionData()
    },
    methods:{
        // 查询列表页面
        getevaluStartList() {
            let that = this
            let year = ''
            let month = ''
            if (that.resAnnual !== '') {
                year = that.resAnnual.substring(0, that.resAnnual.indexOf('-'))
                month = that.resAnnual.substring(that.resAnnual.indexOf('-')+1, that.resAnnual.length)
                if (month<10) {
                    month = month.substring(1, 2)
                }
            }
            let params = {
                pageNum: that.page.currentPage,
                pageSize: that.page.pagesize,
                binSection: that.resbinSection,
                checkCycle: that.rescycle,
                year: year,
                month: month
            }
            apiGetEvalReportList(params).then(datas =>{
                if (datas && datas.data) {
                    that.evaluationReportData = datas.data.records
                    that.page.total = datas.data.total
                }
            })
        },
        //考评周期
        getPeriodData() {
            let that = this
            let params = {
                superKey: 'KPZQ0001'
            }
            apiGetdatadictionaryList(params).then(datas =>{
                if (datas && datas.data) {
                    that.periodData = datas.data
                }
            })
        },
        getBinSectionData() {
            let that = this
            apiGetbinsectionList().then(datas =>{
                if (datas && datas.data) {
                    that.moduleData = datas.data
                }
            })
        },
        //明细
        getDetail(row) {
            this.$refs.reportTable.init(row)
        },
        getSeachData() {
            this.page.currentPage = 1
            this.getevaluStartList()
        },
        resetSeach() {
            this.page.currentPage = 1
            this.rescycle = ''
            this.resbinSection = ''
            this.resAnnual = ''
            this.getevaluStartList()
        },
        handleSizeChange(val){
            this.page.pagesize = val
            this.getevaluStartList()
        },
        handleCurrentChange(val){
            this.page.currentPage =val
            this.getevaluStartList()
        },
        rowClick(selection, row) {
            this.changeDateSelect = selection
        },
    }
}
</script>

<style lang="less">
.evaluationReport{
    .evaluationReportBtn{
        .collectSeach{
                display: flex;
                padding: 24px 20px;
                border-bottom: 1px solid#D6DBEA;
                .exceed{
                    display: flex;
                    .exceedSpan{
                        width: 80px;
                        height: 12px;
                        font-size: 14px;
                        font-family: Microsoft YaHei;
                        font-weight: 400;
                        color: #8991B0;
                        line-height: 12px;
                        margin-top: 14px;
                    }
                    .el-input{
                        margin-right:10px;
                        height: 40px;
                        .el-input__inner{
                            height:40px;
                        }
                        .el-input__suffix{
                            .el-select__caret{
                                line-height:30px;
                            }
                        }
                    }
                }
                .el-select{
                    margin-right:10px;
                    .el-input__inner{
                        height:30px;
                    }
                    .el-input__suffix{
                        .el-select__caret{
                            line-height:30px;
                        }
                    }
                }
        }
        span{
            font-size:14px;
        }
        .PeriodBtn{
            display: flex;
                justify-content: flex-end;
                padding: 20px 0;
        }
        .el-button{
            height: 30px;
            // width:100px;
            padding: 0 20px ;
            // padding-top: 8px;
            span{
                margin:0;
            }
        }
        .evaluationReportTableData{
            .el-table{
                .el-table__body-wrapper{
                    height: 60vh !important;
                }
                .el-input__inner{
                    height: 30px !important;
                }
                .el-radio__label{
                    display: none;
                }
                .indicitem{
                    color: #409EFF;
                    font-size: 12px;
                    margin-right: 20px;
                    cursor:pointer;
                    &:hover{
                        text-decoration: underline;
                    }
                }
            }
            .el-pagination{
                margin-top: 20px;
                text-align: end;
                position: relative;
            }
        }
        .el-overlay{
            .el-dialog{
                .el-dialog__body{
                    padding: 30px 60px 30px 20px !important;
                    .periodFrom{
                        .el-select, .el-input{
                            width: 100%;
                        }
                        .el-input{
                            height: 30px;
                        }
                    }
                }
            }
        }
    }
    
}
</style>