CloudRecordDetail.vue 18 KB

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