<template>
    <div>
      <h3>检查项</h3>
      <el-table v-loading="loading" :data="inforList">
        <el-table-column label="检查项任务编码" align="center" prop="fCheckTaskCode" />
        <el-table-column label="检查项唯一编码" align="center" prop="fUniqueCode" />
        <el-table-column label="检查项名称" align="center" prop="fCheckTimeName" />
        <el-table-column label="检查对象分类" align="center" prop="fCheckClassification" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <span v-if="scope.row.fCheckClassification">{{ scope.row.fCheckClassification }}</span>
            <span v-else>-</span>
          </template>
        </el-table-column>
        <el-table-column label="隐患级别" align="center" prop="fHazardLevel">
          <template slot-scope="scope">
            <span v-if="scope.row.fHazardLevel">{{ scope.row.fHazardLevel }}</span>
            <span v-else>-</span>
          </template>
        </el-table-column>
        <el-table-column label="启用状态" align="center" prop="fEnableState" :formatter="fEnableStateFormat" />
        <el-table-column label="检查依据" align="center" prop="fCheckBasis" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <span v-if="scope.row.fCheckBasis">{{ scope.row.fCheckBasis }}</span>
            <span v-else>-</span>
          </template>
        </el-table-column>
        <el-table-column label="隐患分类分级标准" align="center" prop="hazardName" width="150" :show-overflow-tooltip="true"/>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-document"
              @click="handleDetail(scope.row)"
            >详情</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        :pageSizes="[5,10, 20, 30, 50]"
        @pagination="getList"
      />

      <!-- 详情 -->
      <DetailInfo ref="detail"/>
    </div>
</template>

<script>
  import { listInfor } from "@/api/supervision/inspect";
  import DetailInfo from "../../inspect/components/DetailInfo";
  export default {
    name: "inspect",
    props:{
      fCheckTaskCode:{
        type: String
      }
    },
    components:{
      DetailInfo
    },
    data(){
        return{
          loading: false,
          total: 0,
          inforList: [],
          queryParams: {
            pageNum: 1,
            pageSize: 5,
          },
          // 启用状态,0-启用,1-禁用字典
          fEnableStateOptions: [],
          // 删除标记,0-可用,1-已删除字典
          fDeleteFlagOptions: [],
          fTypeCodeOptions: []
        }
    },
    created() {
      this.queryParams.fCheckTaskCode = this.fCheckTaskCode;
      this.getList();
      this.getDicts("t_enable_state").then(response => {
          this.fEnableStateOptions = response.data;
      });
      this.getDicts("t_delete_flag").then(response => {
          this.fDeleteFlagOptions = response.data;
      });
      this.getDicts("t_type_code").then(response => {
          this.fTypeCodeOptions = response.data;
      });
    },
    methods:{
      getList() {
        this.loading = true;
        listInfor(this.queryParams).then(response => {
          this.inforList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 启用状态,0-启用,1-禁用字典翻译
      fEnableStateFormat(row, column) {
        return this.selectDictLabel(this.fEnableStateOptions, row.fEnableState);
      },
      // 删除标记,0-可用,1-已删除字典翻译
      fDeleteFlagFormat(row, column) {
        return this.selectDictLabel(this.fDeleteFlagOptions, row.fDeleteFlag);
      },
      // 检查对象分类
      fTypeCodeFormat(row, column) {
        const type = this.selectDictLabel(this.fTypeCodeOptions, row.fCheckClassification);
        return type ? type : "-";
      },
      //详情
      handleDetail(row){
        this.$refs.detail.getDetailInfo(row.fInsInsListInforId);
      },
    }
  }
</script>

<style scoped>

</style>