<!--资格审核-->
<template>
  <div class="check">
    <div class="check-page" v-if="pageType == 1">
      <el-form :model="queryParams" ref="queryForm" style="margin-top:20px;" :inline="true">
        <el-form-item label="关键字" prop="searchValue">
          <el-input
            v-model="queryParams.searchValue"
            placeholder="申请人/联系电话/实验地点"
            clearable
            maxLength="30"
            size="small"
          />
        </el-form-item>
        <el-form-item label="审核状态" prop="zgType" label-width="80px">
          <el-select v-model="queryParams.auditStatus" placeholder="请选择" clearable size="small">
            <el-option label="待审核" value="0" />
            <el-option label="已通过" value="1" />
            <el-option label="未通过" value="2" />
          </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 label="" prop="title" style="float: right">
          <p  class="reset-button-one" @click="backPage">返回</p>
        </el-form-item>
      </el-form>
      <el-table border v-loading="loading" :data="tableData">
        <el-table-column label="申请人" align="left" prop="applyUser"/>
        <el-table-column label="联系方式" align="left" prop="phone"></el-table-column>
        <el-table-column label="实验地点" align="left" prop="location"></el-table-column>
        <el-table-column label="气瓶数量" align="left" prop="bottleNumber"></el-table-column>
        <el-table-column label="申请时间" align="left" prop="createTime"></el-table-column>
        <el-table-column label="审核状态" align="left" prop="remark">
          <template slot-scope="scope">
            <p :class="scope.row.remark == 0?'color_warn':(scope.row.remark == 1?'color_14AE10':(scope.row.remark == 2?'color_red':''))">{{scope.row.remark == 0?'待审核':(scope.row.remark == 1?'通过':(scope.row.remark == 2?'驳回':''))}}</p>
          </template>
        </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,'audit')"
                 v-hasPermi="['airbottle:qualificationApplyManage:query']"
              >审核</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>
    <!--审核页面-->
    <check-page v-if="pageType==2" :pageData2="pageData2"></check-page>

  </div>
</template>

<script>
import { qualificationCheckList } from '@/api/gasManage3_0/gasManage'
import { getToken } from "@/utils/auth";
import checkPage from "./qualificationManageCheck.vue"
export default {
  name: "Approval",
  components: {
    checkPage
  },
  data() {
    return {
      //页面状态
      pageType:1,
      loading:false,
      headers: {
        Authorization: "Bearer " + getToken()
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize:20,
        searchValue:'',
        auditStatus:'',
      },
      total:0,
      tableData:[],
      dateRange:[],
      pageData2:{},
    };


  },
  methods: {
    handleClick(index,row,doType){
      let _this=this;
      if(doType=='audit'){//申请
        _this.pageData2.id=row.id;
        _this.pageType=2;
      }else if(doType=='detail'){//查看
        _this.pageType=3;

      }else if(doType=='back'){//返回
        _this.pageType=1;
      }else if(doType=='again'){//重新申请
        _this.pageType=2;
      }
    },
    //返回
    backPage(){
      this.$parent.handleClick('','','back');
      this.$parent.getList();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.searchValue = "";
      this.queryParams.auditStatus = "";
      this.handleQuery();
    },
    getList(){
      let _this=this;
      qualificationCheckList(_this.queryParams).then( response => {
        let res=response.rows;
        _this.tableData=res;
        _this.total=response.total;
      });
    },
  },
  mounted() {
    this.getList()
  }
};
</script>

<style scoped lang="scss">
.check {
  flex: 1;
  display: flex!important;
  flex-direction: column;
  .check-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;

    .button-box{
      width:200px;
      display: flex;
    }
  }

}
</style>
