MonitorCenter.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <div class="monitor-center pt-10px pl-2px pr-2px pb-10px">
  4. <div class="flex">
  5. <div class="monitor-center__item_A">
  6. <span>巷道总长度(m)</span>
  7. <span class="color-green">{{ data.flength }}</span>
  8. </div>
  9. <div class="monitor-center__item_B flex flex-items-center">
  10. <span>吨煤通风费用(元)</span>
  11. <span class="color-yellow">{{ data.cost }}</span>
  12. </div>
  13. </div>
  14. <div class="flex">
  15. <div class="ml-7px text-center">
  16. <span>总风量(m³/min)</span>
  17. <div class="number_grid">
  18. <span v-for="(c, i) in data.m3Str" :key="`vhccmcc-${i}`">{{ c }}</span>
  19. </div>
  20. </div>
  21. <div class="ml-7px text-center">
  22. <span>总阻力(pa)</span>
  23. <div class="number_grid">
  24. <span v-for="(c, i) in data.paStr" :key="`vhccmcc-${i}`">{{ c }}</span>
  25. </div>
  26. </div>
  27. <div class="ml-7px text-center">
  28. <span>等积孔(m³)</span>
  29. <div class="number_grid">
  30. <span v-for="(c, i) in data.eStr" :key="`vhccmcc-${i}`">{{ c }}</span>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="monitor-center flex flex-wrap w-240px ml-166px">
  36. <div v-for="(item, i) in chartOptions" :key="`vhccmc-${i}`" class="w-100px m-10px">
  37. <Chart class="w-100% m-auto" height="100px" :option="item.option" />
  38. <div class="monitor-center__chart_title">{{ item.title }}</div>
  39. </div>
  40. </div>
  41. </template>
  42. <script lang="ts" setup>
  43. import { onMounted, ref } from 'vue';
  44. import Chart from '/@/components/chart/Chart.vue';
  45. import { EChartsOption } from 'echarts';
  46. import _ from 'lodash';
  47. // import mapComponent from './components/3Dmap/index.vue';
  48. // 设备类别,是个枚举 TODO: 将手动换为自动获取类别
  49. // const devicekind = 'fanlocal';
  50. const data = ref<Record<string, any>>({});
  51. // 图表相关
  52. const chartOptions = ref([
  53. { title: '外部漏风率', option: getChartOption(40) },
  54. { title: '有效风量率', option: getChartOption(30) },
  55. { title: '灵敏度A', option: getChartOption(20) },
  56. { title: '灵敏度B', option: getChartOption(50) },
  57. ]);
  58. function getChartOption(percent: number): EChartsOption {
  59. const data = [
  60. // 最下面的一环
  61. {
  62. // 中间展示数据的一环
  63. name: 'root',
  64. value: 100,
  65. // itemStyle: item1,
  66. children: [
  67. {
  68. value: percent,
  69. name: 'node-0',
  70. children: [
  71. {
  72. name: 'leaf-0-0',
  73. value: percent,
  74. },
  75. ],
  76. },
  77. {
  78. name: 'node-1',
  79. value: 100 - percent,
  80. itemStyle: {
  81. color: 'transparent',
  82. },
  83. children: [
  84. {
  85. name: 'leaf-1-0',
  86. value: 100 - percent,
  87. },
  88. ],
  89. },
  90. ],
  91. },
  92. ];
  93. return {
  94. title: {
  95. text: percent + '%',
  96. left: 'center',
  97. top: 'center',
  98. textStyle: {
  99. color: '#0afff0',
  100. },
  101. },
  102. grid: {
  103. show: false,
  104. },
  105. xAxis: { show: false },
  106. yAxis: { show: false },
  107. series: {
  108. startAngle: 270,
  109. // radius: ['60%', '90%'],
  110. nodeClick: false,
  111. type: 'sunburst',
  112. sort: undefined,
  113. emphasis: {
  114. focus: 'none',
  115. },
  116. label: {
  117. show: false,
  118. },
  119. labelLine: { show: false },
  120. levels: [
  121. {},
  122. {
  123. radius: ['60%', '65%'],
  124. // 最靠内测的第一层
  125. itemStyle: {
  126. color: '#0afff0',
  127. },
  128. },
  129. {
  130. radius: ['70%', '90%'],
  131. itemStyle: {
  132. color: {
  133. type: 'linear',
  134. x: 0,
  135. y: 0,
  136. x2: 0,
  137. y2: 1,
  138. colorStops: [
  139. {
  140. offset: 0,
  141. color: '#55fdbf', // 0% 处的颜色
  142. },
  143. {
  144. offset: 0.6,
  145. color: '#4bcbff', // 0% 处的颜色
  146. },
  147. {
  148. offset: 1,
  149. color: '#56e6ff', // 100% 处的颜色
  150. },
  151. ],
  152. },
  153. borderWidth: 0,
  154. },
  155. },
  156. {
  157. radius: ['95%', '100%'],
  158. itemStyle: {
  159. color: '#0afff0',
  160. },
  161. },
  162. ],
  163. itemStyle: {
  164. borderWidth: 0,
  165. },
  166. tooltip: {
  167. show: false,
  168. },
  169. silent: true,
  170. data,
  171. },
  172. };
  173. }
  174. function fetchData() {
  175. Promise.resolve({
  176. flength: 222,
  177. m3: 33333,
  178. pa: 44444,
  179. e: 55555,
  180. cost: 111,
  181. p1: 40,
  182. p2: 20,
  183. p3: 30,
  184. p4: 10,
  185. }).then((r: any) => {
  186. data.value = r;
  187. const reference = [r.p1, r.p2, r.p3, r.p4];
  188. r.eStr = _.pad(r.e.toString(), 5, '0');
  189. r.m3Str = _.pad(r.m3.toString(), 5, '0');
  190. r.paStr = _.pad(r.pa.toString(), 5, '0');
  191. chartOptions.value.forEach((item, i) => {
  192. item.option = getChartOption(reference[i]);
  193. });
  194. });
  195. }
  196. onMounted(() => {
  197. fetchData();
  198. });
  199. </script>
  200. <style lang="less" scoped>
  201. @import '/@/design/theme.less';
  202. @import '/@/design/theme.less';
  203. .monitor-center__primary_text {
  204. font-size: 20px;
  205. color: @vent-gas-primary-text;
  206. }
  207. .monitor-center {
  208. background-image: @vent-configurable-home-bg-img;
  209. border-top: 2px solid @vent-configurable-home-light-border;
  210. color: @white;
  211. }
  212. .monitor-center__item_A {
  213. width: 201px;
  214. height: 36px;
  215. background-image: url('@/assets/images/home-container/configurable/list_item_green.png');
  216. padding-left: 45px;
  217. line-height: 36px;
  218. }
  219. .monitor-center__item_B {
  220. width: 201px;
  221. height: 36px;
  222. background-image: url('@/assets/images/home-container/configurable/list_item_yellow.png');
  223. padding-left: 45px;
  224. line-height: 36px;
  225. }
  226. .number_grid {
  227. width: 125px;
  228. height: 37px;
  229. background-image: url('@/assets/images/home-container/configurable/number_grid.png');
  230. line-height: 37px;
  231. display: flex;
  232. justify-content: flex-start;
  233. padding: 0 2px 0 2px;
  234. span {
  235. flex-basis: 20%;
  236. }
  237. }
  238. .monitor-center__chart_title {
  239. width: 100%;
  240. text-align: center;
  241. border-bottom: 1px solid @vent-configurable-home-light-border;
  242. }
  243. </style>