WeatherList.vue 11 KB

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