<template>
  <div class="text-block" :style="styles">
    <div class="activity-item danger">
      <div v-if="viewData.dangerCode" class="text-row">
        <div v-if="viewData.dangerCode" class="text-item">
          <span class="text-label right">隐患编码：</span>
          <span> {{ viewData.dangerCode }} </span>
        </div>
        <div v-if="viewData.status" class="text-item">
          <span class="text-label right">隐患状态：</span>
          <span> {{ viewData.status | dangerStatusFilter }} </span>
        </div>
        <div v-if="viewData.dangerTitle" class="text-item">
          <span class="text-label right">隐患名称：</span>
          <span> {{ viewData.dangerTitle }} </span>
        </div>
        <div v-if="viewData.dangerTitle" class="text-item">
          <span class="text-label right">隐患类别：</span>
          <span> {{ viewData.dangerCatTitle }} </span>
        </div>
        <div v-if="viewData.dangerLevel" class="text-item">
          <span class="text-label right">隐患等级：</span>
          <span> {{ viewData.dangerLevel | dangerLevelFilter }} </span>
        </div>
        <div v-if="viewData.riskPointTitle" class="text-item">
          <span class="text-label right">所在位置：</span>
          <span> {{ viewData.riskPointTitle }}</span>
        </div>
        <div v-if="viewData.dangerDeadLine" class="text-item">
          <span class="text-label right">整改期限：</span>
          <span> {{ viewData.dangerDeadLine }}</span>
        </div>
        <div v-if="viewData.dangerDesc" class="text-item">
          <span class="text-label right">描述：</span>
          <span> {{ viewData.dangerDesc }} </span>
        </div>
      </div>
    </div>
    <div class="activity-item submit">
      <div v-if="viewData.submitAccountName" class="text-row">
        <div v-if="viewData.submitAccountName" class="text-item">
          <span class="text-label right">提交人员：</span>
          <span> {{ viewData.submitAccountName }}( {{ viewData.submitPositionName }} ) </span>
        </div>
        <div v-if="viewData.submitGroupName" class="text-item">
          <span class="text-label right">所在部位：</span>
          <span> {{ viewData.submitGroupName }} </span>
        </div>
      </div>
    </div>
    <div class="activity-item rectify">
      <div v-if="viewData.rectifyAccountId" class="text-row">
        <div v-if="viewData.rectifyAccountId" class="text-item">
          <span class="text-label right">整改人员：</span>
          <span> {{ viewData.rectifyAccountName }}</span>
        </div>
        <div v-if="viewData.rectifyGroupName" class="text-item">
          <span class="text-label right">所在部门：</span>
          <span> {{ viewData.rectifyGroupName }} </span>
        </div>
      </div>
      <div v-if="viewData.rectifyMeasure" class="text-row">
        <div v-if="viewData.rectifyMeasure" class="text-item">
          <span class="text-label right">整改措施：</span>
          <span> {{ viewData.rectifyMeasure }}</span>
        </div>
      </div>
      <div v-if="viewData.rectifyRemark" class="text-row">
        <div v-if="viewData.rectifyRemark" class="text-item">
          <span class="text-label right">整改说明：</span>
          <span> {{ viewData.rectifyRemark }}</span>
        </div>
      </div>
    </div>
    <div v-if="viewData.attachList&&viewData.attachList.length>0" class="activity-item attach">
      <div v-for="(attach,index) in viewData.attachList" :key="index" class="attach-item">
        <el-image
          style="width: 100px; height: 100px"
          :src="attach.fileUrl"
          :preview-src-list="[attach.fileUrl]"
          fit="fill"
        />
        <div class="tag">{{ attach.taskCode |taskCodeFilter }}</div>
      </div>
    </div>
  </div>
</template>
<script>
import { dangerLevel, dangerSource, dangerStatus, rectifyCat } from '@/utils'
export default {
  name: 'DangerInfo',
  components: { },
  filters: {
    dangerSourceFilter(ival) {
      return dangerSource(ival)
    },
    dangerLevelFilter(ival) {
      return dangerLevel(ival)
    },
    dangerStatusFilter(ival) {
      return dangerStatus(ival)
    },
    rectifyFilter(ival) {
      return rectifyCat(ival)
    },
    taskCodeFilter(code) {
      const enums = {
        'submit': '提交',
        'accept': '验收',
        'review': '评审',
        'rectify': '整改'
      }
      return enums[code]
    }

  },
  props: {
    viewData: {
      type: Object,
      default: undefined
    },
    styles: {
      type: String,
      default: ''
    }

  },
  data() {
    return {

    }
  }
}

</script>
<style lang="scss" scoped>
  .text-block{
    margin-bottom: 20px;
    &.form{
      .activity-item{
        padding-left: 50px;
      }
    }
  }
.activity-item{
  margin-top:1px;
  background-color: #28475c;
  &.attach{
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    align-items: center;
    padding: 5px 0;
    .attach-item{
      position: relative;
      height: 100px;
      margin-left: 10px;
      .tag{
        width: 100%;
        position: absolute;
        bottom: 0;
        padding: 3px 0;
        line-height: 1;
        background-color: rgba(0,0,0,0.6);
        color: #fff;
        text-align: center;
      }
    }
  }
}
</style>
