<!--用气申请-->
<template>
  <div class="app-container approval_handle">
    <div class="approval_handle-page" v-if="pageType == 1">
      <div class="top-click-img-box">
        <img src="@/assets/ZDimages/gasManage3_0/icon_banner_yqsq.png" alt="">
          <p v-hasPermiRouter="['airbottle:useAgsApplyManage:add']" @click="handleClick('','','apply')">开始申请</p>
      </div>
      <el-form :model="queryParams" ref="queryForm" style="margin-top:20px;" :inline="true">
        <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>
      <el-table border v-loading="loading" :data="tableData">
        <el-table-column label="申请实验室" align="left" prop="location"/>
        <el-table-column label="申请时间" align="left" prop="createTime"></el-table-column>
        <el-table-column label="使用气体" align="left" prop="useGasName"></el-table-column>
        <el-table-column label="使用期限" align="left" prop="startTime">
          <template slot-scope="scope">
            {{scope.row.startTime}}至{{scope.row.endTime}}
          </template>
        </el-table-column>
        <el-table-column label="状态" align="left" prop="auditStatus">
          <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="table-button-box">
              <p class="table-button-null"></p>
              <p class="table-button-p"
                 v-hasPermiRouter="['airbottle:useAgsApplyManage:detail']"
                 @click="handleClick('',scope.row,'detail')"
              >查看</p>
              <p class="table-button-null"></p>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <pagination :page-sizes="[20, 30, 40, 50]"
        :total="total"
        layout="total, prev, pager, next, sizes, jumper"
        :page.sync="queryParams.page"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
    <!--添加页面-->
    <add-page v-if="pageType==2" :pageData="pageData"></add-page>
     <!--详情页面-->
    <detail-page v-if="pageType==3" :pageData2="pageData2"></detail-page>
  </div>
</template>

<script>
import { useAgsApplyList,} from '@/api/gasManage3_0/index'
import { getToken } from "@/utils/auth";
import addPage from "./useGasAdd.vue"
import detailPage from "./useGasDetail.vue"
export default {
  name: "Approval",
  components: {
    addPage,
    detailPage
  },
  data() {
    return {
      //页面状态
      pageType:1,
      loading:false,
      headers: {
        Authorization: "Bearer " + getToken()
      },
      // 查询参数
      queryParams: {
        page: 1,
        pageSize:20,
        auditStatus:'',
      },
      total:0,
      tableData:[],
      pageData:{},//0添加1编辑
      pageData2:{},
    };
  },
  methods: {
      handleClick(index,row,doType){
        let _this=this;
        if(doType=='apply'){//申请
          _this.pageData.status=0;
          _this.pageType=2;
        }else if(doType=='detail'){//查看
          _this.pageData2.id=row.id;
          _this.pageData2.remark=row.remark;
          _this.pageType=3;
        }else if(doType=='back'){//返回
          _this.pageType=1;
        }else if(doType=='again'){//重新申请
          _this.pageType=2;
          _this.pageData.status=1;
          _this.pageData.id=row;
        }
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.page = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.queryParams.auditStatus = "";
        this.handleQuery();
      },
      getList(){
        let _this=this;
        useAgsApplyList(_this.queryParams).then( response => {
          let res=response.rows;
          _this.tableData=res;
          _this.total=response.total;
        });
      },
  },
  mounted() {
    this.getList()
  }
};
</script>

<style scoped lang="scss">
  .approval_handle {
    display: flex!important;
    flex-direction: column;
    .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;
      .top-click-img-box{
        width:1536px;
        height:250px;
        margin:0 auto 20px;
        position: relative;
        img{
          width:1536px;
          height:250px;
        }
        p{
          margin:0;
          position: absolute;
          left:294px;
          bottom:24px;
          width:200px;
          height:50px;
          border-radius:25px;
          line-height:50px;
          font-size:24px;
          text-align: center;
          color:#fff;
          font-weight: 500;
          border: 1px solid #69eeff;
          cursor: pointer;
        }
      }
      .form-box{
      }
      .button-box{
        width:200px;
        display: flex;
      }
    }

  }
</style>
