DeviceList.vue 11 KB

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