StreamProxyList.vue 11 KB

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