<!-- 选择用户 -->
<template>
  <div class="page-container selectUser-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" multiple placeholder="学年" style="width: 120px">
            <el-option
              v-for="dict in optionListA"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </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 optionListB"
              :key="dict.deptId"
              :label="dict.deptName"
              :value="dict.deptId"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="" prop="queryParamsData3">
          <el-select v-model="queryParams.queryParamsData3" multiple placeholder="用户类别" style="width: 120px">
            <el-option
              v-for="dict in optionListC"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="" prop="queryParamsData5">
          <el-select v-model="queryParams.queryParamsData5" placeholder="专业" style="width: 140px">
            <el-option
              v-for="dict in optionListE"
              :key="dict.id"
              :label="dict.disciplineName"
              :value="dict.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="" prop="queryParamsData6">
          <el-input
            maxLength="30"
            v-model="queryParams.queryParamsData6"
            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-submit-common-style-button"
           style="float: right;"
           @click="checkButton()"
        >确定</p>
      </el-form>
    </div>
    <div class="page-content-box">
      <el-table class="table-box" v-loading="loading" border :data="dataList"
                ref="multipleTable" :row-key="getRowKey" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" :reserve-selection="true"></el-table-column>
        <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/>
        <el-table-column label="学年" prop="content" width="200" show-overflow-tooltip/>
        <el-table-column label="学院单位" prop="content" width="200" show-overflow-tooltip/>
      </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 { examElDisciplineTypeList,systemDeptCurrentDept, } from "@/api/safetyEducationExaminationNew/index";
  export default {
    name: 'addPage',
    props: {
      propsData: {}
    },
    data() {
      return {
        //页面遮罩
        loading:false,
        //下拉列表数据
        optionListA:[],
        optionListB:[],
        optionListC:[],
        optionListD:[],
        optionListE:[],
        //查询条件
        queryParams:{
          page:1,
          pageSize:20,
          queryParamsData1:null,
          queryParamsData2 :null,
          queryParamsData3 :null,
          queryParamsData4 :null,
          queryParamsData5 :null,
          queryParamsData6 :'',
        },
        //列表数据
        dataList:[{}],
        //数据数量
        total:0,
        //存储所有被勾选的数据
        multipleSelection: [],
      }
    },
    created() {

    },
    mounted() {
      this.examElDisciplineTypeList();
      this.systemDeptCurrentDept();
    },
    methods: {
      // 提交按钮
      checkButton() {
        if(!this.multipleSelection[0]){
          this.msgError('请勾选用户')
          return
        }
        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 :null,
          queryParamsData5 :null,
        });
        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);
        });
      },
      //查询全部专业类别
      examElDisciplineTypeList(){
        examElDisciplineTypeList({}).then(response => {
          this.$set(this,'optionListE',response.data);
        });
      },
      //学院列表
      systemDeptCurrentDept(){
        systemDeptCurrentDept({}).then(response => {
          this.$set(this,'optionListB',response.data);
        });
      },
      getRowKey(row) {
        return row.id;
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
        console.log('当前所有选中的数据：', this.multipleSelection);
      },
    }
  }
</script>

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