index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <div class="gasMonitor">
  3. <customHeader>瓦斯钻孔实时监测</customHeader>
  4. <div class="content">
  5. <div class="left-box">
  6. <div class="video">
  7. <video controls autoplay muted loop fluent style="height: 100%; width: 100%; padding: 30px 20px">
  8. <source :src="`${baseApiUrl}/sys/common/static/gif/output_video.mp4`" type="video/mp4" />
  9. </video>
  10. </div>
  11. </div>
  12. <div class="right-box">
  13. <div class="count">
  14. <div class="icon"></div>
  15. <div class="count-content">
  16. <span class="conten">{{ usedCount }}</span>
  17. <span>钻孔计数</span>
  18. </div>
  19. </div>
  20. <div class="status">
  21. <div class="icon"></div>
  22. <div class="status-content">
  23. <span class="conten">{{ curStatus }}</span>
  24. <span>钻杆状态</span>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. </template>
  31. <script setup lang="ts">
  32. import { ref, onMounted, onUnmounted } from 'vue';
  33. import { getVideoPlayTime, getGasZkStatus } from './gasZk.api';
  34. import customHeader from '/@/components/vent/customHeader.vue';
  35. import { useGlobSetting } from '/@/hooks/setting';
  36. const globSetting = useGlobSetting();
  37. const baseApiUrl = globSetting.domainUrl;
  38. const videoPlayTime = ref(0); //视频开始播放时间
  39. const curStatus = ref(''); //当前状态
  40. const usedCount = ref(''); //钻孔计数
  41. const videoUrl = ref('');
  42. let timer: IntervalHandle; //定时器
  43. //时间轮询
  44. const startPolling = () => {
  45. // 清除定时器
  46. stopPolling();
  47. // 设置新定时器
  48. timer = setInterval(async () => {
  49. try {
  50. const res = await getGasZkStatus({
  51. playTime: videoPlayTime.value,
  52. });
  53. // 更新数据
  54. usedCount.value = res.usedCount;
  55. curStatus.value = res.curStatus;
  56. startPolling();
  57. } catch (error) {
  58. console.error('请求失败,停止轮询', error);
  59. stopPolling();
  60. }
  61. }, 1000);
  62. };
  63. // 停止轮询 清除定时器
  64. const stopPolling = () => {
  65. if (timer !== null) {
  66. clearInterval(timer);
  67. timer = null;
  68. }
  69. };
  70. onMounted(async () => {
  71. try {
  72. videoPlayTime.value = await getVideoPlayTime();
  73. // 第一次请求
  74. const res = await getGasZkStatus({
  75. playTime: videoPlayTime.value,
  76. });
  77. usedCount.value = res.usedCount;
  78. curStatus.value = res.curStatus;
  79. // 启动轮询
  80. startPolling();
  81. } catch (error) {
  82. console.error('初始化失败', error);
  83. }
  84. });
  85. // 组件卸载时清理
  86. onUnmounted(() => {
  87. stopPolling();
  88. });
  89. </script>
  90. <style lang="less" scoped>
  91. @import '/@/design/theme.less';
  92. @{theme-deepblue} {
  93. .gasMonitor {
  94. --image-border: url('/@/assets/images/themify/deepblue/fire/border.png');
  95. }
  96. }
  97. .gasMonitor {
  98. --image-border: url('/@/assets/images/fire/border.png');
  99. position: relative;
  100. width: calc(100% - 20px);
  101. height: calc(100% - 90px);
  102. position: relative;
  103. margin: 30px 10px 10px 10px;
  104. .content {
  105. position: relative;
  106. width: 100%;
  107. height: 100%;
  108. display: flex;
  109. justify-content: space-between;
  110. align-items: center;
  111. margin-top: 80px;
  112. .left-box {
  113. flex: 3;
  114. height: 100%;
  115. padding: 10px;
  116. background: var(--image-border) no-repeat center;
  117. background-size: 100% 100%;
  118. .video {
  119. height: 100%;
  120. }
  121. }
  122. .right-box {
  123. flex: 1;
  124. margin-left: 30px;
  125. height: 100%;
  126. background: var(--image-border) no-repeat center;
  127. background-size: 100% 100%;
  128. .count {
  129. margin: 30px;
  130. height: 200px;
  131. padding: 0 20px;
  132. display: flex;
  133. flex-direction: row;
  134. align-items: center;
  135. background-image: url('/@/assets/images/vent/gas/gasZkBorder.png');
  136. background-size: 100% 100%;
  137. .icon {
  138. margin-bottom: 20px;
  139. width: 35%;
  140. height: 65%;
  141. background-image: url('/@/assets/images/vent/gas/zkcount.png');
  142. background-size: 100% 100%;
  143. margin-left: 10px;
  144. }
  145. .count-content {
  146. display: flex;
  147. flex-direction: column;
  148. font-size: 20px;
  149. color: #fff;
  150. margin-left: 25px;
  151. .conten {
  152. font-weight: bold;
  153. margin-bottom: 20px;
  154. color: #27fded;
  155. font-style: italic;
  156. }
  157. }
  158. }
  159. .status {
  160. margin: 30px;
  161. padding: 0 20px;
  162. height: 200px;
  163. display: flex;
  164. flex-direction: row;
  165. align-items: center;
  166. background-image: url('/@/assets/images/vent/gas/gasZkBorder.png');
  167. background-size: 100% 100%;
  168. .icon {
  169. margin-bottom: 20px;
  170. width: 35%;
  171. height: 65%;
  172. background-image: url('/@/assets/images/vent/gas/zgStatus.png');
  173. background-size: 100% 100%;
  174. margin-left: 10px;
  175. }
  176. .status-content {
  177. display: flex;
  178. flex-direction: column;
  179. font-size: 20px;
  180. color: #fff;
  181. margin-left: 25px;
  182. .conten {
  183. margin-bottom: 20px;
  184. font-weight: bold;
  185. color: #27fded;
  186. font-style: italic;
  187. }
  188. }
  189. }
  190. }
  191. }
  192. }
  193. </style>