right-center.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div class="right_center">
  3. <div class="right_center-title">
  4. <div class="flex items-center">
  5. <img src="@/assets/img/home/title_arrow.png" alt="" />
  6. 问题类型统计
  7. </div>
  8. </div>
  9. <div class="right_center-content h100">
  10. <template v-if="list.length">
  11. <v-chart
  12. class="chart"
  13. :option="option"
  14. :loading="loading"
  15. :loading-options="loadingOptions"
  16. />
  17. </template>
  18. <empty v-else />
  19. </div>
  20. </div>
  21. </template>
  22. <script setup lang="ts">
  23. import { defineAsyncComponent, onMounted, ref, watch } from "vue";
  24. import { loadingOptions } from "@/utils/constants";
  25. import { problemType } from "@/api/judicial";
  26. import dayjs from "dayjs";
  27. import mittBus from "@/utils/mitt";
  28. const Empty = defineAsyncComponent(
  29. () => import("@/components/Empty/index.vue")
  30. );
  31. const props = defineProps({
  32. dateArray: {
  33. type: Array,
  34. default: () => [],
  35. },
  36. });
  37. const date = ref([]);
  38. watch(
  39. () => props.dateArray,
  40. (val: any) => {
  41. date.value = val;
  42. },
  43. { immediate: true }
  44. );
  45. watch(
  46. () => props.dateArray,
  47. (val: any) => {
  48. getData();
  49. }
  50. );
  51. const list = ref<any>([]);
  52. const loading = ref(false);
  53. const option = ref<any>({});
  54. const AreaCode = ref(null);
  55. const getData = async () => {
  56. loading.value = true;
  57. try {
  58. const { result } = await problemType({
  59. StartTime: dayjs(date.value[0]).format("YYYY-MM-DD"),
  60. EndTime: dayjs(date.value[1]).format("YYYY-MM-DD"),
  61. AreaCode: AreaCode.value,
  62. });
  63. /* const result = [
  64. {
  65. eventTypeName: "不作为",
  66. count: 5,
  67. },
  68. {
  69. eventTypeName: "乱作为",
  70. count: 10,
  71. },
  72. {
  73. eventTypeName: "程序不规范",
  74. count: 6,
  75. },
  76. {
  77. eventTypeName: "结果不公正",
  78. count: 12,
  79. },
  80. ];*/
  81. const xData = result.map((item: any) => {
  82. return item.eventTypeName;
  83. });
  84. list.value = result.map((item: any) => {
  85. return item.count;
  86. });
  87. setOption(xData, list.value);
  88. loading.value = false;
  89. } catch (e) {
  90. loading.value = false;
  91. console.log(e);
  92. }
  93. };
  94. const setOption = (xData: any, data: any) => {
  95. option.value = {
  96. tooltip: {
  97. trigger: "axis",
  98. axisPointer: {
  99. type: "shadow",
  100. },
  101. },
  102. grid: {
  103. left: "5%",
  104. right: "5%",
  105. containLabel: true,
  106. },
  107. xAxis: {
  108. type: "category",
  109. data: xData,
  110. axisLabel: {
  111. color: "#fff",
  112. },
  113. },
  114. yAxis: {
  115. type: "value",
  116. axisLabel: {
  117. color: "#fff",
  118. },
  119. },
  120. series: [
  121. {
  122. data: data,
  123. type: "bar",
  124. barWidth: "20",
  125. },
  126. ],
  127. };
  128. };
  129. onMounted(() => {
  130. getData();
  131. mittBus.on("SelectArea", (data: any) => {
  132. AreaCode.value = data.areaCode;
  133. getData();
  134. });
  135. });
  136. </script>
  137. <style scoped lang="scss">
  138. .right_center {
  139. &-content {
  140. margin-top: 15px;
  141. height: 100%;
  142. }
  143. &-title {
  144. display: flex;
  145. justify-content: space-between;
  146. align-items: center;
  147. padding-right: 20px;
  148. }
  149. }
  150. </style>