groutHomeJj.vue 5.6 KB

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