channelList.vue 13 KB

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