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

        <el-col :span="12">
          <el-form-item label="项目编码">
            <span v-if="detailInfo.fProjectCode">{{ detailInfo.fProjectCode }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <!-- <el-col :span="12">
          <el-form-item label="外部工程编码">
            <span v-if="detailInfo.fProjectNo">{{ detailInfo.fProjectNo }}</span>
            <span v-else>-</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.fConstructionStart">{{ detailInfo.fConstructionStart }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="计划竣工时间">
            <span v-if="detailInfo.fConstructionEnd">{{ detailInfo.fConstructionEnd }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="项目位置描述">
            <span v-if="detailInfo.fAddress">{{ detailInfo.fAddress }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

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

        <el-col :span="12">
          <el-form-item label="涉气施工点位位置属性"> 
            <span v-if="detailInfo.fConstructionPointType == 1">城镇</span>
            <span v-else-if="detailInfo.fConstructionPointType == 0">农村</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="管道压力等级分类">
            <span v-if="detailInfo.fPipePress">{{ $parent.fPipePressFormat(detailInfo) }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="施工是否主动报备">
            <span v-if="detailInfo.fReportFlag == 1">是</span>
            <span v-else-if="detailInfo.fReportFlag == 0">否</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="施工状态">
            <span v-if="detailInfo.fConstructionStatus == 1">未开工</span>
            <span v-else-if="detailInfo.fConstructionStatus == 2">正在施工</span>
            <span v-else-if="detailInfo.fConstructionStatus == 3">已完工</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="建设单位名称">
            <span v-if="detailInfo.fBuildDepartment">{{ detailInfo.fBuildDepartment }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="建设单位项目负责人姓名">
            <span v-if="detailInfo.fProjectLeader">{{ detailInfo.fProjectLeader }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="建设单位项目负责人电话">
            <span v-if="detailInfo.fProjectLeaderPhone">{{ detailInfo.fProjectLeaderPhone }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="所属行业">
            <span v-if="detailInfo.fIndustry">{{ detailInfo.fIndustry }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="行业安全监管部门名称">
            <span v-if="detailInfo.fDepartmentName">{{ detailInfo.fDepartmentName }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="施工单位名称">
            <span v-if="detailInfo.fConstructDepartment">{{ detailInfo.fConstructDepartment }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="施工单位项目负责人姓名">
            <span v-if="detailInfo.fBuildProjectLeaderName">{{ detailInfo.fBuildProjectLeaderName }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="施工单位项目负责人电话">
            <span v-if="detailInfo.fBuildProjectLeaderPhone">{{ detailInfo.fBuildProjectLeaderPhone }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="施工单位技术负责人姓名">
            <span v-if="detailInfo.fTechnicalLeaderName">{{ detailInfo.fTechnicalLeaderName }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="施工单位技术负责人电话">
            <span v-if="detailInfo.fTechnicalLeaderPhone">{{ detailInfo.fTechnicalLeaderPhone }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="监理单位名称">
            <span v-if="detailInfo.fSupervisionUnitName">{{ detailInfo.fSupervisionUnitName }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="监理单位总监理工程师姓名">
            <span v-if="detailInfo.fChiefEngineerName">{{ detailInfo.fChiefEngineerName }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="监理单位总监理工程师电话">
            <span v-if="detailInfo.fChiefEngineerPhone">{{ detailInfo.fChiefEngineerPhone }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="施工点位巡线员编码">
            <span v-if="detailInfo.fPatrolSafetyOfficerNo">{{ detailInfo.fPatrolSafetyOfficerNo }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="施工点位巡线员姓名">
            <span v-if="detailInfo.fPartrolSafetyOfficerName">{{ detailInfo.fPartrolSafetyOfficerName }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="施工点位巡线员电话">
            <span v-if="detailInfo.fPatrolSafetyOfficerPhone">{{ detailInfo.fPatrolSafetyOfficerPhone }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="驻村安全员编码">
            <span v-if="detailInfo.fResidentSafetyOfficerNo">{{ detailInfo.fResidentSafetyOfficerNo }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>


        <el-col :span="12">
          <el-form-item label="驻村安全员姓名">
            <span v-if="detailInfo.fResidentSafetyOfficerName">{{ detailInfo.fResidentSafetyOfficerName }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>


        <el-col :span="12">
          <el-form-item label="驻村安全员电话">
            <span v-if="detailInfo.fResidentSafetyOfficerPhone">{{ detailInfo.fResidentSafetyOfficerPhone }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="燃气企业旁站人员编码">
            <span v-if="detailInfo.fGasCompanyStationNo">{{ detailInfo.fGasCompanyStationNo }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="燃气企业旁站人员姓名">
            <span v-if="detailInfo.fGasCompanyStationName">{{ detailInfo.fGasCompanyStationName }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="燃气企业旁站人员电话">
            <span v-if="detailInfo.fGasCompanyStationPhone">{{ detailInfo.fGasCompanyStationPhone }}</span>
            <span v-else>-</span>
          </el-form-item>
        </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="fUploadTimeLabel" >
                <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.entUploadTime }}</span>
            </el-form-item>
          </el-col> 
      </el-row>
    </el-form>

  </el-dialog>

</template>

<script>
  import { getInfor } from "@/api/thirdbuild/project";
  import { enterpriseLists ,queryAllEnterprise} from "@/api/regulation/info";
  import { getDefaultCountyList } from "@/api/area/county";
  export default {
    name: "detail-info",
    data(){
        return{
          enterprises: [],
          countyInfo: [],
          fUploadTypeLable: "",
          fUploadTimeLabel: "",
          enterpriseName:"",
          detailInfo: {},
          detailOpen: false,
          fUploadType: "",
          fUploadTime: null
        }
    },
  created() { 
    this.getCountyInfo();
    this.getEnterpriseLists();
  },
    methods:{
      
      //根据不同角色显示不同字段
      showUploadType() {
        let roleId = this.$store.state.user.roleId;
        if (roleId == 3) {
          this.fUploadType =  this.detailInfo.govUploadState
          this.fUploadTypeLable = "上报省厅状态"
        }
        if (roleId == 5) {
          this.fUploadType =  this.detailInfo.entUploadState
          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.fUploadTimeLabel = "上报省厅时间"
        }
        if (roleId == 5) {
          this.fUploadTime =  this.detailInfo.entUploadTime
          this.fUploadTimeLabel = "上报时间"
        }
      },
      //获取县级
      getCountyInfo(){
        getDefaultCountyList().then(res =>{
          if(res.code == 200 && res.data){
          this.countyInfo =  res.data;
        }
      })
      },
      beyondCountyFormat(row){
        let info = this.countyInfo.find(item => item.fId == row.fDistrictId);
        return info?info.fName:"-";
      },
      beyondCompanyFormat(row){
        let info = this.enterprises.find(item => item.enterpriseId == row.fCompanyInfoId);
        return info?info.enterpriseName:"-";
      },
      //所属单位
      getEnterpriseLists(){ 
        queryAllEnterprise().then(response => { 
          this.enterprises = response; 
        }); 
      },
      getDetailInfo(id){
        getInfor(id).then(res =>{
          if(res.code == 200 && res.data){
            this.detailInfo = res.data;
            this.detailInfo.fDistrictId = this.beyondCountyFormat(this.detailInfo);
            let companyInfoId = this.detailInfo.fCompanyInfoId;
            if (companyInfoId != null) {
              this.enterpriseName= this.beyondCompanyFormat(this.detailInfo);
            }
            this.showUploadType();
            this.showUploadTime();
            this.detailOpen = true;
          }
        })
      }
    }
  }
</script>

<style scoped>

</style>
