videoList.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div id="app">
  3. <el-container>
  4. <el-header>
  5. <uiHeader></uiHeader>
  6. </el-header>
  7. <el-main>
  8. <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;">
  9. <span style="font-size: 1rem; font-weight: bold;">设备列表</span>
  10. <div style="position: absolute; right: 1rem; top: 0.3rem;">
  11. <el-button icon="el-icon-refresh-right" circle size="mini" @click="getDeviceList()"></el-button>
  12. </div>
  13. </div>
  14. <devicePlayer ref="devicePlayer"></devicePlayer>
  15. <!--设备列表-->
  16. <el-table :data="deviceList" border style="width: 100%" :height="winHeight">
  17. <el-table-column prop="name" label="名称" width="180" align="center">
  18. </el-table-column>
  19. <el-table-column prop="deviceId" label="设备编号" width="240" align="center">
  20. </el-table-column>
  21. <el-table-column label="地址" width="180" align="center">
  22. <template slot-scope="scope">
  23. <div slot="reference" class="name-wrapper">
  24. <el-tag size="medium">{{ scope.row.host.address }}</el-tag>
  25. </div>
  26. </template>
  27. </el-table-column>
  28. <el-table-column prop="manufacturer" label="厂家" align="center">
  29. </el-table-column>
  30. <el-table-column prop="model" label="固件版本" align="center">
  31. </el-table-column>
  32. <el-table-column label="流传输模式" align="center" width="160">
  33. <template slot-scope="scope">
  34. <el-select size="mini" @change="transportChange(scope.row)" v-model="scope.row.streamMode" placeholder="请选择">
  35. <el-option key="UDP" label="UDP" value="UDP"></el-option>
  36. <el-option key="TCP-ACTIVE" label="TCP主动模式" :disabled="true" value="TCP-ACTIVE"></el-option>
  37. <el-option key="TCP-PASSIVE" label="TCP被动模式" value="TCP-PASSIVE"></el-option>
  38. </el-select>
  39. </template>
  40. </el-table-column>
  41. <el-table-column prop="channelCount" label="通道数" align="center">
  42. </el-table-column>
  43. <el-table-column label="状态" width="180" align="center">
  44. <template slot-scope="scope">
  45. <div slot="reference" class="name-wrapper">
  46. <el-tag size="medium" v-if="scope.row.online == 1">在线</el-tag>
  47. <el-tag size="medium" type="info" v-if="scope.row.online == 0">离线</el-tag>
  48. </div>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="操作" width="240" align="center" fixed="right">
  52. <template slot-scope="scope">
  53. <el-button size="mini" icon="el-icon-refresh" @click="refDevice(scope.row)">刷新通道</el-button>
  54. <el-button size="mini" icon="el-icon-s-open" type="primary" @click="showChannelList(scope.row)">查看通道</el-button>
  55. </template>
  56. </el-table-column>
  57. </el-table>
  58. <el-pagination
  59. style="float: right"
  60. @size-change="handleSizeChange"
  61. @current-change="currentChange"
  62. :current-page="currentPage"
  63. :page-size="count"
  64. :page-sizes="[15, 25, 35, 50]"
  65. layout="total, sizes, prev, pager, next"
  66. :total="total">
  67. </el-pagination>
  68. </el-main>
  69. </el-container>
  70. </div>
  71. </template>
  72. <script>
  73. import uiHeader from './UiHeader.vue'
  74. export default {
  75. name: 'app',
  76. components: {
  77. uiHeader
  78. },
  79. data() {
  80. return {
  81. deviceList: [], //设备列表
  82. currentDevice: {}, //当前操作设备对象
  83. videoComponentList: [],
  84. updateLooper: 0, //数据刷新轮训标志
  85. currentDeviceChannelsLenth:0,
  86. winHeight: window.innerHeight - 200,
  87. currentPage:1,
  88. count:15,
  89. total:0
  90. };
  91. },
  92. computed: {
  93. getcurrentDeviceChannels: function() {
  94. let data = this.currentDevice['channelMap'];
  95. let channels = null;
  96. if (data) {
  97. channels = Object.keys(data).map(key => {
  98. return data[key];
  99. });
  100. this.currentDeviceChannelsLenth = channels.length;
  101. }
  102. console.log("数据:" + JSON.stringify(channels));
  103. return channels;
  104. }
  105. },
  106. mounted() {
  107. this.initData();
  108. this.updateLooper = setInterval(this.initData, 10000);
  109. },
  110. destroyed() {
  111. this.$destroy('videojs');
  112. clearTimeout(this.updateLooper);
  113. },
  114. methods: {
  115. initData: function() {
  116. this.getDeviceList();
  117. },
  118. currentChange: function(val){
  119. this.currentPage = val;
  120. this.getDeviceList();
  121. },
  122. handleSizeChange: function(val){
  123. this.count = val;
  124. this.getDeviceList();
  125. },
  126. getDeviceList: function() {
  127. let that = this;
  128. this.$axios.get(`/api/devices`,{
  129. params: {
  130. page: that.currentPage - 1,
  131. count: that.count
  132. }
  133. } )
  134. .then(function (res) {
  135. console.log(res);
  136. that.total = res.data.total;
  137. that.deviceList = res.data.data;
  138. })
  139. .catch(function (error) {
  140. console.log(error);
  141. });
  142. },
  143. showChannelList: function(row) {
  144. console.log(JSON.stringify(row))
  145. this.$router.push(`/channelList/${row.deviceId}/0/15/1`);
  146. },
  147. //gb28181平台对接
  148. //刷新设备信息
  149. refDevice: function(itemData) {
  150. ///api/devices/{deviceId}/sync
  151. console.log("刷新对应设备:" + itemData.deviceId);
  152. this.$axios({
  153. method: 'post',
  154. url: '/api/devices/' + itemData.deviceId + '/sync'
  155. }).then(function(res) {
  156. // console.log("刷新设备结果:"+JSON.stringify(res));
  157. }).catch(function(e) {
  158. that.$message({
  159. showClose: true,
  160. message: '请求成功',
  161. type: 'success'
  162. });
  163. });;
  164. },
  165. //通知设备上传媒体流
  166. sendDevicePush: function(itemData) {
  167. let deviceId = this.currentDevice.deviceId;
  168. let channelId = itemData.channelId;
  169. console.log("通知设备推流1:" + deviceId + " : " + channelId);
  170. let that = this;
  171. this.$axios({
  172. method: 'get',
  173. url: '/api/play/' + deviceId + '/' + channelId
  174. }).then(function(res) {
  175. let ssrc = res.data.ssrc;
  176. that.$refs.devicePlayer.play(ssrc,deviceId,channelId);
  177. }).catch(function(e) {
  178. });
  179. },
  180. transportChange: function (row) {
  181. console.log(row);
  182. console.log(`修改传输方式为 ${row.streamMode}:${row.deviceId} `);
  183. let that = this;
  184. this.$axios({
  185. method: 'get',
  186. url: '/api/devices/' + row.deviceId + '/transport/' + row.streamMode
  187. }).then(function(res) {
  188. }).catch(function(e) {
  189. });
  190. }
  191. }
  192. };
  193. </script>
  194. <style>
  195. .videoList {
  196. display: flex;
  197. flex-wrap: wrap;
  198. align-content: flex-start;
  199. }
  200. .video-item {
  201. position: relative;
  202. width: 15rem;
  203. height: 10rem;
  204. margin-right: 1rem;
  205. background-color: #000000;
  206. }
  207. .video-item-img {
  208. position: absolute;
  209. top: 0;
  210. bottom: 0;
  211. left: 0;
  212. right: 0;
  213. margin: auto;
  214. width: 100%;
  215. height: 100%;
  216. }
  217. .video-item-img:after {
  218. content: "";
  219. display: inline-block;
  220. position: absolute;
  221. z-index: 2;
  222. top: 0;
  223. bottom: 0;
  224. left: 0;
  225. right: 0;
  226. margin: auto;
  227. width: 3rem;
  228. height: 3rem;
  229. background-image: url("../assets/loading.png");
  230. background-size: cover;
  231. background-color: #000000;
  232. }
  233. .video-item-title {
  234. position: absolute;
  235. bottom: 0;
  236. color: #000000;
  237. background-color: #ffffff;
  238. line-height: 1.5rem;
  239. padding: 0.3rem;
  240. width: 14.4rem;
  241. }
  242. </style>