DeviceList.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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%;font-size: 12px;" :height="winHeight">
  17. <el-table-column prop="name" label="名称" align="center">
  18. </el-table-column>
  19. <el-table-column prop="deviceId" label="设备编号" width="180" align="center">
  20. </el-table-column>
  21. <el-table-column prop="manufacturer" label="厂家" align="center">
  22. </el-table-column>
  23. <el-table-column label="流传输模式" align="center" width="120">
  24. <template slot-scope="scope">
  25. <el-select size="mini" @change="transportChange(scope.row)" v-model="scope.row.streamMode" placeholder="请选择">
  26. <el-option key="UDP" label="UDP" value="UDP"></el-option>
  27. <el-option key="TCP-ACTIVE" label="TCP主动模式" :disabled="true" value="TCP-ACTIVE"></el-option>
  28. <el-option key="TCP-PASSIVE" label="TCP被动模式" value="TCP-PASSIVE"></el-option>
  29. </el-select>
  30. </template>
  31. </el-table-column>
  32. <el-table-column prop="channelCount" label="通道数" align="center">
  33. </el-table-column>
  34. <el-table-column label="状态" width="120" align="center">
  35. <template slot-scope="scope">
  36. <div slot="reference" class="name-wrapper">
  37. <el-tag size="medium" v-if="scope.row.online == 1">在线</el-tag>
  38. <el-tag size="medium" type="info" v-if="scope.row.online == 0">离线</el-tag>
  39. </div>
  40. </template>
  41. </el-table-column>
  42. <el-table-column prop="keepaliveTime" label="最近心跳" align="center" width="140">
  43. </el-table-column>
  44. <el-table-column prop="registerTime" label="最近注册" align="center" width="140">
  45. </el-table-column>
  46. <el-table-column prop="updateTime" label="更新时间" align="center" width="140">
  47. </el-table-column>
  48. <el-table-column prop="createTime" label="创建时间" align="center" width="140">
  49. </el-table-column>
  50. <el-table-column label="地址" width="180" align="center">
  51. <template slot-scope="scope">
  52. <div slot="reference" class="name-wrapper">
  53. <el-tag size="medium">{{ scope.row.hostAddress }}</el-tag>
  54. </div>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="操作" width="360" align="center" fixed="right">
  58. <template slot-scope="scope">
  59. <el-button size="mini" :ref="scope.row.deviceId + 'refbtn' " v-if="scope.row.online!=0" icon="el-icon-refresh" @click="refDevice(scope.row)">刷新</el-button>
  60. <el-button-group>
  61. <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>
  62. <el-button size="mini" icon="el-icon-location" v-bind:disabled="scope.row.online==0" type="primary" @click="showDevicePosition(scope.row)">定位</el-button>
  63. <el-button size="mini" icon="el-icon-delete" type="primary" @click="edit(scope.row)">编辑</el-button>
  64. <el-button size="mini" icon="el-icon-delete" type="danger" v-if="scope.row.online==0" @click="deleteDevice(scope.row)">删除</el-button>
  65. </el-button-group>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <el-pagination
  70. style="float: right"
  71. @size-change="handleSizeChange"
  72. @current-change="currentChange"
  73. :current-page="currentPage"
  74. :page-size="count"
  75. :page-sizes="[15, 25, 35, 50]"
  76. layout="total, sizes, prev, pager, next"
  77. :total="total">
  78. </el-pagination>
  79. <deviceEdit ref="deviceEdit" ></deviceEdit>
  80. </el-main>
  81. </el-container>
  82. </div>
  83. </template>
  84. <script>
  85. import uiHeader from './UiHeader.vue'
  86. import deviceEdit from './dialog/deviceEdit.vue'
  87. export default {
  88. name: 'app',
  89. components: {
  90. uiHeader,
  91. deviceEdit
  92. },
  93. data() {
  94. return {
  95. deviceList: [], //设备列表
  96. currentDevice: {}, //当前操作设备对象
  97. videoComponentList: [],
  98. updateLooper: 0, //数据刷新轮训标志
  99. currentDeviceChannelsLenth:0,
  100. winHeight: window.innerHeight - 200,
  101. currentPage:1,
  102. count:15,
  103. total:0,
  104. getDeviceListLoading: false
  105. };
  106. },
  107. computed: {
  108. getcurrentDeviceChannels: function() {
  109. let data = this.currentDevice['channelMap'];
  110. let channels = null;
  111. if (data) {
  112. channels = Object.keys(data).map(key => {
  113. return data[key];
  114. });
  115. this.currentDeviceChannelsLenth = channels.length;
  116. }
  117. console.log("数据:" + JSON.stringify(channels));
  118. return channels;
  119. }
  120. },
  121. mounted() {
  122. this.initData();
  123. this.updateLooper = setInterval(this.initData, 10000);
  124. },
  125. destroyed() {
  126. this.$destroy('videojs');
  127. clearTimeout(this.updateLooper);
  128. },
  129. methods: {
  130. initData: function() {
  131. this.getDeviceList();
  132. },
  133. currentChange: function(val){
  134. this.currentPage = val;
  135. this.getDeviceList();
  136. },
  137. handleSizeChange: function(val){
  138. this.count = val;
  139. this.getDeviceList();
  140. },
  141. getDeviceList: function() {
  142. let that = this;
  143. this.getDeviceListLoading = true;
  144. this.$axios({
  145. method: 'get',
  146. url:`/api/device/query/devices`,
  147. params: {
  148. page: that.currentPage,
  149. count: that.count
  150. }
  151. }).then(function (res) {
  152. console.log(res);
  153. console.log(res.data.list);
  154. that.total = res.data.total;
  155. that.deviceList = res.data.list;
  156. that.getDeviceListLoading = false;
  157. }).catch(function (error) {
  158. console.log(error);
  159. that.getDeviceListLoading = false;
  160. });
  161. },
  162. deleteDevice: function(row) {
  163. let that = this;
  164. this.$axios({
  165. method: 'delete',
  166. url:`/api/device/query/devices/${row.deviceId}/delete`
  167. }).then((res)=>{
  168. this.getDeviceList();
  169. }).catch((error) =>{
  170. console.log(error);
  171. });
  172. },
  173. showChannelList: function(row) {
  174. console.log(JSON.stringify(row))
  175. this.$router.push(`/channelList/${row.deviceId}/0/15/1`);
  176. },
  177. showDevicePosition: function(row) {
  178. console.log(JSON.stringify(row))
  179. this.$router.push(`/devicePosition/${row.deviceId}/0/15/1`);
  180. },
  181. //gb28181平台对接
  182. //刷新设备信息
  183. refDevice: function(itemData) {
  184. console.log("刷新对应设备:" + itemData.deviceId);
  185. var that = this;
  186. that.$refs[itemData.deviceId + 'refbtn' ].loading = true;
  187. this.$axios({
  188. method: 'post',
  189. url: '/api/device/query/devices/' + itemData.deviceId + '/sync'
  190. }).then(function(res) {
  191. console.log("刷新设备结果:"+JSON.stringify(res));
  192. if (!res.data.deviceId) {
  193. that.$message({
  194. showClose: true,
  195. message: res.data,
  196. type: 'error'
  197. });
  198. }else{
  199. that.$message({
  200. showClose: true,
  201. message: '请求成功',
  202. type: 'success'
  203. });
  204. }
  205. that.initData()
  206. that.$refs[itemData.deviceId + 'refbtn' ].loading = false;
  207. }).catch(function(e) {
  208. console.error(e)
  209. that.$refs[itemData.deviceId + 'refbtn' ].loading = false;
  210. });;
  211. },
  212. //通知设备上传媒体流
  213. sendDevicePush: function(itemData) {
  214. // let deviceId = this.currentDevice.deviceId;
  215. // let channelId = itemData.channelId;
  216. // console.log("通知设备推流1:" + deviceId + " : " + channelId);
  217. // let that = this;
  218. // this.$axios({
  219. // method: 'get',
  220. // url: '/api/play/' + deviceId + '/' + channelId
  221. // }).then(function(res) {
  222. // let ssrc = res.data.ssrc;
  223. // that.$refs.devicePlayer.play(ssrc,deviceId,channelId);
  224. // }).catch(function(e) {
  225. // });
  226. },
  227. transportChange: function (row) {
  228. console.log(row);
  229. console.log(`修改传输方式为 ${row.streamMode}:${row.deviceId} `);
  230. let that = this;
  231. this.$axios({
  232. method: 'post',
  233. url: '/api/device/query/transport/' + row.deviceId + '/' + row.streamMode
  234. }).then(function(res) {
  235. }).catch(function(e) {
  236. });
  237. },
  238. edit: function (row) {
  239. console.log(row);
  240. this.$refs.deviceEdit.openDialog(row, ()=>{
  241. this.$refs.deviceEdit.close();
  242. this.$message({
  243. showClose: true,
  244. message: "设备修改成功,通道字符集将在下次更新生效",
  245. type: "success",
  246. });
  247. setTimeout(this.getDeviceList, 200)
  248. })
  249. }
  250. }
  251. };
  252. </script>
  253. <style>
  254. .videoList {
  255. display: flex;
  256. flex-wrap: wrap;
  257. align-content: flex-start;
  258. }
  259. .video-item {
  260. position: relative;
  261. width: 15rem;
  262. height: 10rem;
  263. margin-right: 1rem;
  264. background-color: #000000;
  265. }
  266. .video-item-img {
  267. position: absolute;
  268. top: 0;
  269. bottom: 0;
  270. left: 0;
  271. right: 0;
  272. margin: auto;
  273. width: 100%;
  274. height: 100%;
  275. }
  276. .video-item-img:after {
  277. content: "";
  278. display: inline-block;
  279. position: absolute;
  280. z-index: 2;
  281. top: 0;
  282. bottom: 0;
  283. left: 0;
  284. right: 0;
  285. margin: auto;
  286. width: 3rem;
  287. height: 3rem;
  288. background-image: url("../assets/loading.png");
  289. background-size: cover;
  290. background-color: #000000;
  291. }
  292. .video-item-title {
  293. position: absolute;
  294. bottom: 0;
  295. color: #000000;
  296. background-color: #ffffff;
  297. line-height: 1.5rem;
  298. padding: 0.3rem;
  299. width: 14.4rem;
  300. }
  301. </style>