ModuleFour.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <module-container title="放行速率分析">
  3. <div class="module-four-content">
  4. <div class="chart-row">
  5. <div class="chart-item">
  6. <div class="chart-title">T1航站楼放行速率</div>
  7. <div ref="chart1" class="echarts"></div>
  8. </div>
  9. <div class="chart-item">
  10. <div class="chart-title">T2航站楼放行速率</div>
  11. <div ref="chart2" class="echarts"></div>
  12. </div>
  13. </div>
  14. <div class="chart-row">
  15. <div class="chart-item">
  16. <div class="chart-title">大队总平均速率对比(国内)</div>
  17. <div ref="chart3" class="echarts"></div>
  18. </div>
  19. <div class="chart-item">
  20. <div class="chart-title">大队总平均速率对比(国际+中转)</div>
  21. <div ref="chart4" class="echarts"></div>
  22. </div>
  23. </div>
  24. </div>
  25. </module-container>
  26. </template>
  27. <script setup>
  28. import { ref, onMounted, onBeforeUnmount } from 'vue'
  29. import * as echarts from 'echarts'
  30. import ModuleContainer from './ModuleContainer.vue'
  31. import { useEcharts } from '@/hooks/chart.js'
  32. const chart1 = ref(null)
  33. const chart2 = ref(null)
  34. const chart3 = ref(null)
  35. const chart4 = ref(null)
  36. const { setOption: setOption1 } = useEcharts(chart1)
  37. const { setOption: setOption2 } = useEcharts(chart2)
  38. const { setOption: setOption3 } = useEcharts(chart3)
  39. const { setOption: setOption4 } = useEcharts(chart4)
  40. const generateData = () => {
  41. const data = []
  42. for (let i = 0; i < 30; i++) {
  43. data.push(Math.floor(Math.random() * 60) + 120)
  44. }
  45. return data
  46. }
  47. const xAxisData = []
  48. for (let i = 1; i <= 30; i++) {
  49. xAxisData.push(i + '日')
  50. }
  51. const lineChartOption = (data1, data2, color1, color2) => ({
  52. grid: {
  53. left: '10%',
  54. top: '15%',
  55. right: '5%',
  56. bottom: '15%',
  57. containLabel: true
  58. },
  59. xAxis: {
  60. type: 'category',
  61. data: xAxisData,
  62. axisLine: { lineStyle: { color: '#999' } },
  63. axisLabel: { fontSize: 10, color: '#666' }
  64. },
  65. yAxis: {
  66. type: 'value',
  67. axisLine: { lineStyle: { color: '#999' } },
  68. axisLabel: { fontSize: 10, color: '#666' },
  69. splitLine: { lineStyle: { color: '#eee' } }
  70. },
  71. legend: {
  72. top: 0,
  73. right: 10,
  74. textStyle: { fontSize: 10 }
  75. },
  76. series: [
  77. {
  78. name: '高峰期时段',
  79. type: 'line',
  80. smooth: true,
  81. symbol: 'circle',
  82. symbolSize: 6,
  83. data: data1,
  84. itemStyle: { color: color1 },
  85. areaStyle: {
  86. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  87. { offset: 0, color: color1 + '40' },
  88. { offset: 1, color: color1 + '10' }
  89. ])
  90. }
  91. },
  92. {
  93. name: '非高峰期时段',
  94. type: 'line',
  95. smooth: true,
  96. symbol: 'circle',
  97. symbolSize: 6,
  98. data: data2,
  99. itemStyle: { color: color2 },
  100. areaStyle: {
  101. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  102. { offset: 0, color: color2 + '40' },
  103. { offset: 1, color: color2 + '10' }
  104. ])
  105. }
  106. }
  107. ]
  108. })
  109. const barLineChartOption = (data1, data2, data3, colors) => ({
  110. grid: {
  111. left: '10%',
  112. top: '15%',
  113. right: '5%',
  114. bottom: '15%',
  115. containLabel: true
  116. },
  117. xAxis: {
  118. type: 'category',
  119. data: xAxisData,
  120. axisLine: { lineStyle: { color: '#999' } },
  121. axisLabel: { fontSize: 10, color: '#666', rotate: 45 }
  122. },
  123. yAxis: {
  124. type: 'value',
  125. axisLine: { lineStyle: { color: '#999' } },
  126. axisLabel: { fontSize: 10, color: '#666' },
  127. splitLine: { lineStyle: { color: '#eee' } }
  128. },
  129. legend: {
  130. top: 0,
  131. right: 10,
  132. textStyle: { fontSize: 10 }
  133. },
  134. series: [
  135. {
  136. name: '安检三大队',
  137. type: 'bar',
  138. data: data1,
  139. itemStyle: { color: colors[0] },
  140. barWidth: 8
  141. },
  142. {
  143. name: '安检二大队',
  144. type: 'line',
  145. smooth: true,
  146. symbol: 'circle',
  147. symbolSize: 6,
  148. data: data2,
  149. itemStyle: { color: colors[1] }
  150. },
  151. {
  152. name: '安检一大队',
  153. type: 'line',
  154. smooth: true,
  155. symbol: 'circle',
  156. symbolSize: 6,
  157. data: data3,
  158. itemStyle: { color: colors[2] }
  159. }
  160. ]
  161. })
  162. onMounted(() => {
  163. setOption1(lineChartOption(generateData(), generateData(), '#3b82f6', '#22c55e'))
  164. setOption2(lineChartOption(generateData(), generateData(), '#2563eb', '#16a34a'))
  165. setOption3(barLineChartOption(generateData(), generateData(), generateData(), ['#3b82f6', '#22c55e', '#f97316']))
  166. setOption4(barLineChartOption(generateData(), generateData(), generateData(), ['#3b82f6', '#22c55e', '#f97316']))
  167. })
  168. </script>
  169. <style lang="less" scoped>
  170. .module-four-content {
  171. height: 100%;
  172. display: flex;
  173. flex-direction: column;
  174. gap: 10px;
  175. }
  176. .chart-row {
  177. flex: 1;
  178. display: flex;
  179. gap: 10px;
  180. }
  181. .chart-item {
  182. flex: 1;
  183. display: flex;
  184. flex-direction: column;
  185. background: #fff;
  186. border-radius: 6px;
  187. padding: 8px;
  188. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  189. }
  190. .chart-title {
  191. font-size: 12px;
  192. color: #333;
  193. margin-bottom: 5px;
  194. text-align: center;
  195. }
  196. .echarts {
  197. flex: 1;
  198. width: 100%;
  199. min-height: 0;
  200. }
  201. </style>