chooseChannelForGb.vue 13 KB

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