Newer
Older
smartwell_front / src / views / home / dashboard / fullScreen-components / deviceAlarmTrend.vue
lyg on 25 Sep 3 KB 事件地图
<!--
  Description: 事件大屏 - 数据展示- 设备报警趋势
  Author: 李亚光
  Date: 2024-09-18
 -->
<script lang="ts" setup name="FullScreenDeviceAlarmTrend">
import layout from './layout.vue'
// 宽高
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
})
const listQuery = ref({
  timeType: '1',
})
const selectTimeType = (type: string) => {
  listQuery.value.timeType = type
}
const xAxisData = ref<any[]>([])
const data = ref<any[]>([])
onMounted(() => {
  setTimeout(() => {
    xAxisData.value = [
      '2024-09-17',
      '2024-09-18',
      '2024-09-19',
      '2024-09-20',
      '2024-09-21',
      '2024-09-22',
      '2024-09-23',
      '2024-09-24',
    ]
    data.value = [
      {
        name: '报警次数',
        data: [9, 6, 0, 12, 2, 3, 7, 0],
        symbol: 'circle',
        color: '#E6271D',
      },
    ]
  }, 1000)
})
</script>

<template>
  <layout class="layout" :height="height" :width="width" title="设备报警趋势" subtitle="Equipment Alarm Trend">
    <template #content>
      <div class="container">
        <!-- 筛选条件 -->
        <div class="search">
          <el-button
            :class="listQuery.timeType === '1' ? 'active' : ''" round size="small" style="margin: 0 5px;"
            @click="selectTimeType('1')"
          >
            近7日
          </el-button>
          <el-button
            :class="listQuery.timeType === '2' ? 'active' : ''" round size="small" style="margin: 0 5px;"
            @click="selectTimeType('2')"
          >
            本月
          </el-button>
          <el-button
            :class="listQuery.timeType === '3' ? 'active' : ''" round size="small" style="margin: 0 5px;"
            @click="selectTimeType('3')"
          >
            本年
          </el-button>
        </div>
        <line-chart
          :data="data" :x-axis-data="xAxisData" :style="{ width: '100%', height: `${height - 30}px` }"
          font-color="#fff" :legend="{
            show: true,
            // icon: 'line',
            orient: 'horizontal', // 图例方向
            align: 'left', // 图例标记和文本的对齐,默认自动
            top: 5,
            right: 20,
            itemWidth: 20,
            itemHeight: 12,
            textStyle: {
              color: '#fff',
            },
          }"
        />
      </div>
    </template>
  </layout>
</template>

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

::v-deep(.el-button) {
  background-color: rgba($color: #103f60, $alpha: 80%);
  border-color: #fff;
  color: #fff;
}

.container {
  position: relative;

  .search {
    position: absolute;
    top: 5px;
    left: 10px;
    z-index: 10;
  }
}

.active {
  color: #3d7eff;
  border-color: #e6ebf5;
  outline: none;
  background-color: rgba($color: #98a7bb, $alpha: 80%);
}

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

  // overflow: hidden;
}
</style>