chooseChannelForGb.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <div id="chooseChannelForGb" >
  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; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;">
  8. 搜索: <el-input @input="search" 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="search" style="margin-right: 1rem; width:6rem" v-model="channelType" placeholder="请选择" default-first-option>
  10. <el-option label="全部" value=""></el-option>
  11. <el-option label="设备" value="false"></el-option>
  12. <el-option label="子目录" value="true"></el-option>
  13. </el-select>
  14. 在线状态: <el-select size="mini" style="margin-right: 1rem; width:6rem" @change="search" v-model="online" placeholder="请选择" default-first-option>
  15. <el-option label="全部" value=""></el-option>
  16. <el-option label="在线" value="true"></el-option>
  17. <el-option label="离线" value="false"></el-option>
  18. </el-select>
  19. <el-button v-if="catalogId !== null" icon="el-icon-delete" size="mini" style="margin-right: 1rem;" :disabled="gbChannels.length === 0 || multipleSelection.length === 0" type="danger" @click="batchDel">批量移除</el-button>
  20. <el-button v-if="catalogId === null" icon="el-icon-plus" size="mini" style="margin-right: 1rem;" :disabled="gbChannels.length === 0 || multipleSelection.length === 0" @click="batchAdd">批量添加</el-button>
  21. </div>
  22. <el-table ref="gbChannelsTable" :data="gbChannels" border style="width: 100%" :height="winHeight" :row-key="(row)=> row.deviceId + row.channelId" @selection-change="handleSelectionChange">
  23. <el-table-column align="center" type="selection" :reserve-selection="true" width="55">
  24. </el-table-column>
  25. <el-table-column prop="channelId" label="通道编号" width="180" align="center">
  26. </el-table-column>
  27. <el-table-column prop="name" label="通道名称" show-overflow-tooltip align="center">
  28. </el-table-column>
  29. <el-table-column prop="deviceId" label="设备编号" width="180" align="center">
  30. </el-table-column>
  31. <el-table-column label="设备地址" width="180" align="center">
  32. <template slot-scope="scope">
  33. <div slot="reference" class="name-wrapper">
  34. <el-tag size="medium">{{ scope.row.hostAddress }}</el-tag>
  35. </div>
  36. </template>
  37. </el-table-column>
  38. <el-table-column prop="manufacturer" label="厂家" align="center">
  39. </el-table-column>
  40. <el-table-column label="操作" width="100" align="center" fixed="right">
  41. <template slot-scope="scope">
  42. <el-button-group>
  43. <el-button size="mini" icon="el-icon-plus" v-if="catalogId === null" @click="add(scope.row)">添加</el-button>
  44. <el-button size="mini" icon="el-icon-delete" v-if="catalogId !== null" type="danger" @click="remove(scope.row)">移除</el-button>
  45. </el-button-group>
  46. </template>
  47. </el-table-column>
  48. </el-table>
  49. <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">
  50. </el-pagination>
  51. <getCatalog ref="getCatalog" :platformId="platformId" ></getCatalog>
  52. </div>
  53. </template>
  54. <script>
  55. import getCatalog from './getCatalog'
  56. export default {
  57. name: 'chooseChannelForGb',
  58. computed: {
  59. // getPlayerShared: function () {
  60. // return {
  61. // sharedUrl: window.location.host + '/' + this.videoUrl,
  62. // sharedIframe: '<iframe src="' + window.location.host + '/' + this.videoUrl + '"></iframe>',
  63. // sharedRtmp: this.videoUrl
  64. // };
  65. // }
  66. },
  67. props: ['platformId','catalogId', 'catalogName'],
  68. created() {
  69. this.initData();
  70. },
  71. components: {
  72. getCatalog,
  73. },
  74. data() {
  75. return {
  76. gbChannels: [],
  77. gbChoosechannel:{},
  78. searchSrt: "",
  79. channelType: "",
  80. online: "",
  81. choosed: "",
  82. currentPage: 1,
  83. count: 10,
  84. total: 0,
  85. eventEnable: false,
  86. multipleSelection: [],
  87. winHeight: window.innerHeight - 400,
  88. };
  89. },
  90. watch:{
  91. platformId(newData, oldData){
  92. console.log(newData)
  93. this.getChannelList()
  94. },
  95. catalogId(newData, oldData){
  96. this.getChannelList()
  97. },
  98. },
  99. methods: {
  100. initData: function() {
  101. this.getChannelList();
  102. },
  103. currentChange: function (val) {
  104. this.currentPage = val;
  105. this.initData();
  106. },
  107. handleSizeChange: function (val) {
  108. this.count = val;
  109. console.log(val)
  110. this.initData();
  111. },
  112. add: function (row) {
  113. this.getCatalogFromUser((catalogId)=> {
  114. this.$axios({
  115. method:"post",
  116. url:"/api/platform/update_channel_for_gb",
  117. data:{
  118. platformId: this.platformId,
  119. channelReduces: [row],
  120. catalogId: catalogId
  121. }
  122. }).then((res)=>{
  123. console.log("保存成功")
  124. this.getChannelList();
  125. }).catch(function (error) {
  126. console.log(error);
  127. });
  128. })
  129. },
  130. remove: function (row) {
  131. console.log(row)
  132. this.$axios({
  133. method:"delete",
  134. url:"/api/platform/del_channel_for_gb",
  135. data:{
  136. platformId: this.platformId,
  137. channelReduces: [row]
  138. }
  139. }).then((res)=>{
  140. console.log("移除成功")
  141. this.getChannelList();
  142. }).catch(function (error) {
  143. console.log(error);
  144. });
  145. },
  146. // checkedChange: function (val) {
  147. // let that = this;
  148. // if (!that.eventEnable) {
  149. // return;
  150. // }
  151. // let newData = {};
  152. // let addData = [];
  153. // let delData = [];
  154. // if (val.length > 0) {
  155. // for (let i = 0; i < val.length; i++) {
  156. // const element = val[i];
  157. // let key = element.deviceId + "_" + element.channelId;
  158. // newData[key] = element;
  159. // if (!!!that.gbChoosechannel[key]){
  160. // addData.push(element)
  161. // }else{
  162. // delete that.gbChoosechannel[key]
  163. // }
  164. // }
  165. //
  166. // let oldKeys = Object.keys(that.gbChoosechannel);
  167. // if (oldKeys.length > 0) {
  168. // for (let i = 0; i < oldKeys.length; i++) {
  169. // const key = oldKeys[i];
  170. // delData.push(that.gbChoosechannel[key])
  171. // }
  172. // }
  173. //
  174. // }else{
  175. // let oldKeys = Object.keys(that.gbChoosechannel);
  176. // if (oldKeys.length > 0) {
  177. // for (let i = 0; i < oldKeys.length; i++) {
  178. // const key = oldKeys[i];
  179. // delData.push(that.gbChoosechannel[key])
  180. // }
  181. // }
  182. // }
  183. //
  184. // that.gbChoosechannel = newData;
  185. // if (Object.keys(addData).length >0) {
  186. // that.$axios({
  187. // method:"post",
  188. // url:"/api/platform/update_channel_for_gb",
  189. // data:{
  190. // platformId: that.platformId,
  191. // channelReduces: addData,
  192. // catalogId: that.catalogId
  193. // }
  194. // }).then((res)=>{
  195. // console.log("保存成功")
  196. // }).catch(function (error) {
  197. // console.log(error);
  198. // });
  199. // }
  200. // if (delData.length >0) {
  201. // that.$axios({
  202. // method:"delete",
  203. // url:"/api/platform/del_channel_for_gb",
  204. // data:{
  205. // platformId: that.platformId,
  206. // channelReduces: delData
  207. // }
  208. // }).then((res)=>{
  209. // console.log("移除成功")
  210. // let nodeIds = new Array();
  211. // for (let i = 0; i < delData.length; i++) {
  212. // nodeIds.push(delData[i].channelId)
  213. // }
  214. // }).catch(function (error) {
  215. // console.log(error);
  216. // });
  217. // }
  218. // },
  219. // shareAllCheckedChange: function (val) {
  220. //
  221. // },
  222. getChannelList: function () {
  223. let that = this;
  224. this.$axios({
  225. method:"get",
  226. url:`/api/platform/channel_list`,
  227. params: {
  228. page: that.currentPage,
  229. count: that.count,
  230. query: that.searchSrt,
  231. online: that.online,
  232. catalogId: that.catalogId,
  233. platformId: that.platformId,
  234. channelType: that.channelType
  235. }
  236. })
  237. .then(function (res) {
  238. if (res.data.code === 0 ) {
  239. that.total = res.data.data.total;
  240. that.gbChannels = res.data.data.list;
  241. that.gbChoosechannel = {};
  242. }
  243. // 防止出现表格错位
  244. that.$nextTick(() => {
  245. that.$refs.gbChannelsTable.doLayout();
  246. that.eventEnable = true;
  247. })
  248. })
  249. .catch(function (error) {
  250. console.log(error);
  251. });
  252. },
  253. search: function() {
  254. this.initData();
  255. },
  256. handleGBSelectionChange: function() {
  257. this.initData();
  258. },
  259. batchDel: function() {
  260. this.$confirm(`确认这${this.multipleSelection.length}个通道吗?`, '提示', {
  261. confirmButtonText: '确定',
  262. cancelButtonText: '取消',
  263. type: 'warning'
  264. }).then(() => {
  265. this.$axios({
  266. method:"delete",
  267. url:"/api/platform/del_channel_for_gb",
  268. data:{
  269. platformId: this.platformId,
  270. channelReduces: this.multipleSelection
  271. }
  272. }).then((res)=>{
  273. console.log("移除成功")
  274. this.$refs.gbChannelsTable.clearSelection()
  275. this.getChannelList();
  276. }).catch(function (error) {
  277. console.log(error);
  278. });
  279. }).catch(() => {
  280. });
  281. },
  282. batchAdd: function() {
  283. this.getCatalogFromUser((catalogId)=> {
  284. this.$axios({
  285. method: "post",
  286. url: "/api/platform/update_channel_for_gb",
  287. data: {
  288. platformId: this.platformId,
  289. channelReduces: this.multipleSelection,
  290. catalogId: catalogId,
  291. }
  292. }).then((res) => {
  293. console.log("保存成功")
  294. this.$refs.gbChannelsTable.clearSelection()
  295. this.getChannelList();
  296. }).catch(function (error) {
  297. console.log(error);
  298. });
  299. });
  300. },
  301. handleSelectionChange: function (val) {
  302. this.multipleSelection = val;
  303. },
  304. getCatalogFromUser(callback){
  305. this.$refs.getCatalog.openDialog(callback)
  306. },
  307. }
  308. };
  309. </script>
  310. <style>
  311. </style>