Newer
Older
xc-business-system / src / views / dataManagement / components / data / meteringVerification.vue
dutingting on 29 Nov 10 KB 临时提交
<!-- 计量检定分析  --数据看板 -->
<script name="meteringVerification" lang="ts" setup>
import dayjs from 'dayjs'
import draggable from 'vuedraggable'
import { colors } from '../environment/colors'
import { getRangeAllTime } from '@/utils/date'
import ScrollTable from '@/components/ScrollTable/index.vue'
const props = defineProps({
  lab: {
    type: String,
    default: '',
  },
})
watch(() => props.lab, (newVal) => {
  if (newVal) {
    fetchData()
  }
})
const showChart = ref<any[]>([
  {
    name: '在检智能模型分析',
    type: 'pie',
    source: 'system',
    center: ['50%', '60%'],
    labelPosition: 'outside',
    radius: '70%',
    data: [],
  },
  {
    name: '当年已检智能模型排行TOP10',
    type: 'rank-table',
    source: 'system',
    data: [],
    columns: [
      {
        text: '智能模型名称',
        value: 'name',
        align: 'center',
      },
      {
        text: '已检数量',
        value: 'count',
        align: 'center',
      },
    ],
  },
  {
    name: '检定及时分析',
    type: 'pie',
    source: 'system',
    center: ['50%', '60%'],
    labelPosition: 'outside',
    radius: '70%',
    data: [],
  },
  {
    name: '检定结果分析',
    type: 'bar-horizontal',
    source: 'system',
    xAxisData: [],
    data: [],
    smooth: false,
    gradient: false,
  },
])
watch(() => showChart.value.length, () => {
  setTimeout(() => {
    const resize = new Event('resize')
    window.dispatchEvent(resize)
  })
})
// 模拟数据
const loading = ref(false)
function fetchData() {
  loading.value = true
  setTimeout(() => {
    // 在检智能模型分析
    const name1 = ['分包方', '无线脉冲组', '电学电源组', '热工力学组', '智能模型分包方']
    showChart.value.filter((item: any) => item.name === '在检智能模型分析')[0].data = name1.map((item: string) => ({
      name: item,
      value: String(Math.floor(Math.random() * 100) + 1),
    }))
    // 当年已检智能模型排行TOP10
    const name2 = ['模拟示波器', '功率计', '铷种', '通用技术器', '一般压力表', '精密压力表', '数字多用表', '频谱分析仪', '频率计数器', '多功能电力参数测量仪']
    showChart.value.filter((item: any) => item.name === '当年已检智能模型排行TOP10')[0].data = name2.map((item: string) => ({
      name: item,
      count: String(Math.floor(Math.random() * 100) + 1),
    }))
    console.log(showChart.value.filter((item: any) => item.name === '当年已检智能模型排行TOP10')[0])
    // 检定及时分析
    const name3 = ['提前检定', '按时检定', '滞后检定']
    showChart.value.filter((item: any) => item.name === '检定及时分析')[0].data = name3.map((item: string) => ({
      name: item,
      value: String(Math.floor(Math.random() * 100) + 1),
    }))
    // 检定结果分析
    const name4 = ['合格', '限用', '停用', '校准']
    showChart.value.filter((item: any) => item.name === '检定结果分析')[0].data = [{
      name: '数量',
      data: name4.map(item => Math.floor(Math.random() * 100) + 1),
    }]
    showChart.value.filter((item: any) => item.name === '检定结果分析')[0].xAxisData = name4
    loading.value = false
  }, 3000)
}
setTimeout(() => {
  fetchData()
}, 100)
defineExpose({
  showChart,
})

// 拖拽结束
const onEnd = () => {
  console.log('拖拽结束')
  const resize = new Event('resize')
  window.dispatchEvent(resize)
}
</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">
              1476
            </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">
              67
            </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">
              45
            </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">
              90%
            </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">
              48%
            </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">
              12%
            </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">
              92%
            </div>
          </div>
        </div>
      </div>
      <!-- 图表区域 -->
      <!-- <div class="chart"> -->
      <draggable
        v-model="showChart" item-key="name" class="chart"
        animation="300"
        drag-class="dragClass"
        ghost-class="ghostClass"
        chosen-class="chosenClass"
        @end="onEnd"
      >
        <template #item="{ element, index }">
          <div :style="{ width: `${showChart.length === 4 ? '48%' : index === 0 || index === 1 ? '48%' : '31.5%'}` }" class="chart-item">
            <div class="chart-name">
              {{ element.name }}
            </div>
            <div v-loading="loading" class="chart-page">
              <pie-chart v-if="element.type === 'pie'" :title="element.title" :show-total="element.showTotal" :data="element.data" :colors="colors" :center="element.center" label-formatter="{style1|{c}}" :label-position="element.labelPosition" :radius="element.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' }" />
              <scroll-table v-if="element.type === 'rank-table'" style="width: 100%;" :height="330" :data="element.data" :columns="element.columns" />
              <line-chart v-if="element.type === 'line'" :colors="colors" :gradient="element.gradient" :x-axis-data="element.xAxisData" :data="element.data" :smooth="element.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-vertical v-if="element.type === 'bar-vertical'" :bar-coner="0" :data="element.data" :x-axis-data="element.xAxisData" :legend="{ itemWidth: 8, itemHeight: 8, type: 'scroll', orient: 'horizontal', icon: 'roundRect', left: '0', top: '10' }" />
              <bar-chart-horizontal v-if="element.type === 'bar-horizontal'" bar-width="10" :bar-coner="0" :data="element.data" :x-axis-data="element.xAxisData" :legend="{ itemWidth: 8, itemHeight: 8, type: 'scroll', orient: 'horizontal', icon: 'roundRect', left: '0', top: '10' }" />
            </div>
          </div>
        </template>
      </draggable>
      <!-- </div> -->
    </div>
  </div>
</template>

<style lang="scss" scoped>
.dragClass {
  /* background-color: blueviolet !important; */
  opacity: 1 !important;
  box-shadow: none !important;
  outline: none !important;
  background-image: none !important;
  color: #6ff !important;
}

.ghostClass {
  /* background-color: blue !important; */
}

.chosenClass {
  color: #6ff !important;

  /* background-color: #ccc !important; */

  /* opacity: 1 !important; */

  /* width: 32.5% !important; */
}

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

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

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