<template>
  <div class="table-container">
    <el-row class="second-title">规则说明</el-row>
    <div>
      <el-row class="content">受理员得分 = 按时立案分数 + 按时发送核实分 + 按时发送核查分</el-row>
      <el-row class="content">按时立案分数 = 按时立案数量/立案总数 * 100 * 按时立案因子</el-row>
      <el-row class="content">按时发送核实分 = 按时安排数/安排核实数 * 100 * 按时发送核实因子</el-row>
      <el-row class="content">按时发送核查分 = 按时安排数/安排核查数 * 100 * 按时发送核查因子</el-row>
    </div>
    <el-row style="padding:20px"/>
    <el-row class="second-title">考核因子</el-row>
    <div>
      <el-row>
        <el-col :span="8" class="cell">按时立案因子</el-col>
        <el-col :span="8" class="cell">按时发送核实因子</el-col>
        <el-col :span="8" class="cell">按时发送核查因子</el-col>
      </el-row>
      <el-row>
        <el-col :span="8" class="cell">按时立案数/立案数</el-col>
        <el-col :span="8" class="cell">按时安排数/安排核实数</el-col>
        <el-col :span="8" class="cell">按时安排数/安排核查数</el-col>
      </el-row>
      <el-row>
        <el-col :span="8" class="cell">
          <el-input v-model="accessRule.registerOntimeReceiver" size="small" style="width:25%"/> %
          <el-button type="text" class="submit-button" @click="updateAccessFactor()">修改</el-button>
        </el-col>
        <el-col :span="8" class="cell">
          <el-input v-model="accessRule.disVerifyOntime" size="small" style="width:25%"/> %
          <el-button type="text" class="submit-button" @click="updateAccessFactor()">修改</el-button>
        </el-col>
        <el-col :span="8" class="cell">
          <el-input v-model="accessRule.disCheckOntime" size="small" style="width:25%"/> %
          <el-button type="text" class="submit-button" @click="updateAccessFactor()">修改</el-button>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import { getAssessFactor, updateAssessFactor } from '@/api/assess/assessRule'
import { validateIntPlus } from '@/utils/validate'
export default {
  name: 'AssessRuleReceiver',
  data() {
    return {
      role: '',
      accessRule: {
        id: '', // id
        shouldReport: '', // 监督员，要求上报数
        checkFactor: '', // 监督员，核查因子
        verify: '', // 监督员，核实因子
        registerOntimeReceiver: '', // 受理员，按时立案因子
        disVerifyOntime: '', // 受理员，按时发送核实因子
        disCheckOntime: '', // 受理员 按时发送核查因子
        registerOntimeMonitor: '', // 值班长，按时立案因子
        closeOntime: '', // 值班长，按时结案因子
        teamMark: '', // 值班长，团队分因子
        disOntime: '', // 派遣员，按时派遣因子
        disExact: '', // 派遣员，准确派遣因子
        processAuditOntime: '', // 派遣员，按时处理审核因子
        adjustOntime: '' // 派遣员，按时调整因子
      }
    }
  },
  mounted() {
    this.fetchData()
  },
  methods: {
    // 获取考核规则
    fetchData() {
      getAssessFactor().then(response => {
        this.accessRule = response.data
      })
    },
    // 更新考核规则
    updateAccessFactor() {
      if (this.validateData()) {
        updateAssessFactor(this.accessRule).then(response => {
          if (response.code === 200) {
            this.$message.success('修改成功')
          }
        })
      }
    },
    validateData() {
      if (!validateIntPlus('' + this.accessRule.registerOntimeReceiver, 0, 100)) {
        this.$message.error('按时立案因子的允许填写范围为0到100')
        return false
      }
      if (!validateIntPlus('' + this.disVerifyOntime, 0, 100)) {
        this.$message.error('按时发送核实因子的允许填写范围为0到100')
        return false
      }
      if (!validateIntPlus('' + this.disCheckOntime, 0, 100)) {
        this.$message.error('按时发送核查因子的允许填写范围为0到100')
        return false
      }
      return true
    }
  }

}
</script>

<style lang="scss" scoped>
  .second-title{
    border: 1px solid #eee;
    background-color: #eee;
    border-top: 0;
    font-size: 1.5em;
    padding: 10px;
    text-align: center;
  }
  .content{
    border: 1px solid #eee;
    border-top: 0;
    font-size: 1.2em;
    padding: 5px;
    text-align: center;
  }
  .cell{
    border: 1px solid #eee;
    font-size: 1.2em;
    border-top: 0;
    padding: 5px;
    text-align: center;
    position: relative;
  }
  .submit-button{
    margin-left: 10px;
  }
  /deep/ input.el-input__inner {
    color: red;
    font-size: 1.2em;
  }
</style>
