<!--
 * @Author: daidai
 * @Date: 2022-03-01 15:27:58
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-05-07 11:24:14
 * @FilePath: \web-pc\src\pages\big-screen\view\indexs\right-center.vue
-->
<template>
  <div v-if="data.pageflag" class="right_center_wrap beautify-scroll-def"
    :class="{ 'overflow-y-auto': !sbtxSwiperFlag }">
    <component :is="data.components" :list="data.list" hover :step="data.defaultOption.step"
      :singleHeight="data.defaultOption.singleHeight" :singleWaitTime="3000">
      <ul class="right_center ">
        <li class="right_center_item" v-for="(item, i) in data.list" :key="i">
          <span class="orderNum">{{ i + 1 }}</span>
          <div class="inner_right">
            <div class="dibu"></div>
            <div class="flex">
              <div class="info">
                <span class="labels ">设备ID：</span>
                <span class="contents zhuyao"> {{ item.fuelId }}</span>
              </div>
              <div class="info">
                <span class="labels">机型：</span>
                <span class="contents "> {{ item.model }}</span>
              </div>
              <!--  <div class="info">
                <span class="labels">告警值：</span>
                <span class="contents warning"> {{ item.alertvalue | montionFilter }}</span>
              </div> -->
            </div>


            <div class="flex">

              <div class="info">
                <span class="labels"> 站点名称：</span>
                <span class="contents ciyao" style="font-size:12px"> {{ item.oilCompany }}</span>
              </div>
              <div class="info time">
                <span class="labels">时间：</span>
                <span class="contents" style="font-size:12px"> {{ item.createdDate }}</span>
              </div>

            </div>
            <div class="flex">

              <div class="info">
                <span class="labels">报警内容：</span>
                <span class="contents ciyao" :class="{ warning: item.alarmDescription }"> {{ item.alarmDescription ||
                  '无'
                  }}</span>
              </div>
            </div>
          </div>
        </li>
      </ul>
    </component>
  </div>
  <Reacquire v-else @onclick="getData" style="line-height:200px" />

</template>

<script setup>
import { currentPOST } from '/@/api/newDeviceVision/modules'
import { Vue3SeamlessScroll } from 'vue3-seamless-scroll' // vue3引入方式
import Kong from "/@/views/admin/visualization/newDeviceVision/components/kong.vue";
import { computed, onBeforeMount, reactive } from 'vue';
import store from '/@/stores/newDeviceVision/modules/setting'


const data = reactive({
  list: [],
  pageflag: true,
  defaultOption: {
    ...store.state.defaultOption,
    limitMoveNum: 3,
    singleHeight: 250,
    step: 0,
  },
  components: Vue3SeamlessScroll
})

const sbtxSwiperFlag = computed(() => {
  let ssyjSwiper = store.state.ssyjSwiper
  if (ssyjSwiper) {
    data.components = Vue3SeamlessScroll
  } else {
    data.components = Kong
  }
  return ssyjSwiper
})

onBeforeMount(() => {
  getData()
})

const getData = () => {
  data.pageflag = true
  // data.pageflag =false
  currentPOST('big5', { limitNum: 50 }).then(res => {
    console.log('实时预警', res);
    if (res.success) {
      data.list = res.data
      let timer = setTimeout(() => {
        clearTimeout(timer)
        data.defaultOption.step = store.state.defaultOption.step
      }, store.state.defaultOption.waitTime);
    } else {
      data.pageflag = false
    }
  })

}

</script>
<style lang='scss' scoped>
.right_center {
  width: 100%;
  height: 100%;

  .right_center_item {
    display: flex;
    align-items: center;
    justify-content: center;
    height: auto;
    padding: 10px;
    font-size: 14px;
    color: #fff;

    .orderNum {
      margin: 0 20px 0 -20px;
    }


    .inner_right {
      position: relative;
      height: 100%;
      width: 400px;
      flex-shrink: 0;
      line-height: 1.5;

      .dibu {
        position: absolute;
        height: 2px;
        width: 104%;
        background-image: url("../../assets/img/zuo_xuxian.png");
        bottom: -12px;
        left: -2%;
        background-size: cover;
      }
    }

    .info {
      margin-right: 10px;
      display: flex;
      align-items: center;

      .labels {
        flex-shrink: 0;
        font-size: 12px;
        color: rgba(255, 255, 255, 0.6);
      }

      .zhuyao {
        // color: $primary-color;
        font-size: 15px;
      }

      .ciyao {
        color: rgba(255, 255, 255, 0.8);
      }

      .warning {
        color: #E6A23C;
        font-size: 15px;
      }
    }

  }
}

.right_center_wrap {
  overflow: hidden;
  width: 100%;
  height: 250px;
}

.overflow-y-auto {
  overflow-y: auto;
}
</style>