nitrogenEcharts.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <div class="nitrogen-echatrs-box">
  3. <div class="button-box">
  4. <div style="color: #fff; font-weight: 600;">{{ currentTime }}</div>
  5. </div>
  6. <div class="echarts-container">
  7. <div v-for="(item, index) in dataSource" :key="index" class="echarts-item">
  8. <div class="echarts-nitrogen-item">
  9. <BarAndLine
  10. xAxisPropType="readTime"
  11. :dataSource="item"
  12. height="100%"
  13. :chartsColumns="nitrogenChartsColumns"
  14. :option="nitrogenOption"
  15. chartsType="detail" />
  16. </div>
  17. <div class="echarts-cqg-item">
  18. <BarAndLine
  19. xAxisPropType="readTime"
  20. :dataSource="item"
  21. height="100%"
  22. :chartsColumns="cqgChartsColumns"
  23. :option="cqgOption"
  24. chartsType="detail" />
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script setup lang="ts">
  31. import{ref, onMounted, onUnmounted, reactive } from 'vue'
  32. import dayjs from 'dayjs'
  33. import BarAndLine from '/@/components/chart/BarAndLine.vue';
  34. import { list } from '../nitrogen.api'
  35. const nitrogenChartsColumns = [
  36. {
  37. legend: '空压机排气压力',
  38. seriesName: '(Mpa)',
  39. ymax: 100,
  40. yname: 'Pa',
  41. linetype: 'line',
  42. yaxispos: 'left',
  43. color: '#9BCB75',
  44. sort: 1,
  45. xRotate: 0,
  46. dataIndex: 'compressExhaustPressF1',
  47. },
  48. {
  49. legend: '空压机分离压力',
  50. seriesName: '(Mpa)',
  51. ymax: 100,
  52. yname: 'Mpa',
  53. linetype: 'line',
  54. yaxispos: 'left',
  55. color: '#1EB0FC',
  56. sort: 1,
  57. xRotate: 0,
  58. dataIndex: 'compressSeparatePressF1',
  59. },
  60. {
  61. legend: '空压机主机温度',
  62. seriesName: '(℃)',
  63. ymax: 200,
  64. yname: '℃',
  65. linetype: 'line',
  66. yaxispos: 'right',
  67. color: '#FDB146',
  68. sort: 2,
  69. xRotate: 0,
  70. dataIndex: 'compressHostTempF1',
  71. },
  72. {
  73. legend: '空压机机组温度',
  74. seriesName: '(℃)',
  75. ymax: 200,
  76. yname: '℃',
  77. linetype: 'line',
  78. yaxispos: 'right',
  79. color: '#EE6666',
  80. sort: 2,
  81. xRotate: 0,
  82. dataIndex: 'compressCrewTempF1',
  83. },
  84. ];
  85. const cqgChartsColumns = [
  86. {
  87. legend: '储气罐压力',
  88. seriesName: '(Mpa)',
  89. ymax: 100,
  90. yname: 'Pa',
  91. linetype: 'line',
  92. yaxispos: 'left',
  93. color: '#9BCB75',
  94. sort: 1,
  95. xRotate: 0,
  96. dataIndex: 'airReceiverPress',
  97. },
  98. {
  99. legend: '储气罐温度',
  100. seriesName: '(℃)',
  101. ymax: 100,
  102. yname: '℃',
  103. linetype: 'line',
  104. yaxispos: 'right',
  105. color: '#DD7FCD',
  106. sort: 2,
  107. xRotate: 0,
  108. dataIndex: 'airReceiverTemp',
  109. },
  110. {
  111. legend: '储气罐流量',
  112. seriesName: '(m³/k)',
  113. ymax: 200,
  114. yname: 'm³/k',
  115. linetype: 'line',
  116. yaxispos: 'right',
  117. color: '#56B1FD',
  118. sort: 3,
  119. xRotate: 0,
  120. dataIndex: 'airReceiverFlow',
  121. },
  122. ];
  123. const nitrogenOption = {
  124. grid: {
  125. top: '20%',
  126. left: '2px',
  127. right: '0px',
  128. bottom: '3%',
  129. containLabel: true
  130. },
  131. toolbox: {
  132. feature:{
  133. }
  134. }
  135. }
  136. const cqgOption = {
  137. grid: {
  138. top: '20%',
  139. left: '0px',
  140. right: '40px',
  141. bottom: '3%',
  142. containLabel: true
  143. },
  144. toolbox: {
  145. feature: {
  146. }
  147. }
  148. }
  149. const currentTime = ref(dayjs().format('YYYY-MM-DD HH:mm:ss'))
  150. // const monitorData = [] as any[]
  151. const dataSource = reactive<any[]>([])
  152. // https获取监测数据
  153. let timer: null | NodeJS.Timeout = null;
  154. let count = 0
  155. async function getMonitor(flag?) {
  156. if (Object.prototype.toString.call(timer) === '[object Null]') {
  157. timer = await setTimeout(async () => {
  158. await getDataSource();
  159. if (timer) {
  160. timer = null;
  161. }
  162. await getMonitor();
  163. }, flag ? 0 : 1000);
  164. }
  165. };
  166. async function getDataSource() {
  167. const res = await list({ devicetype: 'pressurefan', pagetype: 'normal' });
  168. const dataList = res.msgTxt[0].datalist || [];
  169. dataList.forEach((data, index) => {
  170. const item = data.readData;
  171. Object.assign(item, data);
  172. item['readTime'] = item['readTime'].substring(11)
  173. if(count == 0){
  174. dataSource.push([item])
  175. }else {
  176. if(dataSource[index].length < 10){
  177. dataSource[index].push(item)
  178. }else {
  179. dataSource[index].shift()
  180. dataSource[index].push(item)
  181. }
  182. }
  183. });
  184. count++ // 实时数据累计
  185. console.log('实时监测数据----->', dataSource)
  186. };
  187. onMounted(() => {
  188. getMonitor(true)
  189. })
  190. onUnmounted(() => {
  191. if (timer) {
  192. clearTimeout(timer);
  193. timer = undefined;
  194. }
  195. });
  196. </script>
  197. <style lang="less" scoped>
  198. .button-box{
  199. text-align: end;
  200. margin-top: 10px;
  201. margin-right: 10px;
  202. }
  203. .nitrogen-echatrs-box{
  204. width: 100%;
  205. height: 100%;
  206. }
  207. .echarts-container{
  208. position: fixed;
  209. width: 100%;
  210. height: 730px;
  211. color: #fff;
  212. overflow: scroll;
  213. top: 100px;
  214. left: 0;
  215. display: flex;
  216. flex-direction: column;
  217. z-index: 99999;
  218. .echarts-item{
  219. display: flex;
  220. flex-direction: row;
  221. justify-content: space-between;
  222. .echarts-nitrogen-item{
  223. width: calc(60% - 30px);
  224. height: 240px;
  225. }
  226. .echarts-cqg-item{
  227. width: calc(40% - 10px);
  228. height: 240px;
  229. }
  230. }
  231. }
  232. </style>