<template>
  <div class="checkUserPage">
    <el-form :model="queryParams" class="form-box" ref="queryForm" :inline="true">
      <el-form-item label="关键字" prop="searchValue" label-width="80px">
        <el-input
          maxLength="30"
          v-model="queryParams.searchValue"
          placeholder="实验室/房间号/姓名"
          clearable
          style="width: 200px"/>
      </el-form-item>
      <el-form-item label="学院" prop="deptId" label-width="50px">
        <el-select v-model="queryParams.deptId" clearable placeholder="请选择学院">
          <el-option
            v-for="item in deptSelectList"
            :key="item.deptId"
            :label="item.deptName"
            :value="item.deptId">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <p class="inquire-button-one" @click="handleQuery" style="margin-right:10px;">查询</p>
        <p class="reset-button-one" @click="resetQuery">重置</p>
      </el-form-item>
      <el-form-item style="float: right;" v-hasPermi="['check:set:query']">
        <el-col :span="1.5">
          <p class="inquire-button-one"
             style="width:100px;"
             @click="configButton(1)"
          >检查者配置</p>
        </el-col>
      </el-form-item>
    </el-form>
    <el-table  border :data="tableList" ref="multipleTable">
      <el-table-column label="序号" align="center"  type="index" width="60" />
      <el-table-column label="实验室" align="center" prop="subName" show-overflow-tooltip/>
      <el-table-column label="学院" align="center" prop="deptName" show-overflow-tooltip width="300"/>
      <el-table-column label="检查者" align="center" prop="nickNames" show-overflow-tooltip width="500"/>
      <el-table-column label="操作人" align="center" prop="createName" show-overflow-tooltip width="200"/>
      <!--<el-table-column label="操作时间" align="center" prop="createTime" show-overflow-tooltip width="300"/>-->
    </el-table>
    <pagination :page-sizes="[20, 30, 40, 50]"
                v-show="total>0"
                :total="total"
                :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize"
                @pagination="getList"
    />
    <configDialog v-if="configDialogType" :configDialogData="queryParams"></configDialog>
  </div>
</template>

<script>
  import { listDepartments } from "@/api/system/dept";
  import { checkStaffList } from '@/api/safetyCheck/index'
  import configDialog from './configDialog.vue'
  export default {
    name: 'checkUserPage',
    components: {
      configDialog
    },
    data(){
      return{
        // 组件数据
        configDialogType:false,
        configDialogData:{
          configType:1,//1.检查人员配置 2.整改人员配置
        },
        //查询数据
        deptSelectList:[],
        queryParams:{
          pageNum:1,
          pageSize:20,
          staffType:1,
          searchValue:"",
          deptId:""
        },
        tableList:[{}],
        total:0,
      }
    },
    created(){

    },
    mounted(){
      this.listDepartments();
      this.getList();
    },
    methods:{
      //配置按钮
      configButton(type){
        console.log('type',type)
        if(type == 1){
          this.$set(this,'configDialogType',true);
        }else if(type == 2){
          this.$set(this,'configDialogType',false);
        }else if(type == 3){
          this.getList();
          this.$set(this,'configDialogType',false);
        }
      },
      //获取数据列表
      getList(){
        checkStaffList(this.queryParams).then(response => {
          this.total = response.data.total;
          this.tableList = response.data.records;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.$set(this.queryParams,'pageNum',1);
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.$set(this,'queryParams',{
          pageNum:1,
          pageSize:20,
          staffType:1,
          searchValue:"",
          deptId:""
        });
        this.handleQuery();
      },
      //获取学院列表
      listDepartments(){
        listDepartments().then(response => {
          this.deptSelectList = response.data;
        });
      },
    }
  }
</script>

<style scoped lang="scss">
  .checkUserPage{
    padding:20px;
    flex:1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
</style>
