<!--个人证书管理-->
<template>
    <div class="app-container myCertificate">
      <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="请输入证书名称"
            clearable
            size="small"
          />
        </el-form-item>
        <el-form-item>
          <p class="inquire-button-one" style="margin-right:10px;" @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="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="button-box">
              <p class="table-min-button"
                 style="margin-right:10px;"
                 @click="lockClick(scope.row)"
              ><i class="el-icon-view"></i>查看</p>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        layout="total, prev, pager, next, sizes, jumper"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />

      <!-- 查看证书 -->
      <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
        <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 { queryMyCert } from "@/api/myPage/myCertificate";
  export default {
    name: "index",
    data() {
      return {
        title:"",
        open:false,
        // 显示搜索条件
        showSearch: true,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          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;
        queryMyCert(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("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 {
    display: flex!important;
    flex-direction: column;
    box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
    padding:20px!important;
    flex:1;
    .button-box{
      width:90px;
      margin:0 auto;
    }
  }
</style>

