Newer
Older
smartwell_front / src / views / home / dashboard / fullScreen-components / allAlarmStatus.vue
liyaguang on 28 Feb 5 KB 正式环境问题排查
<!--
  Description: 综合大屏 - 数据展示- 总体报警情况
  Author: 李亚光
  Date: 2024-09-18
 -->
<script lang="ts" setup name="FullScreenAllAlarmStatus">
import layout from './layout.vue'
import { alarmStatistics } from '@/api/home/dashboard/fullScreen'
const $props = defineProps({
  type: {
    type: String,
    required: true,
  },
})
// 宽高
const height = ref((window.innerHeight - 100 - 50) / 3)
const width = ref((window.innerWidth - (window.innerWidth * 0.6) - 30) / 2)
window.addEventListener('resize', () => {
  height.value = (window.innerHeight - 100 - 50) / 3
  width.value = (window.innerWidth - (window.innerWidth * 0.6) - 30) / 2
})
onBeforeUnmount(() => {
  window.addEventListener('resize', () => {})
})
const img = {
  frame1: new URL('@/assets/images/map/frame1.png', import.meta.url),
  frame2: new URL('@/assets/images/map/frame2.png', import.meta.url),
}
const dataList = ref([
  {
    name: '闸井泄露',
    id: '1',
    value: '15',
  },
  {
    name: '管线泄露',
    id: '2',
    value: '16',
  },
  {
    name: '场站泄露',
    id: '3',
    value: '0',
  },
  {
    name: '现场作业',
    id: '4',
    value: '0',
  },
  {
    name: '外力破坏',
    id: '5',
    value: '2',
  },
  {
    name: '其他',
    id: '6',
    value: '2',
  },
])

const pre = computed(() => {
  return dataList.value.slice(0, 3)
})
const next = computed(() => {
  return dataList.value.slice(3, 6)
})
const allAlarm = computed(() => {
  return dataList.value.map((item: any) => Number(item.value)).reduce((pre, next) => {
    return pre + next
  })
})
// console.log(pre.value, next.value)
// 获取数据
const loading = ref(true)
const fetchData = () => {
  loading.value = true
  alarmStatistics({ type: $props.type }).then((res) => {
    dataList.value = res.data.map((item: any, index: number) => ({ ...item, id: index + 1 }))
    loading.value = false
  }).catch(() => {
    loading.value = false
  })
}
watch(() => $props.type, (newVal) => {
  if (newVal) {
    fetchData()
  }
  else {
    loading.value = false
  }
}, {
  deep: true,
  immediate: true,
})
</script>

<template>
  <layout v-loading="loading" class="layout" :height="height" :width="width" title="总体报警情况" subtitle="Overall Alarm Situation">
    <template #content>
      <div class="container">
        <div class="left">
          <div v-for="item in pre" :key="item.id" class="item">
            <div class="img" :style="{ height: `${(height - 50) / 3}px` }">
              <img :src="img.frame2">
              <div class="name">
                <div class="name1">
                  {{ item.name }}
                </div>
                <div class="value">
                  {{ item.value }}
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="middle">
          <div class="container1" :style="{ height: `${(height - 50)}px` }">
            <img class="img1" :src="img.frame2">
            <img class="img2" :src="img.frame1">
            <div class="name">
              <div class="value">
                {{ allAlarm }}
              </div>
              <div class="title1">
                当前报警
              </div>
            </div>
          </div>
        </div>
        <div class="left">
          <div v-for="item in next" :key="item.id" class="item">
            <div class="img" :style="{ height: `${(height - 50) / 3}px` }">
              <img :src="img.frame2">
              <div class="name">
                <div class="name1">
                  {{ item.name }}
                </div>
                <div class="value">
                  {{ item.value }}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </template>
  </layout>
</template>

<style lang="scss" scoped>
::v-deep(.el-loading-mask) {
  background-color: rgba($color: #0b0b0f, $alpha: 95%);
}

.container {
  display: flex;

  .left {
    width: 30%;
    color: #a7ceec;

    .item {
      margin: 7px 0;
      display: flex;
      justify-content: center;
      align-items: center;
      position: relative;

      img {
        width: 88%;
        // height: 100%;
        margin: 0 auto;
      }

      .name {
        position: absolute;
        top: 51%;
        left: 46%;
        transform: translate(-50%, -50%);

        .name1 {
          width: 100%;
          text-align: center;
          font-size: 12px;
        }

        .value {
          margin-top: 5px;
          font-size: 14px;
          text-align: center;
        }
      }
    }
  }

  .middle {
    width: 40%;

    .container1 {
      width: 100%;
      position: relative;

      .img1 {
        width: 100%;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
      }

      .img2 {
        width: 70%;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
      }

      .name {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        color: #a7ceec !important;

        .value {
          text-align: center;
          font-size: 24px;
          font-weight: 700;
          color: #d81010;
        }

        .title1 {
          margin-top: 10px;
          font-weight: 700;
        }
      }
    }
  }
}

// .layout {
//   ::v-deep(.title) {
//     padding-left: 8px !important;
//     color: #fff;
//     font-weight: 700;
//     // padding-left: 20px;
//     box-sizing: border-box;
//   }
// }
</style>