videoList.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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="80" 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="360" 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-group>
  55. <el-button size="mini" icon="el-icon-video-camera-solid" v-bind:disabled="scope.row.online==0" type="primary" @click="showChannelList(scope.row)">通道</el-button>
  56. <el-button size="mini" icon="el-icon-location" v-bind:disabled="scope.row.online==0" type="primary" @click="showDevicePosition(scope.row)">定位</el-button>
  57. <el-button size="mini" icon="el-icon-s-tools" v-bind:disabled="scope.row.online==0" type="primary">控制</el-button>
  58. </el-button-group>
  59. </template>
  60. </el-table-column>
  61. </el-table>
  62. <el-pagination
  63. style="float: right"
  64. @size-change="handleSizeChange"
  65. @current-change="currentChange"
  66. :current-page="currentPage"
  67. :page-size="count"
  68. :page-sizes="[15, 25, 35, 50]"
  69. layout="total, sizes, prev, pager, next"
  70. :total="total">
  71. </el-pagination>
  72. </el-main>
  73. </el-container>
  74. </div>
  75. </template>
  76. <script>
  77. import uiHeader from './UiHeader.vue'
  78. export default {
  79. name: 'app',
  80. components: {
  81. uiHeader
  82. },
  83. data() {
  84. return {
  85. deviceList: [], //设备列表
  86. currentDevice: {}, //当前操作设备对象
  87. videoComponentList: [],
  88. updateLooper: 0, //数据刷新轮训标志
  89. currentDeviceChannelsLenth:0,
  90. winHeight: window.innerHeight - 200,
  91. currentPage:1,
  92. count:15,
  93. total:0,
  94. getDeviceListLoading: false
  95. };
  96. },
  97. computed: {
  98. getcurrentDeviceChannels: function() {
  99. let data = this.currentDevice['channelMap'];
  100. let channels = null;
  101. if (data) {
  102. channels = Object.keys(data).map(key => {
  103. return data[key];
  104. });
  105. this.currentDeviceChannelsLenth = channels.length;
  106. }
  107. console.log("数据:" + JSON.stringify(channels));
  108. return channels;
  109. }
  110. },
  111. mounted() {
  112. this.initData();
  113. this.updateLooper = setInterval(this.initData, 10000);
  114. },
  115. destroyed() {
  116. this.$destroy('videojs');
  117. clearTimeout(this.updateLooper);
  118. },
  119. methods: {
  120. initData: function() {
  121. this.getDeviceList();
  122. },
  123. currentChange: function(val){
  124. this.currentPage = val;
  125. this.getDeviceList();
  126. },
  127. handleSizeChange: function(val){
  128. this.count = val;
  129. this.getDeviceList();
  130. },
  131. getDeviceList: function() {
  132. let that = this;
  133. this.getDeviceListLoading = true;
  134. this.$axios.get(`/api/devices`,{
  135. params: {
  136. page: that.currentPage,
  137. count: that.count
  138. }
  139. } )
  140. .then(function (res) {
  141. console.log(res);
  142. console.log(res.data.list);
  143. that.total = res.data.total;
  144. that.deviceList = res.data.list;
  145. that.getDeviceListLoading = false;
  146. })
  147. .catch(function (error) {
  148. console.log(error);
  149. that.getDeviceListLoading = false;
  150. });
  151. },
  152. showChannelList: function(row) {
  153. console.log(JSON.stringify(row))
  154. this.$router.push(`/channelList/${row.deviceId}/0/15/1`);
  155. },
  156. showDevicePosition: function(row) {
  157. console.log(JSON.stringify(row))
  158. this.$router.push(`/devicePosition/${row.deviceId}/0/15/1`);
  159. },
  160. //gb28181平台对接
  161. //刷新设备信息
  162. refDevice: function(itemData) {
  163. ///api/devices/{deviceId}/sync
  164. console.log("刷新对应设备:" + itemData.deviceId);
  165. var that = this;
  166. that.$refs[itemData.deviceId + 'refbtn' ].loading = true;
  167. this.$axios({
  168. method: 'post',
  169. url: '/api/devices/' + itemData.deviceId + '/sync'
  170. }).then(function(res) {
  171. console.log("刷新设备结果:"+JSON.stringify(res));
  172. if (!res.data.deviceId) {
  173. that.$message({
  174. showClose: true,
  175. message: res.data,
  176. type: 'error'
  177. });
  178. }else{
  179. that.$message({
  180. showClose: true,
  181. message: '请求成功',
  182. type: 'success'
  183. });
  184. }
  185. that.initData()
  186. that.$refs[itemData.deviceId + 'refbtn' ].loading = false;
  187. }).catch(function(e) {
  188. console.error(e)
  189. that.$refs[itemData.deviceId + 'refbtn' ].loading = false;
  190. });;
  191. },
  192. //通知设备上传媒体流
  193. sendDevicePush: function(itemData) {
  194. // let deviceId = this.currentDevice.deviceId;
  195. // let channelId = itemData.channelId;
  196. // console.log("通知设备推流1:" + deviceId + " : " + channelId);
  197. // let that = this;
  198. // this.$axios({
  199. // method: 'get',
  200. // url: '/api/play/' + deviceId + '/' + channelId
  201. // }).then(function(res) {
  202. // let ssrc = res.data.ssrc;
  203. // that.$refs.devicePlayer.play(ssrc,deviceId,channelId);
  204. // }).catch(function(e) {
  205. // });
  206. },
  207. transportChange: function (row) {
  208. console.log(row);
  209. console.log(`修改传输方式为 ${row.streamMode}:${row.deviceId} `);
  210. let that = this;
  211. this.$axios({
  212. method: 'get',
  213. url: '/api/devices/' + row.deviceId + '/transport/' + row.streamMode
  214. }).then(function(res) {
  215. }).catch(function(e) {
  216. });
  217. }
  218. }
  219. };
  220. </script>
  221. <style>
  222. .videoList {
  223. display: flex;
  224. flex-wrap: wrap;
  225. align-content: flex-start;
  226. }
  227. .video-item {
  228. position: relative;
  229. width: 15rem;
  230. height: 10rem;
  231. margin-right: 1rem;
  232. background-color: #000000;
  233. }
  234. .video-item-img {
  235. position: absolute;
  236. top: 0;
  237. bottom: 0;
  238. left: 0;
  239. right: 0;
  240. margin: auto;
  241. width: 100%;
  242. height: 100%;
  243. }
  244. .video-item-img:after {
  245. content: "";
  246. display: inline-block;
  247. position: absolute;
  248. z-index: 2;
  249. top: 0;
  250. bottom: 0;
  251. left: 0;
  252. right: 0;
  253. margin: auto;
  254. width: 3rem;
  255. height: 3rem;
  256. background-image: url("../assets/loading.png");
  257. background-size: cover;
  258. background-color: #000000;
  259. }
  260. .video-item-title {
  261. position: absolute;
  262. bottom: 0;
  263. color: #000000;
  264. background-color: #ffffff;
  265. line-height: 1.5rem;
  266. padding: 0.3rem;
  267. width: 14.4rem;
  268. }
  269. </style>