GbDeviceSelect.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div id="addUser" v-loading="getDeviceListLoading">
  3. <el-dialog
  4. title="选择设备"
  5. width="40%"
  6. top="2rem"
  7. :close-on-click-modal="false"
  8. :visible.sync="showDialog"
  9. :destroy-on-close="true"
  10. @close="close()"
  11. >
  12. <div class="page-header">
  13. <div class="page-header-btn">
  14. 搜索:
  15. <el-input @input="getDeviceList" style="margin-right: 1rem; width: auto;" size="mini" placeholder="关键字"
  16. prefix-icon="el-icon-search" v-model="searchSrt" clearable></el-input>
  17. 在线状态:
  18. <el-select size="mini" style="width: 8rem; margin-right: 1rem;" @change="getDeviceList" v-model="online" placeholder="请选择"
  19. default-first-option>
  20. <el-option label="全部" value=""></el-option>
  21. <el-option label="在线" value="true"></el-option>
  22. <el-option label="离线" value="false"></el-option>
  23. </el-select>
  24. <el-button icon="el-icon-refresh-right" circle size="mini" :loading="getDeviceListLoading"
  25. @click="getDeviceList()"></el-button>
  26. </div>
  27. </div>
  28. <!--设备列表-->
  29. <el-table :data="deviceList" style="width: 100%;font-size: 12px;" :height="winHeight" header-row-class-name="table-header" @selection-change="handleSelectionChange">
  30. <el-table-column type="selection" width="55" >
  31. </el-table-column>
  32. <el-table-column prop="name" label="名称" min-width="160">
  33. </el-table-column>
  34. <el-table-column prop="deviceId" label="设备编号" min-width="200" >
  35. </el-table-column>
  36. <el-table-column prop="manufacturer" label="厂家" min-width="120" >
  37. </el-table-column>
  38. <el-table-column label="状态" min-width="120">
  39. <template slot-scope="scope">
  40. <div slot="reference" class="name-wrapper">
  41. <el-tag size="medium" v-if="scope.row.onLine">在线</el-tag>
  42. <el-tag size="medium" type="info" v-if="!scope.row.onLine">离线</el-tag>
  43. </div>
  44. </template>
  45. </el-table-column>
  46. </el-table>
  47. <el-pagination
  48. style="float: right"
  49. @size-change="handleSizeChange"
  50. @current-change="currentChange"
  51. :current-page="currentPage"
  52. :page-size="count"
  53. :page-sizes="[15, 25, 35, 50, 200, 1000, 50000]"
  54. layout="total, sizes, prev, pager, next"
  55. :total="total">
  56. </el-pagination>
  57. </el-dialog>
  58. </div>
  59. </template>
  60. <script>
  61. export default {
  62. name: "gbDeviceSelect",
  63. props: {},
  64. computed: {},
  65. data() {
  66. return {
  67. showDialog: false,
  68. deviceList: [], //设备列表
  69. currentDevice: {}, //当前操作设备对象
  70. searchSrt: "",
  71. online: null,
  72. videoComponentList: [],
  73. updateLooper: 0, //数据刷新轮训标志
  74. currentDeviceChannelsLenth: 0,
  75. winHeight: window.innerHeight - 200,
  76. currentPage: 1,
  77. count: 15,
  78. total: 0,
  79. getDeviceListLoading: false,
  80. multipleSelection: [],
  81. };
  82. },
  83. mounted() {
  84. this.initData();
  85. },
  86. methods: {
  87. initData: function () {
  88. this.getDeviceList();
  89. },
  90. currentChange: function (val) {
  91. this.currentPage = val;
  92. this.getDeviceList();
  93. },
  94. handleSizeChange: function (val) {
  95. this.count = val;
  96. this.getDeviceList();
  97. },
  98. handleSelectionChange: function (val){
  99. this.multipleSelection = val;
  100. },
  101. getDeviceList: function () {
  102. this.getDeviceListLoading = true;
  103. this.$axios({
  104. method: 'get',
  105. url: `/api/device/query/devices`,
  106. params: {
  107. page: this.currentPage,
  108. count: this.count,
  109. query: this.searchSrt,
  110. status: this.online,
  111. }
  112. }).then( (res)=> {
  113. if (res.data.code === 0) {
  114. this.total = res.data.data.total;
  115. this.deviceList = res.data.data.list;
  116. }
  117. this.getDeviceListLoading = false;
  118. }).catch( (error)=> {
  119. console.error(error);
  120. this.getDeviceListLoading = false;
  121. });
  122. },
  123. openDialog: function (callback) {
  124. this.listChangeCallback = callback;
  125. this.showDialog = true;
  126. },
  127. onSubmit: function () {
  128. },
  129. close: function () {
  130. this.showDialog = false;
  131. },
  132. }
  133. };
  134. </script>