DedustHome.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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="280" 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<any>({});
  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. if (c.type === 'default' && c.status) {
  69. return {
  70. ...c,
  71. value: c.status.find((e) => _.get(source, c.prop) === e.value)?.label,
  72. label: c.label,
  73. };
  74. }
  75. return {
  76. ...c,
  77. value: _.get(source, c.prop),
  78. label: c.label,
  79. };
  80. });
  81. }
  82. // 各个模块的配置项
  83. const dedustMonitorProp = computed(() => {
  84. return {
  85. items: transConfigToProp(dedustMonitorConfig, deviceInfo.value),
  86. };
  87. });
  88. const dedustStatusPropA = computed(() => {
  89. return {
  90. status: statusConfigA as any,
  91. items: transConfigToProp(dedustStatusConfigA, deviceInfo.value),
  92. };
  93. });
  94. const dedustStatusPropB = computed(() => {
  95. return {
  96. status: statusConfigB as any,
  97. items: transConfigToProp(dedustStatusConfigB, deviceInfo.value),
  98. };
  99. });
  100. const dedustStatusPropC = computed(() => {
  101. return {
  102. status: statusConfigC as any,
  103. items: transConfigToProp(dedustStatusConfigC, deviceInfo.value),
  104. };
  105. });
  106. // 监测数据
  107. const selectData = reactive({});
  108. // https获取监测数据
  109. let timer: null | NodeJS.Timeout = null;
  110. function getMonitor(flag?) {
  111. if (Object.prototype.toString.call(timer) === '[object Null]') {
  112. timer = setTimeout(
  113. async () => {
  114. if (props.deviceId) {
  115. const data = await getDataSource(props.deviceId);
  116. Object.assign(selectData, data);
  117. }
  118. if (timer) {
  119. timer = null;
  120. }
  121. await getMonitor();
  122. loading.value = false;
  123. },
  124. flag ? 0 : 1000
  125. );
  126. }
  127. }
  128. async function getDataSource(systemID) {
  129. const res = await list({ devicetype: 'sys', systemID, type: 'all' });
  130. res.deviceInfo.dedustefan.datalist.forEach((e: any) => {
  131. Object.assign(e, e.readData);
  132. e.readData = null;
  133. });
  134. deviceInfo.value = _.get(res, 'deviceInfo.dedustefan.datalist[0]', { warnDes: '设备断开' });
  135. workFaceHistorySource.value = res.sysInfo.history;
  136. workFaceSource.value = Object.assign(res.sysInfo, res.sysInfo.readData);
  137. loading.value = false;
  138. }
  139. onBeforeMount(() => {});
  140. onMounted(async () => {
  141. loading.value = true;
  142. timer = null;
  143. await getMonitor(true);
  144. });
  145. onUnmounted(() => {
  146. if (timer) {
  147. clearTimeout(timer);
  148. timer = null;
  149. }
  150. });
  151. </script>
  152. <style lang="less" scoped>
  153. @import '/@/design/vent/modal.less';
  154. // @import '../less/tunFace.less';
  155. @import '../../comment/less/workFace.less';
  156. @ventSpace: zxm;
  157. .dust-fan-monitor {
  158. display: flex;
  159. flex-wrap: wrap;
  160. }
  161. .dust-fan-monitor-item {
  162. width: 152px;
  163. height: 70px;
  164. display: flex;
  165. flex-direction: column;
  166. justify-content: center;
  167. align-items: center;
  168. border: 1px solid rgba(25, 251, 255, 0.4);
  169. box-shadow: inset 0 0 20px rgba(0, 197, 255, 0.4);
  170. background: rgba(0, 0, 0, 0.06666667);
  171. margin-bottom: 5px;
  172. padding: 8px 0;
  173. &:nth-child(2n) {
  174. margin-left: 12px;
  175. }
  176. .title {
  177. color: #5dfaff;
  178. }
  179. .unit {
  180. font-size: 13px;
  181. color: #ffffffaa;
  182. }
  183. .value {
  184. color: #ffb212;
  185. }
  186. }
  187. .fault {
  188. .title {
  189. color: #c4fdff;
  190. }
  191. .value {
  192. // color: #FFB212;
  193. color: #61ddb1;
  194. }
  195. }
  196. </style>