DeviceList.vue 11 KB

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