StreamProxyList.vue 13 KB

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