chooseChannelForStream.vue 10 KB

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