videoStats.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <div class="videoStats panel-box risk-warning">
  3. <div class="corner-deco tl"></div><div class="corner-deco tr"></div>
  4. <div class="corner-deco bl"></div><div class="corner-deco br"></div>
  5. <div class="panel-title">实验室视频监控</div>
  6. <div class="video-content">
  7. <!--<webRTC v-if="webRtcType"></webRTC>-->
  8. <videoForMod v-for="(item,index) in modList" :key="index"
  9. :deviceNo="item.deviceNo"></videoForMod>
  10. <!--<mpegts-video style="display: inline-block;margin:0 5px 5px 0;"-->
  11. <!--:videoProps="item" v-for="(item,index) in demoList" :key="index"></mpegts-video>-->
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import { getVideoList,laboratoryLabScreenScreenConfigGet,iotDeviceList,iotCameraFindByCondition } from '@/api/index'
  17. import videoForMod from '@/components/videoForMod/videoForMod.vue'
  18. import webRTC from './webRTC.vue'
  19. import mpegtsVideo from '@/components/mpegtsVideo/mpegtsVideo.vue'
  20. export default {
  21. name: 'videoStats',
  22. components: {
  23. videoForMod,
  24. webRTC,
  25. mpegtsVideo,
  26. },
  27. data () {
  28. return {
  29. width:470,
  30. height:280,
  31. modList:[],
  32. pollTimer:null,
  33. page:1,
  34. webRtcType:false,
  35. demoList:[],
  36. }
  37. },
  38. created(){
  39. },
  40. mounted(){
  41. // this.laboratoryLabScreenScreenConfigGet();
  42. // this.pollTimer = setInterval(this.laboratoryLabScreenScreenConfigGet, 5 * 60 * 1000)
  43. this.initialize();
  44. },
  45. methods:{
  46. /* 测试方法开始 */
  47. initialize() {
  48. let self = this;
  49. self.$set(self, 'videoType', false);
  50. self.$set(self, 'videoList', []);
  51. // type 1.楼栋 2.楼层 3.楼道 4.实验室
  52. let obj = {
  53. page:'1',
  54. pageSize:'4',
  55. buildId:'',
  56. floorId:'',
  57. passageway:'',
  58. subIds:['2067514255432413184'],
  59. protocol:window.location.href.indexOf('https') !== -1?'wss':'ws',
  60. streamType:1,
  61. source:1,
  62. };
  63. iotCameraFindByCondition(obj).then(response => {
  64. let list = [];
  65. for(let i=0;i<response.data.records.length;i++){
  66. list.push(
  67. {
  68. width: this.width, //(宽度:非必传-默认600)
  69. height: this.height, //(高度:非必传-默认338)
  70. url: response.data.records[i].streamUrl,
  71. cameraIndexCode: response.data.records[i].deviceNo,
  72. }
  73. )
  74. }
  75. this.$set(this,'demoList',list)
  76. });
  77. },
  78. /* 测试方法结束 */
  79. //指定视频
  80. async iotDeviceList(){
  81. let obj = {
  82. page: this.page,
  83. pageSize: 4,
  84. typeKey: "camera",
  85. orderBy:"subject_id desc"
  86. };
  87. const res = await iotDeviceList(obj)
  88. if (res.code === 200) {
  89. this.$set(this,'modList',res.data.records);
  90. if(res.data.current<(res.data.pages-1)){
  91. this.page++
  92. }else{
  93. this.$set(this,'page',1);
  94. }
  95. }
  96. },
  97. async laboratoryLabScreenScreenConfigGet(){
  98. try {
  99. const res = await laboratoryLabScreenScreenConfigGet({ screenType: 2 })
  100. if (res.code === 200) {
  101. this.$set(this,'modList',[]);
  102. if(res.data.effective){
  103. this.$set(this,'webRtcType',true);
  104. this.$set(this,'page',1);
  105. let list = [];
  106. for(let i=0;i<res.data.items.length;i++){
  107. if(i<3){
  108. list.push(res.data.items[i])
  109. }
  110. }
  111. this.$set(this,'modList',list);
  112. }else{
  113. this.$set(this,'webRtcType',false);
  114. this.iotDeviceList();
  115. }
  116. }
  117. } catch (e) {
  118. }
  119. },
  120. //刷新视屏
  121. getVideoData(data) {
  122. let obj = {
  123. page: 1,
  124. pageSize: 4,
  125. passageway: '',
  126. protocol: window.location.href.indexOf('https') !== -1 ? 'wss' : 'ws',
  127. streamType: 1,
  128. source: 4,
  129. subIds: data,
  130. };
  131. this.$set(this, 'videoQueryParams', obj);
  132. this.$nextTick(() => {
  133. this.videoInitialize()
  134. })
  135. },
  136. async videoInitialize() {
  137. let self = this;
  138. self.$set(self, 'videoType', false);
  139. self.$set(self, 'videoList', []);
  140. try {
  141. // const res = await getVideoList(this.videoQueryParams)
  142. // 假数据开始
  143. let res = {
  144. data: {
  145. total: 100,
  146. records: [
  147. {streamUrl: '1', deviceNo: '1'},
  148. {streamUrl: '2', deviceNo: '2'},
  149. {streamUrl: '3', deviceNo: '3'},
  150. {streamUrl: '4', deviceNo: '4'},
  151. ],
  152. }
  153. };
  154. // 假数据结束
  155. let list = [];
  156. for(let i=0;i<res.data.records.length;i++){
  157. list.push(
  158. {
  159. width: self.width, //(宽度:非必传-默认600)
  160. height: self.height, //(高度:非必传-默认338)
  161. url: res.data.records[i].streamUrl,
  162. cameraIndexCode: res.data.records[i].deviceNo,
  163. }
  164. )
  165. }
  166. this.$set(this,'videoList',list)
  167. this.$nextTick(()=>{
  168. setTimeout(function(){
  169. self.$set(self, 'videoType', true);
  170. },1000);
  171. })
  172. } catch (e) {
  173. console.error('VideoGrid:', e)
  174. }
  175. },
  176. },
  177. }
  178. </script>
  179. <style scoped lang="scss">
  180. .videoStats{
  181. }
  182. .risk-warning {
  183. display: flex;
  184. flex-direction: column;
  185. }
  186. .video-content{
  187. padding: 0;
  188. position: relative;
  189. z-index: 2;
  190. flex: 1;
  191. min-height: 0;
  192. .videoForMod:nth-child(2){
  193. margin-left:10px;
  194. }
  195. .videoForMod:nth-child(3){
  196. margin-top:5px;
  197. }
  198. .videoForMod:nth-child(4){
  199. margin-top:5px;
  200. margin-left:10px;
  201. }
  202. }
  203. </style>