DeviceList.vue 13 KB

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