DeviceList.vue 12 KB

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