<!--个人证书管理-->
<template>
    <div class="app-container myCertificate">
      <div class="page-container">
        <div class="page-form-title-box">
          <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="80px" class="form-box" style="margin-bottom:20px;">
            <el-form-item label="" prop="certTitle">
              <el-input
                v-model="queryParams.certTitle"
                placeholder="请输入证书名称"
                size="small"
              />
            </el-form-item>
            <el-form-item>
              <p class="page-inquire-common-style-button" style="margin-right:10px;" @click="handleQuery">查询</p>
              <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
            </el-form-item>
          </el-form>
        </div>
        <div class="page-content-box">
          <el-table v-loading="loading" border class="table-box" :data="recordList">
            <el-table-column label="证书名称" align="left" prop="certTitle" />
            <el-table-column label="获得日期" align="left" prop="createTime" />
            <el-table-column label="截止日期" align="left" prop="expirationTime" />
            <el-table-column label="证书编号" align="left" prop="code" />
            <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="130">
              <template slot-scope="scope">
                <div class="table-button-box">
                  <p class="table-button-null"></p>
                  <p class="table-button-p"
                     @click="lockClick(scope.row)"
                  >查看</p>
                  <p class="table-button-null"></p>
                </div>
              </template>
            </el-table-column>
          </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.page"
                      :limit.sync="queryParams.pageSize"
                      @pagination="getList"
          />
        </div>
      </div>
      <!-- 查看证书 -->
      <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body :close-on-click-modal="false">
        <div class="scrollbar-box" style="width:960px;max-height:700px;overflow-y: scroll;">
          <img style="width:960px;" :src="imgUrl">
        </div>
      </el-dialog>
    </div>
</template>

<script>
  import { examExamQueryMyCert } from "@/api/safetyEducationExam/index";
  export default {
    name: "index",
    data() {
      return {
        title:"",
        open:false,
        // 显示搜索条件
        showSearch: true,
        // 查询参数
        queryParams: {
          page: 1,
          pageSize:20,
          certTitle:''
        },
        //列表数据
        recordList:[],
        total:0,
        //证书地址
        imgUrl:"",
      }
    },
    created() {
      this.getList()
    },
    mounted(){

    },
    methods:{
      lockClick(row){
        this.title = row.certTitle;
        this.imgUrl = row.certUrl;
        this.open = true;
      },
      /** 查询数据 */
      getList() {
        this.loading = true;
        examExamQueryMyCert(this.queryParams).then( response => {
          this.recordList =  response.data.records;
          this.total =  response.data.total;
          this.loading = false;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.page = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.queryParams.bonusType = null;
        this.queryParams.semesterId = null;
        this.queryParams.statTime = null;
        this.queryParams.endTime = null;
        this.dateRange = [];
        this.recordList = [];
        this.handleQuery();
      },
    }
  }
</script>

<style scoped lang="scss">
  .myCertificate {
    .button-box{
      width:90px;
      margin:0 auto;
    }
  }
</style>

