CloudRecord.vue 9.1 KB

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