chooseChannelForStream.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <div id="chooseChannelFoStream" >
  3. <div style="font-size: 17px; color: #606060; white-space: nowrap; line-height: 30px; font-family: monospace;">
  4. <span v-if="catalogId == null">{{catalogName}}的直播流</span>
  5. <span v-if="catalogId != null">{{catalogName}}({{catalogId}})的直播流</span>
  6. </div>
  7. <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;">
  8. 搜索: <el-input @input="getChannelList" style="margin-right: 1rem; width: auto;" size="mini" placeholder="关键字" prefix-icon="el-icon-search" v-model="searchSrt" clearable> </el-input>
  9. <!-- 流媒体: <el-select size="mini" @change="getChannelList" style="margin-right: 1rem;" v-model="mediaServerId" placeholder="请选择" default-first-option>-->
  10. <!-- <el-option label="全部" value=""></el-option>-->
  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-select size="mini" style="margin-right: 1rem;" @change="getChannelList" v-model="pushing" placeholder="请选择" default-first-option>
  19. <el-option label="全部" value=""></el-option>
  20. <el-option label="推流进行中" value="true"></el-option>
  21. <el-option label="推流未进行" value="false"></el-option>
  22. </el-select>
  23. <el-button v-if="catalogId !== null" icon="el-icon-delete" size="mini" style="margin-right: 1rem;" :disabled="gbStreams.length === 0 || multipleSelection.length === 0" type="danger" @click="batchDel">批量移除</el-button>
  24. <el-button v-if="catalogId === null" icon="el-icon-plus" size="mini" style="margin-right: 1rem;" :disabled="gbStreams.length === 0 || multipleSelection.length === 0" @click="batchAdd">批量添加</el-button>
  25. </div>
  26. <el-table ref="gbStreamsTable" :data="gbStreams" border style="width: 100%" :height="winHeight" :row-key="(row)=> row.app + row.stream" @selection-change="handleSelectionChange">
  27. <el-table-column align="center" type="selection" :reserve-selection="true" width="55">
  28. </el-table-column>
  29. <el-table-column prop="name" label="名称" show-overflow-tooltip align="center">
  30. </el-table-column>
  31. <el-table-column prop="app" label="应用名" show-overflow-tooltip align="center">
  32. </el-table-column>
  33. <el-table-column prop="stream" label="流ID" show-overflow-tooltip align="center">
  34. </el-table-column>
  35. <el-table-column prop="gbId" label="国标编码" show-overflow-tooltip align="center">
  36. </el-table-column>
  37. <el-table-column label="流来源" width="100" align="center">
  38. <template slot-scope="scope">
  39. <div slot="reference" class="name-wrapper">
  40. <el-tag size="medium" v-if="scope.row.streamType == 'proxy'">拉流代理</el-tag>
  41. <el-tag size="medium" v-if="scope.row.streamType == 'push'">推流</el-tag>
  42. </div>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="操作" width="100" align="center" fixed="right" >
  46. <template slot-scope="scope">
  47. <el-button-group>
  48. <el-button size="mini" icon="el-icon-plus" v-if="catalogId === null" @click="add(scope.row, scope)">添加</el-button>
  49. <el-button size="mini" icon="el-icon-delete" v-if="catalogId !== null" type="danger" @click="remove(scope.row, scope)">移除</el-button>
  50. </el-button-group>
  51. </template>
  52. </el-table-column>
  53. </el-table>
  54. <el-pagination style="float: right;margin-top: 1rem;" @size-change="handleSizeChange" @current-change="currentChange" :current-page="currentPage" :page-size="count" :page-sizes="[10, 20, 30, 50]" layout="total, sizes, prev, pager, next" :total="total">
  55. </el-pagination>
  56. <getCatalog ref="getCatalog" :platformId="platformId" ></getCatalog>
  57. </div>
  58. </template>
  59. <script>
  60. import MediaServer from './../service/MediaServer'
  61. import getCatalog from './getCatalog'
  62. export default {
  63. name: 'chooseChannelFoStream',
  64. computed: {
  65. // getPlayerShared: function () {
  66. // return {
  67. // sharedUrl: window.location.host + '/' + this.videoUrl,
  68. // sharedIframe: '<iframe src="' + window.location.host + '/' + this.videoUrl + '"></iframe>',
  69. // sharedRtmp: this.videoUrl
  70. // };
  71. // }
  72. },
  73. props: ['platformId', 'catalogId', 'catalogName'],
  74. created() {
  75. this.initData();
  76. console.log(this.catalogId)
  77. },
  78. components: {
  79. getCatalog,
  80. },
  81. data() {
  82. return {
  83. gbStreams: [],
  84. gbChoosechannel:{},
  85. channelType: "",
  86. online: "",
  87. choosed: "",
  88. currentPage: 1,
  89. count: 10,
  90. total: 0,
  91. searchSrt: "",
  92. pushing: "",
  93. mediaServerId: "",
  94. mediaServerList: [],
  95. mediaServerObj : new MediaServer(),
  96. eventEnable: false,
  97. multipleSelection: [],
  98. winHeight: window.innerHeight - 350,
  99. };
  100. },
  101. watch:{
  102. platformId(newData, oldData){
  103. this.getChannelList()
  104. },
  105. catalogId(newData, oldData){
  106. this.getChannelList()
  107. },
  108. },
  109. methods: {
  110. initData: function() {
  111. this.mediaServerObj.getOnlineMediaServerList((data)=>{
  112. this.mediaServerList = data.data;
  113. })
  114. this.getChannelList();
  115. },
  116. currentChange: function (val) {
  117. this.currentPage = val;
  118. this.getChannelList();
  119. },
  120. handleSizeChange: function (val) {
  121. this.count = val;
  122. console.log(val)
  123. this.getChannelList();
  124. },
  125. add: function (row, scope) {
  126. this.getCatalogFromUser((catalogId)=>{
  127. this.$axios({
  128. method:"post",
  129. url:"/api/gbStream/add",
  130. data:{
  131. platformId: this.platformId,
  132. catalogId: catalogId,
  133. gbStreams: [row],
  134. }
  135. }).then((res)=>{
  136. console.log("保存成功")
  137. // this.gbStreams.splice(scope.$index,1)
  138. this.getChannelList();
  139. }).catch(function (error) {
  140. console.log(error);
  141. });
  142. })
  143. },
  144. remove: function (row, scope) {
  145. this.$axios({
  146. method:"delete",
  147. url:"/api/gbStream/del",
  148. data:{
  149. platformId: this.platformId,
  150. gbStreams: [row],
  151. }
  152. }).then((res)=>{
  153. console.log("移除成功")
  154. // this.gbStreams.splice(scope.$index,1)
  155. this.getChannelList();
  156. }).catch(function (error) {
  157. console.log(error);
  158. });
  159. },
  160. getChannelList: function () {
  161. let that = this;
  162. this.$axios({
  163. method: 'get',
  164. url:`/api/gbStream/list`,
  165. params: {
  166. page: that.currentPage,
  167. count: that.count,
  168. query: that.searchSrt,
  169. pushing: that.online,
  170. platformId: that.platformId,
  171. catalogId: that.catalogId,
  172. mediaServerId: that.mediaServerId
  173. }
  174. })
  175. .then(function (res) {
  176. that.total = res.data.total;
  177. that.gbStreams = res.data.list;
  178. that.gbChoosechannel = {};
  179. // 防止出现表格错位
  180. that.$nextTick(() => {
  181. that.$refs.gbStreamsTable.doLayout();
  182. // 默认选中
  183. that.eventEnable = true;
  184. })
  185. })
  186. .catch(function (error) {
  187. console.log(error);
  188. });
  189. },
  190. batchDel: function() {
  191. this.$confirm(`确认这${this.multipleSelection.length}个通道吗?`, '提示', {
  192. confirmButtonText: '确定',
  193. cancelButtonText: '取消',
  194. type: 'warning'
  195. }).then(() => {
  196. this.$axios({
  197. method:"delete",
  198. url:"/api/gbStream/del",
  199. data:{
  200. platformId: this.platformId,
  201. gbStreams: this.multipleSelection,
  202. }
  203. }).then((res)=>{
  204. console.log("移除成功")
  205. this.$refs.gbStreamsTable.clearSelection()
  206. this.getChannelList();
  207. }).catch(function (error) {
  208. console.log(error);
  209. });
  210. }).catch(() => {
  211. });
  212. },
  213. batchAdd: function() {
  214. this.getCatalogFromUser((catalogId)=>{
  215. this.$axios({
  216. method:"post",
  217. url:"/api/gbStream/add",
  218. data:{
  219. platformId: this.platformId,
  220. catalogId: catalogId,
  221. gbStreams: this.multipleSelection,
  222. }
  223. }).then((res)=>{
  224. console.log("保存成功")
  225. this.$refs.gbStreamsTable.clearSelection()
  226. this.getChannelList();
  227. }).catch(function (error) {
  228. console.log(error);
  229. });
  230. })
  231. },
  232. getCatalogFromUser(callback){
  233. this.$refs.getCatalog.openDialog(callback)
  234. },
  235. handleSelectionChange: function (val) {
  236. this.multipleSelection = val;
  237. },
  238. }
  239. };
  240. </script>
  241. <style>
  242. </style>