<template>
  <div class="app-container">
    <el-row>
      <el-col :span="24">
        <el-button @click="toRecord">操作记录</el-button>
        <el-button>导出得分N/A</el-button>
      </el-col>
    </el-row>

    <!-- 列表区域 -->
    <el-table :data="user" style="width: 100%" v-loading="loading">
      <el-table-column type="index" width="40"></el-table-column>
      <el-table-column prop="name" label="姓名"></el-table-column>
      <el-table-column prop="phone" label="手机号" width="110"></el-table-column>
      <el-table-column prop="deptId" label="部门" width="80"></el-table-column>
      <el-table-column label="个人得分" width="80">
        <template slot-scope="scope">
          <span>{{score[scope.$index] == null? null: score[scope.$index].personalScore}}</span>
        </template>
      </el-table-column>
      <el-table-column label="建议得分" width="80">
        <template slot-scope="scope">
          <span>{{score[scope.$index] == null? null: score[scope.$index].ideaScore}}</span>
        </template>
      </el-table-column>
      <el-table-column label="总得分" width="80">
        <template slot-scope="scope">
          <span>{{score[scope.$index] == null? null: score[scope.$index].total}}</span>
        </template>
      </el-table-column>
      <el-table-column label="评分人" width="100">
        <template slot-scope="scope">
          <span>{{score[scope.$index] == null? null: score[scope.$index].rater}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="indate" label="时间" width="100"></el-table-column>
    </el-table>

    <!-- 页码区域 -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageIndex"
      :page-sizes="[20, 50, 100]"
      :page-size="20"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      background
      style="float: right"
    ></el-pagination>
  </div>
</template>

<script>
import request from "@/utils/request";
export default {
  data() {
    return {
      idea: [],
      score: [],
      user: [],
      loading: false,
      //分页相关
      pageIndex: 1,
      pageSize: 20,
      total: 0
    };
  },
  methods: {
    //获取全部分数统计信息
    getAllScore() {
      this.loading = true;
      request({
        url: "/score/getAllScore",
        method: "post",
        params: {
          pageIndex: this.pageIndex,
          pageSize: this.pageSize
        }
      })
        .then(response => {
          this.idea = response.data.idea.records;
          this.score = response.data.score;
          this.user = response.data.user;
          this.total = response.data.idea.total;
          this.loading = false;
        })
        .catch(error => {
          this.loading = false;
        });
    },

    //到记录页面
    toRecord() {
      this.$router.push("/record");
    },

    //页码规格变更
    handleSizeChange(val) {
      this.pageSize = val;
      this.getAllScore();
    },

    //页码页数变更
    handleCurrentChange(val) {
      this.pageIndex = val;
      this.getAllScore();
    }
  },
  mounted() {
    this.getAllScore();
  }
};
</script>

<style scoped>
</style>

