<template>
  <el-dialog title="详情" :visible.sync="detailOpen" width="1200px" append-to-body destroy-on-close :close-on-click-modal="false">
    <el-form label-width="170px">
      <el-row class="el-row-table">
        <el-col :span="14">
          <el-col :span="12">
            <el-form-item label="燃气企业" >
              <span>{{ enterpriseName }}</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="项目名称">
              <span v-if="detailInfo.fProjectName">{{ detailInfo.fProjectName }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

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

          <el-col :span="12">
            <el-form-item label="关联对象类型" >
              <span v-if="detailInfo.fIdNo">{{ $parent.fRelationObjectTypeFormat(detailInfo) }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="年度" >
              <span v-if="detailInfo.fYear">{{ detailInfo.fYear }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="项目开始时间" >
              <span v-if="detailInfo.fStartTime">{{ detailInfo.fStartTime }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="项目结束时间" >
              <span v-if="detailInfo.fEndTime">{{ detailInfo.fEndTime }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="项目总投资/万元" >
              <span v-if="detailInfo.fTotalInvestment">{{ detailInfo.fTotalInvestment }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="实施主体" >
              <span v-if="detailInfo.fSubjectImplementation">{{ detailInfo.fSubjectImplementation }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="联系人" >
              <span v-if="detailInfo.fConcatPerson">{{ detailInfo.fConcatPerson }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="联系电话" >
              <span v-if="detailInfo.fConcatTel">{{ detailInfo.fConcatTel }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="实际改造完成时间" >
              <span v-if="detailInfo.fActualFinishTime">{{ detailInfo.fActualFinishTime }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="建设内容" >
              <span v-if="detailInfo.fConstructionContent">{{ detailInfo.fConstructionContent }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="改造进度/百分比" >
              <span v-if="detailInfo.fReconstructionProgress">{{ detailInfo.fReconstructionProgress }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="资金拨付进度/百分比" >
              <span v-if="detailInfo.fFundsDisbursementProgress">{{ detailInfo.fFundsDisbursementProgress }}</span>
              <span v-else>-</span>
            </el-form-item>
          </el-col>
        </el-col>

        <el-col :span="9">
          <div style="width: 100%;height: 390px; border: 1px solid rgb(218, 213, 213);margin-bottom: 10px;">
            <div style="width: 100%;height: 100%" id="hiddenContainer"></div>
          </div>
        </el-col>

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

    <el-divider content-position="left">上报时态</el-divider>
    <el-form label-width="170px">
      <el-row class="el-row-table">
          <el-col :span="12">
                <el-form-item :label="fUploadTypeLable" >
                  <span>{{fUploadType}}</span>
                </el-form-item>
          </el-col>

          <el-col :span="12">
              <el-form-item :label="fUploadTimeLable" >
                <span>{{ fUploadTime }}</span>
              </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item  v-if="this.$store.state.user.roleId == 3" label="企业端上报时间" >
              <span>{{ detailInfo.fUploadTime }}</span>
            </el-form-item>
          </el-col>
      </el-row>
    </el-form>


  </el-dialog>

</template>

<script>
  import { getProcess } from "@/api/oldpipesystem/process";
  import { enterpriseLists ,queryAllEnterprise} from "@/api/regulation/info";
  import { getDefaultCountyList } from "@/api/area/county";
  import {EditorMap} from "@/utils/mapClass/getPath";
  export default {
    name: "detail-info",
    data(){
        return{
          map: null,
          coordinateslist:[],
          enterprises: [],
          countyInfo: [],
          detailInfo: {},
          enterpriseName:"",
          detailOpen: false,
          fUploadTimeLable: "",
          fUploadTypeLable: "",
          fUploadType: "",
          fUploadTime: null
        }
    },
  created() {
    this.getCountyInfo();
    this.getEnterpriseLists();
  },
    methods:{
      //根据不同角色显示不同字段
      showUploadType() {
        let roleId = this.$store.state.user.roleId;
        console.log("roleId == 3" + (roleId == 3))
        if (roleId == 3) {
          this.fUploadType =  this.detailInfo.govUploadState
          this.fUploadTypeLable = "上报省厅状态"
        }
        if (roleId == 5) {
          this.fUploadType =  this.detailInfo.fUploadType
          this.fUploadTypeLable = "上报状态"
        }

        if (this.fUploadType == '0') {
          this.fUploadType = "未上报"
        }
        if (this.fUploadType == '1') {
          this.fUploadType = "已上报"
        }
      },
      showUploadTime() {

        let roleId = this.$store.state.user.roleId;
        if (roleId == 3) {
          this.fUploadTime =  this.detailInfo.govUploadTime
          this.fUploadTimeLable = "上报省厅时间"
        }
        if (roleId == 5) {
          this.fUploadTime =  this.detailInfo.fUploadTime
          this.fUploadTimeLable = "上报时间"
        }
      },
      //获取县级
      getCountyInfo(){
        getDefaultCountyList().then(res =>{
          if(res.code == 200 && res.data){
          this.countyInfo =  res.data;
        }
      })
      },
      //所属单位
      getEnterpriseLists(){
        queryAllEnterprise().then(response => {
          this.enterprises = response;
        });
      },
      beyondCountyFormat(row){
        let info = this.countyInfo.find(item => item.fId == row.fRegion);
        return info?info.fName:"-";
      },
      beyondCompanyFormat(row){
        let info = this.enterprises.find(item => item.enterpriseId == row.fEnterpriseId);
        return info?info.enterpriseName:"-";
      },
      getDetailInfo(id){
        getProcess(id).then(res =>{
          if(res.code == 200 && res.data){
            this.detailInfo = res.data;
            this.detailInfo.fRegion = this.beyondCountyFormat(this.detailInfo);
            let fEnterpriseId = this.detailInfo.fEnterpriseId;
            if (fEnterpriseId != null) {
              this.enterpriseName= this.beyondCompanyFormat(this.detailInfo);
            }

            this.showUploadType();
            this.showUploadTime();
            this.detailOpen = true;

            this.$nextTick(() => {
              const path = eval(this.$store.state.user.systemSetting.map_center);
              console.log("path",path);
              const text=this.detailInfo.coordinates
              if(text){
                this.coordinateslist=JSON.parse(text);
                this.map = new EditorMap("hiddenContainer", {center:path}, this);
                this.map.addPipeLine({ path: this.coordinateslist });
              }

            });
          }
        })
      }
    }
  }
</script>

<style scoped>

</style>
