Newer
Older
xc-business-system / src / views / dataManagement / components / data / resourceManage.vue
lyg on 21 May 2024 9 KB 数据看板开发(5个)
<!-- 资源管理分析  --数据看板 -->
<script name="resourceManage" 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',
    xAxisData: [],
    data: [],
    smooth: false,
    gradient: true,
  },
  {
    name: '人员证书分布',
    type: 'bar-double',
    source: 'system',
    legendData: [],
    xAxisData: [],
    data1: [],
    data2: [],

  },
  {
    name: '体系文件分类',
    type: 'pie',
    source: 'system',
    data: [],
    labelPosition: 'outside',
    radius: ['60%', '45%'],
  },
  {
    name: '测试校准检定方法查新分析',
    type: 'bar-vertical',
    source: 'bar',
  },
])
watch(() => showChart.value.length, () => {
  setTimeout(() => {
    const resize = new Event('resize')
    window.dispatchEvent(resize)
  })
})
// 模拟数据
const loading = ref(false)
function fetchData() {
  loading.value = true
  // 人员持证到期趋势
  const name1 = ['2023年第一季度', '2023年第二季度', '2023年第三季度', '2023年第四季度', '2024年第一季度', '2024年第二季度', '2024年第三季度', '2024年第四季度']
  showChart.value.filter((item: any) => item.name === '人员持证到期趋势')[0].data = [{
    name: '持证证书数量',
    symbol: 'emptyCircle',
    data: name1.map(item => Math.floor(Math.random() * 100) + 1),
  }]
  showChart.value.filter((item: any) => item.name === '人员持证到期趋势')[0].xAxisData = name1
  // 人员证书分布
  const name2 = ['证书总数', '有效证书总数']
  const name3 = ['检定员证', '内审员证', '其他']
  showChart.value.filter((item: any) => item.name === '人员证书分布')[0].legendData = name2
  showChart.value.filter((item: any) => item.name === '人员证书分布')[0].xAxisData = name3
  showChart.value.filter((item: any) => item.name === '人员证书分布')[0].data1 = name3.map(() => Math.floor(Math.random() * 100) + 1)
  showChart.value.filter((item: any) => item.name === '人员证书分布')[0].data2 = showChart.value.filter((item: any) => item.name === '人员证书分布')[0].data1.map(item => item - 5 > 0 ? item - 5 : 0)
  // 体系文件分类
  const name4 = ['质量手册', '程序文件', '作业指导书', '其他']
  showChart.value.filter((item: any) => item.name === '体系文件分类')[0].data = name4.map(item => ({
    name: item,
    value: Math.floor(Math.random() * 100) + 1,
  }))
  // 测试校准检定方法查新分析
  const name5 = ['电学电源组', '无线脉冲组', '热工力学组']
  const name6 = ['有查新', '无查新']
  showChart.value.filter((item: any) => item.name === '测试校准检定方法查新分析')[0].data = name6.map(item => ({
    name: item,
    data: name5.map(item => Math.floor(Math.random() * 100) + 1),
  }))
  showChart.value.filter((item: any) => item.name === '测试校准检定方法查新分析')[0].xAxisData = name5
  setTimeout(() => {
    const resize = new Event('resize')
    window.dispatchEvent(resize)
  })
  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">
              3021
            </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">
              60141
            </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">
              36412
            </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">
              3264
            </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">
              4532
            </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">
              6842
            </div>
          </div>
        </div>
      </div>
      <!-- 图表区域 -->
      <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-loading="loading" class="chart-page">
            <pie-chart v-if="item.type === 'pie'" title=" " :show-total="true" :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-double v-if="item.type === 'bar-double'" :legend-data="item.legendData" :data1="item.data1" :data2="item.data2" :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>
  </div>
</template>

<style lang="scss" scoped>
.icon-button-icon {
  width: 50px;
  height: 50px;
}

.container {
  position: relative;

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

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

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

      .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>