DedustHome.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <a-spin tip="Loading..." :spinning="loading">
  3. <div class="monitor-container">
  4. <div class="lr left-box vent-margin-t-10">
  5. <ventBox1>
  6. <template #title>
  7. <div>除尘机状态</div>
  8. </template>
  9. <template #container>
  10. <List layout="double-columns" title="故障状态" v-bind="dedustStatusPropA" />
  11. <List title="报警状态" v-bind="dedustStatusPropB" />
  12. <List title="激活状态" v-bind="dedustStatusPropC" />
  13. </template>
  14. </ventBox1>
  15. </div>
  16. <div class="lr right-box">
  17. <ventBox1 class="vent-margin-t-10">
  18. <template #title>
  19. <div>监测参数</div>
  20. </template>
  21. <template #container>
  22. <List v-bind="dedustMonitorProp" />
  23. </template>
  24. </ventBox1>
  25. </div>
  26. </div>
  27. </a-spin>
  28. </template>
  29. <script setup lang="ts">
  30. import { onBeforeMount, ref, onMounted, onUnmounted, reactive, defineProps, computed } from 'vue';
  31. import { list } from '../dedust.api';
  32. import ventBox1 from '/@/components/vent/ventBox1.vue';
  33. // import { SvgIcon } from '/@/components/Icon';
  34. import {
  35. dedustMonitorConfig,
  36. dedustStatusConfigA,
  37. dedustStatusConfigB,
  38. dedustStatusConfigC,
  39. statusConfigA,
  40. statusConfigB,
  41. statusConfigC,
  42. } from '../dedust.data';
  43. import List from '/@/views/vent/gas/components/list/index.vue';
  44. import _ from 'lodash';
  45. const props = defineProps({
  46. deviceId: {
  47. type: String,
  48. require: true,
  49. },
  50. });
  51. const loading = ref(false);
  52. // 默认初始是第一行
  53. // const openDust = ref(false);
  54. const deviceInfo = ref({});
  55. const workFaceSource = ref({});
  56. const workFaceHistorySource = ref([]);
  57. // const gateDataSource = ref([]);
  58. // const windowDataSource = ref([]);
  59. // const windDataSource = ref([]);
  60. // const temperatureDataSource = ref([]);
  61. // const fireDataSource = ref([]);
  62. // 将列表配置项转换为列表可用的prop
  63. function transConfigToProp(config, source) {
  64. return config.map((c) => {
  65. return {
  66. ...c,
  67. value: _.get(source, c.prop),
  68. label: c.label,
  69. };
  70. });
  71. }
  72. // 各个模块的配置项
  73. const dedustMonitorProp = computed(() => {
  74. return {
  75. items: transConfigToProp(dedustMonitorConfig, deviceInfo.value),
  76. };
  77. });
  78. const dedustStatusPropA = computed(() => {
  79. return {
  80. status: statusConfigA as any,
  81. items: transConfigToProp(dedustStatusConfigA, deviceInfo.value),
  82. };
  83. });
  84. const dedustStatusPropB = computed(() => {
  85. return {
  86. status: statusConfigB as any,
  87. items: transConfigToProp(dedustStatusConfigB, deviceInfo.value),
  88. };
  89. });
  90. const dedustStatusPropC = computed(() => {
  91. return {
  92. status: statusConfigC as any,
  93. items: transConfigToProp(dedustStatusConfigC, deviceInfo.value),
  94. };
  95. });
  96. // 监测数据
  97. const selectData = reactive({});
  98. // https获取监测数据
  99. let timer: null | NodeJS.Timeout = null;
  100. function getMonitor(flag?) {
  101. if (Object.prototype.toString.call(timer) === '[object Null]') {
  102. timer = setTimeout(
  103. async () => {
  104. if (props.deviceId) {
  105. const data = await getDataSource(props.deviceId);
  106. Object.assign(selectData, data);
  107. }
  108. if (timer) {
  109. timer = null;
  110. }
  111. await getMonitor();
  112. loading.value = false;
  113. },
  114. flag ? 0 : 1000
  115. );
  116. }
  117. }
  118. async function getDataSource(systemID) {
  119. const res = await list({ devicetype: 'sys', systemID, type: 'all' });
  120. res.deviceInfo.dedustefan.datalist.forEach((e: any) => {
  121. Object.assign(e, e.readData);
  122. e.readData = null;
  123. });
  124. deviceInfo.value = _.get(res, 'deviceInfo.dedustefan.datalist[0]', {});
  125. workFaceHistorySource.value = res.sysInfo.history;
  126. workFaceSource.value = Object.assign(res.sysInfo, res.sysInfo.readData);
  127. loading.value = false;
  128. }
  129. onBeforeMount(() => {});
  130. onMounted(async () => {
  131. loading.value = true;
  132. timer = null;
  133. await getMonitor(true);
  134. });
  135. onUnmounted(() => {
  136. if (timer) {
  137. clearTimeout(timer);
  138. timer = null;
  139. }
  140. });
  141. </script>
  142. <style lang="less" scoped>
  143. @import '/@/design/vent/modal.less';
  144. // @import '../less/tunFace.less';
  145. @import '../../comment/less/workFace.less';
  146. @ventSpace: zxm;
  147. .dust-fan-monitor {
  148. display: flex;
  149. flex-wrap: wrap;
  150. }
  151. .dust-fan-monitor-item {
  152. width: 152px;
  153. height: 70px;
  154. display: flex;
  155. flex-direction: column;
  156. justify-content: center;
  157. align-items: center;
  158. border: 1px solid rgba(25, 251, 255, 0.4);
  159. box-shadow: inset 0 0 20px rgba(0, 197, 255, 0.4);
  160. background: rgba(0, 0, 0, 0.06666667);
  161. margin-bottom: 5px;
  162. padding: 8px 0;
  163. &:nth-child(2n) {
  164. margin-left: 12px;
  165. }
  166. .title {
  167. color: #5dfaff;
  168. }
  169. .unit {
  170. font-size: 13px;
  171. color: #ffffffaa;
  172. }
  173. .value {
  174. color: #ffb212;
  175. }
  176. }
  177. .fault {
  178. .title {
  179. color: #c4fdff;
  180. }
  181. .value {
  182. // color: #FFB212;
  183. color: #61ddb1;
  184. }
  185. }
  186. </style>