<template>
  <div class="assign-compare">
    <el-form ref="FilterForm" label-position="left" inline>
      <!-- <el-form-item label="卷面总分：">
        <el-input-number
          v-model.number="filter.scope"
          :min="0"
          :max="99999"
          :step="1"
          step-strictly
          :controls="false"
          style="width: 130px"
        ></el-input-number>
      </el-form-item> -->
      <el-form-item label="及格分：">
        <el-input-number
          v-model.number="filter.passScore"
          :min="0"
          :max="99999"
          :step="0.1"
          step-strictly
          :controls="false"
          style="width: 130px"
        ></el-input-number>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="search">查询</el-button>
      </el-form-item>
    </el-form>

    <table class="table">
      <tr>
        <th rowspan="2">对比项</th>
        <th colspan="3">总体有效人数：{{ result.size }}人</th>
      </tr>
      <tr>
        <th>平均分</th>
        <th>不及格率</th>
        <th>不及格人数</th>
      </tr>
      <tr>
        <td>赋分前</td>
        <td>{{ result.assignBeforeAverageScore }}</td>
        <td>{{ result.assignBeforeFailRate }}</td>
        <td>{{ result.assignBeforeFailCount }}</td>
      </tr>
      <tr>
        <td>赋分后</td>
        <td>{{ result.assignAfterAverageScore }}</td>
        <td>{{ result.assignAfterFailRate }}</td>
        <td>{{ result.assignAfterFailCount }}</td>
      </tr>
    </table>
  </div>
</template>

<script>
import { assignmentCompareResult } from "../../api";

export default {
  name: "assign-compare",
  props: {
    assignInfo: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    return {
      filter: {
        passScore: "",
      },
      result: {},
    };
  },
  methods: {
    async search() {
      const datas = {
        ...this.assignInfo,
        ...this.filter,
      };

      const data = await assignmentCompareResult(datas);
      this.result = data || {};
    },
  },
};
</script>
