DeviceList.vue 11 KB

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