groutHomeJj.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <div class="monitor-container">
  3. <div class="header-box">
  4. <div class="header-container">
  5. <div class="device-detail">
  6. <div class="device-title">&nbsp</div>
  7. <div class="device-val">是否带电</div>
  8. <div class="device-val">是否运行</div>
  9. <div class="device-val">故障</div>
  10. </div>
  11. <div v-for="(device, key) in deviceMonitorList" class="device-detail" :key="key">
  12. <div class="device-title">{{ device.title }}</div>
  13. <div v-for="(detailItem, index) in device.dataList" :key="detailItem.code" class="device-val">
  14. <span v-if="index == 0" :style="{ color: monitorData[detailItem.code] != 1 ? '#BFBFBF' : '#10BC79' }">{{
  15. monitorData[detailItem.code] == 0 ? '不带电' : monitorData[detailItem.code] == 1 ? '带电' : '-'
  16. }}</span>
  17. <span v-if="index == 1" :style="{ color: monitorData[detailItem.code] != 1 ? '#BFBFBF' : '#10BC79' }">{{
  18. monitorData[detailItem.code] == 0 ? '未运行' : monitorData[detailItem.code] == 1 ? '运行' : '-'
  19. }}</span>
  20. <span
  21. v-if="index == 2"
  22. :style="{ color: monitorData[detailItem.code] == 0 ? '#10BC79' : monitorData[detailItem.code] == 1 ? '#F14C4C' : '#BFBFBF' }"
  23. >{{ monitorData[detailItem.code] == 0 ? '正常' : monitorData[detailItem.code] == 1 ? '报警' : '-' }}</span
  24. >
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. <div
  30. v-if="renderPlayer"
  31. ref="playerRef"
  32. style="z-index: 999; position: absolute; top: 100px; right: 15px; height: 100%; margin: auto; pointer-events: none"
  33. >
  34. </div>
  35. </div>
  36. </template>
  37. <script setup lang="ts">
  38. import { watch, ref, onMounted, onUnmounted, defineProps, reactive, onBeforeUnmount } from 'vue';
  39. import { mountedThree, destroy, setModelType } from '../grout.threejs';
  40. import { deviceMonitorList } from '../grout.data';
  41. import { list } from '../grout.api';
  42. import { useCamera } from '/@/hooks/system/useCamera';
  43. const props = defineProps({
  44. deviceId: {
  45. type: String,
  46. require: true,
  47. },
  48. deviceType: {
  49. type: String,
  50. require: true,
  51. },
  52. });
  53. const loading = ref(false);
  54. const monitorData = ref({});
  55. // 监测数据
  56. const selectData = reactive({});
  57. const playerRef = ref();
  58. const renderPlayer = ref(true);
  59. const { getCamera, removeCamera } = useCamera();
  60. // https获取监测数据
  61. let timer: null | NodeJS.Timeout = null;
  62. function getMonitor(flag?) {
  63. if (Object.prototype.toString.call(timer) === '[object Null]') {
  64. return new Promise((resolve) => {
  65. timer = setTimeout(
  66. async () => {
  67. if (props.deviceId) {
  68. await getDataSource(props.deviceId);
  69. }
  70. if (timer) {
  71. timer = null;
  72. }
  73. resolve(null);
  74. await getMonitor();
  75. },
  76. flag ? 0 : 1000
  77. );
  78. });
  79. }
  80. }
  81. async function getDataSource(systemID) {
  82. const res = await list({ devicetype: 'pulping_auto', systemID, pagetype: 'normal' });
  83. const result = res.deviceInfo;
  84. for (const key in result) {
  85. const item = result[key];
  86. if (item.type.startsWith('pulping')) {
  87. monitorData.value = Object.assign(item['datalist'][0], item['datalist'][0]['readData']);
  88. }
  89. loading.value = false;
  90. }
  91. }
  92. watch(
  93. () => props.deviceId,
  94. async (deviceId) => {
  95. if (deviceId) {
  96. await getCamera(deviceId, playerRef, renderPlayer);
  97. }
  98. },
  99. { immediate: true }
  100. );
  101. onMounted(() => {
  102. loading.value = true;
  103. mountedThree().then(async () => {
  104. // await setModelType('groutBase');
  105. await setModelType('bertaiBase');
  106. loading.value = false;
  107. timer = null;
  108. getMonitor(true);
  109. });
  110. });
  111. onBeforeUnmount(() => {
  112. removeCamera(playerRef);
  113. });
  114. onUnmounted(() => {
  115. destroy();
  116. if (timer) {
  117. clearTimeout(timer);
  118. timer = undefined;
  119. }
  120. });
  121. </script>
  122. <style lang="less" scoped>
  123. @import '/@/design/theme.less';
  124. @import '/@/design/vent/modal.less';
  125. @ventSpace: zxm;
  126. @{theme-deepblue} {
  127. .monitor-container {
  128. --box-shadow: #316b92;
  129. --border-color: #0a80fad4;
  130. }
  131. }
  132. .monitor-container {
  133. --box-shadow: #0099b8;
  134. --border-color: #00baffd4;
  135. width: 100%;
  136. height: 100%;
  137. // height: 550px;
  138. // border: 1px solid #fff;
  139. margin-top: 40px;
  140. display: flex;
  141. // justify-content: space-between;
  142. justify-content: center;
  143. padding: 0 5px;
  144. .header-box {
  145. // width: 100%;
  146. margin-top: 50px;
  147. .header-container {
  148. height: auto;
  149. display: flex;
  150. flex-direction: row;
  151. justify-content: center;
  152. color: #fff;
  153. box-shadow: 0 0 30px var(--box-shadow) inset;
  154. }
  155. .device-title {
  156. width: 110px;
  157. text-align: center;
  158. border-top: 1px solid var(--border-color);
  159. border-left: 1px solid var(--border-color);
  160. line-height: 46px;
  161. color: var(--vent-table-action-link);
  162. background-color: #00bbff21;
  163. }
  164. .device-detail {
  165. text-align: center;
  166. &:first-child {
  167. background-color: #00bbff11;
  168. }
  169. &:last-child {
  170. .device-val,
  171. .device-title {
  172. border-right: 1px solid var(--border-color);
  173. }
  174. }
  175. .device-val {
  176. line-height: 36px;
  177. border-top: 1px solid var(--border-color);
  178. border-left: 1px solid var(--border-color);
  179. &:last-child {
  180. border-bottom: 1px solid var(--border-color);
  181. }
  182. }
  183. }
  184. }
  185. }
  186. :deep(.@{ventSpace}-tabs-tabpane-active) {
  187. overflow: auto;
  188. }
  189. .input-box {
  190. display: flex;
  191. align-items: center;
  192. padding-left: 10px;
  193. .input-title {
  194. color: #73e8fe;
  195. width: auto;
  196. }
  197. .@{ventSpace}-input-number {
  198. border-color: #ffffff88 !important;
  199. }
  200. margin-right: 10px;
  201. }
  202. </style>