CloudRecordChannelList.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div class="box box-primary ids">
  3. <div class="box-header">
  4. <h4 class="text-primary text-center">云端录像通道列表</h4>
  5. </div>
  6. <div class="box-body">
  7. <div class="form-inline">
  8. <div class="form-group form-group-sm">
  9. <label>搜索</label>
  10. <input type="text" class="form-control" placeholder="关键字" v-model.trim="q" @keydown.enter.prevent ref="q">
  11. </div>
  12. </div>
  13. <br>
  14. <div class="clearfix"></div>
  15. <el-table :data="pageData" stripe :default-sort="{prop: 'serial', order: 'ascending'}" @sort-change="sortChange">
  16. <el-table-column min-width="250" label="设备国标编号" prop="serial" show-overflow-tooltip sortable="custom"></el-table-column>
  17. <el-table-column min-width="250" label="通道国标编号" prop="code" show-overflow-tooltip sortable="custom"></el-table-column>
  18. <!-- <el-table-column min-width="200" label="通道名称" prop="name" show-overflow-tooltip></el-table-column> -->
  19. <el-table-column min-width="160" label="操作" :fixed="!isMobile() ? 'right' : undefined">
  20. <template slot-scope="scope">
  21. <div class="btn-group btn-group-xs">
  22. <router-link :to="`/cloudrecord/timeview/${scope.row.serial}/${scope.row.code}`" class="btn btn-info">
  23. <i class="fa fa-file-video-o"></i> 查看录像
  24. </router-link>
  25. <a role="button" class="btn btn-danger" @click.prevent="remove(scope.row)" v-if="hasAnyRole(serverInfo, userInfo, '管理员')">
  26. <i class="fa fa-remove"></i> 删除
  27. </a>
  28. </div>
  29. </template>
  30. </el-table-column>
  31. </el-table>
  32. </div>
  33. <div class="box-footer clearfix" v-if="total > 0">
  34. <el-pagination layout="prev,pager,next" class="pull-right" :total="total" :page-size.sync="pageSize" :current-page.sync="page"></el-pagination>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import Vue from 'vue'
  40. import {
  41. mapState
  42. } from 'vuex'
  43. import _ from 'lodash'
  44. import $ from 'jquery'
  45. import moment from 'moment'
  46. export default {
  47. data() {
  48. return {
  49. pageSize: 10,
  50. q: "",
  51. page: 1,
  52. pageData: [],
  53. total: 0,
  54. sort: '',
  55. order: ''
  56. }
  57. },
  58. mounted() {
  59. // this.$refs['q'].focus();
  60. // this.load(); //load when sort change
  61. },
  62. computed: {
  63. ...mapState(['serverInfo', 'userInfo'])
  64. },
  65. methods: {
  66. ready(){
  67. this.$watch('q', function() {
  68. this.doDelaySearch();
  69. });
  70. this.$watch('page', function(val) {
  71. this.doSearch(val);
  72. });
  73. },
  74. load() {
  75. $.get('/api/v1/cloudrecord/querychannels', {
  76. start: (this.page - 1) * this.pageSize,
  77. limit: this.pageSize,
  78. q: this.q,
  79. sort: this.sort,
  80. order: this.order
  81. }).then(data => {
  82. this.pageData = data.rows;
  83. this.total = data.total;
  84. })
  85. },
  86. sortChange(data) {
  87. this.sort = data.prop;
  88. this.order = data.order;
  89. this.load();
  90. },
  91. selectDevice(id) {
  92. this.$emit("select-device", id);
  93. },
  94. doSearch(page = 1) {
  95. var query = {};
  96. if (this.q) query["q"] = this.q;
  97. this.$router.replace({
  98. path: `/cloudrecord/${page}`,
  99. query: query
  100. });
  101. },
  102. doDelaySearch: _.debounce(function () {
  103. this.doSearch();
  104. }, 500),
  105. async remove(row) {
  106. this.$confirm(`删除 ${row.name} ,会将设备所有录像删除,确认继续?`, '提示').then(() => {
  107. $.get('/api/v1/cloudrecord/removechannel', {
  108. serial: row.serial,
  109. code: row.code,
  110. }).always(() => {
  111. this.load();
  112. })
  113. }).catch(() => {})
  114. }
  115. },
  116. beforeRouteEnter(to, from, next) {
  117. next(vm => {
  118. vm.q = to.query.q || "";
  119. vm.page = parseInt(to.params.page) || 1;
  120. vm.ready();
  121. })
  122. },
  123. beforeRouteUpdate(to, from, next) {
  124. next();
  125. this.$nextTick(() => {
  126. this.q = to.query.q || "";
  127. this.page = parseInt(to.params.page) || 1;
  128. this.pageData = [];
  129. this.load();
  130. })
  131. }
  132. }
  133. </script>