operationsForHistoryLog.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <div id="app" style="width: 100%; background-color: #FFFFFF">
  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="getFileList" 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. size="mini"
  14. v-model="startTime"
  15. type="datetime"
  16. value-format="yyyy-MM-dd HH:mm:ss"
  17. @change="getFileList"
  18. placeholder="选择日期时间">
  19. </el-date-picker>
  20. 结束时间:
  21. <el-date-picker
  22. size="mini"
  23. v-model="endTime"
  24. type="datetime"
  25. value-format="yyyy-MM-dd HH:mm:ss"
  26. @change="getFileList"
  27. placeholder="选择日期时间">
  28. </el-date-picker>
  29. <!-- <el-button size="mini" icon="el-icon-delete" type="danger" @click="deleteRecord()">批量删除</el-button>-->
  30. <el-button icon="el-icon-refresh-right" circle size="mini" :loading="loading"
  31. @click="getFileList()"></el-button>
  32. </div>
  33. </div>
  34. <!--日志列表-->
  35. <el-table size="medium" :data="fileList" style="width: 100%" :height="winHeight">
  36. <el-table-column
  37. type="selection"
  38. width="55">
  39. </el-table-column>
  40. <el-table-column prop="fileName" label="文件名">
  41. </el-table-column>
  42. <el-table-column prop="fileSize" label="文件大小">
  43. <template slot-scope="scope">
  44. {{formatFileSize(scope.row.fileSize)}}
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="开始时间">
  48. <template slot-scope="scope">
  49. {{formatTimeStamp(scope.row.startTime)}}
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="结束时间">
  53. <template slot-scope="scope">
  54. {{formatTimeStamp(scope.row.endTime)}}
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="操作" width="200" fixed="right">
  58. <template slot-scope="scope">
  59. <el-button size="medium" icon="el-icon-document" type="text" @click="showLogView(scope.row)">查看
  60. </el-button>
  61. <el-button size="medium" icon="el-icon-download" type="text" @click="downloadFile(scope.row)">下载
  62. </el-button>
  63. <!-- <el-button size="medium" icon="el-icon-delete" type="text" style="color: #f56c6c"-->
  64. <!-- @click="deleteRecord(scope.row)">删除-->
  65. <!-- </el-button>-->
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <el-dialog
  70. top="10"
  71. :title="playerTitle"
  72. :visible.sync="showLog"
  73. width="90%">
  74. <operationsFoShowLog ref="recordVideoPlayer" :fileUrl="fileUrl" :loadEnd="loadEnd"></operationsFoShowLog>
  75. </el-dialog>
  76. </div>
  77. </template>
  78. <script>
  79. import uiHeader from '../layout/UiHeader.vue'
  80. import MediaServer from './service/MediaServer'
  81. import operationsFoShowLog from './dialog/operationsFoShowLog.vue'
  82. import moment from 'moment'
  83. export default {
  84. name: 'app',
  85. components: {
  86. uiHeader, operationsFoShowLog
  87. },
  88. data() {
  89. return {
  90. search: '',
  91. startTime: '',
  92. endTime: '',
  93. showLog: false,
  94. playerTitle: '',
  95. fileUrl: '',
  96. playerStyle: {
  97. "margin": "auto",
  98. "margin-bottom": "20px",
  99. "width": window.innerWidth / 2 + "px",
  100. "height": this.winHeight / 2 + "px",
  101. },
  102. mediaServerList: [], // 滅体节点列表
  103. mediaServerId: "", // 媒体服务
  104. mediaServerPath: null, // 媒体服务地址
  105. fileList: [], // 设备列表
  106. chooseRecord: null, // 媒体服务
  107. updateLooper: 0, //数据刷新轮训标志
  108. winHeight: window.innerHeight - 180,
  109. loading: false,
  110. mediaServerObj: new MediaServer(),
  111. };
  112. },
  113. computed: {},
  114. mounted() {
  115. this.initData();
  116. },
  117. destroyed() {
  118. this.$destroy('recordVideoPlayer');
  119. },
  120. methods: {
  121. initData: function () {
  122. this.getFileList();
  123. },
  124. getFileList: function () {
  125. this.$axios({
  126. method: 'get',
  127. url: `/api/log/list`,
  128. params: {
  129. query: this.search,
  130. startTime: this.startTime,
  131. endTime: this.endTime,
  132. }
  133. }).then((res) => {
  134. console.log(res)
  135. if (res.data.code === 0) {
  136. this.fileList = res.data.data;
  137. }
  138. this.loading = false;
  139. }).catch((error) => {
  140. console.log(error);
  141. this.loading = false;
  142. });
  143. },
  144. showLogView(file) {
  145. this.playerTitle = '正在加载日志...'
  146. this.fileUrl = `/api/log/file/${file.fileName}`
  147. this.showLog = true
  148. this.file = file
  149. },
  150. downloadFile(file) {
  151. const link = document.createElement('a');
  152. link.target = "_blank";
  153. link.download = file.fileName;
  154. if (process.env.NODE_ENV === 'development') {
  155. link.href = `/debug/api/log/file/${file.fileName}`
  156. }else {
  157. link.href = `/api/log/file/${file.fileName}`
  158. }
  159. link.click();
  160. },
  161. loadEnd() {
  162. this.playerTitle = this.file.fileName
  163. },
  164. deleteRecord() {
  165. // TODO
  166. let that = this;
  167. this.$axios({
  168. method: 'delete',
  169. url: `/record_proxy/api/record/delete`,
  170. params: {
  171. page: that.currentPage,
  172. count: that.count
  173. }
  174. }).then(function (res) {
  175. console.log(res)
  176. if (res.data.code === 0) {
  177. that.total = res.data.data.total;
  178. that.fileList = res.data.data.list;
  179. }
  180. }).catch(function (error) {
  181. console.log(error);
  182. });
  183. },
  184. formatTime(time) {
  185. const h = parseInt(time / 3600 / 1000)
  186. const minute = parseInt((time - h * 3600 * 1000) / 60 / 1000)
  187. let second = Math.ceil((time - h * 3600 * 1000 - minute * 60 * 1000) / 1000)
  188. if (second < 0) {
  189. second = 0;
  190. }
  191. return (h > 0 ? h + `小时` : '') + (minute > 0 ? minute + '分' : '') + (second > 0 ? second + '秒' : '')
  192. },
  193. formatTimeStamp(time) {
  194. return moment.unix(time / 1000).format('yyyy-MM-DD HH:mm:ss')
  195. },
  196. formatFileSize(fileSize) {
  197. if (fileSize < 1024) {
  198. return fileSize + 'B';
  199. } else if (fileSize < (1024*1024)) {
  200. let temp = fileSize / 1024;
  201. temp = temp.toFixed(2);
  202. return temp + 'KB';
  203. } else if (fileSize < (1024*1024*1024)) {
  204. let temp = fileSize / (1024*1024);
  205. temp = temp.toFixed(2);
  206. return temp + 'MB';
  207. } else {
  208. let temp = fileSize / (1024*1024*1024);
  209. temp = temp.toFixed(2);
  210. return temp + 'GB';
  211. }
  212. }
  213. }
  214. };
  215. </script>
  216. <style>
  217. </style>