channelList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <div id="channelList">
  3. <el-container>
  4. <el-header>
  5. <uiHeader></uiHeader>
  6. </el-header>
  7. <el-main>
  8. <div style="background-color: #FFFFFF; position: relative; padding: 1rem 0.5rem 0.5rem 0.5rem; text-align: center;">
  9. <span style="font-size: 1rem; font-weight: 500; ">通道列表({{parentChannelId ==0 ? deviceId:parentChannelId}})</span>
  10. </div>
  11. <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;">
  12. <el-button icon="el-icon-arrow-left" size="mini" style="margin-right: 1rem;" type="primary" @click="showDevice">返回</el-button>
  13. 搜索: <el-input @input="search" style="margin-right: 1rem; width: auto;" size="mini" placeholder="关键字" prefix-icon="el-icon-search" v-model="searchSrt" clearable> </el-input>
  14. 通道类型: <el-select size="mini" @change="search" style="margin-right: 1rem;" v-model="channelType" placeholder="请选择" default-first-option>
  15. <el-option label="全部" value=""></el-option>
  16. <el-option label="设备" value="false"></el-option>
  17. <el-option label="子目录" value="true"></el-option>
  18. </el-select>
  19. 在线状态: <el-select size="mini" @change="search" v-model="online" placeholder="请选择" default-first-option>
  20. <el-option label="全部" value=""></el-option>
  21. <el-option label="在线" value="on"></el-option>
  22. <el-option label="离线" value="off"></el-option>
  23. </el-select>
  24. </div>
  25. <devicePlayer ref="devicePlayer"></devicePlayer>
  26. <!--设备列表-->
  27. <el-table ref="channelListTable" :data="deviceChannelList" :height="winHeight" border style="width: 100%">
  28. <el-table-column prop="channelId" label="通道编号" width="210">
  29. </el-table-column>
  30. <el-table-column prop="name" label="通道名称">
  31. </el-table-column>
  32. <el-table-column prop="subCount" label="子节点数">
  33. </el-table-column>
  34. <el-table-column label="开启音频" align="center">
  35. <template slot-scope="scope">
  36. <el-switch @change="updateChannel(scope.row)" v-model="scope.row.hasAudio" active-color="#409EFF">
  37. </el-switch>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="状态" width="180" align="center">
  41. <template slot-scope="scope">
  42. <div slot="reference" class="name-wrapper">
  43. <el-tag size="medium" v-if="scope.row.status == 1">在线</el-tag>
  44. <el-tag size="medium" type="info" v-if="scope.row.status == 0">离线</el-tag>
  45. </div>
  46. </template>
  47. </el-table-column>
  48. <el-table-column prop="ptztypeText" label="云台类型">
  49. </el-table-column>
  50. <el-table-column label="操作" width="280" align="center" fixed="right">
  51. <template slot-scope="scope">
  52. <el-button-group>
  53. <el-button size="mini" icon="el-icon-video-play" v-if="scope.row.parental == 0" @click="sendDevicePush(scope.row)">播放</el-button>
  54. <el-button size="mini" icon="el-icon-switch-button" type="danger" v-if="scope.row.play" @click="stopDevicePush(scope.row)">停止</el-button>
  55. <el-button size="mini" icon="el-icon-s-open" type="primary" v-if="scope.row.parental == 1" @click="changeSubchannel(scope.row)">查看</el-button>
  56. <!-- <el-button size="mini" icon="el-icon-video-camera" type="primary" >设备录象</el-button>-->
  57. <!-- <el-button size="mini" @click="sendDevicePush(scope.row)">录像查询</el-button> -->
  58. </el-button-group>
  59. </template>
  60. </el-table-column>
  61. </el-table>
  62. <el-pagination style="float: right" @size-change="handleSizeChange" @current-change="currentChange" :current-page="currentPage" :page-size="count" :page-sizes="[15, 20, 30, 50]" layout="total, sizes, prev, pager, next" :total="total">
  63. </el-pagination>
  64. </el-main>
  65. </el-container>
  66. <Loading v-if="isLoging" marginTop="-50%"></Loading>
  67. </div>
  68. </template>
  69. <script>
  70. import devicePlayer from './gb28181/devicePlayer.vue'
  71. import uiHeader from './UiHeader.vue'
  72. import Loading from './Loading.vue'
  73. export default {
  74. name: 'channelList',
  75. components: {
  76. devicePlayer,
  77. uiHeader,
  78. Loading
  79. },
  80. data() {
  81. return {
  82. deviceId: this.$route.params.deviceId,
  83. parentChannelId: this.$route.params.parentChannelId,
  84. deviceChannelList: [],
  85. videoComponentList: [],
  86. currentPlayerInfo: {}, //当前播放对象
  87. updateLooper: 0, //数据刷新轮训标志
  88. searchSrt: "",
  89. channelType: "",
  90. online: "",
  91. winHeight: window.innerHeight - 250,
  92. currentPage: parseInt(this.$route.params.page),
  93. count: parseInt(this.$route.params.count),
  94. total: 0,
  95. beforeUrl: "/videoList",
  96. isLoging: false
  97. };
  98. },
  99. mounted() {
  100. this.initData();
  101. // this.updateLooper = setInterval(this.initData, 10000);
  102. },
  103. destroyed() {
  104. this.$destroy('videojs');
  105. clearTimeout(this.updateLooper);
  106. },
  107. methods: {
  108. initData: function () {
  109. if (this.parentChannelId == "" || this.parentChannelId == 0) {
  110. this.getDeviceChannelList();
  111. } else {
  112. this.showSubchannels();
  113. }
  114. },
  115. initParam: function () {
  116. this.deviceId = this.$route.params.deviceId;
  117. this.parentChannelId = this.$route.params.parentChannelId;
  118. this.currentPage = parseInt(this.$route.params.page);
  119. this.count = parseInt(this.$route.params.count);
  120. if (this.parentChannelId == "" || this.parentChannelId == 0) {
  121. this.beforeUrl = "/videoList"
  122. }
  123. },
  124. currentChange: function (val) {
  125. var url = `/${this.$router.currentRoute.name}/${this.deviceId}/${this.parentChannelId}/${this.count}/${val}`
  126. console.log(url)
  127. this.$router.push(url).then(() => {
  128. this.initParam();
  129. this.initData();
  130. })
  131. },
  132. handleSizeChange: function (val) {
  133. var url = `/${this.$router.currentRoute.name}/${this.$router.params.deviceId}/${this.$router.params.parentChannelId}/${val}/1`
  134. this.$router.push(url).then(() => {
  135. this.initParam();
  136. this.initData();
  137. })
  138. },
  139. getDeviceChannelList: function () {
  140. let that = this;
  141. console.log(this.currentPage - 1)
  142. this.$axios.get(`/api/devices/${this.$route.params.deviceId}/channels`, {
  143. params: {
  144. page: that.currentPage - 1,
  145. count: that.count,
  146. query: that.searchSrt,
  147. online: that.online,
  148. channelType: that.channelType
  149. }
  150. })
  151. .then(function (res) {
  152. console.log(res);
  153. that.total = res.data.total;
  154. that.deviceChannelList = res.data.data;
  155. // 防止出现表格错位
  156. that.$nextTick(() => {
  157. that.$refs.channelListTable.doLayout();
  158. })
  159. })
  160. .catch(function (error) {
  161. console.log(error);
  162. });
  163. },
  164. //gb28181平台对接
  165. //刷新设备信息
  166. refDevice: function (itemData) {
  167. ///api/devices/{deviceId}/sync
  168. console.log("刷新对应设备:" + itemData.deviceId);
  169. this.$axios({
  170. method: 'post',
  171. url: '/api/devices/' + itemData.deviceId + '/sync'
  172. }).then(function (res) {
  173. // console.log("刷新设备结果:"+JSON.stringify(res));
  174. }).catch(function (e) {
  175. that.$message({
  176. showClose: true,
  177. message: '请求成功',
  178. type: 'success'
  179. });
  180. });
  181. },
  182. //通知设备上传媒体流
  183. sendDevicePush: function (itemData) {
  184. console.log(itemData)
  185. let deviceId = this.deviceId;
  186. this.isLoging = true;
  187. let channelId = itemData.channelId;
  188. console.log("通知设备推流1:" + deviceId + " : " + channelId);
  189. let that = this;
  190. this.$axios({
  191. method: 'get',
  192. url: '/api/play/' + deviceId + '/' + channelId
  193. }).then(function (res) {
  194. console.log(res.data)
  195. let ssrc = res.data.ssrc;
  196. that.isLoging = false;
  197. if (!!ssrc) {
  198. that.$refs.devicePlayer.play(res.data, deviceId, channelId, itemData.hasAudio);
  199. that.initData();
  200. } else {
  201. that.$message.error(res.data);
  202. }
  203. }).catch(function (e) {});
  204. },
  205. stopDevicePush: function (itemData) {
  206. console.log(itemData)
  207. var that = this;
  208. this.$axios({
  209. method: 'post',
  210. url: '/api/play/' + itemData.ssrc + '/stop'
  211. }).then(function (res) {
  212. console.log(JSON.stringify(res));
  213. that.initData();
  214. });
  215. },
  216. showDevice: function () {
  217. this.$router.push(this.beforeUrl).then(() => {
  218. this.initParam();
  219. this.initData();
  220. })
  221. },
  222. changeSubchannel(itemData) {
  223. console.log(this.$router.currentRoute)
  224. this.beforeUrl = this.$router.currentRoute.path;
  225. var url = `/${this.$router.currentRoute.name}/${this.$router.currentRoute.params.deviceId}/${itemData.channelId}/${this.$router.currentRoute.params.count}/1`
  226. this.$router.push(url).then(() => {
  227. this.searchSrt = "";
  228. this.channelType = "";
  229. this.online = "";
  230. this.initParam();
  231. this.initData();
  232. })
  233. },
  234. showSubchannels: function (channelId) {
  235. let that = this;
  236. this.$axios.get(`/api/subChannels/${this.deviceId}/${this.parentChannelId}/channels`, {
  237. params: {
  238. page: that.currentPage - 1,
  239. count: that.count,
  240. query: that.searchSrt,
  241. online: that.online,
  242. channelType: that.channelType
  243. }
  244. })
  245. .then(function (res) {
  246. that.total = res.data.total;
  247. that.deviceChannelList = res.data.data;
  248. // 防止出现表格错位
  249. that.$nextTick(() => {
  250. that.$refs.channelListTable.doLayout();
  251. })
  252. })
  253. .catch(function (error) {
  254. console.log(error);
  255. });
  256. },
  257. search: function () {
  258. console.log(this.searchSrt)
  259. this.currentPage = 1;
  260. this.total = 0;
  261. this.initData();
  262. },
  263. updateChannel: function (row) {
  264. console.log(row)
  265. this.$axios({
  266. method: 'post',
  267. url: `/api/channel/update/${this.deviceId}`,
  268. params: row
  269. }).then(function (res) {
  270. console.log(JSON.stringify(res));
  271. });
  272. }
  273. }
  274. };
  275. </script>
  276. <style>
  277. .videoList {
  278. display: flex;
  279. flex-wrap: wrap;
  280. align-content: flex-start;
  281. }
  282. .video-item {
  283. position: relative;
  284. width: 15rem;
  285. height: 10rem;
  286. margin-right: 1rem;
  287. background-color: #000000;
  288. }
  289. .video-item-img {
  290. position: absolute;
  291. top: 0;
  292. bottom: 0;
  293. left: 0;
  294. right: 0;
  295. margin: auto;
  296. width: 100%;
  297. height: 100%;
  298. }
  299. .video-item-img:after {
  300. content: "";
  301. display: inline-block;
  302. position: absolute;
  303. z-index: 2;
  304. top: 0;
  305. bottom: 0;
  306. left: 0;
  307. right: 0;
  308. margin: auto;
  309. width: 3rem;
  310. height: 3rem;
  311. background-image: url("../assets/loading.png");
  312. background-size: cover;
  313. background-color: #000000;
  314. }
  315. .video-item-title {
  316. position: absolute;
  317. bottom: 0;
  318. color: #000000;
  319. background-color: #ffffff;
  320. line-height: 1.5rem;
  321. padding: 0.3rem;
  322. width: 14.4rem;
  323. }
  324. </style>