DedustHome.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <div
  3. v-show="!loading"
  4. id="dedustCss"
  5. style="width: 100%; height: 100%; position: absolute; pointer-events: none; overflow: hidden; z-index: 2; top: 0px; left: 0px"
  6. >
  7. <FourBorderBg id="dedustEnvA">
  8. <div class="monitor-item" v-for="(data, index) in dedustEnvModalA" :key="index" :id="`dedustCss3D${index}`">
  9. <span class="monitor-title">{{ data.label }}:</span>
  10. <span class="monitor-val">{{ get(deviceInfo, data.prop, '-') }}</span>
  11. </div>
  12. <!-- <div class="title">
  13. {{ monitorData[groupNum - 1]['strname'] }}
  14. </div> -->
  15. </FourBorderBg>
  16. <FourBorderBg id="dedustEnvB">
  17. <div class="monitor-item" v-for="(data, index) in dedustEnvModalB" :key="index" :id="`dedustCss3D${index}`">
  18. <span class="monitor-title">{{ data.label }}:</span>
  19. <span class="monitor-val">{{ get(deviceInfo, data.prop, '-') }}</span>
  20. </div>
  21. </FourBorderBg>
  22. </div>
  23. <div class="monitor-container">
  24. <div style="position: absolute; height: 40px; width: 100%; top: calc(50%-20px); font-size: 20px; color: red; text-align: center">
  25. {{ deviceInfo.warnDes }}
  26. </div>
  27. <div class="lr left-box vent-margin-t-10">
  28. <ventBox1>
  29. <template #title>
  30. <div>除尘机状态</div>
  31. </template>
  32. <template #container>
  33. <List icon="warning-title" type="status-light" :labelWidth="130" layout="double-columns" title="故障状态" v-bind="dedustStatusPropA" />
  34. <List icon="warning-title" type="status-light" :labelWidth="300" title="报警状态" v-bind="dedustStatusPropB" />
  35. <List icon="warning-title" type="status-light" :labelWidth="280" title="激活状态" v-bind="dedustStatusPropC" />
  36. </template>
  37. </ventBox1>
  38. </div>
  39. <div class="lr right-box">
  40. <ventBox1 class="vent-margin-t-10">
  41. <template #title>
  42. <div>监测参数</div>
  43. </template>
  44. <template #container>
  45. <List :labelWidth="200" v-bind="dedustMonitorProp" />
  46. </template>
  47. </ventBox1>
  48. <ventBox1>
  49. <template #title>
  50. <div>环境参数</div>
  51. </template>
  52. <template #container>
  53. <List :labelWidth="200" v-bind="dedustEnvProp" />
  54. </template>
  55. </ventBox1>
  56. </div>
  57. </div>
  58. </template>
  59. <script setup lang="ts">
  60. import FourBorderBg from '/@/views/vent/comment/components/fourBorderBg.vue';
  61. import { onBeforeMount, ref, onMounted, onUnmounted, defineProps, computed } from 'vue';
  62. import { list } from '../dedust.api';
  63. import ventBox1 from '/@/components/vent/ventBox1.vue';
  64. import { mountedThree, destroy, setModelType } from '../dedust.threejs';
  65. // import { SvgIcon } from '/@/components/Icon';
  66. import {
  67. dedustEnvConfig,
  68. dedustEnvModalA,
  69. dedustEnvModalB,
  70. dedustMonitorConfig,
  71. dedustStatusConfigA,
  72. dedustStatusConfigB,
  73. dedustStatusConfigC,
  74. statusConfigA,
  75. statusConfigB,
  76. statusConfigC,
  77. } from '../dedust.data';
  78. import List from '/@/views/vent/gas/components/list/index.vue';
  79. import _ from 'lodash';
  80. import { get } from '../../../home/billboard/utils';
  81. const props = defineProps({
  82. deviceId: {
  83. type: String,
  84. require: true,
  85. },
  86. });
  87. const loading = ref(false);
  88. const deviceInfo = ref<any>({});
  89. // 将列表配置项转换为列表可用的prop
  90. function transConfigToProp(config, source) {
  91. return config.map((c) => {
  92. if (c.type === 'default' && c.status) {
  93. return {
  94. ...c,
  95. value: c.status.find((e) => _.get(source, c.prop) === e.value)?.label,
  96. label: c.label,
  97. };
  98. }
  99. return {
  100. ...c,
  101. value: _.get(source, c.prop),
  102. label: c.label,
  103. };
  104. });
  105. }
  106. // 各个模块的配置项
  107. const dedustMonitorProp = computed(() => {
  108. return {
  109. items: transConfigToProp(dedustMonitorConfig, deviceInfo.value),
  110. };
  111. });
  112. const dedustEnvProp = computed(() => {
  113. return {
  114. items: transConfigToProp(dedustEnvConfig, deviceInfo.value),
  115. };
  116. });
  117. const dedustStatusPropA = computed(() => {
  118. return {
  119. status: statusConfigA as any,
  120. items: transConfigToProp(dedustStatusConfigA, deviceInfo.value),
  121. };
  122. });
  123. const dedustStatusPropB = computed(() => {
  124. return {
  125. status: statusConfigB as any,
  126. items: transConfigToProp(dedustStatusConfigB, deviceInfo.value),
  127. };
  128. });
  129. const dedustStatusPropC = computed(() => {
  130. return {
  131. status: statusConfigC as any,
  132. items: transConfigToProp(dedustStatusConfigC, deviceInfo.value),
  133. };
  134. });
  135. // https获取监测数据
  136. let timer: NodeJS.Timeout;
  137. async function getDataSource(systemID) {
  138. const res = await list({ devicetype: 'sys', systemID, type: 'all' });
  139. // 保留第一项数据
  140. _.forEach(_.get(res, 'deviceInfo.dedustefan.datalist', []), (e) => {
  141. Object.assign(e, e.readData);
  142. deviceInfo.value = e || { warnDes: '设备断开' };
  143. return -1;
  144. });
  145. }
  146. onBeforeMount(() => {});
  147. onMounted(() => {
  148. loading.value = true;
  149. mountedThree('#dedust3D', ['#dedustCss', '#dedustEnvA', '#dedustEnvB']).then(() => {
  150. setModelType('dedust').finally(() => {
  151. loading.value = false;
  152. });
  153. });
  154. timer = setInterval(() => {
  155. getDataSource(props.deviceId);
  156. }, 1000);
  157. });
  158. onUnmounted(() => {
  159. clearInterval(timer);
  160. destroy();
  161. });
  162. </script>
  163. <style lang="less" scoped>
  164. @import '/@/design/theme.less';
  165. @import '/@/design/vent/modal.less';
  166. // @import '../less/tunFace.less';
  167. @import '../../comment/less/workFace.less';
  168. @ventSpace: zxm;
  169. .monitor-item {
  170. display: flex;
  171. justify-content: space-between;
  172. margin-bottom: 3px;
  173. .monitor-val {
  174. font-size: 14px;
  175. }
  176. }
  177. .monitor-title {
  178. width: 200px;
  179. color: var(--vent-font-action-link);
  180. font-weight: 400;
  181. font-size: 14px;
  182. }
  183. .dust-fan-monitor {
  184. display: flex;
  185. flex-wrap: wrap;
  186. }
  187. .dust-fan-monitor-item {
  188. width: 152px;
  189. height: 70px;
  190. display: flex;
  191. flex-direction: column;
  192. justify-content: center;
  193. align-items: center;
  194. border: 1px solid rgba(25, 251, 255, 0.4);
  195. box-shadow: inset 0 0 20px rgba(0, 197, 255, 0.4);
  196. background: rgba(0, 0, 0, 0.06666667);
  197. margin-bottom: 5px;
  198. padding: 8px 0;
  199. &:nth-child(2n) {
  200. margin-left: 12px;
  201. }
  202. .title {
  203. color: #5dfaff;
  204. }
  205. .unit {
  206. font-size: 13px;
  207. color: #ffffffaa;
  208. }
  209. .value {
  210. color: #ffb212;
  211. }
  212. }
  213. .fault {
  214. .title {
  215. color: #c4fdff;
  216. }
  217. .value {
  218. // color: #FFB212;
  219. color: #61ddb1;
  220. }
  221. }
  222. </style>