index.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <a-card title="系统概览" >
  3. <a-row justify="space-between" >
  4. <a-col>
  5. <a-select style="width: 170px;" v-model:value="spaceId" >
  6. <a-select-option v-for="item in spaceList" :key="item.id" :value="item.spaceId" >{{item.spaceName}}</a-select-option>
  7. </a-select>
  8. </a-col>
  9. <a-col><a-button type="primary" @click="reload" >刷新</a-button></a-col>
  10. </a-row>
  11. <!-- 仪表盘 -->
  12. <a-spin :spinning="loading" >
  13. <div class="board">
  14. <a-row>
  15. <a-col :span="24" >今日数据</a-col>
  16. <a-col :span="24">
  17. <a-row align="middle" >
  18. <a-col :span="8" >
  19. <div id="pie" style="width: 200px;height: 300px;" ></div>
  20. </a-col>
  21. <a-col :span="16" >
  22. <a-row :gutter="[8, 8]" >
  23. <a-col :span="11" v-for="(item, index) in statisticList" :key="index" >
  24. <a-statistic
  25. :title="item.label"
  26. :value="0"
  27. :precision="2"
  28. suffix="%"
  29. :value-style="{ color: '#3f8600' }"
  30. style="margin-right: 50px"
  31. >
  32. <template #prefix>
  33. <arrow-up-outlined />
  34. </template>
  35. </a-statistic>
  36. </a-col>
  37. </a-row>
  38. </a-col>
  39. </a-row>
  40. </a-col>
  41. </a-row>
  42. </div>
  43. </a-spin>
  44. </a-card>
  45. </template>
  46. <script lang='ts' setup >
  47. import { SpaceController } from '@/controller'
  48. import { onMounted, ref } from 'vue'
  49. import * as echarts from 'echarts'
  50. import { pieOption } from './echartsJson'
  51. import { ArrowUpOutlined } from '@ant-design/icons-vue'
  52. import { useSchedulerOnce } from '@/hooks'
  53. const spaceList = ref<CVS.space[]>([])
  54. const spaceId = ref(null)
  55. const loading = ref<boolean>(false)
  56. const statisticList = [{ label: '上行带宽峰值' }, { label: '上行流量' }, { label: '下行带宽峰值' }, { label: '下行流量' }]
  57. const initPie = () => {
  58. const chartDom = document.getElementById('pie')!
  59. const myChart = echarts.init(chartDom)
  60. myChart.setOption(pieOption)
  61. }
  62. const reload = () => {
  63. loading.value = true
  64. useSchedulerOnce(() => {
  65. console.log('????')
  66. loading.value = false
  67. }, 1000)
  68. }
  69. const getSpaceList = async () => {
  70. spaceList.value = await SpaceController.list()
  71. spaceId.value = spaceList.value[0].spaceId
  72. }
  73. onMounted(() => {
  74. getSpaceList()
  75. initPie()
  76. reload()
  77. })
  78. </script>
  79. <style lang='less' scoped >
  80. .board {
  81. width: 100%;
  82. margin-top: 10px;
  83. padding: 10px 20px 20px;
  84. border: 1px solid #ebebeb;
  85. }
  86. </style>
  87. ./echartsJson