runTendency.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <div class="content-chart-row">
  3. <div class="column-row-title">
  4. <span class="title-text"><img src="@/assets/images/title-icon.png" alt=""/>重点指标运行趋势
  5. <span class="s-span">(周)</span>
  6. </span>
  7. <span class="btn-span" @click="visible=true">指标配置</span>
  8. </div>
  9. <div class="column-content chart-content run-tendency">
  10. <div class="run-title">
  11. <div v-for="(item,index) in trendData" :class="[`r-t-row`,{'active':index===active}]" @click="clickTrend(index)">
  12. <div class="r-value">{{item.value.toFixed(1)}}%</div>
  13. <div>
  14. <div class="r-obj-name">{{item.objName}}</div>
  15. <div class="r-obj-metrics-name">{{item.metricsName}}</div>
  16. </div>
  17. </div>
  18. </div>
  19. <div class="chart-sort" v-if="trendData[active]">
  20. {{trendData[active].objName || "-"}}
  21. <div ref="chartSort" style="height: 218px;" />
  22. </div>
  23. </div>
  24. </div>
  25. <el-dialog title="指标配置" v-model="visible" width="600">
  26. <index-config @update="getMsTrend"/>
  27. </el-dialog>
  28. </template>
  29. <script setup lang="ts">
  30. import {msTrend,msTrendDetail} from "@/api/index/hl"
  31. import {formatDate} from "@/utils/index.js"
  32. import indexConfig from "./indexConfig.vue"
  33. import * as echarts from "echarts";
  34. const trendData = ref([])
  35. const active = ref(0)
  36. const chartSort = ref(null)
  37. const visible = ref(false)
  38. onMounted(() => {
  39. getMsTrend()
  40. })
  41. async function getMsTrend(){
  42. const res = await msTrend()
  43. trendData.value = res.data
  44. await clickTrend(0)
  45. }
  46. async function clickTrend(index){
  47. active.value = index
  48. const res = await msTrendDetail(trendData.value[index].objMetricsId)
  49. initChart(res.data)
  50. }
  51. function initChart(res) {
  52. const myChart = echarts.init(chartSort.value);
  53. const option = {
  54. grid: {
  55. left: '0%',
  56. right: '0%',
  57. bottom: '0%',
  58. top: '5%',
  59. },
  60. xAxis: {
  61. type: 'category',
  62. boundaryGap: false,
  63. data: res.map(p=>formatDate(p.time)),
  64. },
  65. yAxis: {
  66. type: 'value',
  67. splitLine: {
  68. lineStyle: {
  69. color: "#6B8AC080",
  70. type: 'dashed',
  71. }
  72. }
  73. },
  74. series: [
  75. {
  76. data: res.map(p=>p.value),
  77. type: 'line',
  78. symbolSize: 0,
  79. lineStyle:{
  80. color:'#61d1fc'
  81. },
  82. areaStyle: {
  83. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  84. {
  85. offset: 0,
  86. color: 'rgba(13,27,154,0.8)'
  87. },
  88. {
  89. offset: 1,
  90. color: 'rgb(5,11,72)'
  91. }
  92. ])
  93. },
  94. }
  95. ]
  96. }
  97. myChart.setOption(option)
  98. }
  99. </script>