<!-- 学习情况 -->
<template>
  <div class="page-container academicPerformance-addPage">
    <div class="page-form-title-box">
      <el-form :model="queryParams" class="form-box" ref="queryForm"
               :inline="true" style="width:100%;">
        <!--<el-form-item label="" prop="passStatus">-->
          <!--<el-select v-model="queryParams.passStatus" placeholder="是否完成" style="width: 120px">-->
            <!--<el-option label="已完成" value="1"/>-->
            <!--<el-option label="未完成" value="0"/>-->
          <!--</el-select>-->
        <!--</el-form-item>-->
        <el-form-item label="" prop="deptId">
          <el-cascader
            style="width: 180px"
            v-model="queryParams.deptId"
            :options="optionListA"
            :props="{
                    emitPath:false,
                    checkStrictly: true,
                    value: 'deptId',
                    label: 'deptName',
                    children: 'child',
                  }"
            :show-all-levels="false"
            filterable
            placeholder="学院单位"
          ></el-cascader>
        </el-form-item>
        <el-form-item label="" prop="keyword">
          <el-input
            maxLength="30"
            v-model="queryParams.keyword"
            placeholder="姓名/学工号"
            style="width: 240px"
          />
        </el-form-item>
        <p class="page-inquire-common-style-button" @click="handleQuery">查询</p>
        <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
        <p class="page-add-common-style-button" style="float: right;" @click="exportButton()">导出</p>
      </el-form>
    </div>
    <div class="page-content-box">
      <el-table class="table-box"  border :data="dataList">
        <el-table-column label="姓名" prop="userName"  show-overflow-tooltip/>
        <el-table-column label="学工号" prop="account" width="140" show-overflow-tooltip/>
        <el-table-column label="学院单位" prop="deptName" width="240" show-overflow-tooltip/>
        <el-table-column label="完成时间" prop="completeTime" width="200" show-overflow-tooltip>
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.completeTime,"{y}-{m}-{d} {h}:{i}") }}</span>
          </template>
        </el-table-column>
        <el-table-column label="学时" prop="rewardCreditHours" width="200" show-overflow-tooltip/>
        <el-table-column label="积分" prop="rewardPoints" width="200" show-overflow-tooltip/>
        <!--<el-table-column label="是否完成" prop="passStatus" width="200" show-overflow-tooltip>-->
          <!--<template slot-scope="scope">-->
            <!--<span>{{ scope.row.passStatus == 1?'已完成':'未完成' }}</span>-->
          <!--</template>-->
        <!--</el-table-column>-->
      </el-table>
      <pagination :page-sizes="[20, 30, 40, 50]"
                  v-show="total>0"
                  :total="total"
                  :page.sync="queryParams.page"
                  :limit.sync="queryParams.pageSize"
                  @pagination="getList"
      />
    </div>
  </div>
</template>

<script>
  import {
    examElExamResultRewardPage,systemDeptCurrentDept,
  } from "@/api/safetyEducationExaminationNew/index";
  export default {
    name: 'addPage',
    props: {
      drawerPropsData: {}
    },
    data() {
      return {
        //下拉列表数据
        optionListA:[],
        //查询条件
        queryParams:{
          page:1,
          pageSize:20,
          deptId:null,
          academicYear :null,
          disciplineId :null,
          userType :null,
          passStatus :null,
          keyword :'',
        },
        //列表数据
        dataList:[],
        //数据数量
        total:0,
      }
    },
    created() {

    },
    mounted() {
      this.getList();
      this.systemDeptCurrentDept();
    },
    methods: {
      //导出
      exportButton(){
        let self = this;
        self.$confirm(`确认导出数据?`, "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(async () => {
          let obj = JSON.parse(JSON.stringify(self.queryParams))
          obj.examId = this.drawerPropsData.examId
          self.download('/exam/elExamResult/reward-export', {...obj}, '学习情况-'+this.drawerPropsData.examName+'.xlsx')
        }).catch(() => {})
      },
      //查询按钮
      handleQuery(){
        this.$set(this.queryParams,'page',1);
        this.getList();
      },
      //重置按钮
      resetQuery(){
        this.$set(this,'queryParams',{
          page:1,
          pageSize:20,
          deptId:null,
          academicYear :null,
          disciplineId :null,
          userType :null,
          passStatus :null,
          keyword :'',
        });
        this.getList();
      },
      //获取数据列表
      getList(){
        let obj = JSON.parse(JSON.stringify(this.queryParams))
        obj.examId = this.drawerPropsData.examId
        examElExamResultRewardPage(obj).then(response => {
          this.$set(this,'dataList',response.data.records);
          this.$set(this,'total',response.data.total);
        });
      },
      //学院列表
      systemDeptCurrentDept(){
        systemDeptCurrentDept({}).then(response => {
          const list = response.data || [];
          this.formatTreeData(list);
          this.$set(this,'optionListA',list);
        });
      },
    }
  }
</script>

<style scoped lang="scss">
  .academicPerformance-addPage {
    flex:1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
</style>
