enroll-dashboard.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <mx-echarts ref="echarts" :options="option" canvas-id="dashboard"/>
  3. </template>
  4. <script setup>
  5. import {onMounted, ref} from 'vue'
  6. import {useEventListener} from "@vueuse/core";
  7. import {useTransfer} from "@/hooks/useTransfer";
  8. import {useTheme} from "@/hooks/useTheme";
  9. import mxConst from "@/common/mxConst";
  10. const option = ref({})
  11. const {theme} = useTheme()
  12. const {transferTo} = useTransfer()
  13. const echarts = ref(null)
  14. useEventListener(echarts, 'click', (e) => {
  15. const sysInfo = uni.getSystemInfoSync()
  16. const {x, y} = e
  17. const [width, height] = [120, 60]
  18. const rect = {x: (sysInfo.windowWidth - width) / 2, y: 140, width, height}
  19. if (x >= rect.x && x <= rect.x + rect.width &&
  20. y >= rect.y && y <= rect.y + rect.height) {
  21. transferTo(mxConst.routes.portal)
  22. }
  23. })
  24. // hooks
  25. onMounted(() => {
  26. initChart()
  27. })
  28. function initChart() {
  29. option.value = {
  30. series: [
  31. {
  32. type: 'gauge',
  33. center: ['50%', '50%'],
  34. startAngle: 200,
  35. endAngle: -20,
  36. min: 0,
  37. max: 100,
  38. splitNumber: 2,
  39. itemStyle: {
  40. color: {
  41. type: 'linear',
  42. x: 0,
  43. y: 0,
  44. x2: 1,
  45. y2: 0,
  46. colorStops: [{
  47. offset: 0, color: theme.value.colors['primary-deep']
  48. }, {
  49. offset: 1, color: theme.value.colors['primary-light']
  50. }]
  51. }
  52. },
  53. progress: {
  54. show: true,
  55. roundCap: true,
  56. width: 15,
  57. },
  58. pointer: {
  59. showAbove: true,
  60. icon: 'arrow',
  61. width: 12,
  62. length: 18,
  63. offsetCenter: [0, '-70%']
  64. },
  65. axisLine: {
  66. roundCap: true,
  67. lineStyle: {
  68. width: 15
  69. }
  70. },
  71. axisTick: {
  72. show: false
  73. },
  74. splitLine: {
  75. show: false
  76. },
  77. axisLabel: {
  78. distance: -40,
  79. fontSize: 14,
  80. color: theme.value.colors.content,
  81. fontWeight: 'lighter',
  82. formatter: v => ({0: '冲', 50: '稳', 100: '保'})[v]
  83. },
  84. detail: {
  85. show: true,
  86. formatter: v => '点击查看',
  87. color: theme.value.colors.tips,
  88. fontSize: 16,
  89. fontWeight: 'lighter',
  90. offsetCenter: [0, '10%']
  91. },
  92. title: {
  93. show: true,
  94. color: theme.value.brands.primary,
  95. offsetCenter: [0, '-20%']
  96. },
  97. data: [
  98. {
  99. value: 100,
  100. name: '测院校录取率'
  101. }
  102. ]
  103. }
  104. ]
  105. }
  106. }
  107. </script>
  108. <style scoped>
  109. </style>