<template>
  <el-dialog title="详情" :visible.sync="detailOpen" width="900px" 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="14">
          <el-col :span="12">
            <el-form-item label="重要风险点编码">
              <span v-if="detailInfo.fRiskCode">{{ detailInfo.fRiskCode }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="重要风险点名称">
              <span v-if="detailInfo.fRiskName">{{ detailInfo.fRiskName }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="涉及燃气企业编码">
              <span v-if="detailInfo.fCompanyId">{{ detailInfo.fCompanyId }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

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

          <el-col :span="12">
            <el-form-item label="重要风险点类型">
              <span v-if="detailInfo.fRiskType">{{ $parent.fRiskTypeFormat(detailInfo) }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="所在位置地址描述">
              <span v-if="detailInfo.fRiskPlaceDetail">{{ detailInfo.fRiskPlaceDetail }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="风险构成">
              <span v-if="detailInfo.fRiskStructure">{{ detailInfo.fRiskStructure }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="风险管控措施">
              <span v-if="detailInfo.fRiskControlMeasures">{{ detailInfo.fRiskControlMeasures }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="备注">
              <span v-if="detailInfo.fRemark">{{ detailInfo.fRemark }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>
        </el-col>

        <el-col :span="10">
          <div id="risk-map" style="height: 400px"></div>
        </el-col>

      </el-row>
    </el-form>
  </el-dialog>

</template>

<script>
  import { getInfor } from "@/api/risk/info";
  import { EditorMap } from "@/utils/mapClass/getPath.js";
  export default {
    name: "detail-info",
    data(){
        return{
          detailInfo: {},
          detailOpen: false
        }
    },
    watch:{
      detailOpen(newVal){
        if(newVal){
          this.initMap();
        }
      }
    },
    methods:{
      getDetailInfo(id){
        getInfor(id).then(res =>{
          if(res.code == 200 && res.data){
            this.detailInfo = res.data;
            this.detailOpen = true;
          }
        })
      },
      initMap(){
        this.$nextTick(() => {
          const path = eval(this.$store.state.user.systemSetting.map_center);
          this.gaoMap = new EditorMap("risk-map", {center:path}, this);
          new AMap.Marker({
            map: this.gaoMap.map,
            position: path,
          });
          this.gaoMap.map.setCenter(path)
        })
      },
      destroyed(){
        this.gaoMap.map.destroy();
      },
    }
  }
</script>

<style scoped lang="scss">
  .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);
  }
</style>
