DeviceList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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 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 label="流传输模式" align="center" width="120">
  31. <template slot-scope="scope">
  32. <el-select size="mini" @change="transportChange(scope.row)" v-model="scope.row.streamMode" placeholder="请选择">
  33. <el-option key="UDP" label="UDP" value="UDP"></el-option>
  34. <el-option key="TCP-ACTIVE" label="TCP主动模式" :disabled="true" value="TCP-ACTIVE"></el-option>
  35. <el-option key="TCP-PASSIVE" label="TCP被动模式" value="TCP-PASSIVE"></el-option>
  36. </el-select>
  37. </template>
  38. </el-table-column>
  39. <el-table-column prop="channelCount" label="通道数" align="center">
  40. </el-table-column>
  41. <el-table-column label="状态" width="120" align="center">
  42. <template slot-scope="scope">
  43. <div slot="reference" class="name-wrapper">
  44. <el-tag size="medium" v-if="scope.row.online == 1">在线</el-tag>
  45. <el-tag size="medium" type="info" v-if="scope.row.online == 0">离线</el-tag>
  46. </div>
  47. </template>
  48. </el-table-column>
  49. <el-table-column prop="keepaliveTime" label="最近心跳" align="center" width="140">
  50. </el-table-column>
  51. <el-table-column prop="registerTime" label="最近注册" align="center" width="140">
  52. </el-table-column>
  53. <el-table-column prop="updateTime" label="更新时间" align="center" width="140">
  54. </el-table-column>
  55. <el-table-column prop="createTime" label="创建时间" align="center" width="140">
  56. </el-table-column>
  57. <el-table-column label="操作" width="450" align="center" fixed="right">
  58. <template slot-scope="scope">
  59. <el-button size="mini" :loading="scope.row.loading" 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-edit" type="primary" @click="edit(scope.row)">编辑</el-button>
  64. <el-button size="mini" icon="el-icon-delete" type="danger" @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 msg = "确定删除此设备?"
  164. if (row.online !== 0) {
  165. msg = "在线设备删除后仍可通过注册再次上线。<br/>如需彻底删除请先将设备离线。<br/><strong>确定删除此设备?</strong>"
  166. }
  167. this.$confirm(msg, '提示', {
  168. dangerouslyUseHTMLString : true,
  169. confirmButtonText: '确定',
  170. cancelButtonText: '取消',
  171. center: true,
  172. type: 'warning'
  173. }).then(() => {
  174. this.$axios({
  175. method: 'delete',
  176. url:`/api/device/query/devices/${row.deviceId}/delete`
  177. }).then((res)=>{
  178. this.getDeviceList();
  179. }).catch((error) =>{
  180. console.log(error);
  181. });
  182. }).catch(() => {
  183. });
  184. },
  185. showChannelList: function(row) {
  186. console.log(JSON.stringify(row))
  187. this.$router.push(`/channelList/${row.deviceId}/0/15/1`);
  188. },
  189. showDevicePosition: function(row) {
  190. console.log(JSON.stringify(row))
  191. this.$router.push(`/devicePosition/${row.deviceId}/0/15/1`);
  192. },
  193. //gb28181平台对接
  194. //刷新设备信息
  195. refDevice: function(itemData) {
  196. console.log("刷新对应设备:" + itemData.deviceId);
  197. var that = this;
  198. that.$set(itemData,"loading", true);
  199. this.$axios({
  200. method: 'post',
  201. url: '/api/device/query/devices/' + itemData.deviceId + '/sync'
  202. }).then(function(res) {
  203. console.log("刷新设备结果:"+JSON.stringify(res));
  204. if (res.data.code !==0) {
  205. that.$message({
  206. showClose: true,
  207. message: res.data.msg,
  208. type: 'error'
  209. });
  210. }else{
  211. that.$message({
  212. showClose: true,
  213. message: res.data.msg,
  214. type: 'success'
  215. });
  216. }
  217. that.initData()
  218. that.$set(itemData,"loading", true);
  219. }).catch(function(e) {
  220. console.error(e)
  221. that.$message({
  222. showClose: true,
  223. message: e,
  224. type: 'error'
  225. });
  226. that.$set(itemData,"loading", true);
  227. });
  228. },
  229. //通知设备上传媒体流
  230. sendDevicePush: function(itemData) {
  231. // let deviceId = this.currentDevice.deviceId;
  232. // let channelId = itemData.channelId;
  233. // console.log("通知设备推流1:" + deviceId + " : " + channelId);
  234. // let that = this;
  235. // this.$axios({
  236. // method: 'get',
  237. // url: '/api/play/' + deviceId + '/' + channelId
  238. // }).then(function(res) {
  239. // let ssrc = res.data.ssrc;
  240. // that.$refs.devicePlayer.play(ssrc,deviceId,channelId);
  241. // }).catch(function(e) {
  242. // });
  243. },
  244. transportChange: function (row) {
  245. console.log(row);
  246. console.log(`修改传输方式为 ${row.streamMode}:${row.deviceId} `);
  247. let that = this;
  248. this.$axios({
  249. method: 'post',
  250. url: '/api/device/query/transport/' + row.deviceId + '/' + row.streamMode
  251. }).then(function(res) {
  252. }).catch(function(e) {
  253. });
  254. },
  255. edit: function (row) {
  256. console.log(row);
  257. this.$refs.deviceEdit.openDialog(row, ()=>{
  258. this.$refs.deviceEdit.close();
  259. this.$message({
  260. showClose: true,
  261. message: "设备修改成功,通道字符集将在下次更新生效",
  262. type: "success",
  263. });
  264. setTimeout(this.getDeviceList, 200)
  265. })
  266. }
  267. }
  268. };
  269. </script>
  270. <style>
  271. .videoList {
  272. display: flex;
  273. flex-wrap: wrap;
  274. align-content: flex-start;
  275. }
  276. .video-item {
  277. position: relative;
  278. width: 15rem;
  279. height: 10rem;
  280. margin-right: 1rem;
  281. background-color: #000000;
  282. }
  283. .video-item-img {
  284. position: absolute;
  285. top: 0;
  286. bottom: 0;
  287. left: 0;
  288. right: 0;
  289. margin: auto;
  290. width: 100%;
  291. height: 100%;
  292. }
  293. .video-item-img:after {
  294. content: "";
  295. display: inline-block;
  296. position: absolute;
  297. z-index: 2;
  298. top: 0;
  299. bottom: 0;
  300. left: 0;
  301. right: 0;
  302. margin: auto;
  303. width: 3rem;
  304. height: 3rem;
  305. background-image: url("../assets/loading.png");
  306. background-size: cover;
  307. background-color: #000000;
  308. }
  309. .video-item-title {
  310. position: absolute;
  311. bottom: 0;
  312. color: #000000;
  313. background-color: #ffffff;
  314. line-height: 1.5rem;
  315. padding: 0.3rem;
  316. width: 14.4rem;
  317. }
  318. </style>