SpotCheckContent.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div class="abnormal-situation-ranking">
  3. <div ref="abnormalSituationRankingChart" class="echarts" />
  4. <div class="item">
  5. <div v-for="(item, index) in list" class="item-line">
  6. <span :style="{background:color[index]}" class="color"></span>
  7. <span>{{ item.name }}</span>
  8. </div>
  9. </div>
  10. </div>
  11. </template>
  12. <script setup>
  13. import { computed, onMounted, ref } from 'vue';
  14. import * as echarts from 'echarts';
  15. import { executeSqlByKeyAndParam } from '@/api/system/sql.js';
  16. import { useEcharts } from '@/hooks/chart.js';
  17. const color = [
  18. '#1DD8FE',
  19. '#8639F8',
  20. ];
  21. const abnormalSituationRankingChart = ref(null);
  22. const chartOption = ref({
  23. color,
  24. radar: [
  25. {
  26. indicator: [],
  27. nameGap: 3,
  28. center: ['50%', '50%'],
  29. radius: 80,
  30. splitNumber: 4,
  31. axisName: {
  32. color: '#fbffff',
  33. },
  34. axisLine: {
  35. lineStyle: {
  36. color: '#fbffff',
  37. opacity: 0.1,
  38. },
  39. },
  40. splitArea: {
  41. areaStyle: {
  42. color: ['none', 'none'],
  43. },
  44. },
  45. splitLine: {
  46. lineStyle: { //所有圆环分隔线。
  47. color: '#fbffff', //分隔线颜色
  48. opacity: 0.5,
  49. },
  50. },
  51. },
  52. ],
  53. series: [
  54. {
  55. type: 'radar',
  56. data: [
  57. {
  58. value: [],
  59. symbol: 'none',
  60. areaStyle: {
  61. color: new echarts.graphic.RadialGradient(1, 1, 1, [
  62. {
  63. color: 'rgba(24,139,178, 0.5)',
  64. offset: 0,
  65. },
  66. {
  67. color: 'rgba(58,146,228, 0.9)',
  68. offset: 1,
  69. },
  70. ]),
  71. },
  72. },
  73. {
  74. value: [],
  75. symbol: 'none',
  76. areaStyle: {
  77. color: new echarts.graphic.RadialGradient(1, 1, 1, [
  78. {
  79. color: 'rgba(58,148,228, 0.5)',
  80. offset: 0,
  81. },
  82. {
  83. color: 'rgba(98,49,189, 0.9)',
  84. offset: 1,
  85. },
  86. ]),
  87. },
  88. },
  89. ],
  90. },
  91. ],
  92. });
  93. const { setOption } = useEcharts(abnormalSituationRankingChart);
  94. const list = computed(() => {
  95. return [
  96. { name: '抽查正常', color: color[0] },
  97. { name: '抽查异常', color: color[1] },
  98. ];
  99. });
  100. onMounted(() => {
  101. executeSqlByKeyAndParam('spot_check_content_distribution', {}).then(res => {
  102. chartOption.value.radar[0].indicator = res.data.map((el, idx) => {
  103. return {
  104. max: el.total_count,
  105. text: el.category_name,
  106. };
  107. });
  108. chartOption.value.series[0].data[0].value = res.data.map(el => el.pass_count);
  109. chartOption.value.series[0].data[1].value = res.data.map(el => el.fail_count);
  110. setOption?.(chartOption.value);
  111. });
  112. });
  113. </script>
  114. <style lang="less" scoped>
  115. .abnormal-situation-ranking {
  116. display: flex;
  117. height: calc(100% - 40px);
  118. .echarts {
  119. flex: 1;
  120. height: 100%;
  121. width: 100%;
  122. }
  123. .item {
  124. width: 100px;
  125. padding: 20px 0;
  126. display: flex;
  127. justify-content: center;
  128. flex-flow: column;
  129. }
  130. .item-line {
  131. display: flex;
  132. align-items: center;
  133. color: #fbffff;
  134. font-size: 12px;
  135. width: 100%;
  136. margin: 8px 0;
  137. .color {
  138. display: inline-flex;
  139. width: 10px;
  140. height: 10px;
  141. border-radius: 5px;
  142. margin-right: 4px;
  143. }
  144. .text {
  145. flex: 1;
  146. display: flex;
  147. justify-content: space-between;
  148. span {
  149. display: inline-flex;
  150. width: 33.33%;
  151. }
  152. }
  153. }
  154. }
  155. </style>