<template>
  <div class="text-block" :style="styles">
    <h3 class="header">{{ viewData.hdangerTitle }}</h3>
    <div class="activity-item danger">
      <div v-if="viewData" class="text-row">
        <div v-if="viewData.status" class="text-item">
          <span class="text-label right">预警状态：</span>
          <span> {{ viewData.status | dangerStatusFilter }} </span>
        </div>
        <div v-if="viewData.hdangerType" class="text-item">
          <span class="text-label right">预警类别：</span>
          <span> {{ viewData.hdangerType===1?'传感器巡检':"人员巡检" }} </span>
        </div>
        <div v-if="viewData.hdangerLevel" class="text-item">
          <span class="text-label right">预警等级：</span>
          <span> {{ viewData.hdangerLevel | dangerLevelFilter }} </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.hdangerDesc" class="text-item">
          <span class="text-label right">预警描述：</span>
          <span> {{ viewData.hdangerDesc }} </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 }}</span>
          <span v-if="viewData.submitPositionName">( {{ 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 no-border">
      <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 { dangerSource, rectifyCat } from '@/utils'
export default {
  name: 'DangerInfo',
  components: { },
  filters: {
    dangerSourceFilter(ival) {
      return dangerSource(ival)
    },
    dangerLevelFilter(val) {
      const status = ['较低', '一般', '较大', '重大']
      return status[val]
    },
    dangerStatusFilter(val) {
      const status = ['待提交', '待评审', '待整改', '待验收', '完成']
      return val === -1 ? '撤销' : status[val]
    },
    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>
.header{
  background-color: #28475c;
  color: #fff;
  margin: 0;
  padding: 5px 0;
  text-align: center;
}
  .text-block{
    margin-bottom: 20px;
    &.form{
      .activity-item{
        padding-left: 50px;
      }
    }
  }
.activity-item{
  background-color: #1d5072;
  border-bottom: 1px solid #586fa3;
  &.no-border{
    border: 0;
  }
  &.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>
