StreamProxyList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <template>
  2. <div id="streamProxyList" style="width: 100%">
  3. <div class="page-header">
  4. <div class="page-title">拉流代理列表</div>
  5. <div class="page-header-btn">
  6. <el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="addStreamProxy">添加代理</el-button>
  7. <el-button v-if="false" icon="el-icon-search" size="mini" style="margin-right: 1rem;" type="primary" @click="addOnvif">搜索ONVIF</el-button>
  8. <el-button icon="el-icon-refresh-right" circle size="mini" @click="refresh()"></el-button>
  9. </div>
  10. </div>
  11. <devicePlayer ref="devicePlayer"></devicePlayer>
  12. <el-table :data="streamProxyList" style="width: 100%" :height="winHeight">
  13. <el-table-column prop="name" label="名称" min-width="120" show-overflow-tooltip/>
  14. <el-table-column prop="app" label="流应用名" min-width="120" show-overflow-tooltip/>
  15. <el-table-column prop="stream" label="流ID" min-width="120" show-overflow-tooltip/>
  16. <el-table-column label="流地址" min-width="400" show-overflow-tooltip >
  17. <template slot-scope="scope">
  18. <div slot="reference" class="name-wrapper">
  19. <el-tag size="medium" v-if="scope.row.type == 'default'">
  20. <i class="cpoy-btn el-icon-document-copy" title="点击拷贝" v-clipboard="scope.row.url" @success="$message({type:'success', message:'成功拷贝到粘贴板'})"></i>
  21. {{scope.row.url}}
  22. </el-tag>
  23. <el-tag size="medium" v-if="scope.row.type != 'default'">
  24. <i class="cpoy-btn el-icon-document-copy" title="点击拷贝" v-clipboard="scope.row.src_url" @success="$message({type:'success', message:'成功拷贝到粘贴板'})"></i>
  25. {{scope.row.src_url}}
  26. </el-tag>
  27. </div>
  28. </template>
  29. </el-table-column>
  30. <el-table-column prop="mediaServerId" label="流媒体" min-width="180" ></el-table-column>
  31. <el-table-column label="类型" width="100" >
  32. <template slot-scope="scope">
  33. <div slot="reference" class="name-wrapper">
  34. <el-tag size="medium">{{scope.row.type}}</el-tag>
  35. </div>
  36. </template>
  37. </el-table-column>
  38. <el-table-column prop="gbId" label="国标编码" min-width="180" show-overflow-tooltip/>
  39. <el-table-column label="状态" min-width="120" >
  40. <template slot-scope="scope">
  41. <div slot="reference" class="name-wrapper">
  42. <el-tag size="medium" v-if="scope.row.status">在线</el-tag>
  43. <el-tag size="medium" type="info" v-if="!scope.row.status">离线</el-tag>
  44. </div>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="启用" min-width="120" >
  48. <template slot-scope="scope">
  49. <div slot="reference" class="name-wrapper">
  50. <el-tag size="medium" v-if="scope.row.enable">已启用</el-tag>
  51. <el-tag size="medium" type="info" v-if="!scope.row.enable">未启用</el-tag>
  52. </div>
  53. </template>
  54. </el-table-column>
  55. <el-table-column prop="createTime" label="创建时间" min-width="150" show-overflow-tooltip/>
  56. <el-table-column label="转HLS" min-width="120" >
  57. <template slot-scope="scope">
  58. <div slot="reference" class="name-wrapper">
  59. <el-tag size="medium" v-if="scope.row.enable_hls">已启用</el-tag>
  60. <el-tag size="medium" type="info" v-if="!scope.row.enable_hls">未启用</el-tag>
  61. </div>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="MP4录制" min-width="120" >
  65. <template slot-scope="scope">
  66. <div slot="reference" class="name-wrapper">
  67. <el-tag size="medium" v-if="scope.row.enable_mp4">已启用</el-tag>
  68. <el-tag size="medium" type="info" v-if="!scope.row.enable_mp4">未启用</el-tag>
  69. </div>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="无人观看自动删除" min-width="160" >
  73. <template slot-scope="scope">
  74. <div slot="reference" class="name-wrapper">
  75. <el-tag size="medium" v-if="scope.row.enable_remove_none_reader">已启用</el-tag>
  76. <el-tag size="medium" type="info" v-if="!scope.row.enable_remove_none_reader">未启用</el-tag>
  77. </div>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="操作" width="360" fixed="right">
  81. <template slot-scope="scope">
  82. <el-button size="medium" icon="el-icon-video-play" type="text" v-if="scope.row.enable" @click="play(scope.row)">播放</el-button>
  83. <el-divider direction="vertical"></el-divider>
  84. <el-button size="medium" icon="el-icon-switch-button" type="text" v-if="scope.row.enable" @click="stop(scope.row)">停用</el-button>
  85. <el-divider direction="vertical"></el-divider>
  86. <el-button size="medium" icon="el-icon-check" type="text" :loading="scope.row.startBtnLoading" v-if="!scope.row.enable" @click="start(scope.row)">启用</el-button>
  87. <el-divider v-if="!scope.row.enable" direction="vertical"></el-divider>
  88. <el-button size="medium" icon="el-icon-delete" type="text" style="color: #f56c6c" @click="deleteStreamProxy(scope.row)">删除</el-button>
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <el-pagination
  93. style="float: right"
  94. @size-change="handleSizeChange"
  95. @current-change="currentChange"
  96. :current-page="currentPage"
  97. :page-size="count"
  98. :page-sizes="[15, 25, 35, 50]"
  99. layout="total, sizes, prev, pager, next"
  100. :total="total">
  101. </el-pagination>
  102. <streamProxyEdit ref="streamProxyEdit" ></streamProxyEdit>
  103. <onvifEdit ref="onvifEdit" ></onvifEdit>
  104. </div>
  105. </template>
  106. <script>
  107. import streamProxyEdit from './dialog/StreamProxyEdit.vue'
  108. import onvifEdit from './dialog/onvifEdit.vue'
  109. import devicePlayer from './dialog/devicePlayer.vue'
  110. import uiHeader from '../layout/UiHeader.vue'
  111. export default {
  112. name: 'streamProxyList',
  113. components: {
  114. devicePlayer,
  115. streamProxyEdit,
  116. onvifEdit,
  117. uiHeader
  118. },
  119. data() {
  120. return {
  121. streamProxyList: [],
  122. currentPusher: {}, //当前操作设备对象
  123. updateLooper: 0, //数据刷新轮训标志
  124. currentDeviceChannelsLenth:0,
  125. winHeight: window.innerHeight - 250,
  126. currentPage:1,
  127. count:15,
  128. total:0,
  129. getListLoading: false,
  130. startBtnLoading: false
  131. };
  132. },
  133. computed: {
  134. },
  135. mounted() {
  136. this.initData();
  137. this.updateLooper = setInterval(this.initData, 1000);
  138. },
  139. destroyed() {
  140. this.$destroy('videojs');
  141. clearTimeout(this.updateLooper);
  142. },
  143. methods: {
  144. initData: function() {
  145. this.getStreamProxyList();
  146. },
  147. currentChange: function(val){
  148. this.currentPage = val;
  149. this.getStreamProxyList();
  150. },
  151. handleSizeChange: function(val){
  152. this.count = val;
  153. this.getStreamProxyList();
  154. },
  155. getStreamProxyList: function() {
  156. let that = this;
  157. this.getListLoading = true;
  158. this.$axios({
  159. method: 'get',
  160. url:`/api/proxy/list`,
  161. params: {
  162. page: that.currentPage,
  163. count: that.count
  164. }
  165. }).then(function (res) {
  166. that.total = res.data.total;
  167. for (let i = 0; i < res.data.list.length; i++) {
  168. res.data.list[i]["startBtnLoading"] = false;
  169. }
  170. that.streamProxyList = res.data.list;
  171. that.getListLoading = false;
  172. }).catch(function (error) {
  173. console.log(error);
  174. that.getListLoading = false;
  175. });
  176. },
  177. addStreamProxy: function(){
  178. this.$refs.streamProxyEdit.openDialog(null, this.initData)
  179. },
  180. addOnvif: function(){
  181. this.getListLoading = true;
  182. this.getListLoading = true;
  183. this.$axios({
  184. method: 'get',
  185. url:`/api/onvif/search?timeout=3000`,
  186. }).then((res) =>{
  187. this.getListLoading = false;
  188. if (res.data.code == 0 ){
  189. if (res.data.data.length > 0) {
  190. this.$refs.onvifEdit.openDialog(res.data.data, (url)=>{
  191. if (url != null) {
  192. this.$refs.onvifEdit.close();
  193. this.$refs.streamProxyEdit.openDialog({type: "default", url: url, src_url: url}, this.initData())
  194. }
  195. })
  196. }else {
  197. this.$message.success("未找到可用设备");
  198. }
  199. }else {
  200. this.$message.error(res.data.msg);
  201. }
  202. }).catch((error)=> {
  203. this.getListLoading = false;
  204. this.$message.error(error.response.data.msg);
  205. });
  206. },
  207. saveStreamProxy: function(){
  208. },
  209. play: function(row){
  210. let that = this;
  211. this.getListLoading = true;
  212. this.$axios({
  213. method: 'get',
  214. url:`/api/media/stream_info_by_app_and_stream`,
  215. params: {
  216. app: row.app,
  217. stream: row.stream,
  218. mediaServerId: row.mediaServerId
  219. }
  220. }).then(function (res) {
  221. that.getListLoading = false;
  222. if (res.data.code === 0) {
  223. that.$refs.devicePlayer.openDialog("streamPlay", null, null, {
  224. streamInfo: res.data.data,
  225. hasAudio: true
  226. });
  227. }else {
  228. that.$message({
  229. showClose: true,
  230. message: "获取地址失败:" + res.data.msg,
  231. type: "error",
  232. });
  233. }
  234. }).catch(function (error) {
  235. console.log(error);
  236. that.getListLoading = false;
  237. });
  238. },
  239. deleteStreamProxy: function(row){
  240. let that = this;
  241. this.getListLoading = true;
  242. that.$axios({
  243. method:"delete",
  244. url:"/api/proxy/del",
  245. params:{
  246. app: row.app,
  247. stream: row.stream
  248. }
  249. }).then((res)=>{
  250. that.getListLoading = false;
  251. that.initData()
  252. }).catch(function (error) {
  253. console.log(error);
  254. that.getListLoading = false;
  255. });
  256. },
  257. start: function(row){
  258. let that = this;
  259. this.getListLoading = true;
  260. this.$set(row, 'startBtnLoading', true)
  261. this.$axios({
  262. method: 'get',
  263. url:`/api/proxy/start`,
  264. params: {
  265. app: row.app,
  266. stream: row.stream
  267. }
  268. }).then(function (res) {
  269. that.getListLoading = false;
  270. that.$set(row, 'startBtnLoading', false)
  271. if (res.data == "success"){
  272. that.initData()
  273. }else {
  274. that.$message({
  275. showClose: true,
  276. message: "保存失败,请检查地址是否可用!",
  277. type: "error",
  278. });
  279. }
  280. }).catch(function (error) {
  281. console.log(error);
  282. that.getListLoading = false;
  283. that.$set(row, 'startBtnLoading', false)
  284. });
  285. },
  286. stop: function(row){
  287. let that = this;
  288. this.getListLoading = true;
  289. this.$axios({
  290. method: 'get',
  291. url:`/api/proxy/stop`,
  292. params: {
  293. app: row.app,
  294. stream: row.stream
  295. }
  296. }).then(function (res) {
  297. that.getListLoading = false;
  298. that.initData()
  299. }).catch(function (error) {
  300. console.log(error);
  301. that.getListLoading = false;
  302. });
  303. },
  304. refresh: function (){
  305. this.initData();
  306. }
  307. }
  308. };
  309. </script>
  310. <style>
  311. .videoList {
  312. display: flex;
  313. flex-wrap: wrap;
  314. align-content: flex-start;
  315. }
  316. .video-item {
  317. position: relative;
  318. width: 15rem;
  319. height: 10rem;
  320. margin-right: 1rem;
  321. background-color: #000000;
  322. }
  323. .video-item-img {
  324. position: absolute;
  325. top: 0;
  326. bottom: 0;
  327. left: 0;
  328. right: 0;
  329. margin: auto;
  330. width: 100%;
  331. height: 100%;
  332. }
  333. .video-item-img:after {
  334. content: "";
  335. display: inline-block;
  336. position: absolute;
  337. z-index: 2;
  338. top: 0;
  339. bottom: 0;
  340. left: 0;
  341. right: 0;
  342. margin: auto;
  343. width: 3rem;
  344. height: 3rem;
  345. background-image: url("../assets/loading.png");
  346. background-size: cover;
  347. background-color: #000000;
  348. }
  349. .video-item-title {
  350. position: absolute;
  351. bottom: 0;
  352. color: #000000;
  353. background-color: #ffffff;
  354. line-height: 1.5rem;
  355. padding: 0.3rem;
  356. width: 14.4rem;
  357. }
  358. .cpoy-btn {
  359. cursor: pointer;
  360. margin-right: 10px;
  361. }
  362. </style>