chooseChannelForStream.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <div id="chooseChannelFoStream" >
  3. <el-table ref="gbStreamsTable" :data="gbStreams" border style="width: 100%" @selection-change="checkedChanage" >
  4. <el-table-column type="selection" width="55" align="center" fixed > </el-table-column>
  5. <el-table-column prop="name" label="名称" show-overflow-tooltip>
  6. </el-table-column>
  7. <el-table-column prop="app" label="应用名" show-overflow-tooltip>
  8. </el-table-column>
  9. <el-table-column prop="stream" label="流ID" show-overflow-tooltip>
  10. </el-table-column>
  11. <el-table-column prop="gbId" label="国标编码" show-overflow-tooltip>
  12. </el-table-column>
  13. <el-table-column label="流来源" width="100" align="center">
  14. <template slot-scope="scope">
  15. <div slot="reference" class="name-wrapper">
  16. <el-tag size="medium" v-if="scope.row.streamType == 'proxy'">拉流代理</el-tag>
  17. <el-tag size="medium" v-if="scope.row.streamType == 'push'">推流</el-tag>
  18. </div>
  19. </template>
  20. </el-table-column>
  21. </el-table>
  22. <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">
  23. </el-pagination>
  24. </div>
  25. </template>
  26. <script>
  27. export default {
  28. name: 'chooseChannelFoStream',
  29. props: {},
  30. computed: {
  31. // getPlayerShared: function () {
  32. // return {
  33. // sharedUrl: window.location.host + '/' + this.videoUrl,
  34. // sharedIframe: '<iframe src="' + window.location.host + '/' + this.videoUrl + '"></iframe>',
  35. // sharedRtmp: this.videoUrl
  36. // };
  37. // }
  38. },
  39. props: ['platformId'],
  40. created() {
  41. this.initData();
  42. },
  43. data() {
  44. return {
  45. gbStreams: [],
  46. gbChoosechannel:{},
  47. searchSrt: "",
  48. channelType: "",
  49. online: "",
  50. choosed: "",
  51. currentPage: 0,
  52. count: 10,
  53. total: 0,
  54. eventEnanle: false
  55. };
  56. },
  57. watch:{
  58. platformId(newData, oldData){
  59. console.log(newData)
  60. this.initData()
  61. },
  62. },
  63. methods: {
  64. initData: function() {
  65. this.getChannelList();
  66. },
  67. currentChange: function (val) {
  68. this.currentPage = val;
  69. this.initData();
  70. },
  71. handleSizeChange: function (val) {
  72. this.count = val;
  73. console.log(val)
  74. this.initData();
  75. },
  76. rowcheckedChanage: function (val, row) {
  77. console.log(val)
  78. console.log(row)
  79. },
  80. checkedChanage: function (val) {
  81. var that = this;
  82. if (!that.eventEnanle) {
  83. return;
  84. }
  85. var tabelData = JSON.parse(JSON.stringify(this.$refs.gbStreamsTable.data));
  86. console.log("checkedChanage")
  87. console.log(val)
  88. var newData = {};
  89. var addData = [];
  90. var delData = [];
  91. if (val.length > 0) {
  92. for (let i = 0; i < val.length; i++) {
  93. const element = val[i];
  94. var key = element.app + "_" + element.stream;
  95. newData[key] = element;
  96. if (!!!that.gbChoosechannel[key]){
  97. addData.push(element)
  98. }else{
  99. delete that.gbChoosechannel[key]
  100. }
  101. }
  102. var oldKeys = Object.keys(that.gbChoosechannel);
  103. if (oldKeys.length > 0) {
  104. for (let i = 0; i < oldKeys.length; i++) {
  105. const key = oldKeys[i];
  106. delData.push(that.gbChoosechannel[key])
  107. }
  108. }
  109. }else{
  110. var oldKeys = Object.keys(that.gbChoosechannel);
  111. if (oldKeys.length > 0) {
  112. for (let i = 0; i < oldKeys.length; i++) {
  113. const key = oldKeys[i];
  114. delData.push(that.gbChoosechannel[key])
  115. }
  116. }
  117. }
  118. that.gbChoosechannel = newData;
  119. if (Object.keys(addData).length >0) {
  120. console.log(addData)
  121. that.$axios({
  122. method:"post",
  123. url:"/api/gbStream/add",
  124. data:{
  125. platformId: that.platformId,
  126. gbStreams: addData,
  127. }
  128. }).then((res)=>{
  129. console.log("保存成功")
  130. }).catch(function (error) {
  131. console.log(error);
  132. });
  133. }
  134. if (Object.keys(delData).length >0) {
  135. console.log(delData)
  136. that.$axios({
  137. method:"delete",
  138. url:"/api/gbStream/del",
  139. data:{
  140. gbStreams: delData,
  141. }
  142. }).then((res)=>{
  143. console.log("移除成功")
  144. }).catch(function (error) {
  145. console.log(error);
  146. });
  147. }
  148. },
  149. shareAllCheckedChanage: function (val) {
  150. this.chooseChanage(null, val)
  151. },
  152. getChannelList: function () {
  153. let that = this;
  154. this.$axios.get(`/api/gbStream/list`, {
  155. params: {
  156. page: that.currentPage,
  157. count: that.count,
  158. query: that.searchSrt,
  159. online: that.online,
  160. choosed: that.choosed,
  161. platformId: that.platformId,
  162. channelType: that.channelType
  163. }
  164. })
  165. .then(function (res) {
  166. that.total = res.data.total;
  167. that.gbStreams = res.data.list;
  168. that.gbChoosechannel = {};
  169. // 防止出现表格错位
  170. that.$nextTick(() => {
  171. that.$refs.gbStreamsTable.doLayout();
  172. // 默认选中
  173. var chooseGBS = [];
  174. for (let i = 0; i < res.data.list.length; i++) {
  175. const row = res.data.list[i];
  176. console.log(row.platformId)
  177. if (row.platformId == that.platformId) {
  178. that.$refs.gbStreamsTable.toggleRowSelection(row, true);
  179. chooseGBS.push(row)
  180. that.gbChoosechannel[row.app+ "_" + row.stream] = row;
  181. }
  182. }
  183. that.eventEnanle = true;
  184. // that.checkedChanage(chooseGBS)
  185. })
  186. console.log(that.gbChoosechannel)
  187. })
  188. .catch(function (error) {
  189. console.log(error);
  190. });
  191. },
  192. handleGBSelectionChange: function() {
  193. this.initData();
  194. },
  195. }
  196. };
  197. </script>
  198. <style>
  199. </style>