Newer
Older
xc-business-system / src / views / dataManagement / components / data / standardDevice.vue
lyg on 22 May 2024 8 KB 安全阀问题修改
<!-- 标准装置分析  --数据看板 -->
<script name="standardDevice" lang="ts" setup>
import dayjs from 'dayjs'
import { colors } from '../environment/colors'
import { getRangeAllTime } from '@/utils/date'
const props = defineProps({
  lab: {
    type: String,
    default: '',
  },
})

watch(() => props.lab, (newVal) => {
  if (newVal) {
    fetchData()
  }
})
const showChart = ref<any[]>([
  {
    name: '近五年标准装置复查趋势',
    type: 'line',
    source: 'system',
    smooth: false,
  },
  {
    name: '标准装置状态分析',
    type: 'bar-horizontal',
    source: 'system',
  },
  {
    name: '近一年部门核查分析',
    type: 'bar-vertical',
    source: 'system',
  },
  {
    name: '当年标准装置核查排行版',
    type: 'rank-table',
    source: 'system',
    columns: [
      {
        text: '标准装置名称',
        value: 'name',
        align: 'center',
      },
      {
        text: '本年度核查次数',
        value: 'dept',
        align: 'center',
      },
      {
        text: '最近核查时间',
        value: 'count',
        align: 'center',
      },

    ],
    data: [],
  },
])
watch(() => showChart.value.length, () => {
  setTimeout(() => {
    const resize = new Event('resize')
    window.dispatchEvent(resize)
  })
})
// 模拟数据
const loading = ref(false)
function fetchData() {
  loading.value = true
  // 近五年标准装置复查趋势
  const name1 = ['电学电源组', '热工压力组', '无线脉冲组']
  const name2 = [] as any[]
  for (let i = Number(dayjs().format('YYYY')); i > Number(dayjs().format('YYYY')) - 5; i--) {
    name2.push(i)
  }
  showChart.value.filter((item: any) => item.name === '近五年标准装置复查趋势')[0].xAxisData = name2.reverse
  showChart.value.filter((item: any) => item.name === '近五年标准装置复查趋势')[0].data = name1.map(item => ({
    name: item,
    data: name2.map(item => Math.floor(Math.random() * 100) + 1),
    symbol: 'emptyCircle',
  }))
  //  标准装置状态分析
  const name3 = ['撤销', '更换', '建标']
  showChart.value.filter((item: any) => item.name === '标准装置状态分析')[0].data = name3.map(item => ({
    name: item,
    data: name1.map(item => Math.floor(Math.random() * 100) + 1),
  }))
  showChart.value.filter((item: any) => item.name === '标准装置状态分析')[0].xAxisData = name1
  // 近一年部门核查分析
  const name4 = dayjs().subtract(6, 'month').format('YYYY-MM')
  console.log(name4, 'name4')
  setTimeout(() => {
    loading.value = false
  }, 3000)
}
setTimeout(() => {
  fetchData()
}, 100)
</script>

<template>
  <div class="container">
    <!-- 展示内容 -->
    <div class="content-count">
      <!-- 统计数据 -->
      <div class="count">
        <div class="count-item">
          <div class="header-icon">
            <svg-icon name="icon-env-device-online" class="icon-button-icon" />
          </div>
          <div class="header-content">
            <div class="content-title">
              标准装置总数
            </div>
            <div class="content-count">
              30214
            </div>
          </div>
        </div>
        <div class="count-item">
          <div class="header-icon">
            <svg-icon name="icon-env-device-online" class="icon-button-icon" />
          </div>
          <div class="header-content">
            <div class="content-title">
              当年复查标准装置总数
            </div>
            <div class="content-count">
              1538
            </div>
          </div>
        </div>
        <div class="count-item">
          <div class="header-icon">
            <svg-icon name="icon-env-device-online" class="icon-button-icon" />
          </div>
          <div class="header-content">
            <div class="content-title">
              核查记录总数
            </div>
            <div class="content-count">
              1445
            </div>
          </div>
        </div>
        <div class="count-item">
          <div class="header-icon">
            <svg-icon name="icon-env-device-online" class="icon-button-icon" />
          </div>
          <div class="header-content">
            <div class="content-title">
              核查记录总数(本年度)
            </div>
            <div class="content-count">
              3641
            </div>
          </div>
        </div>
        <div class="count-item">
          <div class="header-icon">
            <svg-icon name="icon-env-device-online" class="icon-button-icon" />
          </div>
          <div class="header-content">
            <div class="content-title">
              核查记录总数(本季度)
            </div>
            <div class="content-count">
              1039
            </div>
          </div>
        </div>
      </div>
      <!-- 图表区域 -->
      <div class="content">
        <div class="chart">
          <div v-for="(item, index) in showChart" :key="item" :style="{ width: `${showChart.length === 4 ? '48%' : index === 0 || index === 1 ? '48%' : '31.5%'}` }" class="chart-item">
            <div class="chart-name">
              {{ item.name }}
            </div>
            <div v-if="item.needSearch" class="chart-search" />
            <div v-loading="loading" class="chart-page">
              <pie-chart v-if="item.type === 'pie'" :data="item.data" :colors="colors" :center="item.center" label-formatter="{style1|{c}}" :label-position="item.labelPosition" :radius="item.radius" :grid="{ top: 50, left: 15, right: 15, bottom: 10, containLabel: true }" :legend="{ itemWidth: 8, itemHeight: 8, type: 'scroll', orient: 'horizontal', icon: 'roundRect', left: '0', top: '10' }" />
              <line-chart v-if="item.type === 'line'" :colors="colors" :gradient="item.gradient" :x-axis-data="item.xAxisData" :data="item.data" :smooth="item.smooth" :grid="{ top: 47, left: 5, right: 5, bottom: 10, containLabel: true }" :legend="{ itemWidth: 8, itemHeight: 2, type: 'scroll', orient: 'horizontal', icon: 'roundRect', left: '0', top: '5' }" />
              <bar-chart-horizontal-rank v-if="item.type === 'rank'" :colors="colors" label-position="" :x-axis-data="item.xAxisData" :data="item.data" font-color="#000" :grid="{ top: 10, left: 20, right: 20, bottom: 10, containLabel: true }" :legend="{ }" />
              <scroll-table v-if="item.type === 'rank-table'" style="width: 100%;" :height="330" :data="item.data" :columns="item.columns" />
              <bar-chart-horizontal v-if="item.type === 'bar-horizontal'" :bar-coner="0" :data="item.data" :x-axis-data="item.xAxisData" :legend="{ itemWidth: 8, itemHeight: 8, type: 'scroll', orient: 'horizontal', icon: 'roundRect', left: '0', top: '10' }" />
              <bar-chart-vertical v-if="item.type === 'bar-vertical'" :bar-coner="0" :data="item.data" :x-axis-data="item.xAxisData" :legend="{ itemWidth: 8, itemHeight: 8, type: 'scroll', orient: 'horizontal', icon: 'roundRect', left: '0', top: '10' }" />
            </div>
          </div>
        </div>
        <div class="swiper" />
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.content {
  display: flex;

  .chart {
    width: 70%;
  }

  .swiper {
    width: 30%;
  }
}

.icon-button-icon {
  width: 50px;
  height: 50px;
}

.container {
  position: relative;
  // height: 500px;

  .btns {
    width: 100%;
    position: absolute;
    top: -36px;
    right: 60%;
    // left: 50%;
    display: flex;
    justify-content: space-between;
    padding: 0 60px;
  }

  .count {
    display: flex;
    width: 66%;
    margin: 0 auto;
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);

    .count-item {
      // margin-left: 20px;
      width: 40%;
      height: 75px;
      display: flex;
      padding: 0 10px;
      justify-content: space-around;

      .header-icon {
        width: 20%;
        display: flex;
        flex-direction: column;
        justify-content: center;
      }

      .header-content {
        // width: 60%;
        padding: 10px;
        display: flex;
        flex-direction: column;
        justify-content: space-around;

        .content-title {
          font-weight: 700;
        }

        .content-count {
          font-weight: 700;
          font-size: 24px;
          color: #1aaf8b;
        }
      }
    }
  }

  .chart {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    // margin-top: 15px;
    padding-top: 20px;

    .chart-item {
      width: 33%;
      height: 348px;
      // border: 1px solid red;
      margin-top: 10px;

      .chart-name {
        color: #3d6fb6;
        font-size: 18px;
        font-weight: 700;
      }

      .chart-page {
        height: 330px;
      }
    }
  }
}
</style>