<template>
  <el-dialog title="详情" :visible.sync="detailOpen" width="1000px" append-to-body destroy-on-close :close-on-click-modal="false">

    <el-form label-width="140px">
      <el-row class="el-row-table">
        <el-col :span="12">
          <el-form-item label="隐患唯一编码">
            <span v-if="detailInfo.fHazardUniqueCode">{{ detailInfo.fHazardUniqueCode }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="隐患自有编号">
            <span v-if="detailInfo.fHazardOutUniqueCode">{{ detailInfo.fHazardOutUniqueCode }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="供气企业">
            <span v-if="detailInfo.enterpriseName">{{ detailInfo.enterpriseName }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="检查对象分类">
            <span v-if="detailInfo.fObjType">{{ detailInfo.fObjType }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="对象编码">
            <span v-if="detailInfo.fObjCode">{{ detailInfo.fObjCode }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="行政区县级行政区">
            <span v-if="detailInfo.countyName">{{ detailInfo.countyName }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="监督检查时间">
            <span v-if="detailInfo.fCheckTime">{{ detailInfo.fCheckTime }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="隐患分类分级标准">
            <span v-if="detailInfo.levelName">{{ detailInfo.levelName }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="24">
          <el-form-item label="隐患描述">
            <span v-if="detailInfo.fHazardDesc">{{ detailInfo.fHazardDesc }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <!-- 先隐藏掉 -->
        <!-- <el-col :span="12">
          <el-form-item label="是否执行" prop="fIsEnforcement">
            <span v-if="detailInfo.fIsEnforcement == '1'">是</span>
            <span v-else-if="detailInfo.fIsEnforcement == '0'">否</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col> -->


        <el-col :span="12">
          <el-form-item label="隐患整改前照片">
            <el-image
              :src="detailInfo.fBeforePicture"
              :preview-src-list="[detailInfo.fBeforePicture]"
              v-if="detailInfo.fBeforePicture != '' && detailInfo.fBeforePicture != null"
              :z-index=5000
              style="width: 200px;height: 200px;"
            ></el-image>
            <span v-else>-</span>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="备注">
            <span v-if="detailInfo.fRemark">{{ detailInfo.fRemark }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>
      </el-row>

      <el-divider v-if="detailInfo.afterPicture != null" content-position="left">处置</el-divider>

      <el-row v-if="detailInfo.afterPicture != null">
        <el-form-item label="隐患整改后照片">
        <el-col :span="24">
          <el-image
              :src="detailInfo.afterPicture"
              :preview-src-list="[detailInfo.afterPicture]"
              v-if="detailInfo.afterPicture != '' && detailInfo.afterPicture != null"
              :z-index=5000
              style="width: 200px;height: 200px;"
            ></el-image>
          <span v-else>-</span>
        </el-col>
        </el-form-item>
        <el-col :span="24">
          <el-form-item label="处置描述" prop="disposalDetails">
            <span v-if="detailInfo.disposalDetails">{{ detailInfo.disposalDetails }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="处置时间" prop="disposalDetails">
            <span v-if="detailInfo.disposalTime">{{ detailInfo.disposalTime }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>
      </el-row>

      <el-divider v-if="detailInfo.fSupervisionId != null" content-position="left">督办</el-divider>
      <el-row v-if="detailInfo.fSupervisionId != null">
        <el-col :span="24">
          <el-form-item label="督办标题" prop="disposalDetails">
            <span v-if="superDetail.title">{{ superDetail.title }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="督办内容" prop="disposalDetails">
            <span v-if="superDetail.content">{{ superDetail.content }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>
        <el-form-item label="督办照片">
          <el-col :span="24">
            <el-image
              :src="superDetail.imageUrl"
              :preview-src-list="[superDetail.imageUrl]"
              v-if="superDetail.imageUrl != '' && superDetail.imageUrl != null"
              :z-index=5000
              style="width: 200px;height: 200px;"
            ></el-image>
            <span v-else>-</span>
          </el-col>
        </el-form-item>

        <el-form-item label="督办附件:">
              <span class="dbtn" @click="checkFile(superDetail.fileUrl)" v-if="superDetail.fileUrl">
                <i class="el-icon el-icon-view"></i>查看/下载
              </span>
            <span v-else><el-input disabled/></span>
        </el-form-item>

        <el-col :span="12">
          <el-form-item label="督办时间" prop="superDetail">
            <span v-if="superDetail.createTime">{{ superDetail.createTime }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

  </el-dialog>

</template>

<script>
  import { getRef } from "@/api/supervision/spot";
  import { getSupervision } from "@/api/supervision/supervision";

  export default {
    name: "detail-info",
    data(){
        return{
          detailInfo: {
            fDeleteFlag: 0
          },
          detailOpen: false,
          superDetail:{}
        }
    },
    methods:{
      getDetailInfo(id){
        getRef(id).then(res =>{
          if(res.code == 200){
            if(res.data.fSupervisionId!=null){
              this.supervision(res.data.fSupervisionId)
            }
            this.detailInfo = res.data;
            this.detailOpen = true;
          }
        })
      },
      supervision(id){
        getSupervision(id).then(res =>{
          if(res.code == 200){
            this.superDetail = res.data;
          }
        })
      },
      checkFile(url) {
        window.open(url,'_blank');
      },
    }
  }
</script>

<style scoped>
  .dbtn {
    display: inline-block;
    line-height: normal;
    padding-left: 2px;
    padding-right: 2px;
    cursor: pointer;
    border-radius: 3px;
    border-style: solid;
    border-width: 0;
    color: rgb(48, 180, 107);
  }
  .dbtn:hover {
    border-width: 1px;
    border-color: rgb(48, 180, 107);
  }
</style>
