chooseChannelForGb.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <div id="chooseChannelForGb" >
  3. <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;">
  4. 搜索: <el-input @input="search" style="margin-right: 1rem; width: auto;" size="mini" placeholder="关键字" prefix-icon="el-icon-search" v-model="searchSrt" clearable> </el-input>
  5. 通道类型: <el-select size="mini" @change="search" style="margin-right: 1rem; width:6rem" v-model="channelType" placeholder="请选择" default-first-option>
  6. <el-option label="全部" value=""></el-option>
  7. <el-option label="设备" value="false"></el-option>
  8. <el-option label="子目录" value="true"></el-option>
  9. </el-select>
  10. 选择状态: <el-select size="mini" style="margin-right: 1rem; width:6rem" v-model="choosed" @change="search" placeholder="请选择" default-first-option>
  11. <el-option label="全部" value=""></el-option>
  12. <el-option label="已选择" value="true"></el-option>
  13. <el-option label="未选择" value="false"></el-option>
  14. </el-select>
  15. 在线状态: <el-select size="mini" style="margin-right: 1rem; width:6rem" @change="search" v-model="online" placeholder="请选择" default-first-option>
  16. <el-option label="全部" value=""></el-option>
  17. <el-option label="在线" value="true"></el-option>
  18. <el-option label="离线" value="false"></el-option>
  19. </el-select>
  20. <el-checkbox @change="shareAllCheckedChanage">全部共享</el-checkbox>
  21. </div>
  22. <el-table ref="gbChannelsTable" :data="gbChannels" border style="width: 100%" @selection-change="checkedChanage" >
  23. <el-table-column type="selection" width="55" align="center" fixed > </el-table-column>
  24. <el-table-column prop="channelId" label="通道编号" width="210">
  25. </el-table-column>
  26. <el-table-column prop="name" label="通道名称">
  27. </el-table-column>
  28. <el-table-column prop="deviceId" label="设备编号" width="210" >
  29. </el-table-column>
  30. <el-table-column label="设备地址" width="180" align="center">
  31. <template slot-scope="scope">
  32. <div slot="reference" class="name-wrapper">
  33. <el-tag size="medium">{{ scope.row.hostAddress }}</el-tag>
  34. </div>
  35. </template>
  36. </el-table-column>
  37. <el-table-column prop="manufacturer" label="厂家" align="center">
  38. </el-table-column>
  39. </el-table>
  40. <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">
  41. </el-pagination>
  42. </div>
  43. </template>
  44. <script>
  45. export default {
  46. name: 'chooseChannelForGb',
  47. props: {},
  48. computed: {
  49. // getPlayerShared: function () {
  50. // return {
  51. // sharedUrl: window.location.host + '/' + this.videoUrl,
  52. // sharedIframe: '<iframe src="' + window.location.host + '/' + this.videoUrl + '"></iframe>',
  53. // sharedRtmp: this.videoUrl
  54. // };
  55. // }
  56. },
  57. props: ['platformId'],
  58. created() {
  59. this.initData();
  60. },
  61. data() {
  62. return {
  63. gbChannels: [],
  64. gbChoosechannel:{},
  65. searchSrt: "",
  66. channelType: "",
  67. online: "",
  68. choosed: "",
  69. currentPage: 0,
  70. count: 15,
  71. total: 0,
  72. eventEnanle: false
  73. };
  74. },
  75. watch:{
  76. platformId(newData, oldData){
  77. console.log(newData)
  78. this.initData()
  79. },
  80. },
  81. methods: {
  82. initData: function() {
  83. this.getChannelList();
  84. },
  85. currentChange: function (val) {
  86. this.currentPage = val;
  87. this.initData();
  88. },
  89. handleSizeChange: function (val) {
  90. this.count = val;
  91. console.log(val)
  92. this.initData();
  93. },
  94. rowcheckedChanage: function (val, row) {
  95. console.log(val)
  96. console.log(row)
  97. },
  98. checkedChanage: function (val) {
  99. var that = this;
  100. if (!that.eventEnanle) {
  101. return;
  102. }
  103. var tabelData = JSON.parse(JSON.stringify(this.$refs.gbChannelsTable.data));
  104. console.log("checkedChanage")
  105. console.log(val)
  106. var newData = {};
  107. var addData = [];
  108. var delData = [];
  109. if (val.length > 0) {
  110. for (let i = 0; i < val.length; i++) {
  111. const element = val[i];
  112. var key = element.deviceId + "_" + element.channelId;
  113. newData[key] = element;
  114. if (!!!that.gbChoosechannel[key]){
  115. addData.push(element)
  116. }else{
  117. delete that.gbChoosechannel[key]
  118. }
  119. }
  120. var oldKeys = Object.keys(that.gbChoosechannel);
  121. if (oldKeys.length > 0) {
  122. for (let i = 0; i < oldKeys.length; i++) {
  123. const key = oldKeys[i];
  124. delData.push(that.gbChoosechannel[key])
  125. }
  126. }
  127. }else{
  128. var oldKeys = Object.keys(that.gbChoosechannel);
  129. if (oldKeys.length > 0) {
  130. for (let i = 0; i < oldKeys.length; i++) {
  131. const key = oldKeys[i];
  132. delData.push(that.gbChoosechannel[key])
  133. }
  134. }
  135. }
  136. that.gbChoosechannel = newData;
  137. if (Object.keys(addData).length >0) {
  138. that.$axios({
  139. method:"post",
  140. url:"/api/platforms/updateChannelForGB",
  141. data:{
  142. platformId: that.platformId,
  143. channelReduces: addData
  144. }
  145. }).then((res)=>{
  146. console.log("保存成功")
  147. }).catch(function (error) {
  148. console.log(error);
  149. });
  150. }
  151. if (Object.keys(delData).length >0) {
  152. that.$axios({
  153. method:"post",
  154. url:"/api/platforms/delChannelForGB",
  155. data:{
  156. platformId: that.platformId,
  157. channelReduces: delData
  158. }
  159. }).then((res)=>{
  160. console.log("移除成功")
  161. }).catch(function (error) {
  162. console.log(error);
  163. });
  164. }
  165. },
  166. shareAllCheckedChanage: function (val) {
  167. this.chooseChanage(null, val)
  168. },
  169. getChannelList: function () {
  170. let that = this;
  171. this.$axios.get(`/api/platforms/channelList`, {
  172. params: {
  173. page: that.currentPage,
  174. count: that.count,
  175. query: that.searchSrt,
  176. online: that.online,
  177. choosed: that.choosed,
  178. platformId: that.platformId,
  179. channelType: that.channelType
  180. }
  181. })
  182. .then(function (res) {
  183. that.total = res.data.total;
  184. that.gbChannels = res.data.list;
  185. that.gbChoosechannel = {};
  186. // 防止出现表格错位
  187. that.$nextTick(() => {
  188. that.$refs.gbChannelsTable.doLayout();
  189. // 默认选中
  190. var chooseGBS = [];
  191. for (let i = 0; i < res.data.list.length; i++) {
  192. const row = res.data.list[i];
  193. console.log(row.platformId)
  194. if (row.platformId == that.platformId) {
  195. that.$refs.gbChannelsTable.toggleRowSelection(row, true);
  196. chooseGBS.push(row)
  197. that.gbChoosechannel[row.deviceId+ "_" + row.channelId] = row;
  198. }
  199. }
  200. that.eventEnanle = true;
  201. // that.checkedChanage(chooseGBS)
  202. })
  203. console.log(that.gbChoosechannel)
  204. })
  205. .catch(function (error) {
  206. console.log(error);
  207. });
  208. },
  209. search: function() {
  210. this.initData();
  211. },
  212. handleGBSelectionChange: function() {
  213. this.initData();
  214. },
  215. }
  216. };
  217. </script>
  218. <style>
  219. </style>