<!--气瓶使用-->
<template>
  <div class="app-container approval_handle">
    <div class="approval_handle-page">
      <template>
        <el-tabs v-model="activeName"  @tab-click="handleTabClick">
          <el-tab-pane label="领用气瓶" name="1"></el-tab-pane>
          <el-tab-pane label="归还气瓶" name="2"></el-tab-pane>
        </el-tabs>
      </template>
      <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="createTime"></el-table-column>
        <el-table-column label="气瓶规格" align="left" prop="createTime"></el-table-column>
        <el-table-column label="当前气压" align="left" prop="createTime"></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"
                 v-if="activeName==1"
                 v-hasPermi="['airbottle:taskManage:query']"
                 @click="handleClick('',scope.row,'receive')"
              >领用</p>
              <p class="table-min-button"
                 v-if="activeName==2"
                 v-hasPermi="['airbottle:taskManage:query']"
                 @click="handleClick('',scope.row,'return')"
              >归还</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>
    <!--    弹窗-->
    <el-dialog :title=dialogTitle :visible.sync="dialogVisible" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <div style="margin-bottom: 20px">您在领用气瓶前需要确认气表压力与系统显示的压力值是否一致，如不一致则需要在下方填写实际气压值。</div>
        <el-input v-model="form.txt" placeholder="请输入气表实际压力，精确到小数点后一位" />
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取消</el-button>
        <el-button type="primary" @click="submitForm">领用</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { gasApplyList, } from '@/api/gasManage3_0/gasManage'
import { getToken } from "@/utils/auth";
import { mangerVoice } from '@/api/laboratory/subject'
export default {
  name: "Approval",
  data() {
    return {
      activeName:'1',
      dialogTitle:'领用气瓶提示',
      dialogVisible:false,
      //页面状态
      pageType:1,
      loading:false,
      headers: {
        Authorization: "Bearer " + getToken()
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize:20,
        remark:'login',
        searchValue:'',
        startTime:'',
        endTime:'',
      },
      total:0,
      tableData:[{}],
      dateRange:[],
      pageData2:{},
      form:{

      },
      rules:{
        txt:[
          {required: true, message: '请输入播放文字', trigger: 'blur'},
          { required: true, message: "请输入播放文字", validator: this.spaceJudgment, trigger: "blur" }
        ],
      },
    };


  },
  methods: {
      handleTabClick(tab, event) {
        console.log(tab, event);
      },
      handleClick(index,row,doType){
        let _this=this;
        if(doType=='receive'){//领用
          this.dialogTitle='领用气瓶提示';
          this.dialogVisible=true;

        }else if(doType=='return'){//归还
          this.$confirm('请确认已将气瓶放置在气瓶存放点，您是否确认归还?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {

          }).catch(() => {});
        }
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.queryParams.searchValue = "";
        this.dateRange=[];
        this.queryParams.startTime=null;
        this.queryParams.endTime=null
        this.handleQuery();
      },
      // 取消按钮
      cancel() {
        this.form = {};
        this.dialogVisible = false;
      },
      /*提交*/
      submitForm(){
        this.$refs["form"].validate(valid => {
          if (valid) {
            let id = this.subId;

          }
        });
      },
      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>
