<!--个人黑名单-->
<template>
  <div class="app-container myBlackListInfo">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="状态" prop="overStatus" label-width="50px">
        <el-select v-model="queryParams.overStatus" placeholder="请选择状态">
          <el-option
            v-for="dict in overStatusOptions"
            :key="dict.id"
            :label="dict.name"
            :value="dict.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="学期" prop="semesterId" label-width="50px">
        <el-select v-model="queryParams.semesterId" placeholder="请选择学期">
          <el-option
            v-for="dict in semesterOptions"
            :key="dict.id"
            :label="dict.semesterName"
            :value="dict.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="创建时间" prop="dateRange" style="margin-left:10px;">
        <el-date-picker
          :clearable="false"
          v-model="dateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <p class="inquire-button-one" @click="handleQuery">查询</p>
        <p class="reset-button-one" @click="resetQuery">重置</p>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" border :data="recordList">
      <el-table-column label="原因" align="left" prop="reason" />
      <el-table-column label="时间" align="left" prop="createTime" />
      <el-table-column label="处理方式" align="left"  prop="treatmentMethod" />
      <el-table-column label="处理状态" align="left"  prop="surplusPoints">
        <template slot-scope="scope">
          <div class="scope-big-box" v-if="scope.row.learnStatus == 0 || scope.row.learnStatus == 1">
            <p>学习</p>
            <p :class="scope.row.learnStatus == 0 ?'scopeColorA':(scope.row.learnStatus == 1 ?'scopeColorB':'')">{{scope.row.learnStatus == 0 ?'未完成':(scope.row.learnStatus == 1 ?'已完成':'')}}</p>
          </div>
          <div class="scope-big-box" v-if="scope.row.testStatus == 0 || scope.row.testStatus == 1">
            <p>考试</p>
            <p :class="scope.row.testStatus == 0 ?'scopeColorA':(scope.row.testStatus == 1 ?'scopeColorB':'')">{{scope.row.testStatus == 0 ?'未完成':(scope.row.testStatus == 1 ?'已完成':'')}}</p>
          </div>
          <div class="scope-big-box" v-if="scope.row.practiceStatus == 0 || scope.row.practiceStatus == 1">
            <p>做题</p>
            <p :class="scope.row.practiceStatus == 0 ?'scopeColorA':(scope.row.practiceStatus == 1 ?'scopeColorB':'')">{{scope.row.practiceStatus == 0 ?'未完成':(scope.row.practiceStatus == 1 ?'已完成':'')}}</p>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="信用分" align="left"  prop="creditScore" />
    </el-table>
    <pagination :page-sizes="[20, 30, 40, 50]"
      v-show="total>0"
      :total="total"
      layout="total, prev, pager, next, sizes, jumper"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
  import { myBlackDetail } from "@/api/laboratory/blacklist";
  import { getSemesterList } from "@/api/laboratory/semester";
  export default {
    props: {
      propsData:{},
    },
    name: "myBlackListInfo",
    data() {
      return {
        //加载状态
        loading:false,
        // 显示搜索条件
        showSearch: true,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize:20,
          points: null,
          joinUserId: null,
          mode: null,
          deptName: null,
          deptId: null,
          userId: null,
          semesterId: null,
          overStatus: null
        },
        //状态条件
        overStatusOptions:[
          {id:'',name:"全部"},
          {id:1,name:"已完成"},
          {id:0,name:"未完成"},
          {id:-1,name:"无"},
        ],
        //列表数据
        recordList:[],
        total:0,
        // 日期范围
        dateRange: [],
        //学期列表
        semesterOptions:[],
      }
    },
    created(){
      this.getList()
    },
    mounted(){
      this.getSemesterList()
    },
    methods:{
      //返回上级页面
      backPage(){
        this.$parent.goPage(1);
      },
      /** 查询数据 */
      getList() {
        this.loading = true;
        if(this.dateRange&&this.dateRange.length>0)
        {
          this.queryParams.beginTime=this.dateRange[0]
          this.queryParams.endTime=this.dateRange[1]
        }
        else
        {
          this.queryParams.beginTime=null;
          this.queryParams.endTime=null
        }
        myBlackDetail(this.queryParams).then( response => {
          this.recordList =  response.rows;
          this.total =  response.total;
          this.loading = false;
        });
      },
      /** 查询学期列表 */
      getSemesterList() {
        getSemesterList().then(response => {
          this.$set(this, 'semesterOptions', response.data)
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        // this.resetForm("queryParams");
        this.$set(this,'queryParams',{
          pageNum: 1,
          pageSize:20,
          overStatus:"",
          semesterId: '',
        });
        this.recordList = [];
        this.handleQuery();
      },
    },
  }
</script>

<style scoped lang="scss">
  .myBlackListInfo{
    display: flex!important;
    flex-direction: column;
    box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
    padding:11px 20px 20px!important;
    overflow: hidden;
    .scope-big-box{
      display: flex;
      p{
        font-size:14px;
        height:20px;
        line-height:20px;
        margin:4px 0;
      }
      p:nth-child(1){
        margin-right:10px;
      }
      p:nth-child(2){

      }
      .scopeColorA{
        padding:0 4px;
        border-radius:4px;
        color:#999;
        background: #dedede;
      }
      .scopeColorB{
        padding:0 4px;
        border-radius:4px;
        color:#fff;
        background: #39A922;
      }
    }
  }
</style>
