<!-- 学习情况 -->
<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="searchValue">
          <el-input
            maxLength="30"
            v-model="queryParams.searchValue"
            placeholder="姓名/学工号"
            style="width: 140px"
          />
        </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" v-loading="loading" 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="submitTime" width="200" show-overflow-tooltip>
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.submitTime,"{y}-{m}-{d} {h}:{i}") }}</span>
          </template>
        </el-table-column>
        <el-table-column label="学时" prop="durationText" width="200" show-overflow-tooltip/>
        <el-table-column label="积分" prop="score" width="200" show-overflow-tooltip/>
        <el-table-column label="是否完成" prop="resultStatus" width="200" show-overflow-tooltip>
          <template slot-scope="scope">
            <span v-if="scope.row.resultStatus == 0">已完成</span>
            <span v-if="scope.row.resultStatus == 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 {
    systemUserGetCategories,systemUserGetAcademicYear,
    examElExamResultScorePage,examElDisciplineTypeList,systemDeptCurrentDept,
  } from "@/api/safetyEducationExaminationNew/index";
  export default {
    name: 'addPage',
    props: {
      drawerPropsData: {}
    },
    data() {
      return {
        //页面遮罩
        loading:false,
        //下拉列表数据
        optionListA:[],
        //查询条件
        queryParams:{
          page:1,
          pageSize:20,
          deptId:null,
          academicYear :null,
          disciplineId :null,
          userType :null,
          passStatus :null,
          searchValue :'',
        },
        //列表数据
        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(this.queryParams))
          if(this.dateRange[0]){
            obj.startTime = this.dateRange[0]+'T00:00:00'
            obj.endTime = this.dateRange[1]+'T23:59:59'
          }else{
            obj.startTime = "";
            obj.endTime = "";
          }
          self.download('/exam/elExamResult/score-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,
          searchValue :'',
        });
        this.getList();
      },
      //获取数据列表
      getList(){
        console.log('drawerPropsData',this.drawerPropsData)
        this.$set(this,'loading',true);
        let obj = JSON.parse(JSON.stringify(this.queryParams))
        obj.examId = this.drawerPropsData.examId
        examElExamResultScorePage(obj).then(response => {
          this.$set(this,'loading',false);
          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>
