StreamProxyList.vue 12 KB

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