<template>
  <el-dialog title="详情" :visible.sync="detailOpen" width="800px" 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.projectCode">{{ detailInfo.projectCode }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="意外事件标题">
            <span v-if="detailInfo.fTitle">{{ detailInfo.fTitle }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="意外事件描述">
            <span v-if="detailInfo.fDescription">{{ detailInfo.fDescription }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="意外事件发生时间">
            <span v-if="detailInfo.fOccurrenctTime">{{ detailInfo.fOccurrenctTime }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="附件">
              <span
                class="dbtn"
                @click="$parent.checkFile(detailInfo.fAttachment)"
                v-if="detailInfo.fAttachment != null && detailInfo.fAttachment!=''"
              >
                <i class="el-icon el-icon-view"></i>查看/下载
              </span>
            <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-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 { getInc } from "@/api/thirdbuild/accident";
  export default {
    name: "detail-info",
    data(){
        return{
          detailInfo: {},
          fUploadTypeLable: "",
          fUploadTimeLabel: "",
          detailOpen: false,
          fUploadType: "",
          fUploadTime: null
        }
    },
    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 = "上报时间"
        }
      },
      getDetailInfo(id){
        getInc(id).then(res =>{
          if(res.code == 200 && res.data){
            this.detailInfo = res.data;
            this.showUploadType();
            this.showUploadTime();
            this.detailOpen = true;
          }
        })
      }
    }
  }
</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>
