<!--实验中心人员配置-->
<template>
  <div class="app-container approval_handle">
    <div class="approval_handle-page" v-if="pageType == 1">
      <el-form :model="queryParams" ref="queryForm" style="margin-top:20px;" :inline="true">
        <el-form-item label="关键字" prop="name">
          <el-input
            v-model="queryParams.searchValue"
            placeholder="姓名/工号/联系方式"
            clearable
            maxLength="30"
            size="small"
          />
        </el-form-item>
        <el-form-item label="所属院系" prop="deptId" class="form-item">
          <el-select v-model="queryParams.deptId" placeholder="请选择所属院系">
            <el-option
              v-for="dict in deptOptions"
              :key="dict.deptId"
              :label="dict.deptName"
              :value="dict.deptId"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <p class="inquire-button-one" @click="handleQuery">查询</p>
          <p class="reset-button-one" @click="resetQuery">重置</p>
        </el-form-item>
        <el-form-item style="float: right;">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="handleClick('','','add')"
              v-hasPermi="['airbottle:flowDetail:add']"
            >新增</el-button>
          </el-col>
        </el-form-item>
      </el-form>
      <el-table border v-loading="loading" :data="tableData">
        <el-table-column label="姓名" align="left" prop="userName"/>
        <el-table-column label="工号" align="left" prop="userNumber"></el-table-column>
        <el-table-column label="联系方式" align="left" prop="userTelephone"></el-table-column>
        <el-table-column label="所属院系" align="left" prop="deptName"></el-table-column>
        <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="120">
          <template slot-scope="scope">
            <div class="button-box">
              <p class="table-min-button"
                 @click="handleClick('',scope.row,'delete')"
                 v-hasPermi="['airbottle:flowDetail:remove']"
              >删除</p>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        :total="total"
        layout="total, prev, pager, next, sizes, jumper"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
    <!--新增 -->
    <add-page v-if="pageType==2" :pageData2="pageData2"></add-page>
  </div>
</template>

<script>
import {
  RFIDtagAdd,
  listDepartments,
  labCenterPersonList,
  labCenterPersonDelete
} from '@/api/gasManage3_0/gasManage'
import { getToken } from "@/utils/auth";
import addPage from "./labCenterPersonAdd.vue"
export default {
  name: "Approval",
  components: {
    addPage
  },
  data() {
    return {
      dialogVisible :false,
      //页面状态
      pageType:1,
      loading:false,
      headers: {
        Authorization: "Bearer " + getToken()
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize:20,
        searchValue:'',
      },
      form:{
        tagCode:'',
      },
      pageData2:{},
      total:0,
      tableData:[],
      dateRange:[],
      deptOptions:[],
    };
  },
  methods: {
      /** 查询院系列表 */
      getDeptList() {
        listDepartments().then(response => {
          this.$set(this, 'deptOptions', response.data)
        });
      },
      /** 查询楼栋列表  */
      getBuildings(id) {
        if(id) {
          this.$set(this.form, 'buildId', '');//楼栋
          this.buildings = [];
          this.$set(this.form, 'floorId', '');//楼层
          this.floors = [];
          this.$set(this.form, 'layoutId', '');//房间
          this.layoutLists = [];
          listbuildings(id).then(response => {
            this.buildings = response.data;
          });
        }
      },
      handleClick(index,row,doType){

        let _this=this;
        if(doType=='add'){//添加
          _this.pageType=2;
        }else if(doType=='delete'){//删除
          this.$confirm('是否确认删除当前数据项?', "警告", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          }).then(function() {
            labCenterPersonDelete(row.id).then( response => {
              if(response.code==200){
                _this.getList();
                _this.msgSuccess("删除成功");
              }
            });
          }).then(() => {

          }).catch(() => {});
        }else if(doType=='back'){//重新申请
          _this.pageType=1;
        }
      },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.searchValue = "";
      this.queryParams.deptId = "";
      this.handleQuery();
    },
    getList(){
        let _this=this;
      labCenterPersonList(_this.queryParams).then( response => {
          let res=response.rows;
          _this.tableData=res;
          _this.total=response.total;
        });

      },
      submitForm(){
        let _this = this;
        RFIDtagAdd(_this.form).then(res => {
          this.$message({
            type: 'success',
            message: '操作成功!',
            duration:2000,
            onClose:function(){
              _this.backPage();
              _this.loading = false;
            }
          });
        });
      },


  },
  mounted() {
    this.getDeptList();
    this.getList();
  }
};
</script>

<style scoped lang="scss">
  .approval_handle {
    display: flex!important;
    flex-direction: column;
    overflow: hidden;
    .approval_handle-page{
      flex:1;
      display: flex!important;
      flex-direction: column;
      box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
      padding:20px 20px 20px!important;
      border-radius:10px;
      overflow: hidden;
      .button-box{
        width:200px;
        display: flex;
      }
    }
    .entering_t{
      font-size: 16px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #333333;
      line-height: 16px;
      margin: 36px auto 25px;
      text-align: center;
    }
    .entering_img{
      width: 288px;
      height: 140px;
    }
    .entering_input{
      width: 288px;
    }

  }
</style>
