<!-- 选择证书 -->
<template>
  <div class="page-container selectCertificate-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="queryParamsData1">
          <el-select v-model="queryParams.queryParamsData1" placeholder="是否共享" style="width: 120px">
            <el-option label="共享" value="1"/>
            <el-option label="不共享" value="2"/>
          </el-select>
        </el-form-item>
        <el-form-item label="" prop="queryParamsData2">
          <el-select v-model="queryParams.queryParamsData2" placeholder="考试类型" style="width: 140px">
            <el-option
              v-for="dict in optionListA"
              :key="dict.id"
              :label="dict.examTypeName"
              :value="dict.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="" prop="queryParamsData3">
          <el-select v-model="queryParams.queryParamsData3" placeholder="颁发单位" style="width: 120px">
            <el-option
              v-for="dict in optionListB"
              :key="dict.deptId"
              :label="dict.deptName"
              :value="dict.deptId"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="" prop="queryParamsData4">
          <el-input
            maxLength="30"
            v-model="queryParams.queryParamsData4"
            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>
      </el-form>
    </div>
    <div class="page-content-box">
      <el-table class="table-box" v-loading="loading" border :data="dataList">
        <el-table-column label="证书模板名称" prop="name"  show-overflow-tooltip/>
        <el-table-column label="适用考试类型" prop="content" width="200" show-overflow-tooltip/>
        <el-table-column label="是否共享" prop="content" width="200" show-overflow-tooltip>
          <template slot-scope="scope">
            <span style="padding:2px 10px;border:1px solid rgb(1, 131, 251);border-radius:4px;color: rgb(1, 131, 251);background-color:rgba(1, 131, 251,0.2)">共享</span>
            <span style="padding:2px 10px;border:1px solid rgb(245, 154, 35);border-radius:4px;color: rgb(245, 154, 35);background-color:rgba(245, 154, 35,0.2)">不共享</span>
          </template>
        </el-table-column>
        <el-table-column label="颁发单位" prop="content" width="200" show-overflow-tooltip/>
        <el-table-column label="更新人" prop="content" width="200" show-overflow-tooltip/>
        <el-table-column label="操作" width="200" show-overflow-tooltip>
          <template slot-scope="scope">
            <div class="table-button-box">
              <p class="table-button-null"></p>
              <p class="table-button-p"
                 @click="checkButton(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"
                  :page.sync="queryParams.page"
                  :limit.sync="queryParams.pageSize"
                  @pagination="getList"
      />
    </div>
  </div>
</template>

<script>
  import { examElExamTypeList,systemDeptCurrentDept, } from "@/api/safetyEducationExaminationNew/index";
  export default {
    name: 'addPage',
    props: {
      propsData: {}
    },
    data() {
      return {
        //页面遮罩
        loading:false,
        //下拉列表数据
        optionListA:[],
        optionListB:[],
        //查询条件
        queryParams:{
          page:1,
          pageSize:20,
          queryParamsData1:null,
          queryParamsData2 :null,
          queryParamsData3 :null,
          queryParamsData4 :'',
        },
        //列表数据
        dataList:[{}],
        //数据数量
        total:0,
      }
    },
    created() {

    },
    mounted() {
      this.examElExamTypeList();
      this.systemDeptCurrentDept();
    },
    methods: {
      // 提交按钮
      checkButton(row) {
        this.$parent.$parent.drawerOffButton()
      },
      //查询按钮
      handleQuery(){
        this.$set(this.queryParams,'page',1);
        this.getList();
      },
      //重置按钮
      resetQuery(){
        this.$set(this,'queryParams',{
          page:1,
          pageSize:20,
          queryParamsData1:null,
          queryParamsData2 :null,
          queryParamsData3 :null,
          queryParamsData4 :'',
        });
        this.getList();
      },
      //获取数据列表
      getList(){
        this.$set(this,'loading',true);
        let obj = JSON.parse(JSON.stringify(this.queryParams))
        getListFunction(obj).then(response => {
          this.$set(this,'loading',false);
          this.$set(this,'dataList',response.data.records);
          this.$set(this,'total',response.data.total);
        });
      },
      //查询全部考试类型
      examElExamTypeList(){
        examElExamTypeList({}).then(response => {
          this.$set(this,'optionListA',response.data);
        });
      },
      //学院列表
      systemDeptCurrentDept(){
        systemDeptCurrentDept({}).then(response => {
          this.$set(this,'optionListB',response.data);
        });
      },
    }
  }
</script>

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