CloudRecordDetail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. <template>
  2. <div id="recordDetail">
  3. <el-container>
  4. <el-aside width="300px">
  5. <div class="record-list-box-box">
  6. <el-date-picker size="mini" v-model="chooseDate" :picker-options="pickerOptions" type="date" value-format="yyyy-MM-dd" placeholder="日期" @change="dateChange()"></el-date-picker>
  7. <div class="record-list-box" :style="recordListStyle">
  8. <ul v-if="detailFiles.length >0" class="infinite-list record-list" v-infinite-scroll="infiniteScroll" >
  9. <li v-for="item in detailFiles" class="infinite-list-item record-list-item" >
  10. <el-tag v-if="choosedFile != item" @click="chooseFile(item)">
  11. <i class="el-icon-video-camera" ></i>
  12. {{ item.substring(0,17)}}
  13. </el-tag>
  14. <el-tag type="danger" v-if="choosedFile == item">
  15. <i class="el-icon-video-camera" ></i>
  16. {{ item.substring(0,17)}}
  17. </el-tag>
  18. <!-- <a class="el-icon-download" style="color: #409EFF;font-weight: 600;margin-left: 10px;" :href="`${basePath}/${mediaServerId}/record/${recordFile.app}/${recordFile.stream}/${chooseDate}/${item}`" download />-->
  19. <a class="el-icon-download" style="color: #409EFF;font-weight: 600;margin-left: 10px;" :href="`${basePath}/download.html?url=record/${recordFile.app}/${recordFile.stream}/${chooseDate}/${item}`" target="_blank" />
  20. </li>
  21. </ul>
  22. </div>
  23. <div v-if="detailFiles.length ==0" class="record-list-no-val" >暂无数据</div>
  24. </div>
  25. <div class="record-list-option">
  26. <el-button size="mini" type="primary" icon="fa fa-cloud-download" style="margin: auto; " title="裁剪合并" @click="drawerOpen"></el-button>
  27. </div>
  28. </el-aside>
  29. <el-main style="padding: 22px">
  30. <div class="playBox" :style="playerStyle">
  31. <player ref="recordVideoPlayer" :videoUrl="videoUrl" fluent autoplay :height="true" ></player>
  32. </div>
  33. <div class="player-option-box" >
  34. <el-slider
  35. class="playtime-slider"
  36. v-model="playTime"
  37. id="playtimeSlider"
  38. :disabled="detailFiles.length === 0"
  39. :min="sliderMIn"
  40. :max="sliderMax"
  41. :format-tooltip="playTimeFormat"
  42. @change="playTimeChange"
  43. :marks="playTimeSliderMarks">
  44. </el-slider>
  45. <div class="slider-val-box">
  46. <div class="slider-val" v-for="item of detailFiles" :style="'width:' + getDataWidth(item) + '%; left:' + getDataLeft(item) + '%'"></div>
  47. </div>
  48. </div>
  49. </el-main>
  50. </el-container>
  51. <el-drawer
  52. title="录像下载"
  53. :visible.sync="drawer"
  54. :direction="direction"
  55. :before-close="drawerClose">
  56. <div class="drawer-box">
  57. <el-button icon="el-icon-plus" size="mini" type="primary" @click="addTask"></el-button>
  58. <el-tabs type="border-card" style="height: 100%" v-model="tabVal" @tab-click="tabClick">
  59. <el-tab-pane name="running">
  60. <span slot="label"><i class="el-icon-scissors"></i>进行中</span>
  61. <ul class="task-list">
  62. <li class="task-list-item" v-for="item in taskListForRuning">
  63. <div class="task-list-item-box">
  64. <span>{{ item.startTime.substr(10) }}-{{item.endTime.substr(10)}}</span>
  65. <el-progress :percentage="(parseFloat(item.percentage)*100).toFixed(1)"></el-progress>
  66. </div>
  67. </li>
  68. </ul>
  69. </el-tab-pane>
  70. <el-tab-pane name="ended">
  71. <span slot="label"><i class="el-icon-finished"></i>已完成</span>
  72. <ul class="task-list">
  73. <li class="task-list-item" v-for="item in taskListEnded">
  74. <div class="task-list-item-box" style="height: 2rem;line-height: 2rem;">
  75. <span>{{ item.startTime.substr(10) }}-{{item.endTime.substr(10)}}</span>
  76. <a class="el-icon-download download-btn" :href="basePath + '/download.html?url=../' + item.recordFile" target="_blank">
  77. </a>
  78. </div>
  79. </li>
  80. </ul>
  81. </el-tab-pane>
  82. </el-tabs>
  83. </div>
  84. </el-drawer>
  85. <el-dialog title="选择时间段" :visible.sync="showTaskBox">
  86. <el-date-picker
  87. type="datetimerange"
  88. v-model="taskTimeRange"
  89. range-separator="至"
  90. start-placeholder="开始时间"
  91. end-placeholder="结束时间"
  92. format="HH:mm:ss"
  93. placeholder="选择时间范围">
  94. </el-date-picker>
  95. <el-button size="mini" type="primary" @click="addTaskToServer">确认</el-button>
  96. </el-dialog>
  97. </div>
  98. </template>
  99. <script>
  100. // TODO 根据查询的时间列表设置滑轨的最大值与最小值,
  101. import uiHeader from './UiHeader.vue'
  102. import player from './dialog/easyPlayer.vue'
  103. import moment from 'moment'
  104. export default {
  105. name: 'app',
  106. components: {
  107. uiHeader, player
  108. },
  109. props: ['recordFile', 'mediaServerId', 'dateFiles', 'mediaServerPath'],
  110. data() {
  111. return {
  112. basePath: `${this.mediaServerPath}`,
  113. dateFilesObj: [],
  114. detailFiles: [],
  115. chooseDate: null,
  116. videoUrl: null,
  117. choosedFile: null,
  118. queryDate: new Date(),
  119. currentPage: 1,
  120. count: 1000000, // TODO 分页导致滑轨视频有效值无法获取完全
  121. total: 0,
  122. direction: "ltr",
  123. drawer: false,
  124. showTaskBox: false,
  125. taskTimeRange: [],
  126. taskListEnded: [],
  127. taskListForRuning: [],
  128. sliderMIn: 0,
  129. sliderMax: 86400,
  130. autoPlay: true,
  131. taskUpdate: null,
  132. tabVal: "running",
  133. recordListStyle: {
  134. height: this.winHeight + "px",
  135. overflow: "auto",
  136. margin: "10px auto 10px auto"
  137. },
  138. playerStyle: {
  139. "margin": "auto",
  140. "margin-bottom": "20px",
  141. "height": this.winHeight + "px",
  142. },
  143. winHeight: window.innerHeight - 240,
  144. playTime: 0,
  145. playTimeSliderMarks: {
  146. 0: "00:00",
  147. 3600: "01:00",
  148. 7200: "02:00",
  149. 10800: "03:00",
  150. 14400: "04:00",
  151. 18000: "05:00",
  152. 21600: "06:00",
  153. 25200: "07:00",
  154. 28800: "08:00",
  155. 32400: "09:00",
  156. 36000: "10:00",
  157. 39600: "11:00",
  158. 43200: "12:00",
  159. 46800: "13:00",
  160. 50400: "14:00",
  161. 54000: "15:00",
  162. 57600: "16:00",
  163. 61200: "17:00",
  164. 64800: "18:00",
  165. 68400: "19:00",
  166. 72000: "20:00",
  167. 75600: "21:00",
  168. 79200: "22:00",
  169. 82800: "23:00",
  170. 86400: "24:00",
  171. },
  172. pickerOptions:{
  173. cellClassName:(date) =>{
  174. // 通过显示一个点标识这一天有录像
  175. let time = moment(date).format('YYYY-MM-DD')
  176. if (this.dateFilesObj[time]){
  177. return "data-picker-true"
  178. }else {
  179. return "data-picker-false"
  180. }
  181. }
  182. }
  183. };
  184. },
  185. computed: {
  186. },
  187. mounted() {
  188. this.recordListStyle.height = this.winHeight + "px";
  189. this.playerStyle["height"] = this.winHeight + "px";
  190. // 查询当年有视频的日期
  191. this.getDateInYear(()=>{
  192. if (Object.values(this.dateFilesObj).length > 0){
  193. this.chooseDate = Object.values(this.dateFilesObj)[Object.values(this.dateFilesObj).length -1];
  194. this.dateChange();
  195. }
  196. })
  197. },
  198. destroyed() {
  199. this.$destroy('recordVideoPlayer');
  200. },
  201. methods: {
  202. dateChange(){
  203. this.playTime = 0;
  204. this.detailFiles = [];
  205. this.currentPage = 1;
  206. this.sliderMIn= 0;
  207. this.sliderMax= 86400;
  208. let chooseFullDate = new Date(this.chooseDate + " " + "00:00:00");
  209. if (chooseFullDate.getFullYear() !== this.queryDate.getFullYear()
  210. || chooseFullDate.getMonth() !== this.queryDate.getMonth()){
  211. // this.getDateInYear()
  212. }
  213. this.queryRecordDetails(()=>{
  214. if (this.detailFiles.length > 0){
  215. let timeForFile = this.getTimeForFile(this.detailFiles[0]);
  216. let lastTimeForFile = this.getTimeForFile(this.detailFiles[this.detailFiles.length - 1]);
  217. let timeNum = timeForFile[0].getTime() - new Date(this.chooseDate + " " + "00:00:00").getTime()
  218. let lastTimeNum = lastTimeForFile[1].getTime() - new Date(this.chooseDate + " " + "00:00:00").getTime()
  219. this.playTime = parseInt(timeNum/1000)
  220. this.sliderMIn = parseInt(timeNum/1000 - timeNum/1000%(60*60))
  221. this.sliderMax = parseInt(lastTimeNum/1000 - lastTimeNum/1000%(60*60)) + 60*60
  222. }
  223. });
  224. },
  225. infiniteScroll(){
  226. if (this.total > this.detailFiles.length) {
  227. this.currentPage ++;
  228. this.queryRecordDetails();
  229. }
  230. },
  231. queryRecordDetails: function (callback){
  232. let that = this;
  233. that.$axios({
  234. method: 'get',
  235. url:`/record_proxy/${that.mediaServerId}/api/record/file/list`,
  236. params: {
  237. app: that.recordFile.app,
  238. stream: that.recordFile.stream,
  239. startTime: that.chooseDate + " 00:00:00",
  240. endTime: that.chooseDate + " 23:59:59",
  241. page: that.currentPage,
  242. count: that.count
  243. }
  244. }).then(function (res) {
  245. that.total = res.data.data.total;
  246. that.detailFiles = that.detailFiles.concat(res.data.data.list);
  247. that.loading = false;
  248. if (callback) callback();
  249. }).catch(function (error) {
  250. console.log(error);
  251. that.loading = false;
  252. });
  253. },
  254. chooseFile(file){
  255. this.choosedFile = file;
  256. if (file == null) {
  257. this.videoUrl = "";
  258. }else {
  259. // TODO 控制列表滚动条
  260. this.videoUrl = `${this.basePath}/record/${this.recordFile.app}/${this.recordFile.stream}/${this.chooseDate}/${this.choosedFile}`
  261. console.log(this.videoUrl)
  262. }
  263. },
  264. getDataWidth(item){
  265. let timeForFile = this.getTimeForFile(item);
  266. let result = (timeForFile[2])/((this.sliderMax - this.sliderMIn)*1000)
  267. return result*100
  268. },
  269. getDataLeft(item){
  270. let timeForFile = this.getTimeForFile(item);
  271. let differenceTime = timeForFile[0].getTime() - new Date(this.chooseDate + " 00:00:00").getTime()
  272. return parseFloat((differenceTime - this.sliderMIn * 1000)/((this.sliderMax - this.sliderMIn)*1000))*100 ;
  273. },
  274. playTimeChange(val){
  275. let minTime = this.getTimeForFile(this.detailFiles[0])[0]
  276. let maxTime = this.getTimeForFile(this.detailFiles[this.detailFiles.length - 1])[1];
  277. this.chooseFile(null);
  278. let timeMilli = new Date(this.chooseDate + " 00:00:00").getTime() + val*1000
  279. if (timeMilli >= minTime.getTime() && timeMilli <= maxTime.getTime()){
  280. for (let i = 0; i < this.detailFiles.length; i++) {
  281. let timeForFile = this.getTimeForFile(this.detailFiles[i]);
  282. if (timeMilli >= timeForFile[0].getTime() && timeMilli <= timeForFile[1].getTime()){
  283. // TODO 当前未按照实际时间偏移,仅仅是找到对应的文静播放
  284. this.chooseFile(this.detailFiles[i])
  285. return;
  286. }
  287. }
  288. }
  289. },
  290. getTimeForFile(file){
  291. let timeStr = file.substring(0,17);
  292. let starTime = new Date(this.chooseDate + " " + timeStr.split("-")[0]);
  293. let endTime = new Date(this.chooseDate + " " + timeStr.split("-")[1]);
  294. return [starTime, endTime, endTime.getTime() - starTime.getTime()];
  295. },
  296. playTimeFormat(val){
  297. let h = parseInt(val/3600);
  298. let m = parseInt((val - h*3600)/60);
  299. let s = parseInt(val - h*3600 - m*60);
  300. return h + ":" + m + ":" + s
  301. },
  302. deleteRecord(){
  303. // TODO
  304. let that = this;
  305. this.$axios({
  306. method: 'delete',
  307. url:`/record_proxy/${that.mediaServerId}/api/record/delete`,
  308. params: {
  309. page: that.currentPage,
  310. count: that.count
  311. }
  312. }).then(function (res) {
  313. if (res.data.code == 0) {
  314. that.total = res.data.data.total;
  315. that.recordList = res.data.data.list;
  316. }
  317. }).catch(function (error) {
  318. console.log(error);
  319. });
  320. },
  321. getDateInYear(callback){
  322. let that = this;
  323. that.dateFilesObj = {};
  324. this.$axios({
  325. method: 'get',
  326. url:`/record_proxy/${that.mediaServerId}/api/record/date/list`,
  327. params: {
  328. app: that.recordFile.app,
  329. stream: that.recordFile.stream
  330. }
  331. }).then(function (res) {
  332. if (res.data.code === 0) {
  333. if (res.data.data.length > 0) {
  334. for (let i = 0; i < res.data.data.length; i++) {
  335. that.dateFilesObj[res.data.data[i]] = res.data.data[i]
  336. }
  337. console.log(that.dateFilesObj)
  338. }
  339. }
  340. if(callback)callback();
  341. }).catch(function (error) {
  342. console.log(error);
  343. });
  344. },
  345. tabClick(){
  346. this.getTaskList(this.tabVal === "ended")
  347. },
  348. drawerClose(){
  349. this.drawer = false;
  350. if (this.taskUpdate != null) {
  351. window.clearInterval(this.taskUpdate)
  352. }
  353. },
  354. drawerOpen(){
  355. this.drawer = true;
  356. if (this.taskUpdate != null) {
  357. window.clearInterval(this.taskUpdate)
  358. }
  359. this.taskUpdate = setInterval(()=>{
  360. this.getTaskList(this.tabVal === "ended")
  361. }, 1000)
  362. },
  363. addTask(){
  364. this.showTaskBox = true;
  365. let startTimeStr = this.chooseDate + " " + this.detailFiles[0].substring(0,8);
  366. let endTimeStr = this.chooseDate + " " + this.detailFiles[this.detailFiles.length - 1].substring(9,17);
  367. this.taskTimeRange[0] = new Date(startTimeStr)
  368. this.taskTimeRange[1] = new Date(endTimeStr)
  369. },
  370. addTaskToServer(){
  371. let that = this;
  372. this.$axios({
  373. method: 'get',
  374. url:`/record_proxy/${that.mediaServerId}/api/record/file/download/task/add`,
  375. params: {
  376. app: that.recordFile.app,
  377. stream: that.recordFile.stream,
  378. startTime: moment(this.taskTimeRange[0]).format('YYYY-MM-DD HH:mm:ss'),
  379. endTime: moment(this.taskTimeRange[1]).format('YYYY-MM-DD HH:mm:ss'),
  380. }
  381. }).then(function (res) {
  382. if (res.data.code === 0 && res.data.msg === "success") {
  383. that.showTaskBox = false
  384. that.getTaskList(false);
  385. }else {
  386. that.$message.error(res.data.msg);
  387. }
  388. }).catch(function (error) {
  389. console.log(error);
  390. });
  391. },
  392. handleTabClick() {
  393. this.getTaskList(this.tabVal === "ended")
  394. },
  395. getTaskList(isEnd){
  396. let that = this;
  397. this.$axios({
  398. method: 'get',
  399. url:`/record_proxy/${that.mediaServerId}/api/record/file/download/task/list`,
  400. params: {
  401. isEnd: isEnd,
  402. }
  403. }).then(function (res) {
  404. if (res.data.code == 0) {
  405. if (isEnd){
  406. that.taskListEnded = res.data.data;
  407. }else {
  408. that.taskListForRuning = res.data.data;
  409. }
  410. }
  411. }).catch(function (error) {
  412. console.log(error);
  413. });
  414. }
  415. }
  416. };
  417. </script>
  418. <style>
  419. .el-slider__runway {
  420. background-color:rgba(206, 206, 206, 0.47) !important;
  421. }
  422. .el-slider__bar {
  423. background-color: rgba(153, 153, 153, 0) !important;
  424. }
  425. .playtime-slider {
  426. position: relative;
  427. z-index: 100;
  428. }
  429. .data-picker-true{
  430. }
  431. .data-picker-true:after{
  432. content: "";
  433. position: absolute;
  434. width: 4px;
  435. height: 4px;
  436. background-color: #606060;
  437. border-radius: 4px;
  438. left: 45%;
  439. top: 74%;
  440. }
  441. .data-picker-false{
  442. }
  443. .slider-val-box{
  444. height: 6px;
  445. position: relative;
  446. top: -22px;
  447. }
  448. .slider-val{
  449. height: 6px;
  450. background-color: #007CFF;
  451. position: absolute;
  452. }
  453. .record-list-box-box{
  454. width: 250px;
  455. float: left;
  456. }
  457. .record-list-box{
  458. overflow: auto;
  459. width: 220px;
  460. list-style: none;
  461. padding: 0;
  462. margin: 0;
  463. margin-top: 0px;
  464. padding: 1rem 0;
  465. background-color: #FFF;
  466. margin-top: 10px;
  467. }
  468. .record-list{
  469. list-style: none;
  470. padding: 0;
  471. margin: 0;
  472. background-color: #FFF;
  473. }
  474. .record-list-no-val {
  475. position: absolute;
  476. color: #9f9f9f;
  477. top: 50%;
  478. left: 110px;
  479. }
  480. .record-list-item{
  481. padding: 0;
  482. margin: 0;
  483. margin: 0.5rem 0;
  484. cursor: pointer;
  485. }
  486. .record-list-option {
  487. width: 10px;
  488. float: left;
  489. margin-top: 39px;
  490. }
  491. .drawer-box{
  492. height: 100%;
  493. }
  494. .task-list{
  495. list-style: none;
  496. padding: 0;
  497. margin: 0;
  498. background-color: #FFF;
  499. }
  500. .task-list-item{
  501. padding: 0;
  502. margin: 0;
  503. margin: 1.5rem 0;
  504. }
  505. .task-list-item-box{
  506. text-align: left;
  507. font-size: 13px;
  508. color: #555;
  509. }
  510. .download-btn{
  511. display: inline-block;
  512. line-height: 1;
  513. white-space: nowrap;
  514. cursor: pointer;
  515. background: #FFF;
  516. background-color: rgb(255, 255, 255);
  517. border: 1px solid #DCDFE6;
  518. border-top-color: rgb(220, 223, 230);
  519. border-right-color: rgb(220, 223, 230);
  520. border-bottom-color: rgb(220, 223, 230);
  521. border-left-color: rgb(220, 223, 230);
  522. border-top-color: rgb(220, 223, 230);
  523. border-right-color: rgb(220, 223, 230);
  524. border-bottom-color: rgb(220, 223, 230);
  525. border-left-color: rgb(220, 223, 230);
  526. -webkit-appearance: none;
  527. text-align: center;
  528. -webkit-box-sizing: border-box;
  529. box-sizing: border-box;
  530. outline: 0;
  531. margin: 0;
  532. -webkit-transition: .1s;
  533. transition: .1s;
  534. font-weight: 500;
  535. padding: 7px 14px;
  536. font-size: 0.875rem;
  537. border-radius: 4px;
  538. font-size: 0.75rem;
  539. border-radius: 3px;
  540. color: #FFF;
  541. background-color: #409EFF;
  542. border-color: #409EFF;
  543. float: right;
  544. }
  545. .download-btn:hover{
  546. background: #66b1ff;
  547. border-color: #66b1ff;
  548. color: #FFF;
  549. }
  550. .time-box{
  551. }
  552. </style>