<template>
    <div class="scoringRules" v-loading="loadingImport">
        <div class="scoringRulesBtn">
            <div class="collectSeach" :style="$utils.collectSeachSty()">
                <div class="exceed">
                    <span class="exceedSpan">指标名称：</span>
                    <el-input v-model="indicatorIdS" placeholder="请输入指标名称"></el-input>
                </div>
                <div class="exceed">
                    <span class="exceedSpan" style="width: 80px">业务属性：</span>
                    <el-select v-model="binSectionIds" placeholder="请选择业务属性">
                        <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" style="width: 80px;margin-left:10px">考评周期：</span>
                    <el-select v-model="evaluationCycleStr" placeholder="请选择考评周期">
                        <el-option
                        v-for="item in periodData"
                        :key="item.keyValue"
                        :label="item.keyName"
                        :value="item.keyValue"
                        :disabled="item.keyValue === 'YDKP'">
                        </el-option>
                    </el-select>
                </div>
                <seachs @handleSeach="getSeachData" @handleRest="resetSeach"></seachs>
            </div>
            <div class="scoringRulesTableData">
                <el-table :data="scoringRulesData" style="width: 100%" @row-dblclick="editRuleDetail">
                    <el-table-column label="序号" type="index" align="center" />
                    <el-table-column label="指标编码" prop="indicatorCode" width="200" />
                    <el-table-column label="业务属性" prop="binSectionName" />
                    <el-table-column label="业务阶段" prop="binStageName" />
                    <el-table-column label="指标类型" prop="indicatorTypeName" width="200" />
                    <el-table-column label="指标名称" prop="indicatorName" width="300" />
                    <el-table-column label="考评周期" prop="evaluationCycle">
                        <template #default="scope">
                            <span>{{scope.row.evaluationCycle==='YDKP'?'月度考评':scope.row.evaluationCycle==='JDKP'?'季度考评':'年度考评'}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column label="指标单位" prop="unit" />
                    <el-table-column label="是否专项" prop="isAdditional" />
                    <el-table-column label="描述" width="250">
                        <template #default="scope">
                            <span>{{scope.row.des}}</span>
                        </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>
        <rule-new-detail ref="ruleNewDetail"></rule-new-detail>
    </div>
</template>

<script>
import seachs from '../seachGroup.vue'
import ruleNewDetail from './scoringRulesNewDetailPage.vue'
import {apiGetIndicatorList, apiGetbinsectionList,
 apiGetIndicatorTypeList, apiGetdatadictionaryList, apiGetbinstageList} from '../../api/api'
export default {
  components: { seachs, ruleNewDetail },
    data() {
        return {
            indicatorIdS: '',
            binSectionIds: '',
            evaluationCycleStr: '',
            scoringRulesData:[],
            moduleData: [],
            stageData: [],
            periodData: [],
            page:{
                pagesize: 12,
                currentPage: 1,
                total: 0
            },
            winPix: window.devicePixelRatio,
        }
    },
    created() {
        this.getEvaluationData()
        this.getDataDictionary()
        this.getPeriodData()
    },
    methods:{
        // 查询指标数据
        getEvaluationData() {
            let that = this
            let params = {
                pageNum: that.page.currentPage,
                pageSize: that.page.pagesize,
                indicatorName: that.indicatorIdS,
                binSection: that.binSectionIds,
                evaluationCycle: that.evaluationCycleStr
            }
            apiGetIndicatorList(params).then(datas =>{
                if (datas && datas.data) {
                    that.scoringRulesData = datas.data.records
                    that.page.total = datas.data.total
                }
            })
        },
        // 查询指标类别
        getindicatorTypeData() {
            let that = this
            apiGetIndicatorTypeList().then(datas =>{
                if (datas && datas.data) {
                    that.indicatorTypeData = datas.data
                }
            })
        },
        //考评周期
        getPeriodData() {
            let that = this
            let params = {
                superKey: 'KPZQ0001'
            }
            apiGetdatadictionaryList(params).then(datas =>{
                if (datas && datas.data) {
                    that.periodData = datas.data
                }
            })
        },
        // 查询部门
        // 查询规则模块和阶段数据
        getDataDictionary(val) {
            let that = this
            apiGetbinsectionList().then(datas =>{
                if (datas && datas.data) {
                    that.moduleData = datas.data
                }
            })
            apiGetbinstageList().then(datas =>{
                if (datas && datas.data) {
                    that.stageData = datas.data
                }
            })
        },
        editRuleDetail(row) {
            this.$refs.ruleNewDetail.init(row)
        },
        getSeachData() {
            this.page.currentPage = 1
            this.getEvaluationData()
        },
        resetSeach() {
            this.page.currentPage = 1
            this.indicatorIdS = ''
            this.binSectionIds = ''
            this.evaluationCycleStr = ''
            this.getEvaluationData()
        },
        handleSizeChange(val){
            this.page.pagesize = val
            this.getEvaluationData()
        },
        handleCurrentChange(val){
            this.page.currentPage =val
            this.getEvaluationData()
        }
    }
}
</script>

<style lang="less">
.scoringRules{
    .scoringRulesBtn{
        .collectSeach{
            display: flex;
            padding: 24px 20px;
            border-bottom: 1px solid#D6DBEA;
                .exceed{
                    display: flex;
                    .exceedSpan{
                        width: 100px;
                        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;
                        .el-input__inner{
                            height:30px;
                        }
                        .el-input__suffix{
                            .el-select__caret{
                                line-height:30px;
                            }
                        }
                    }
                    .el-select{
                        line-height: 40px !important;
                        .el-input__inner, .is-disabled{
                            height:40px !important;
                        }
                        .el-input__suffix{
                            .el-select__caret{
                                line-height:40px;
                            }
                        }
                    }
                }
        }
        span{
            font-size:14px;
        }
        .PeriodBtn{
            display: flex;
            justify-content: flex-end;
            padding: 20px 0;
        }
        .el-button{
            height: 30px;
            // width:100px;
            padding: 0 30px ;
            // padding-top: 8px;
            span{
                margin:0;
            }
        }
        .indexdialog{
            .el-overlay{
                .el-dialog{
                    .el-dialog__body{
                        padding: 0px 20px 0px 20px !important;
                        border-top: 1px solid #D6DBEA;
                        border-bottom: 1px solid #D6DBEA;
                        .periodFrom{
                            .el-select, .el-input{
                                width: 100%;
                            }
                            .el-select{
                                .el-input__inner, .is-disabled{
                                    height:30px !important;
                                }
                            }
                            .DruleForm{
                                padding: 20px 60px 20px 20px;
                            }
                            .indicatorItemBtn{
                                padding: 10px 20px 0 20px;
                                border-left: 1px solid #D6DBEA;
                                span{
                                    font-size:14px;
                                }
                                .PeriodBtnDia{
                                    display: flex;
                                    justify-content: space-between;
                                    padding: 20px 0;
                                    .indItemC{
                                        position: relative;
                                        // left: -600px;
                                        top: 15px;
                                        font-size: 16px;
                                        font-family: Microsoft YaHei;
                                        font-weight: 600;
                                        color: #3B7AD1;
                                    }
                                    .el-button{
                                        height: 30px;
                                        padding: 0 30px ;
                                        span{
                                            margin:0;
                                        }
                                    }
                                    .is-disabled{
                                        opacity: 0.5;
                                    }
                                }
                                .indicatorItemTableData{
                                    // max-height: 75vh !important;
                                    height: 75vh !important;
                                    overflow-y: auto;
                                    .datasMsg{
                                        .tableBtn {
                                            display: flex;
                                            justify-content: end;
                                            margin-right: 30px;
                                            img{
                                                margin-right: 5px;
                                                margin-top: 1px;
                                                width: 18px;
                                                height: 18px;
                                            }
                                            span{
                                                position: relative;
                                                top: -2px;
                                                font-size: 14px;
                                                font-family: Microsoft YaHei;
                                                font-weight: 400;
                                            }
                                        }
                                        .add{
                                            cursor: pointer;
                                            span{
                                                color: #3B7AD1;
                                            }
                                        }
                                        .el-collapse{
                                            .el-collapse-item{
                                                .el-collapse-item__header{
                                                    .nameTit{
                                                        display: inline-block;
                                                        height: 20px;
                                                        font-size: 12px;
                                                        font-weight: bold;
                                                        position: relative;
                                                        top: -8px;
                                                    }
                                                    .el-input{
                                                        width: 150px;
                                                        margin-right: 10px;
                                                    }
                                                }
                                                .el-table{
                                                    .el-table__body-wrapper{
                                                    }
                                                    .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-button{
                                                    height: 26px;
                                                    padding: 0 15px ;
                                                    span{
                                                        margin:0;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    .emptyData{
                                        display: inline-block;
                                        width: 100%;
                                        // border: 1px solid #d9d9d9;
                                        text-align: center;
                                        margin-top: 50px;
                                    }
                                }
                            }
                        }
                    }
                    .el-dialog__footer{
                        .dialog-footer{
                            display: flex;
                            justify-content: center;
                            .el-button{
                                width: 180px !important;
                                height: 40px !important;
                            }
                        }
                    }
                }
            }
        }
    }
  .scoringRulesTableData{
    margin-top: 30px;
    .el-table{
        .el-table__body-wrapper{
            height: 63vh !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;
    }
    }
    
}
</style>