Newer
Older
safe_production_front / src / views / bigScreen / components / areaDanger.vue
dutingting on 17 Jan 2 KB gm大屏第一版
<!-- 区域安全隐患分类 -->
<script lang="ts" setup>
import type { Ref } from 'vue'
import { onMounted, ref } from 'vue'
import { getAreaDanger } from '@/api/bs'
const safeCatogeryByDeptData: any = ref([]) // 单元安全隐患分类Y轴
const safeCatogeryByDeptYDataMax = ref() // 单元安全隐患分类Y轴
const safeCatogeryByDeptXData: Ref<string[]> = ref([]) // 单元安全隐患分类X轴
const loading = ref(false) // loading
// 单元安全隐患分类
function fetchAreaDanger() {
  loading.value = true
  // const value = [88, 58, 55, 77, 23, 40, 55]
  // const value1 = [10, 20, 34, 5, 44, 55, 1]
  // const value2 = [67, 67, 67, 88, 23, 50, 66]
  // const value3 = [67, 58, 88, 78, 23, 40, 122]
  // safeCatogeryByDeptData.value = [{ name: '有害气体', data: value }, { name: '易燃易爆', data: value1 }, { name: '机械', data: value2 }, { name: '其他', data: value3 }]
  // // safeCatogeryByDeptYDataMax.value = Math.max(value) > 10 ? Math.max(value) : 10
  // safeCatogeryByDeptXData.value = ['二部', '201', '203', '283', '23', '25', '706']
  getAreaDanger().then((res) => {
    safeCatogeryByDeptData.value = res.data.yData
    safeCatogeryByDeptXData.value = res.data.xData
    loading.value = false
  }).catch(() => {
    loading.value = false
  })
}

onMounted(() => {
  fetchAreaDanger()
})
</script>

<template>
  <div style="width: 100%;height: 100%;" class="area-danger-bs" v-loading="loading">
    <bar-chart-vertical
      unit=""
      :x-axis-data="safeCatogeryByDeptXData"
      :data="safeCatogeryByDeptData"
      :max="safeCatogeryByDeptYDataMax"
      :barConer="2"
      :useDefaultCoclor="true"
      :legend="{
        textStyle: {
          color: '#acdddf',
          fontSize: 12,
        },
        show: true,
        orient: 'horizontal',
        // right: '20%',
        // top: 'center',
        icon: 'circle',
        itemWidth: 12,
        itemHeight: 12,
        y: 'top',
        x: 'center',
        type: 'scroll', // 显示分页
      }"
      :grid="{
        top: 50,
        left: 10,
        right: 10,
        bottom: 0,
        containLabel: true, // 是否包含坐标轴的刻度标签
      }"
      axisLineColor="#acdddf"
      fontColor="#acdddf"
      :isAutomaticCarousel="true"
      tooltipTextColor="#fff"
      tooltipBackgroundColor="rgba(3, 53, 139, .9)"
    />
  </div>
</template>

<style lang="scss">
  .area-danger-bs {
  .el-loading-mask {
    background-color: rgba(30, 90, 142, 0.7); /* 更改为你想要的颜色 */
  }
}
</style>