center-bottom.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <v-chart
  3. class="chart"
  4. :option="option"
  5. v-if="JSON.stringify(option) != '{}'"
  6. />
  7. </template>
  8. <script setup lang="ts">
  9. import { ref, reactive, onMounted, nextTick } from "vue";
  10. import { currentGET } from "@/api";
  11. import { graphic } from "echarts/core";
  12. import signalR from "@/utils/signalR";
  13. const option = ref({});
  14. const getData = () => {
  15. currentGET("centerBottom", {}).then((res) => {
  16. console.log("工单类型统计", res);
  17. if (res.success) {
  18. setOption(res.data);
  19. } else {
  20. window["$message"]({
  21. text: res.msg,
  22. type: "warning",
  23. });
  24. }
  25. });
  26. const setOption = async (newData: any) => {
  27. option.value = {
  28. tooltip: {
  29. trigger: "axis",
  30. backgroundColor: "rgba(0,0,0,.6)",
  31. borderColor: "rgba(147, 235, 248, .8)",
  32. textStyle: {
  33. color: "#FFF",
  34. },
  35. formatter: function (params: any) {
  36. // 添加单位
  37. var result = params[0].name + "<br>";
  38. params.forEach(function (item: any) {
  39. if (item.value) {
  40. if (item.seriesName == "安装率") {
  41. result +=
  42. item.marker +
  43. " " +
  44. item.seriesName +
  45. " : " +
  46. item.value +
  47. "%</br>";
  48. } else {
  49. result +=
  50. item.marker +
  51. " " +
  52. item.seriesName +
  53. " : " +
  54. item.value +
  55. "个</br>";
  56. }
  57. } else {
  58. result += item.marker + " " + item.seriesName + " : - </br>";
  59. }
  60. });
  61. return result;
  62. },
  63. },
  64. legend: {
  65. data: ["已安装", "计划安装", "安装率"],
  66. textStyle: {
  67. color: "#B4B4B4",
  68. },
  69. top: "0",
  70. },
  71. grid: {
  72. left: "50px",
  73. right: "40px",
  74. bottom: "30px",
  75. top: "20px",
  76. },
  77. xAxis: {
  78. data: newData.category,
  79. axisLine: {
  80. lineStyle: {
  81. color: "#B4B4B4",
  82. },
  83. },
  84. axisTick: {
  85. show: false,
  86. },
  87. },
  88. yAxis: [
  89. {
  90. splitLine: { show: false },
  91. axisLine: {
  92. lineStyle: {
  93. color: "#B4B4B4",
  94. },
  95. },
  96. axisLabel: {
  97. formatter: "{value}",
  98. },
  99. },
  100. {
  101. splitLine: { show: false },
  102. axisLine: {
  103. lineStyle: {
  104. color: "#B4B4B4",
  105. },
  106. },
  107. axisLabel: {
  108. formatter: "{value}% ",
  109. },
  110. },
  111. ],
  112. series: [
  113. {
  114. name: "已安装",
  115. type: "bar",
  116. barWidth: 10,
  117. itemStyle: {
  118. borderRadius: 5,
  119. color: new graphic.LinearGradient(0, 0, 0, 1, [
  120. { offset: 0, color: "#956FD4" },
  121. { offset: 1, color: "#3EACE5" },
  122. ]),
  123. },
  124. data: newData.barData,
  125. },
  126. {
  127. name: "计划安装",
  128. type: "bar",
  129. barGap: "-100%",
  130. barWidth: 10,
  131. itemStyle: {
  132. borderRadius: 5,
  133. color: new graphic.LinearGradient(0, 0, 0, 1, [
  134. { offset: 0, color: "rgba(156,107,211,0.8)" },
  135. { offset: 0.2, color: "rgba(156,107,211,0.5)" },
  136. { offset: 1, color: "rgba(156,107,211,0.2)" },
  137. ]),
  138. },
  139. z: -12,
  140. data: newData.lineData,
  141. },
  142. {
  143. name: "安装率",
  144. type: "line",
  145. smooth: true,
  146. showAllSymbol: true,
  147. symbol: "emptyCircle",
  148. symbolSize: 8,
  149. yAxisIndex: 1,
  150. itemStyle: {
  151. color: "#F02FC2",
  152. },
  153. data: newData.rateData,
  154. },
  155. ],
  156. };
  157. };
  158. };
  159. onMounted(() => {
  160. getData();
  161. signalR.joinGroup("BsDataShowArea5");
  162. });
  163. </script>
  164. <style scoped lang="scss"></style>