<!--奖励分明细-->
<template>
  <div class="rewardPointsList">
    <div class="title-box">
      <p>奖励分明细</p>
      <p class="reset-button-one" @click="backPage"><i class="el-icon-arrow-left"></i>返回</p>
    </div>
    <div class="rewardPointsListPage">
      <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
        <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 label="状态" prop="bonusType" label-width="50px">
          <el-select v-model="queryParams.bonusType" clearable placeholder="请选择变动状态">
            <el-option
              v-for="dict in bonusTypeOptions"
              :key="dict.id"
              :label="dict.name"
              :value="dict.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <p class="inquire-button-one" style="margin:0 20px;" @click="handleQuery">查询</p>
          <p class="reset-button-one" @click="resetQuery">重置</p>
        </el-form-item>
        <div style="float: right">
          <p class="queryParams-data-box">
            获得总奖励分：{{propsData.allBonusPoints>0?propsData.allBonusPoints:0}}
          </p>
          <p class="queryParams-data-box">
            已兑换奖励分：{{propsData.consumeBonusPoints>0?propsData.consumeBonusPoints:0}}
          </p>
          <p class="queryParams-data-box">
            剩余奖励分：{{propsData.bonusPoints>0?propsData.bonusPoints:0}}
          </p>
        </div>
        <!--<el-form-item class="button-box" style="float: right">-->
        <!--<p class="reset-button-one" @click="backPage"><i class="el-icon-arrow-left"></i>返回</p>-->
        <!--</el-form-item>-->
      </el-form>
      <el-table v-loading="loading" border :data="recordList" style="margin-top:20px;">
        <el-table-column label="奖励分变动信息" align="left" prop="messageContent" />
        <el-table-column label="变更时间" align="left" prop="createTime" />
        <el-table-column label="变动" align="left" prop="points">
          <template slot-scope="scope">
            <p :class="scope.row.points>0?'color_14AE10':(scope.row.points<0?'color_FF4E00':'')">{{scope.row.points}}</p>
          </template>
        </el-table-column>
        <el-table-column label="奖励分余额" align="left"  prop="surplusPoints" />
      </el-table>
      <pagination
        style="margin-top:20px;"
        v-show="total>0"
        :total="total"
        layout="total, prev, pager, next, sizes, jumper"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </div>
</template>

<script>
  import { rewardScoreList } from "@/api/exam/record";
  export default {
    name: "rewardPointsList",
    props: {
      propsData:{},
    },
    data() {
      return {
        //加载状态
        loading:false,
        // 显示搜索条件
        showSearch: true,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize:20,
          points: null,
          joinUserId: null,
          mode: null,
          deptName: null,
          deptId: null,
          userId: null,
        },
        //状态条件
        bonusTypeOptions:[
          {id:1,name:"获得"},
          {id:2,name:"扣减"},
        ],
        //列表数据
        recordList:[],
        total:0,
        // 日期范围
        dateRange: [],
      }
    },
    created(){
      this.getList()
    },
    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
        }

        this.queryParams.pointsId = this.propsData.userId;
        this.queryParams.pointsType = 2;
        rewardScoreList(this.queryParams).then( response => {
          this.recordList =  response.rows;
          this.total =  response.total;
          this.loading = false;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryParams");
        this.queryParams = {};
        this.dateRange = [];
        this.recordList = [];
        this.handleQuery();
      },
    },
  }
</script>

<style scoped>

</style>

<style scoped lang="scss">
  .rewardPointsList {
    flex:1;
    display: flex!important;
    flex-direction: column;
    overflow: hidden;
    *{
      margin:0;
    }
    .title-box{
      display: flex;
      border-bottom: 1px solid #E0E0E0;
      p:nth-child(1){
        flex:1;
        line-height:80px;
        color:#0045AF;
        font-size:18px;
        margin-left:20px;
      }
      p:nth-child(2){
        margin:20px;
      }
    }
    .rewardPointsListPage{
      flex:1;
      display: flex!important;
      flex-direction: column;
      overflow: hidden;
      padding:20px;
    }
    .queryParams-data-box{
      margin:0 0 0 20px;
      font-size:14px;
      display: inline-block;
      color:#606266;
      line-height:40px!important;
    }
  }
</style>
