CloudRecord.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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-select size="mini" @change="chooseMediaChange" style="width: 16rem; margin-right: 1rem;" v-model="mediaServerId" placeholder="请选择" :disabled="recordDetail">
  11. <el-option
  12. v-for="item in mediaServerList"
  13. :key="item.id"
  14. :label="item.id"
  15. :value="item.id">
  16. </el-option>
  17. </el-select>
  18. <el-button v-if="!recordDetail" icon="el-icon-refresh-right" circle size="mini" :loading="loading" @click="getRecordList()"></el-button>
  19. </div>
  20. </div>
  21. <div v-if="!recordDetail">
  22. <!--设备列表-->
  23. <el-table :data="recordList" style="width: 100%" :height="winHeight">
  24. <el-table-column prop="app" label="应用名" >
  25. </el-table-column>
  26. <el-table-column prop="stream" label="流ID" >
  27. </el-table-column>
  28. <el-table-column prop="time" label="时间" >
  29. </el-table-column>
  30. <el-table-column label="操作" width="360" fixed="right">
  31. <template slot-scope="scope">
  32. <el-button size="medium" icon="el-icon-folder-opened" type="text" @click="showRecordDetail(scope.row)">查看</el-button>
  33. <!-- <el-button size="mini" icon="el-icon-delete" type="danger" @click="deleteRecord(scope.row)">删除</el-button>-->
  34. </template>
  35. </el-table-column>
  36. </el-table>
  37. <el-pagination
  38. style="float: right"
  39. @size-change="handleSizeChange"
  40. @current-change="currentChange"
  41. :current-page="currentPage"
  42. :page-size="count"
  43. :page-sizes="[15, 25, 35, 50]"
  44. layout="total, sizes, prev, pager, next"
  45. :total="total">
  46. </el-pagination>
  47. </div>
  48. <cloud-record-detail ref="cloudRecordDetail" v-if="recordDetail" :recordFile="chooseRecord" :mediaServerId="mediaServerId" :mediaServerPath="mediaServerPath" ></cloud-record-detail>
  49. </div>
  50. </template>
  51. <script>
  52. import uiHeader from '../layout/UiHeader.vue'
  53. import cloudRecordDetail from './CloudRecordDetail.vue'
  54. import MediaServer from './service/MediaServer'
  55. export default {
  56. name: 'app',
  57. components: {
  58. uiHeader, cloudRecordDetail
  59. },
  60. data() {
  61. return {
  62. mediaServerList: [], // 滅体节点列表
  63. mediaServerId: null, // 媒体服务
  64. mediaServerPath: null, // 媒体服务地址
  65. recordList: [], // 设备列表
  66. chooseRecord: null, // 媒体服务
  67. updateLooper: 0, //数据刷新轮训标志
  68. winHeight: window.innerHeight - 250,
  69. currentPage:1,
  70. count:15,
  71. total:0,
  72. loading: false,
  73. mediaServerObj : new MediaServer(),
  74. recordDetail: false
  75. };
  76. },
  77. computed: {
  78. },
  79. mounted() {
  80. this.initData();
  81. },
  82. destroyed() {
  83. // this.$destroy('videojs');
  84. },
  85. methods: {
  86. initData: function() {
  87. // 获取媒体节点列表
  88. this.getMediaServerList();
  89. // this.getRecordList();
  90. },
  91. currentChange: function(val){
  92. this.currentPage = val;
  93. this.getRecordList();
  94. },
  95. handleSizeChange: function(val){
  96. this.count = val;
  97. this.getRecordList();
  98. },
  99. getMediaServerList: function (){
  100. let that = this;
  101. that.mediaServerObj.getOnlineMediaServerList((data)=>{
  102. that.mediaServerList = data.data;
  103. if (that.mediaServerList.length > 0) {
  104. that.mediaServerId = that.mediaServerList[0].id
  105. that.setMediaServerPath(that.mediaServerId);
  106. that.getRecordList();
  107. }
  108. })
  109. },
  110. setMediaServerPath: function (serverId) {
  111. let that = this;
  112. let i;
  113. for (i = 0; i < that.mediaServerList.length; i++) {
  114. if (serverId === that.mediaServerList[i].id) {
  115. break;
  116. }
  117. }
  118. let port = that.mediaServerList[i].httpPort;
  119. if (location.protocol === "https:" && that.mediaServerList[i].httpSSlPort) {
  120. port = that.mediaServerList[i].httpSSlPort
  121. }
  122. that.mediaServerPath = location.protocol + "//" + that.mediaServerList[i].streamIp + ":" + port
  123. console.log(that.mediaServerPath)
  124. },
  125. getRecordList: function (){
  126. let that = this;
  127. this.$axios({
  128. method: 'get',
  129. url:`/record_proxy/${that.mediaServerId}/api/record/list`,
  130. params: {
  131. page: that.currentPage,
  132. count: that.count
  133. }
  134. }).then(function (res) {
  135. console.log(res)
  136. if (res.data.code === 0) {
  137. that.total = res.data.data.total;
  138. that.recordList = res.data.data.list;
  139. }
  140. that.loading = false;
  141. }).catch(function (error) {
  142. console.log(error);
  143. that.loading = false;
  144. });
  145. },
  146. backToList(){
  147. this.recordDetail= false;
  148. },
  149. chooseMediaChange(val){
  150. console.log(val)
  151. this.total = 0;
  152. this.recordList = [];
  153. this.setMediaServerPath(val);
  154. this.getRecordList();
  155. },
  156. showRecordDetail(row){
  157. this.recordDetail = true;
  158. this.chooseRecord = row;
  159. // 查询是否存在录像
  160. // this.$axios({
  161. // method: 'delete',
  162. // url:`/record_proxy/api/record/delete`,
  163. // params: {
  164. // page: this.currentPage,
  165. // count: this.count
  166. // }
  167. // }).then((res) => {
  168. // console.log(res)
  169. // this.total = res.data.data.total;
  170. // this.recordList = res.data.data.list;
  171. // }).catch(function (error) {
  172. // console.log(error);
  173. // });
  174. },
  175. deleteRecord(){
  176. // TODO
  177. let that = this;
  178. this.$axios({
  179. method: 'delete',
  180. url:`/record_proxy/api/record/delete`,
  181. params: {
  182. page: that.currentPage,
  183. count: that.count
  184. }
  185. }).then(function (res) {
  186. console.log(res)
  187. if (res.data.code === 0) {
  188. that.total = res.data.data.total;
  189. that.recordList = res.data.data.list;
  190. }
  191. }).catch(function (error) {
  192. console.log(error);
  193. });
  194. },
  195. }
  196. };
  197. </script>
  198. <style>
  199. </style>