channelList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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" style="margin-right: 1rem;" @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. <el-checkbox size="mini" style="margin-right: 1rem; float: right;" v-model="autoList" @change="autoListChange">自动刷新</el-checkbox>
  25. </div>
  26. <devicePlayer ref="devicePlayer" v-loading="isLoging"></devicePlayer>
  27. <!--设备列表-->
  28. <el-table ref="channelListTable" :data="deviceChannelList" :height="winHeight" border style="width: 100%">
  29. <el-table-column prop="channelId" label="通道编号" width="210">
  30. </el-table-column>
  31. <el-table-column prop="name" label="通道名称">
  32. </el-table-column>
  33. <el-table-column prop="subCount" label="子节点数">
  34. </el-table-column>
  35. <el-table-column label="开启音频" align="center">
  36. <template slot-scope="scope">
  37. <el-switch @change="updateChannel(scope.row)" v-model="scope.row.hasAudio" active-color="#409EFF">
  38. </el-switch>
  39. </template>
  40. </el-table-column>
  41. <el-table-column label="状态" width="180" align="center">
  42. <template slot-scope="scope">
  43. <div slot="reference" class="name-wrapper">
  44. <el-tag size="medium" v-if="scope.row.status == 1">在线</el-tag>
  45. <el-tag size="medium" type="info" v-if="scope.row.status == 0">离线</el-tag>
  46. </div>
  47. </template>
  48. </el-table-column>
  49. <el-table-column prop="ptztypeText" label="云台类型">
  50. </el-table-column>
  51. <el-table-column label="操作" width="280" align="center" fixed="right">
  52. <template slot-scope="scope">
  53. <el-button-group>
  54. <!-- <el-button size="mini" icon="el-icon-video-play" v-if="scope.row.parental == 0" @click="sendDevicePush(scope.row)">播放</el-button> -->
  55. <el-button size="mini" icon="el-icon-video-play" @click="sendDevicePush(scope.row)">播放</el-button>
  56. <el-button size="mini" icon="el-icon-switch-button" type="danger" v-if="!!scope.row.streamId" @click="stopDevicePush(scope.row)">停止</el-button>
  57. <el-button size="mini" icon="el-icon-s-open" type="primary" v-if="scope.row.parental == 1" @click="changeSubchannel(scope.row)">查看</el-button>
  58. <el-button size="mini" icon="el-icon-video-camera" type="primary" @click="queryRecords(scope.row)">设备录象</el-button>
  59. <!-- <el-button size="mini" @click="sendDevicePush(scope.row)">录像查询</el-button> -->
  60. </el-button-group>
  61. </template>
  62. </el-table-column>
  63. </el-table>
  64. <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">
  65. </el-pagination>
  66. </el-main>
  67. </el-container>
  68. </div>
  69. </template>
  70. <script>
  71. import devicePlayer from './gb28181/devicePlayer.vue'
  72. import uiHeader from './UiHeader.vue'
  73. import moment from "moment";
  74. export default {
  75. name: 'channelList',
  76. components: {
  77. devicePlayer,
  78. uiHeader
  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. autoList: false
  98. };
  99. },
  100. mounted() {
  101. this.initData();
  102. if (this.autoList) {
  103. this.updateLooper = setInterval(this.initData, 1500);
  104. }
  105. },
  106. destroyed() {
  107. this.$destroy('videojs');
  108. clearTimeout(this.updateLooper);
  109. },
  110. methods: {
  111. initData: function () {
  112. if (this.parentChannelId == "" || this.parentChannelId == 0) {
  113. this.getDeviceChannelList();
  114. } else {
  115. this.showSubchannels();
  116. }
  117. },
  118. initParam: function () {
  119. this.deviceId = this.$route.params.deviceId;
  120. this.parentChannelId = this.$route.params.parentChannelId;
  121. this.currentPage = parseInt(this.$route.params.page);
  122. this.count = parseInt(this.$route.params.count);
  123. if (this.parentChannelId == "" || this.parentChannelId == 0) {
  124. this.beforeUrl = "/videoList"
  125. }
  126. },
  127. currentChange: function (val) {
  128. var url = `/${this.$router.currentRoute.name}/${this.deviceId}/${this.parentChannelId}/${this.count}/${val}`
  129. console.log(url)
  130. this.$router.push(url).then(() => {
  131. this.initParam();
  132. this.initData();
  133. })
  134. },
  135. handleSizeChange: function (val) {
  136. var url = `/${this.$router.currentRoute.name}/${this.$router.params.deviceId}/${this.$router.params.parentChannelId}/${val}/1`
  137. this.$router.push(url).then(() => {
  138. this.initParam();
  139. this.initData();
  140. })
  141. },
  142. getDeviceChannelList: function () {
  143. let that = this;
  144. console.log(this.currentPage - 1)
  145. this.$axios.get(`/api/devices/${this.$route.params.deviceId}/channels`, {
  146. params: {
  147. page: that.currentPage - 1,
  148. count: that.count,
  149. query: that.searchSrt,
  150. online: that.online,
  151. channelType: that.channelType
  152. }
  153. })
  154. .then(function (res) {
  155. console.log(res);
  156. that.total = res.data.total;
  157. that.deviceChannelList = res.data.list;
  158. // 防止出现表格错位
  159. that.$nextTick(() => {
  160. that.$refs.channelListTable.doLayout();
  161. })
  162. })
  163. .catch(function (error) {
  164. console.log(error);
  165. });
  166. },
  167. //通知设备上传媒体流
  168. sendDevicePush: function (itemData) {
  169. console.log(itemData)
  170. let deviceId = this.deviceId;
  171. this.isLoging = true;
  172. let channelId = itemData.channelId;
  173. console.log("通知设备推流1:" + deviceId + " : " + channelId );
  174. let that = this;
  175. this.$axios({
  176. method: 'get',
  177. url: '/api/play/' + deviceId + '/' + channelId
  178. }).then(function (res) {
  179. console.log(res.data)
  180. let streamId = res.data.streamId;
  181. that.isLoging = false;
  182. if (!!streamId) {
  183. // that.$refs.devicePlayer.play(res.data, deviceId, channelId, itemData.hasAudio);
  184. that.$refs.devicePlayer.openDialog("media", deviceId, channelId, {
  185. streamInfo: res.data,
  186. hasAudio: itemData.hasAudio
  187. });
  188. that.initData();
  189. } else {
  190. that.$message.error(res.data);
  191. }
  192. }).catch(function (e) {});
  193. },
  194. queryRecords: function (itemData) {
  195. var format = moment().format("YYYY-M-D");
  196. let deviceId = this.deviceId;
  197. let channelId = itemData.channelId;
  198. this.$refs.devicePlayer.openDialog("record", deviceId, channelId, {date: format})
  199. },
  200. stopDevicePush: function (itemData) {
  201. console.log(itemData)
  202. var that = this;
  203. this.$axios({
  204. method: 'post',
  205. url: '/api/play/' + itemData.streamId + '/stop'
  206. }).then(function (res) {
  207. console.log(JSON.stringify(res));
  208. that.initData();
  209. }).catch(function (error) {
  210. if (error.response.status == 402) { // 已经停止过
  211. that.initData();
  212. }else {
  213. console.log(e)
  214. }
  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.list;
  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. autoListChange: function () {
  275. if (this.autoList) {
  276. this.updateLooper = setInterval(this.initData, 1500);
  277. }else{
  278. window.clearInterval(this.updateLooper);
  279. }
  280. }
  281. }
  282. };
  283. </script>
  284. <style>
  285. .videoList {
  286. display: flex;
  287. flex-wrap: wrap;
  288. align-content: flex-start;
  289. }
  290. .video-item {
  291. position: relative;
  292. width: 15rem;
  293. height: 10rem;
  294. margin-right: 1rem;
  295. background-color: #000000;
  296. }
  297. .video-item-img {
  298. position: absolute;
  299. top: 0;
  300. bottom: 0;
  301. left: 0;
  302. right: 0;
  303. margin: auto;
  304. width: 100%;
  305. height: 100%;
  306. }
  307. .video-item-img:after {
  308. content: "";
  309. display: inline-block;
  310. position: absolute;
  311. z-index: 2;
  312. top: 0;
  313. bottom: 0;
  314. left: 0;
  315. right: 0;
  316. margin: auto;
  317. width: 3rem;
  318. height: 3rem;
  319. background-image: url("../assets/loading.png");
  320. background-size: cover;
  321. background-color: #000000;
  322. }
  323. .video-item-title {
  324. position: absolute;
  325. bottom: 0;
  326. color: #000000;
  327. background-color: #ffffff;
  328. line-height: 1.5rem;
  329. padding: 0.3rem;
  330. width: 14.4rem;
  331. }
  332. </style>