DedustHome.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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, inject, onMounted, onUnmounted, 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 { get as GET, forEach } from 'lodash-es';
  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. /** 全局配置(is2DModel 决定二维 / 三维模型) */
  89. const globalConfig: any = inject('globalConfig');
  90. const deviceInfo = ref<any>({});
  91. // 将列表配置项转换为列表可用的prop
  92. function transConfigToProp(config, source) {
  93. return config.map((c) => {
  94. if (c.type === 'default' && c.status) {
  95. return {
  96. ...c,
  97. value: c.status.find((e) => GET(source, c.prop) === e.value)?.label,
  98. label: c.label,
  99. };
  100. }
  101. return {
  102. ...c,
  103. value: GET(source, c.prop),
  104. label: c.label,
  105. };
  106. });
  107. }
  108. // 各个模块的配置项
  109. const dedustMonitorProp = computed(() => {
  110. return {
  111. items: transConfigToProp(dedustMonitorConfig, deviceInfo.value),
  112. };
  113. });
  114. const dedustEnvProp = computed(() => {
  115. return {
  116. items: transConfigToProp(dedustEnvConfig, deviceInfo.value),
  117. };
  118. });
  119. const dedustStatusPropA = computed(() => {
  120. return {
  121. status: statusConfigA as any,
  122. items: transConfigToProp(dedustStatusConfigA, deviceInfo.value),
  123. };
  124. });
  125. const dedustStatusPropB = computed(() => {
  126. return {
  127. status: statusConfigB as any,
  128. items: transConfigToProp(dedustStatusConfigB, deviceInfo.value),
  129. };
  130. });
  131. const dedustStatusPropC = computed(() => {
  132. return {
  133. status: statusConfigC as any,
  134. items: transConfigToProp(dedustStatusConfigC, deviceInfo.value),
  135. };
  136. });
  137. // https获取监测数据
  138. let timer: NodeJS.Timeout;
  139. async function getDataSource(systemID) {
  140. const res = await list({ devicetype: 'sys', systemID, type: 'all' });
  141. // 保留第一项数据
  142. forEach(GET(res, 'deviceInfo.dedustefan.datalist', []), (e) => {
  143. Object.assign(e, e.readData);
  144. deviceInfo.value = e || { warnDes: '设备断开' };
  145. return -1;
  146. });
  147. }
  148. onBeforeMount(() => {});
  149. onMounted(() => {
  150. loading.value = true;
  151. // 二维模式:不初始化三维,模型由 dedustSVG 装配(箭头隐藏)
  152. if (!globalConfig?.is2DModel) {
  153. mountedThree('#dedust3D', ['#dedustCss', '#dedustEnvA', '#dedustEnvB']).then(() => {
  154. setModelType('dedust').finally(() => {
  155. loading.value = false;
  156. });
  157. });
  158. } else {
  159. loading.value = false;
  160. }
  161. timer = setInterval(() => {
  162. getDataSource(props.deviceId);
  163. }, 1000);
  164. });
  165. onUnmounted(() => {
  166. clearInterval(timer);
  167. if (!globalConfig?.is2DModel) {
  168. destroy();
  169. }
  170. });
  171. </script>
  172. <style lang="less" scoped>
  173. @import '/@/design/theme.less';
  174. @import '/@/design/vent/modal.less';
  175. // @import '../less/tunFace.less';
  176. @import '../../comment/less/workFace.less';
  177. @ventSpace: zxm;
  178. .monitor-item {
  179. display: flex;
  180. justify-content: space-between;
  181. margin-bottom: 3px;
  182. .monitor-val {
  183. font-size: 14px;
  184. }
  185. }
  186. .monitor-title {
  187. width: 200px;
  188. color: var(--vent-font-action-link);
  189. font-weight: 400;
  190. font-size: 14px;
  191. }
  192. .dust-fan-monitor {
  193. display: flex;
  194. flex-wrap: wrap;
  195. }
  196. .dust-fan-monitor-item {
  197. width: 152px;
  198. height: 70px;
  199. display: flex;
  200. flex-direction: column;
  201. justify-content: center;
  202. align-items: center;
  203. border: 1px solid rgba(25, 251, 255, 0.4);
  204. box-shadow: inset 0 0 20px rgba(0, 197, 255, 0.4);
  205. background: rgba(0, 0, 0, 0.06666667);
  206. margin-bottom: 5px;
  207. padding: 8px 0;
  208. &:nth-child(2n) {
  209. margin-left: 12px;
  210. }
  211. .title {
  212. color: #5dfaff;
  213. }
  214. .unit {
  215. font-size: 13px;
  216. color: #ffffffaa;
  217. }
  218. .value {
  219. color: #ffb212;
  220. }
  221. }
  222. .fault {
  223. .title {
  224. color: #c4fdff;
  225. }
  226. .value {
  227. // color: #FFB212;
  228. color: #61ddb1;
  229. }
  230. }
  231. </style>