SecurityPosition.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div class="outer-person-container">
  3. <div class="container-title">
  4. <span class="line"></span>
  5. <span class="title">治安重点部位监控</span>
  6. <el-tooltip effect="dark" placement="left">
  7. <span class="position-count">{{ positionCameraCount }}</span>
  8. <template #content>
  9. <span>共{{ positionCameraCount }}个监控位置</span>
  10. </template>
  11. </el-tooltip>
  12. </div>
  13. <div class="monitor-area">
  14. <div v-if="securityPositionCameraInfo.length === 0" class="empty-style">
  15. <img class="empty-img" src="@/assets/images/empty-2.png" alt="" />
  16. <span>暂无治安重点部位监控</span>
  17. </div>
  18. <div v-for="(item, index) in securityPositionCameraInfo" :key="index" class="monitor-item">
  19. <img
  20. v-if="!getCameraUrl(item)"
  21. src="@/assets/images/disaster-overview/no-camera-url.png"
  22. alt=""
  23. class="monitor-no-url"
  24. />
  25. <div class="monitor-video">
  26. <LiveVideo :url="getCameraUrl(item)" :poster="getCameraImg(item)" :id="`monitor-livevideo-${index}`" />
  27. <img
  28. src="@/assets/images/disaster-overview/full-screen.png"
  29. alt=""
  30. class="full-screen"
  31. @click="isFullScreen ? exitFullscreen() : fullScreen(`monitor-livevideo-${index}`, 'overview-monitor')"
  32. />
  33. </div>
  34. <div class="monitor-info">
  35. <img src="@/assets/images/disaster-overview/camera.png" alt="" />
  36. <span class="camera-name" :title="item.positionName + '-' + item.name"
  37. >{{ item.positionName }}-{{ item.name }}</span
  38. >
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </template>
  44. <script setup lang="ts">
  45. import { onMounted, onUnmounted, ref } from 'vue';
  46. import { storeToRefs } from 'pinia';
  47. import screenfull from 'screenfull';
  48. import urlJoin from 'url-join';
  49. import LiveVideo from '@/components/live/LiveVideo.vue';
  50. import { userSplitScreenFullScreen } from '@/store/modules/userSplitScreenFullScreen';
  51. import { CameraInfo } from '@/api/disaster-overview';
  52. import { getSecurityPositionList } from '@/api/security-confidentiality-position';
  53. const { isFullScreen, curFullScreenType } = storeToRefs(userSplitScreenFullScreen());
  54. const { fullScreen, exitFullscreen } = userSplitScreenFullScreen();
  55. interface SecurityPositionCameraInfo extends CameraInfo {
  56. positionName: string;
  57. }
  58. const positionCameraCount = ref(0);
  59. const securityPositionCameraInfo = ref<SecurityPositionCameraInfo[]>([]);
  60. const isHttps = () => {
  61. return window.location.protocol.startsWith('https');
  62. };
  63. const getCameraUrl = (val: CameraInfo) => {
  64. if (val.pushStreamDTO && val.pushStreamDTO.videoUrls) {
  65. const videoUrl = val.pushStreamDTO.videoUrls.pushstreamIp;
  66. const protocol = isHttps() ? 'wss' : 'ws';
  67. // 如果是绝对地址
  68. if (videoUrl.startsWith('http')) {
  69. // 如果是https的话,websocket要用wss
  70. return videoUrl.replace('http', protocol);
  71. }
  72. const u = urlJoin(
  73. `${protocol}://`,
  74. window.location.host,
  75. window.location.pathname === '/' ? '' : window.location.pathname,
  76. videoUrl,
  77. );
  78. return u;
  79. }
  80. return '';
  81. };
  82. const getCameraImg = (val: CameraInfo) => {
  83. if (val.pushStreamDTO && val.pushStreamDTO.imageUrl) {
  84. return val.pushStreamDTO.imageUrl;
  85. }
  86. return '';
  87. };
  88. onMounted(() => {
  89. getSecurityPositionList({
  90. groupName: '',
  91. cameraName: '',
  92. }).then((res) => {
  93. securityPositionCameraInfo.value = res.flatMap((item) => {
  94. return item.children.map((child) => ({
  95. ...child,
  96. positionName: item.groupName,
  97. }));
  98. });
  99. positionCameraCount.value = securityPositionCameraInfo.value.length;
  100. });
  101. });
  102. window.onresize = () => {
  103. if (!screenfull.isFullscreen) {
  104. isFullScreen.value = false; //判断退出全屏,进行赋值
  105. curFullScreenType.value = 'single';
  106. }
  107. };
  108. onUnmounted(() => {
  109. window.onresize = null;
  110. });
  111. </script>
  112. <style scoped lang="scss">
  113. .container-title {
  114. height: 24px;
  115. display: flex;
  116. align-items: center;
  117. font-weight: 500;
  118. font-size: 16px;
  119. color: #000000;
  120. .line {
  121. width: 3px;
  122. height: 16px;
  123. background: #1777ff;
  124. margin-right: 10px;
  125. }
  126. .title {
  127. margin-right: 12px;
  128. }
  129. }
  130. .position-count {
  131. font-size: 18px;
  132. color: #1777ff;
  133. text-shadow: 0 0 10px #1777ff;
  134. }
  135. .outer-person-container {
  136. width: 100%;
  137. height: 100%;
  138. padding-top: 14px;
  139. }
  140. .monitor-area {
  141. width: 100%;
  142. height: calc(100% - 48px);
  143. overflow: auto;
  144. padding: 0 16px;
  145. margin-top: 10px;
  146. .monitor-item:last-child {
  147. margin-bottom: 0;
  148. }
  149. .monitor-item {
  150. margin-bottom: 10px;
  151. .monitor-info {
  152. display: flex;
  153. align-items: center;
  154. .camera-name {
  155. margin-left: 12px;
  156. overflow: hidden;
  157. text-overflow: ellipsis;
  158. white-space: nowrap;
  159. max-width: 100%;
  160. font-size: 14px;
  161. color: #333333;
  162. }
  163. }
  164. .monitor-no-url {
  165. width: 100%;
  166. height: 100%;
  167. object-fit: contain;
  168. }
  169. .monitor-video {
  170. position: relative;
  171. width: 100%;
  172. height: 100%;
  173. }
  174. .full-screen {
  175. position: absolute;
  176. bottom: 10px;
  177. right: 5px;
  178. cursor: pointer;
  179. }
  180. }
  181. .empty-style {
  182. width: 100%;
  183. height: 100%;
  184. display: flex;
  185. flex-direction: column;
  186. justify-content: center;
  187. align-items: center;
  188. font-size: 16px;
  189. color: rgba(0, 0, 0, 0.5);
  190. .empty-img {
  191. width: 100%;
  192. object-fit: contain;
  193. }
  194. }
  195. }
  196. </style>