channelList.vue 13 KB

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