videoList.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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" :loading="getDeviceListLoading" @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.hostAddress }}</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" :ref="scope.row.deviceId + 'refbtn' " icon="el-icon-refresh" @click="refDevice(scope.row)">刷新通道</el-button>
  54. <el-button size="mini" icon="el-icon-s-open" v-bind:disabled="scope.row.online==0" 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. getDeviceListLoading: false
  91. };
  92. },
  93. computed: {
  94. getcurrentDeviceChannels: function() {
  95. let data = this.currentDevice['channelMap'];
  96. let channels = null;
  97. if (data) {
  98. channels = Object.keys(data).map(key => {
  99. return data[key];
  100. });
  101. this.currentDeviceChannelsLenth = channels.length;
  102. }
  103. console.log("数据:" + JSON.stringify(channels));
  104. return channels;
  105. }
  106. },
  107. mounted() {
  108. this.initData();
  109. this.updateLooper = setInterval(this.initData, 10000);
  110. },
  111. destroyed() {
  112. this.$destroy('videojs');
  113. clearTimeout(this.updateLooper);
  114. },
  115. methods: {
  116. initData: function() {
  117. this.getDeviceList();
  118. },
  119. currentChange: function(val){
  120. this.currentPage = val;
  121. this.getDeviceList();
  122. },
  123. handleSizeChange: function(val){
  124. this.count = val;
  125. this.getDeviceList();
  126. },
  127. getDeviceList: function() {
  128. let that = this;
  129. this.getDeviceListLoading = true;
  130. this.$axios.get(`/api/devices`,{
  131. params: {
  132. page: that.currentPage,
  133. count: that.count
  134. }
  135. } )
  136. .then(function (res) {
  137. console.log(res);
  138. console.log(res.data.list);
  139. that.total = res.data.total;
  140. that.deviceList = res.data.list;
  141. that.getDeviceListLoading = false;
  142. })
  143. .catch(function (error) {
  144. console.log(error);
  145. that.getDeviceListLoading = false;
  146. });
  147. },
  148. showChannelList: function(row) {
  149. console.log(JSON.stringify(row))
  150. this.$router.push(`/channelList/${row.deviceId}/0/15/1`);
  151. },
  152. //gb28181平台对接
  153. //刷新设备信息
  154. refDevice: function(itemData) {
  155. ///api/devices/{deviceId}/sync
  156. console.log("刷新对应设备:" + itemData.deviceId);
  157. var that = this;
  158. that.$refs[itemData.deviceId + 'refbtn' ].loading = true;
  159. this.$axios({
  160. method: 'post',
  161. url: '/api/devices/' + itemData.deviceId + '/sync'
  162. }).then(function(res) {
  163. console.log("刷新设备结果:"+JSON.stringify(res));
  164. if (!res.data.deviceId) {
  165. that.$message({
  166. showClose: true,
  167. message: res.data,
  168. type: 'error'
  169. });
  170. }else{
  171. that.$message({
  172. showClose: true,
  173. message: '请求成功',
  174. type: 'success'
  175. });
  176. }
  177. that.initData()
  178. that.$refs[itemData.deviceId + 'refbtn' ].loading = false;
  179. }).catch(function(e) {
  180. console.error(e)
  181. that.$refs[itemData.deviceId + 'refbtn' ].loading = false;
  182. });;
  183. },
  184. //通知设备上传媒体流
  185. sendDevicePush: function(itemData) {
  186. let deviceId = this.currentDevice.deviceId;
  187. let channelId = itemData.channelId;
  188. console.log("通知设备推流1:" + deviceId + " : " + channelId);
  189. let that = this;
  190. this.$axios({
  191. method: 'get',
  192. url: '/api/play/' + deviceId + '/' + channelId
  193. }).then(function(res) {
  194. let ssrc = res.data.ssrc;
  195. that.$refs.devicePlayer.play(ssrc,deviceId,channelId);
  196. }).catch(function(e) {
  197. });
  198. },
  199. transportChange: function (row) {
  200. console.log(row);
  201. console.log(`修改传输方式为 ${row.streamMode}:${row.deviceId} `);
  202. let that = this;
  203. this.$axios({
  204. method: 'get',
  205. url: '/api/devices/' + row.deviceId + '/transport/' + row.streamMode
  206. }).then(function(res) {
  207. }).catch(function(e) {
  208. });
  209. }
  210. }
  211. };
  212. </script>
  213. <style>
  214. .videoList {
  215. display: flex;
  216. flex-wrap: wrap;
  217. align-content: flex-start;
  218. }
  219. .video-item {
  220. position: relative;
  221. width: 15rem;
  222. height: 10rem;
  223. margin-right: 1rem;
  224. background-color: #000000;
  225. }
  226. .video-item-img {
  227. position: absolute;
  228. top: 0;
  229. bottom: 0;
  230. left: 0;
  231. right: 0;
  232. margin: auto;
  233. width: 100%;
  234. height: 100%;
  235. }
  236. .video-item-img:after {
  237. content: "";
  238. display: inline-block;
  239. position: absolute;
  240. z-index: 2;
  241. top: 0;
  242. bottom: 0;
  243. left: 0;
  244. right: 0;
  245. margin: auto;
  246. width: 3rem;
  247. height: 3rem;
  248. background-image: url("../assets/loading.png");
  249. background-size: cover;
  250. background-color: #000000;
  251. }
  252. .video-item-title {
  253. position: absolute;
  254. bottom: 0;
  255. color: #000000;
  256. background-color: #ffffff;
  257. line-height: 1.5rem;
  258. padding: 0.3rem;
  259. width: 14.4rem;
  260. }
  261. </style>