CloudRecord.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <div id="app" style="width: 100%">
  3. <div class="page-header">
  4. <div class="page-title">
  5. <el-page-header v-if="recordDetail" @back="backToList" content="云端录像"></el-page-header>
  6. <div v-if="!recordDetail">云端录像</div>
  7. </div>
  8. <div class="page-header-btn">
  9. 搜索:
  10. <el-input @input="search" style="margin-right: 1rem; width: auto;" size="mini" placeholder="关键字"
  11. prefix-icon="el-icon-search" v-model="search" clearable></el-input>
  12. 开始时间:
  13. <el-date-picker
  14. v-model="startTime"
  15. type="datetime"
  16. placeholder="选择日期时间">
  17. </el-date-picker>
  18. 结束时间:
  19. <el-date-picker
  20. v-model="endTime"
  21. type="datetime"
  22. placeholder="选择日期时间">
  23. </el-date-picker>
  24. 节点选择:
  25. <el-select size="mini" @change="chooseMediaChange" style="width: 16rem; margin-right: 1rem;"
  26. v-model="mediaServerId" placeholder="请选择" :disabled="recordDetail">
  27. <el-option
  28. v-for="item in mediaServerList"
  29. :key="item.id"
  30. :label="item.id"
  31. :value="item.id">
  32. </el-option>
  33. </el-select>
  34. <el-button size="mini" icon="el-icon-delete" type="danger" @click="deleteRecord()">批量删除</el-button>
  35. <el-button v-if="!recordDetail" icon="el-icon-refresh-right" circle size="mini" :loading="loading"
  36. @click="getRecordList()"></el-button>
  37. </div>
  38. </div>
  39. <div v-if="!recordDetail">
  40. <!--设备列表-->
  41. <el-table :data="recordList" style="width: 100%" :height="winHeight">
  42. <el-table-column prop="app" label="应用名">
  43. </el-table-column>
  44. <el-table-column prop="stream" label="流ID" width="380">
  45. </el-table-column>
  46. <el-table-column label="开始时间">
  47. <template slot-scope="scope">
  48. {{formatTimeStamp(scope.row.startTime)}}
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="结束时间">
  52. <template slot-scope="scope">
  53. {{formatTimeStamp(scope.row.endTime)}}
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="时长">
  57. <template slot-scope="scope">
  58. <el-tag>{{formatTime(scope.row.timeLen)}}</el-tag>
  59. </template>
  60. </el-table-column>
  61. <el-table-column prop="fileName" label="文件名称">
  62. </el-table-column>
  63. <el-table-column prop="mediaServerId" label="流媒体">
  64. </el-table-column>
  65. <el-table-column label="操作" width="200" fixed="right">
  66. <template slot-scope="scope">
  67. <el-button size="medium" icon="el-icon-video-play" type="text" @click="showRecordDetail(scope.row)">播放
  68. </el-button>
  69. <el-button size="medium" icon="el-icon-delete" type="text" style="color: #f56c6c"
  70. @click="deleteRecord(scope.row)">删除
  71. </el-button>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. <el-pagination
  76. style="float: right"
  77. @size-change="handleSizeChange"
  78. @current-change="currentChange"
  79. :current-page="currentPage"
  80. :page-size="count"
  81. :page-sizes="[15, 25, 35, 50]"
  82. layout="total, sizes, prev, pager, next"
  83. :total="total">
  84. </el-pagination>
  85. </div>
  86. </div>
  87. </template>
  88. <script>
  89. import uiHeader from '../layout/UiHeader.vue'
  90. import MediaServer from './service/MediaServer'
  91. import moment from 'moment'
  92. export default {
  93. name: 'app',
  94. components: {
  95. uiHeader
  96. },
  97. data() {
  98. return {
  99. search: '',
  100. startTime: '',
  101. endTime: '',
  102. mediaServerList: [], // 滅体节点列表
  103. mediaServerId: null, // 媒体服务
  104. mediaServerPath: null, // 媒体服务地址
  105. recordList: [], // 设备列表
  106. chooseRecord: null, // 媒体服务
  107. updateLooper: 0, //数据刷新轮训标志
  108. winHeight: window.innerHeight - 250,
  109. currentPage: 1,
  110. count: 15,
  111. total: 0,
  112. loading: false,
  113. mediaServerObj: new MediaServer(),
  114. recordDetail: false
  115. };
  116. },
  117. computed: {},
  118. mounted() {
  119. this.initData();
  120. },
  121. destroyed() {
  122. // this.$destroy('videojs');
  123. },
  124. methods: {
  125. initData: function () {
  126. // 获取媒体节点列表
  127. this.getMediaServerList();
  128. // this.getRecordList();
  129. },
  130. currentChange: function (val) {
  131. this.currentPage = val;
  132. this.getRecordList();
  133. },
  134. handleSizeChange: function (val) {
  135. this.count = val;
  136. this.getRecordList();
  137. },
  138. getMediaServerList: function () {
  139. let that = this;
  140. that.mediaServerObj.getOnlineMediaServerList((data) => {
  141. that.mediaServerList = data.data;
  142. if (that.mediaServerList.length > 0) {
  143. that.mediaServerId = that.mediaServerList[0].id
  144. that.setMediaServerPath(that.mediaServerId);
  145. that.getRecordList();
  146. }
  147. })
  148. },
  149. setMediaServerPath: function (serverId) {
  150. let that = this;
  151. let i;
  152. for (i = 0; i < that.mediaServerList.length; i++) {
  153. if (serverId === that.mediaServerList[i].id) {
  154. break;
  155. }
  156. }
  157. let port = that.mediaServerList[i].httpPort;
  158. if (location.protocol === "https:" && that.mediaServerList[i].httpSSlPort) {
  159. port = that.mediaServerList[i].httpSSlPort
  160. }
  161. that.mediaServerPath = location.protocol + "//" + that.mediaServerList[i].streamIp + ":" + port
  162. console.log(that.mediaServerPath)
  163. },
  164. getRecordList: function () {
  165. this.$axios({
  166. method: 'get',
  167. url: `/api/cloud/record/list`,
  168. params: {
  169. app: '',
  170. stream: '',
  171. query: this.search,
  172. startTime: this.startTime,
  173. endTime: this.endTime,
  174. mediaServerId: this.mediaServerId,
  175. page: this.currentPage,
  176. count: this.count
  177. }
  178. }).then((res) => {
  179. console.log(res)
  180. if (res.data.code === 0) {
  181. this.total = res.data.data.total;
  182. this.recordList = res.data.data.list;
  183. }
  184. this.loading = false;
  185. }).catch((error) => {
  186. console.log(error);
  187. this.loading = false;
  188. });
  189. },
  190. backToList() {
  191. this.recordDetail = false;
  192. },
  193. chooseMediaChange(val) {
  194. console.log(val)
  195. this.total = 0;
  196. this.recordList = [];
  197. this.setMediaServerPath(val);
  198. this.getRecordList();
  199. },
  200. showRecordDetail(row) {
  201. this.recordDetail = true;
  202. this.chooseRecord = row;
  203. // 查询是否存在录像
  204. // this.$axios({
  205. // method: 'delete',
  206. // url:`/record_proxy/api/record/delete`,
  207. // params: {
  208. // page: this.currentPage,
  209. // count: this.count
  210. // }
  211. // }).then((res) => {
  212. // console.log(res)
  213. // this.total = res.data.data.total;
  214. // this.recordList = res.data.data.list;
  215. // }).catch(function (error) {
  216. // console.log(error);
  217. // });
  218. this.$router.push(`/cloudRecordDetail/${row.app}/${row.stream}`)
  219. },
  220. deleteRecord() {
  221. // TODO
  222. let that = this;
  223. this.$axios({
  224. method: 'delete',
  225. url: `/record_proxy/api/record/delete`,
  226. params: {
  227. page: that.currentPage,
  228. count: that.count
  229. }
  230. }).then(function (res) {
  231. console.log(res)
  232. if (res.data.code === 0) {
  233. that.total = res.data.data.total;
  234. that.recordList = res.data.data.list;
  235. }
  236. }).catch(function (error) {
  237. console.log(error);
  238. });
  239. },
  240. formatTime(time) {
  241. const h = parseInt(time / 3600)
  242. const minute = parseInt(time / 60 % 60)
  243. const second = Math.ceil(time % 60)
  244. return (h > 0 ? h + `小时` : '') + (minute > 0 ? minute + '分' : '') + second + '秒'
  245. },
  246. formatTimeStamp(time) {
  247. return moment.unix(time).format('yyyy-MM-DD HH:mm:ss')
  248. }
  249. }
  250. };
  251. </script>
  252. <style>
  253. </style>