<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="12">
          <el-form-item label="备注">
            <span v-if="detailInfo.fRemark">{{ detailInfo.fRemark }}</span>
            <span v-else>-</span>
          </el-form-item>
        </el-col>


        <el-col :span="12">
          <el-form-item label="上传状态" >
            <span>{{fUploadType}}</span> 
          </el-form-item>
        </el-col>

        <el-col :span="12">
            <el-form-item label="上传时间" >
              <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: {},
          detailOpen: false,
          fUploadType: "",
          fUploadTime: null
        }
    },
    methods:{
      //根据不同角色显示不同字段
      showUploadType() {
        let roleId = this.$store.state.user.roleId;
        if (roleId == 3) {
          this.fUploadType =  this.detailInfo.govUploadState
        }
        if (roleId == 5) {
          this.fUploadType =  this.detailInfo.entUploadState
        }

        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
        }
        if (roleId == 5) {
          this.fUploadTime =  this.detailInfo.entUploadTime
        }
      },
      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>
