<!--
 * @Description: 报警列表
 * @Author: 王晓颖
 * @Date: 2022-05-13
 -->
<template>
  <div v-if="this.show && data.length>0">
    <transition enter-active-class="animate__animated animate__fadeIn" leave-active-class="animate__animated animate__fadeOut" :duration="500" mode="out-in">
      <div v-if="!tableShow" class="alarm-hidden-div" @click="tableShow=!tableShow">
        告警列表<span>({{ data.length }})</span>
      </div>
    </transition>
    <transition enter-active-class="animate__animated animate__slideInLeft" leave-active-class="animate__animated animate__slideOutLeft" :duration="500" mode="out-in">
      <div v-if="tableShow" class="map-alarm-div">
        <!--报警列表展开样式-->
        <el-scrollbar
          :style="{visibility: tableShow?'visible':'hidden'}"
          :class="{moredatascollor:data.length>6, 'overview-alarm-scroll':true}"
          :native="false"
        >
          <el-table
            :data="data"
            class="alarm-list-table"
            border
            row-class-name="alarm-table-row"
            header-row-class-name="alarm-table-th"
            @row-click="rowClick"
          >
            <el-table-column v-for="column in columns" :key="column.value" :label="column.text" :width="column.width" :align="column.align" show-overflow-tooltip>
              <template slot-scope="scope">
                {{ scope.row[column.value] }}
              </template>
            </el-table-column>
          </el-table>
        </el-scrollbar>
        <div class="map-alarm-div-header">
          <div class="header-box" @click="tableShow = false">
            告警列表
          </div>
        </div>
      </div>
    </transition>
  </div>
</template>

<script>
export default {
  name: 'AlarmList',
  props: {
    show: {
      type: Boolean,
      default: true
    }, // 是否显示
    data: {
      type: Array,
      default: () => []
    } // 报警列表
  },
  data() {
    return {
      columns: [
        { text: '井编号', value: 'wellCode', width: 110, align: 'center' },
        { text: '设备编号', value: 'devcode', width: 120, align: 'center' },
        { text: '告警原因', value: 'alarmContent', align: 'center' },
        { text: '时间', value: 'alarmTime', width: 180, align: 'center' }
      ], // 告警列表显示列
      tableShow: false // 表格显示
    }
  },
  methods: {
    rowClick(row, column, event) {
      this.$emit('row-click', row, column, event)
    }
  }

}
</script>

<style lang="scss" scoped>
.alarm-hidden-div{
  position: absolute;
  z-index: 100;
  top: 0px;
  left: 0px;
  box-sizing: border-box;
  padding: 10px;
  border-radius: 0px 10px 10px 0px;
  background-color: rgba(255, 234, 241,1);
  border: 1px solid #d2d0d0;
  border-left: 0px;
  font-size: 16px;
  font-weight: 500;
  writing-mode:vertical-rl;
  color: #7f7e7e;
  span{
    writing-mode: lr-tb;
  }
  &:hover{
    cursor: pointer;
    color: #535252;
  }
}
.map-alarm-div{
  position: absolute;
  z-index: 100;
  top: 0px;
  left: 0px;
  display: flex;
  align-items: flex-start;
  .map-alarm-div-header{
    .header-box{
      border-radius: 0px 10px 10px 0px;
      background-color: rgba(255, 234, 241,1);
      border: 1px solid #d4cfcf;
      border-left: 0px;
      font-size: 16px;
      font-weight: 400;
      writing-mode:vertical-rl;
      box-sizing: border-box;
      padding: 10px;
      color: #535252;
      .icon-right{
        width: 16px;
        height: 26px;
      }
      &:hover{
        cursor: pointer;
        color: #7f7e7e;
      }
    }
  }
  .overview-alarm-scroll {
    width: 504px;
    .el-scrollbar__wrap {
      overflow-y: auto;
      overflow-x: hidden;
      padding: 0px !important;
      margin-bottom: 0px !important;
    }
  }
  .moredatascollor{
    height: 200px;
  }
  .alarm-list-table{
    td{
      padding: 5px 0px;
    }
  }
}

</style>
<style lang="scss">
.overview-alarm-scroll {
  width: 100%;
  .el-scrollbar__wrap {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0px !important;
    margin-bottom: 0px !important;
  }
}
.alarm-table-row{
  background-color: rgba(255, 234, 241, 0.8) !important;
  td:hover{
    background-color: rgba(255, 234, 241, 1) !important;
  }
  &:hover{
    cursor: pointer;
    td{
      background-color: rgba(255, 234, 241, 1) !important;
    }
  }
}
.alarm-table-th{
  th{
    padding: 7px 0px !important;
    background-color: rgba(255, 234, 241, 0.9) !important;
  }

}
</style>
