<!--预案执行记录-->
<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="zgType" label-width="80px">
          <el-select v-model="queryParams.riskAttribute" placeholder="请选择" clearable size="small">
            <el-option label="全部" value="" />
            <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="groupName"/>
        <el-table-column label="实验室名称" align="left" prop="subjectName"></el-table-column>
        <el-table-column label="预案属性" align="left" prop="riskAttribute">
          <template slot-scope="scope">
            <span>{{scope.row.riskAttribute==1?'火灾预案':(scope.row.riskAttribute==2?'非火灾预案':'')}}</span>
          </template>
        </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-hasPermi="['laboratory:hardware5:edit']" @click="handleClick('',scope.row,'detail')">查看</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>
    <!--详情页面-->
    <detail-page v-if="pageType==2" :pageData="pageData"></detail-page>
  </div>
</template>

<script>
import {
  riskExeRecordList,
} from '@/api/laboratory/subject'
import detailPage from "./planExecuteRecordDetail"
export default {
  name: "Approval",
  components: {
    detailPage
  },
  data() {
    return {
      dialogVisible :false,
      //页面状态
      pageType:1,
      loading:false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize:20,
        searchValue:'',
        riskAttribute:'',
      },
      form:{
        tagCode:'',
      },
      total:0,
      pageData:{},
      tableData:[],
    };
  },
  methods: {

      handleClick(index,row,doType){

        let _this=this;
        if(doType=='detail'){//详情
          _this.pageType=2;
          _this.pageData=row;

        }else if(doType=='back'){//返回
          _this.pageType=1;
        }
      },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.searchValue = "";
      this.queryParams.riskAttribute = "";
      this.handleQuery();
    },
    getList(){
        let _this=this;
      riskExeRecordList(_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;
    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>
