<template>
  <div class="app-container">
    <div>
      <div class="table-ui-head">
        <h5>隐患信息</h5>
      </div>
      <table class="table-ui">
        <tr>
          <td class="tbg">隐患来源</td>
          <td>
            <template v-if="pd.SOURCE=='1'">
              隐患快报
            </template>
            <template v-else-if="pd.SOURCE=='2'">
              清单排查
            </template>
            <template v-else-if="pd.SOURCE=='3'">
              清单排查
            </template>
            <template v-else-if="pd.SOURCE=='8'">
              点检隐患
            </template>
          </td>
        </tr>
        <tr v-if="pd.SOURCE=='2'">
          <td class="tbg">风险点（单元）</td>
          <td>{{ pd.RISK_UNIT }}</td>
        </tr>
        <tr v-if="pd.SOURCE=='2'">
          <td class="tbg">辨识部位</td>
          <td>{{ pd.IDENTIFICATION }}</td>
        </tr>

        <tr v-if="pd.SOURCE=='2'">
          <td class="tbg">存在风险</td>
          <td>{{ pd.RISK_DESCR }}</td>
        </tr>
        <!-- <tr v-if="pd.SOURCE=='2'">
          <td class="tbg">风险点位置</td>
          <td>{{pd.RISK_POSITION}}</td>
        </tr> -->
        <tr v-if="pd.SOURCE=='2'">
          <td class="tbg">风险分级</td>
          <td>{{ pd.LEVEL }}</td>
        </tr>
        <tr v-if="pd.SOURCE=='2'">
          <td class="tbg">检查内容</td>
          <td>{{ pd.CHECK_CONTENT }}</td>
        </tr>

        <tr>
          <td class="tbg">隐患级别</td>
          <td>{{ pd.HIDDENLEVELNAME }}</td>
        </tr>
        <tr>
          <td class="tbg">隐患状态</td>
          <td>
            <template v-if="pd.STATE=='1'">
              未整改
            </template>
            <template v-else-if="pd.STATE=='3'">
              已整改
            </template>
            <template v-else-if="pd.STATE=='4'">
              已验收
            </template>
            <template v-else-if="pd.STATE=='5'">
              忽略隐患
            </template>
            <template v-else-if="pd.STATE=='6'">
              重大隐患
            </template>
            <template v-else-if="pd.STATE=='7'">
              待处理的特殊隐患
            </template>
            <template v-else-if="pd.STATE=='8'">
              处理的特殊隐患
            </template>
            <template v-else-if="pd.STATE=='-1'">
              已超期
            </template>
          </td>
        </tr>
        <tr>
          <td class="tbg">隐患描述</td>
          <td>{{ pd.HIDDENDESCR }}</td>
        </tr>
        <tr>
          <td class="tbg">隐患部位</td>
          <td>{{ pd.HIDDENPART }}</td>
        </tr>
        <tr>
          <td class="tbg">隐患发现部门</td>
          <td>{{ pd.HIDDENFINDDEPTNAME }}</td>
        </tr>
        <tr>
          <td class="tbg">发现人</td>
          <td>{{ pd.CREATORNAME }}</td>
        </tr>
        <tr>
          <td class="tbg">发现时间</td>
          <td>{{ pd.CREATTIME }}</td>
        </tr>
        <tr>
          <td class="tbg">整改类型</td>
          <td>
            <template v-if="pd.RECTIFICATIONTYPE=='1'">
              立即整改
            </template>
            <template v-else-if="pd.RECTIFICATIONTYPE=='2'">
              限期整改
            </template>
          </td>
        </tr>

        <tr v-if="pd.RECTIFICATIONTYPE=='2'">
          <td class="tbg">整改期限</td>
          <td>{{ pd.RECTIFICATIONDEADLINE }}</td>
        </tr>
        <tr>
          <td class="tbg">隐患图片</td>
          <td ref="hImgs" class="img-select">
            <el-image
              v-if="hImgList.length >0"
              :src="hImgList[0]"
              :preview-src-list="hImgList"
              style="width: 300px; height: 300px"/>
          </td>
        </tr>
      </table>
    </div>

    <div v-show="major.STATE >1 && major.IS_LISTING>0">
      <div class="table-ui-head">
        <h5>挂牌信息</h5>
      </div>
      <table class="table-ui">
        <tr>
          <td class="tbg">挂牌编号</td>
          <td>{{ major.CODE }}</td>
        </tr>
        <tr>
          <td class="tbg">挂牌文书</td>
          <td><a @click="download(major.LISTING_FILE)">下载</a></td>
        </tr>
      </table>
    </div>
    <div v-show="major.STATE >3">
      <div class="table-ui-head">
        <h5>隐患整改措施报告</h5>
      </div>
      <table class="table-ui">
        <tr>
          <td class="tbg">附件</td>
          <td><a @click="download(major.REPORT_FILE)">下载</a></td>
        </tr>
      </table>
    </div>

    <div v-show="major.STATE >4">
      <div class="table-ui-head">
        <h5>评审信息</h5>
      </div>
      <table class="table-ui">
        <tr>
          <td class="tbg">评审时间</td>
          <td>{{ major.REVIEW_TIME }}</td>
        </tr>
        <tr>
          <td class="tbg">评审信息</td>
          <td>{{ major.REVIEW_DESCR }}</td>
        </tr>
        <tr>
          <td class="tbg">附件</td>
          <td><a @click="download(major.REVIEW_FILE)">下载</a></td>
        </tr>
      </table>
    </div>

    <div v-show="major.STATE >5">
      <div class="table-ui-head">
        <h5>隐患整改信息</h5>
      </div>
      <table class="table-ui">
        <tr>
          <td class="tbg">整改责任是否到位</td>
          <td>{{ major.IS_SUCCESS1=='1'?'是':'否' }}</td>
        </tr>
        <tr>
          <td class="tbg">整改责任描述</td>
          <td>{{ major.IS_SUCCESS1_DESCR }}</td>
        </tr>

        <tr>
          <td class="tbg">整改措施是否到位</td>
          <td>{{ major.IS_SUCCESS2=='1'?'是':'否' }}</td>
        </tr>
        <tr>
          <td class="tbg">整改措施描述</td>
          <td>{{ major.IS_SUCCESS2_DESCR }}</td>
        </tr>

        <tr>
          <td class="tbg">整改资金是否到位</td>
          <td>{{ major.IS_SUCCESS3=='1'?'是':'否' }}</td>
        </tr>
        <tr>
          <td class="tbg">整改资金</td>
          <td>{{ major.IS_SUCCESS3_DESCR }}</td>
        </tr>

        <tr>
          <td class="tbg">整改时限是否到位</td>
          <td>{{ major.IS_SUCCESS4=='1'?'是':'否' }}</td>
        </tr>
        <tr>
          <td class="tbg">整改时限描述</td>
          <td>{{ major.IS_SUCCESS4_DESCR }}</td>
        </tr>

        <tr>
          <td class="tbg">应急预案是否到位</td>
          <td>{{ major.IS_SUCCESS5=='1'?'是':'否' }}</td>
        </tr>
        <tr>
          <td class="tbg">应急预案描述</td>
          <td>{{ major.IS_SUCCESS5_DESCR }}</td>
        </tr>

        <tr>
          <td class="tbg">整改人</td>
          <td>{{ major.RECTIFY_USER }}</td>
        </tr>
        <tr>
          <td class="tbg">整改时间</td>
          <td>{{ major.RECTIFY_TIME }}</td>
        </tr>
        <tr>
          <td class="tbg">附件</td>
          <td><a @click="download(major.RECTIFY_FILE)">下载</a></td>
        </tr>
      </table>
    </div>
    <div v-show="major.STATE >6">
      <div class="table-ui-head">
        <h5>验收信息</h5>
      </div>
      <table class="table-ui">
        <tr>
          <td class="tbg">验收意见</td>
          <td>{{ major.ACCEPT_DESCR }}</td>
        </tr>
        <tr>
          <td class="tbg">验收报告</td>
          <td><a @click="download(major.ACCEPT_FILE)">下载</a></td>
        </tr>
      </table>
    </div>
    <div class="page-btn-group">
      <div>
        <el-button type="primary" icon="el-icon-arrow-left" plain @click="goBack">返回</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import Pagination from '@/components/Pagination' // 通过 el-pagination二次打包
import { requestFN } from '@/utils/request'
import waves from '@/directive/waves' // waves directive
export default {
  components: { Pagination },
  directives: { waves },
  data() {
    return {
      config: config,
      listLoading: true,
      pd: [],
      hs: [],
      major: [],
      checkList: [],
      hImgList: [],
      rImgList: [],
      sImgList: []
    }
  },
  async created() {
    this.getData()
  },
  methods: {
    download(filePah) {
      window.open(this.config.fileUrl + filePah, '_blank')
    },
    getData() {
      requestFN(
        '/hidden/goEdit',
        {
          HIDDEN_ID: this.$parent.HIDDEN_ID
        }
      ).then((data) => {
        this.pd = data.pd							// 参数map
        this.hs = data.hs							// 参数map
        this.checkList = data.checkList
        if (undefined != data.hImgs && data.hImgs != null && data.hImgs.length > 0) {
          const hImgs = data.hImgs
          for (let i = 0; i < hImgs.length; i++) {
            const src = this.config.fileUrl + hImgs[i].FILEPATH
            this.hImgList.push(src)
          }
        }

        if (undefined != data.rImgs && data.rImgs != null && data.rImgs.length > 0) {
          const rImgs = data.rImgs
          for (let i = 0; i < rImgs.length; i++) {
            const src = this.config.fileUrl + rImgs[i].FILEPATH
            this.rImgList.push(src)
          }
        }

        if (undefined != data.sImgs && data.sImgs != null && data.sImgs.length > 0) {
          const sImgs = data.sImgs
          for (let i = 0; i < sImgs.length; i++) {
            const src = this.config.fileUrl + sImgs[i].FILEPATH
            this.sImgList.push(src)
          }
        }

        if (undefined != data.checkList && data.checkList != null && data.checkList.length > 0) {
          for (var i = 0; i < data.checkList.length; i++) {
            const cImgList = []
            if (undefined != data.checkList[i].cImgs && data.checkList[i].cImgs != null && data.checkList[i].cImgs.length > 0) {
              for (var j = 0; j < data.checkList[i].cImgs.length; j++) {
                const src = this.config.fileUrl + data.checkList[i].cImgs[j].FILEPATH
                cImgList.push(src)
                data.checkList[i].cImgList = cImgList
              }
            }
          }
        }
        this.getMajorData()
        this.$nextTick(() => {
          if (undefined != data.hImgs && data.hImgs != null && data.hImgs.length > 0) {
            const hImgs = data.hImgs
            for (let i = 0; i < hImgs.length; i++) {
              const src = this.config.fileUrl + hImgs[i].FILEPATH
              this.hImgList.push(src)
            }
          }

          if (undefined != data.rImgs && data.rImgs != null && data.rImgs.length > 0) {
            const rImgs = data.rImgs
            for (let i = 0; i < rImgs.length; i++) {
              const src = this.config.fileUrl + rImgs[i].FILEPATH
              this.rImgList.push(src)
            }
          }

          if (undefined != data.sImgs && data.sImgs != null && data.sImgs.length > 0) {
            const sImgs = data.sImgs
            for (let i = 0; i < sImgs.length; i++) {
              const src = this.config.fileUrl + sImgs[i].FILEPATH
              this.sImgList.push(src)
            }
          }

          if (undefined != data.checkList && data.checkList != null && data.checkList.length > 0) {
            for (var i = 0; i < data.checkList.length; i++) {
              const cImgList = []
              if (undefined != data.checkList[i].cImgs && data.checkList[i].cImgs != null && data.checkList[i].cImgs.length > 0) {
                for (var j = 0; j < data.checkList[i].cImgs.length; j++) {
                  const src = this.config.fileUrl + data.checkList[i].cImgs[j].FILEPATH
                  cImgList.push(src)
                  data.checkList[i].cImgList = cImgList
                }
              }
            }
          }
        })
      }).catch((e) => {

      })
    },
    /* getMajorData() {
      requestFN(
        '/majorhidden/goEdit',
        {
          MAJORHIDDEN_ID: this.$parent.MAJORHIDDEN_ID
        }
      ).then((data) => {
        this.major = data.pd
      }).catch((e) => {
      })
    },*/
    goBack() {
      this.$parent.activeName = 'companiesList'
    }
  }
}
</script>
