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