DedustHome.vue 5.4 KB

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