dustPage.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <div class="dustPage">
  3. <div class="top-area">
  4. <div :class="activeIndex == index ? 'top-box1' : 'top-box'" v-for="(item, index) in topAreaList" :key="index" @click="topAreaClick(index)">
  5. <div class="top-title">{{ item.title }}</div>
  6. <div class="top-content">
  7. <div class="content-item" v-for="(items, ind) in item.content" :key="ind">
  8. <span class="item-label">{{ items.label }}</span>
  9. <span class="item-value">{{ items.value }}</span>
  10. </div>
  11. </div>
  12. </div>
  13. </div>
  14. <div class="bot-area">
  15. <div class="title-t">
  16. <div class="text-t">粉尘信息状态监测</div>
  17. </div>
  18. <div class="echart-boxd">
  19. <echartLine :echartDataGq="echartDataFc" :maxY="maxY" :echartDw="echartDw" />
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script lang="ts" setup>
  25. import { ref, computed, reactive, watch, defineProps } from 'vue';
  26. import echartLine from './common/echartLine.vue';
  27. let props = defineProps({
  28. listData: Object,
  29. });
  30. let maxY = ref(0);
  31. //顶部区域数据
  32. let topAreaList = reactive<any[]>([]);
  33. //顶部区域激活选项
  34. let activeIndex = ref(0);
  35. let choiceData = reactive<any[]>([]);
  36. //粉尘图表数据
  37. let echartDataFc = reactive({
  38. maxData: {
  39. lengedData: '粉尘浓度(mg/m³)',
  40. data: [],
  41. },
  42. // minData: {
  43. // lengedData: '粉尘呼尘占比(%)',
  44. // data: []
  45. // },
  46. // aveValue: {
  47. // lengedData: '总尘浓度',
  48. // data: []
  49. // },
  50. xData: [],
  51. });
  52. let echartDw = ref('(mg/m³)');
  53. //顶部区域选项切换
  54. function topAreaClick(index) {
  55. activeIndex.value = index;
  56. echartDataFc.maxData.data.length = 0;
  57. // echartDataFc.minData.data.length = 0
  58. // echartDataFc.aveValue.data.length = 0
  59. echartDataFc.xData.length = 0;
  60. choiceData[index].history.forEach((el) => {
  61. echartDataFc.maxData.data.push(el.dustval);
  62. // echartDataFc.minData.data.push(el.ratio)
  63. // echartDataFc.aveValue.data.push(el.totalDust)
  64. echartDataFc.xData.push(el.time);
  65. });
  66. }
  67. function formatRoundNum(num) {
  68. let interger = Math.ceil(num);
  69. let leng = String(interger).length;
  70. return Math.ceil(interger / Math.pow(10, leng - 1)) * Math.pow(10, leng - 1);
  71. }
  72. watch(
  73. () => props.listData,
  74. (val) => {
  75. topAreaList.length = 0;
  76. echartDataFc.maxData.data.length = 0;
  77. // echartDataFc.minData.data.length = 0
  78. // echartDataFc.aveValue.data.length = 0
  79. echartDataFc.xData.length = 0;
  80. if (JSON.stringify(val.common) != '{}') {
  81. // let dustList = val.common.dust.slice(0, 3);
  82. val.common.dust.forEach((el) => {
  83. topAreaList.push({
  84. title: el.strinstallpos,
  85. content: [
  86. { ids: 0, label: '温度(°C)', value: (Math.random()*(21-20)+20).toFixed(2)},
  87. // { ids: 0, label: '温度(°C)', value: el.readData.temperature || '--' },
  88. { ids: 1, label: '粉尘浓度(mg/m³)', value: (Math.random()*(0.4-0.3)+0.3).toFixed(2) },
  89. // { ids: 1, label: '粉尘浓度(mg/m³)', value: el.readData.dustval || '--' },
  90. { ids: 2, label: '喷雾水压(MPa)', value: (Math.random()*(0.6-0.5)+0.5).toFixed(2) },
  91. // { ids: 2, label: '喷雾水压(MPa)', value: el.readData.waterPressure || '--' },
  92. // { ids: 3, label: '喷雾状态', value: el.readData.atomizingState || '--' },
  93. { ids: 3, label: '喷雾状态', value: '正常' },
  94. ],
  95. });
  96. });
  97. choiceData = val.common.dust;
  98. if (choiceData[activeIndex.value]) {
  99. choiceData[activeIndex.value].history.forEach((el) => {
  100. echartDataFc.maxData.data.push(el.dustval);
  101. // echartDataFc.minData.data.push(el.ratio)
  102. // echartDataFc.aveValue.data.push(el.totalDust)
  103. echartDataFc.xData.push(el.time);
  104. });
  105. let max1 = echartDataFc.maxData.data.reduce((acr, cur) => {
  106. return acr > cur ? acr : cur;
  107. });
  108. maxY.value = formatRoundNum(max1 * 1.5);
  109. } else {
  110. activeIndex.value = 0;
  111. choiceData[activeIndex.value].history.forEach((el) => {
  112. echartDataFc.maxData.data.push(el.dustval);
  113. // echartDataFc.minData.data.push(el.ratio)
  114. // echartDataFc.aveValue.data.push(el.totalDust)
  115. echartDataFc.xData.push(el.time);
  116. });
  117. let max1 = echartDataFc.maxData.data.reduce((acr, cur) => {
  118. return acr > cur ? acr : cur;
  119. });
  120. maxY.value = formatRoundNum(max1 * 1.5);
  121. }
  122. }
  123. },
  124. { deep: true }
  125. );
  126. </script>
  127. <style lang="less" scoped>
  128. .dustPage {
  129. width: 100%;
  130. height: 100%;
  131. padding: 20px;
  132. box-sizing: border-box;
  133. .top-area {
  134. width: 100%;
  135. height: 24%;
  136. display: flex;
  137. justify-content: flex-start;
  138. align-items: flex-end;
  139. margin-bottom: 10px;
  140. overflow-x: auto;
  141. transform: scaleY(-1);
  142. .top-box {
  143. position: relative;
  144. width: 474px;
  145. height: 88%;
  146. flex-shrink: 0;
  147. background: url('../../../../../assets//images/fire/fc-t.png') no-repeat center;
  148. background-size: 100% 100%;
  149. margin: 0px 20px;
  150. transform: scaleY(-1);
  151. .top-title {
  152. width: 80%;
  153. text-align: center;
  154. position: absolute;
  155. left: 50%;
  156. top: 2%;
  157. font-size: 16px;
  158. transform: translate(-50%, 0);
  159. }
  160. .top-content {
  161. position: absolute;
  162. top: 17%;
  163. left: 0;
  164. width: 100%;
  165. height: 83%;
  166. display: flex;
  167. justify-content: flex-start;
  168. align-items: flex-start;
  169. flex-wrap: wrap;
  170. cursor: pointer;
  171. .content-item {
  172. position: relative;
  173. width: 50%;
  174. height: 50%;
  175. background: url('../../../../../assets/images/fire/content-item.png') no-repeat center;
  176. background-size: 88% 50%;
  177. .item-label {
  178. position: absolute;
  179. left: 14%;
  180. top: 50%;
  181. transform: translate(0, -44%);
  182. // font-size: 12px;
  183. }
  184. .item-value {
  185. position: absolute;
  186. right: 14%;
  187. top: 50%;
  188. transform: translate(0, -44%);
  189. // font-size: 12px;
  190. font-family: 'douyuFont';
  191. color: #3df6ff;
  192. }
  193. }
  194. }
  195. }
  196. .top-box1 {
  197. position: relative;
  198. width: 474px;
  199. height: 100%;
  200. flex-shrink: 0;
  201. background: url('../../../../../assets//images/fire/fc-t1.png') no-repeat center;
  202. background-size: 100% 100%;
  203. margin: 0px 20px;
  204. transform: scaleY(-1);
  205. .top-title {
  206. width: 80%;
  207. text-align: center;
  208. position: absolute;
  209. left: 50%;
  210. top: 2%;
  211. font-size: 16px;
  212. transform: translate(-50%, 0);
  213. }
  214. .top-content {
  215. position: absolute;
  216. top: 17%;
  217. left: 0;
  218. width: 100%;
  219. height: 83%;
  220. display: flex;
  221. justify-content: flex-start;
  222. align-items: flex-start;
  223. flex-wrap: wrap;
  224. padding-bottom: 20px;
  225. box-sizing: border-box;
  226. cursor: pointer;
  227. .content-item {
  228. position: relative;
  229. width: 50%;
  230. height: 50%;
  231. background: url('../../../../../assets/images/fire/content-item.png') no-repeat center;
  232. background-size: 88% 50%;
  233. .item-label {
  234. position: absolute;
  235. left: 14%;
  236. top: 50%;
  237. transform: translate(0, -44%);
  238. // font-size: 12px;
  239. }
  240. .item-value {
  241. position: absolute;
  242. right: 14%;
  243. top: 50%;
  244. transform: translate(0, -44%);
  245. // font-size: 12px;
  246. font-family: 'douyuFont';
  247. color: #3df6ff;
  248. }
  249. }
  250. }
  251. }
  252. }
  253. .bot-area {
  254. height: calc(76% - 10px);
  255. padding: 10px 15px;
  256. background: url('../../../../../assets/images/fire/bj1.png') no-repeat center;
  257. background-size: 100% 100%;
  258. box-sizing: border-box;
  259. .title-t {
  260. height: 30px;
  261. margin-bottom: 10px;
  262. display: flex;
  263. justify-content: space-between;
  264. align-items: center;
  265. .text-t {
  266. font-family: 'douyuFont';
  267. font-size: 16px;
  268. }
  269. }
  270. .echart-boxd {
  271. width: 100%;
  272. height: calc(100% - 40px);
  273. }
  274. }
  275. }
  276. </style>