index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container right">
  4. <div class="filter-view">
  5. <div style="flex: 1; min-width: 180px; max-width: 350px;">
  6. <el-input
  7. v-model="params.pageVo.criteria"
  8. placeholder="Search by Name, Email, Contact or Login ID"
  9. @keyup.enter.native="getList" />
  10. </div>
  11. <div>
  12. <el-button
  13. type="primary"
  14. icon="el-icon-search"
  15. @click="getList">
  16. Search
  17. </el-button>
  18. </div>
  19. <div class="filter-flex-button">
  20. <el-button
  21. type="primary"
  22. icon="el-icon-plus"
  23. @click="addRfid">
  24. Add
  25. </el-button>
  26. </div>
  27. </div>
  28. </div>
  29. <el-table
  30. v-loading="table.loading"
  31. :data="table.data"
  32. fit
  33. style="width: 100%;">
  34. <!--el-table-column
  35. label="RFID No."
  36. align="center"
  37. class-name="fixed-width">
  38. <template slot-scope="{row}">
  39. <a class="link-detail" href="javascript:void(0);" @click="viewDevice(row)">{{ row.rfidNumber }}</a>
  40. </template>
  41. </el-table-column-->
  42. <el-table-column
  43. label="RFID No."
  44. align="center"
  45. prop="rfidNumber">
  46. </el-table-column>
  47. <el-table-column
  48. label="Email Address"
  49. align="center"
  50. prop="email"
  51. class-name="fixed-width">
  52. </el-table-column>
  53. <el-table-column
  54. label="User ID"
  55. align="center"
  56. prop="userPk">
  57. </el-table-column>
  58. <el-table-column
  59. label="User Type"
  60. align="center"
  61. prop="userType">
  62. </el-table-column>
  63. <el-table-column
  64. label="Group"
  65. align="center"
  66. prop="groupName">
  67. </el-table-column>
  68. <el-table-column
  69. label="Status"
  70. align="center"
  71. prop="status"
  72. width="100px">
  73. </el-table-column>
  74. <el-table-column
  75. label="Action"
  76. align="center"
  77. class-name="fixed-width">
  78. <template slot-scope="{row}">
  79. <TableAction
  80. @edit="viewDevice(row)"
  81. @delete="handleDelete(row)"/>
  82. </template>
  83. </el-table-column>
  84. </el-table>
  85. <div class="right">
  86. <Pagination
  87. v-show="table.total > 0"
  88. :total="table.total"
  89. :page.sync="params.pageNo"
  90. :limit.sync="params.pageSize"
  91. @pagination="handlePageChange" />
  92. </div>
  93. </div>
  94. </template>
  95. <script>
  96. import Pagination from '@/components/Pagination'
  97. import TableAction from '@/components/TableAction.vue'
  98. import api from '../../http/api/rfid.js'
  99. export default {
  100. data() {
  101. return {
  102. table: {
  103. data: [],
  104. total: 0,
  105. loading: false
  106. },
  107. params: {
  108. pageNo: 1,
  109. pageSize: 10,
  110. pageVo: {
  111. criteria: ""
  112. }
  113. }
  114. }
  115. },
  116. components: { Pagination, TableAction },
  117. created() {
  118. this.getList();
  119. },
  120. methods: {
  121. getList() {
  122. this.table.loading = true;
  123. api.getRfidPages(this.params).then(res => {
  124. this.table.loading = false;
  125. this.table.total = res.total;
  126. this.table.data = res.data
  127. }).catch(err => {
  128. this.table.loading = false;
  129. this.$message.error(err)
  130. });
  131. },
  132. addRfid() {
  133. this.$router.push({
  134. path: '/rfid-card-management/add'
  135. });
  136. },
  137. viewDevice({ocppTagPk}) {
  138. this.$router.push({
  139. path: '/rfid-card-management/edit/' + ocppTagPk
  140. });
  141. },
  142. handleDelete(row) {
  143. this.$confirm('Are you sure you want to delete this rfid?', 'Delete', {
  144. confirmButtonText: 'OK',
  145. cancelButtonText: 'Cancel',
  146. type: 'warning'
  147. }).then(res => {
  148. this.deleteRfid(row.ocppTagPk)
  149. })
  150. },
  151. deleteRfid(id) {
  152. this.table.loading = true;
  153. api.deleteRfidCard({ocppTagPk: id}).then(res => {
  154. this.$message({
  155. message: 'Delete successfully!',
  156. type: 'success'
  157. });
  158. this.getList();
  159. }).catch(err => {
  160. this.$message({
  161. message: err,
  162. type: 'error'
  163. });
  164. this.table.loading = false;
  165. })
  166. },
  167. handlePageChange() {
  168. this.table.loading = true;
  169. this.getList();
  170. }
  171. }
  172. }
  173. </script>
  174. <style>
  175. .link-detail {
  176. text-decoration: underline;
  177. }
  178. </style>