<!--气瓶申请-->
<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="dateRange">
          <el-date-picker
            :clearable="false"
            v-model="dateRange"
            size="small"
            style="width: 240px"
            value-format="yyyy-MM-dd"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </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" width="340">
          <template slot-scope="scope">
              <span>未派送 - {{scope.row.wpsNum}} / 待入库 - {{scope.row.drkNum}} / 已入库 - {{scope.row.storageNum}} / 已拒收 - {{scope.row.refuseNum}}</span>
          </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-hasPermi="['airbottle:taskManage:query']"
                 @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.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
     <!--详情页面-->
    <detail-page v-if="pageType==3" :pageData2="pageData2"></detail-page>
  </div>
</template>

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


  },
  methods: {
      handleClick(index,row,doType){
        let _this=this;
        if(doType=='apply'){//申请
          _this.pageType=2;
        }else if(doType=='detail'){//查看
          _this.pageData2.id=row.id;
          _this.pageType=3;
        }else if(doType=='back'){//返回
          _this.pageType=1;
        }else if(doType=='again'){//重新申请
          _this.pageType=2;
        }
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.queryParams.searchValue = "";
        this.dateRange=[];
        this.queryParams.startTime=null;
        this.queryParams.endTime=null
        this.handleQuery();
      },
      getList(){
        let _this=this;
        if(this.dateRange&&this.dateRange.length>0) {
          this.queryParams.startTime=this.dateRange[0]
          this.queryParams.endTime=this.dateRange[1]
        } else {
          this.queryParams.startTime=null;
          this.queryParams.endTime=null
        }
        gasApplyList(_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;

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

  }
</style>
