PersonnelOnDutySituation.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <ChartsContainer title="人员在岗情况">
  3. <div ref="pie" style="height: 60%;"></div>
  4. <div ref="bar" style="height: 40%;"></div>
  5. </ChartsContainer>
  6. </template>
  7. <script setup>
  8. import { computed } from 'vue';
  9. import ChartsContainer from '../ChartsContainer.vue';
  10. import { useECharts } from '@/hooks/useEcharts.js';
  11. const pie = ref(null)
  12. const bar = ref(null)
  13. const props = defineProps({
  14. personnelCountInfo: {
  15. type: Object,
  16. default: () => ({
  17. allData: 0, // 全部通道
  18. openRate: 0, // 开放率
  19. openData: 0, // 开放通道数
  20. closeData: 0, // 未开放通道数
  21. barGrounp: [ 'T2航站楼', 'T1航站楼' ],
  22. barOpenData: [ 0, 0 ],
  23. barCloseData: [ -0, -0 ],
  24. hasValidData: true
  25. })
  26. }
  27. })
  28. const setChartsOptions = computed(() => {
  29. return {
  30. graphic: [ {
  31. type: 'text',
  32. left: '52%',
  33. top: '40%',
  34. style: {
  35. text: '在岗率',
  36. font: 'bold 20px sans-serif',
  37. fill: '#fff'
  38. }
  39. }, {
  40. type: 'text',
  41. left: '54%',
  42. top: '50%',
  43. style: {
  44. text: (props.personnelCountInfo.openRate || 0) + '%',
  45. font: 'bold 22px sans-serif',
  46. fill: '#fff'
  47. }
  48. } ],
  49. legend: {
  50. data: [ "在岗", "空闲" ],
  51. left: "left",
  52. top: "center",
  53. orient: "vertical",
  54. textStyle: { color: "#fff" },
  55. },
  56. tooltip: {
  57. trigger: 'item'
  58. },
  59. series: [ {
  60. type: "pie",
  61. radius: [ "50%", "70%" ],
  62. center: [ "60%", "50%" ],
  63. label: {
  64. formatter: '{b}\n{c}',
  65. color: '#fff',
  66. fontSize: 14,
  67. },
  68. labelLine: {
  69. length: 3
  70. },
  71. data: [
  72. { value: props.personnelCountInfo.openData, name: "在岗", itemStyle: { color: "#408CFF" } },
  73. { value: props.personnelCountInfo.closeData, name: "空闲", itemStyle: { color: "#A7C8FF" } }
  74. ]
  75. } ],
  76. animation: false,
  77. grid: {
  78. top: 10,
  79. bottom: 50,
  80. left: 20,
  81. right: 20
  82. },
  83. }
  84. })
  85. const setChartsOptionsBar = computed(() => {
  86. return {
  87. grid: {
  88. top: 20,
  89. bottom: 20,
  90. left: 80,
  91. right: 20
  92. },
  93. legend: { show: false },
  94. xAxis: {
  95. type: 'value',
  96. position: 'bottom',
  97. axisLine: { show: true, lineStyle: { color: '#fff' } },
  98. axisTick: { show: false },
  99. axisLabel: { show: false },
  100. splitLine: { show: false },
  101. min: -props.personnelCountInfo.allData || -10,
  102. max: props.personnelCountInfo.allData || 10
  103. },
  104. yAxis: {
  105. type: 'category',
  106. data: props.personnelCountInfo.barGrounp,
  107. axisLine: { show: false },
  108. axisTick: { show: false },
  109. axisLabel: {
  110. color: '#fff',
  111. fontSize: 14,
  112. margin: 10
  113. }
  114. },
  115. series: [
  116. {
  117. name: '在岗',
  118. type: 'bar',
  119. stack: 'total',
  120. barWidth: 20,
  121. itemStyle: { color: '#408CFF' },
  122. label: {
  123. show: true,
  124. position: 'left',
  125. color: '#fff',
  126. formatter: function (params) {
  127. return Math.abs(params.value)
  128. }
  129. },
  130. data: props.personnelCountInfo.barOpenData // T2航站楼开放70,T1航站楼开放30
  131. },
  132. {
  133. name: '空闲',
  134. type: 'bar',
  135. stack: 'total',
  136. barWidth: 20,
  137. itemStyle: { color: '#A7C8FF' },
  138. label: {
  139. show: true,
  140. position: 'right',
  141. color: '#fff',
  142. formatter: function (params) {
  143. return Math.abs(params.value)
  144. }
  145. },
  146. data: props.personnelCountInfo.barCloseData // T2航站楼未开放30,T1航站楼未开放70
  147. }
  148. ],
  149. tooltip: {
  150. trigger: 'axis',
  151. axisPointer: { type: 'shadow' },
  152. formatter: function (params) {
  153. return params[ 0 ].name + '<br/>' +
  154. params[ 0 ].seriesName + ': ' + Math.abs(params[ 0 ].value) + '<br/>' +
  155. params[ 1 ].seriesName + ': ' + Math.abs(params[ 1 ].value);
  156. }
  157. }
  158. }
  159. })
  160. useECharts(pie, setChartsOptions);
  161. useECharts(bar, setChartsOptionsBar);
  162. </script>
  163. <style lang="scss" scoped></style>