channelList.vue 9.3 KB

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