選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

userManagementPage.vue 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <!-- eslint-disable max-len -->
  3. <div class="container">
  4. <br />
  5. <br />
  6. <div class="row">
  7. <div class="col-md-12 col-lg-8">
  8. <div class="title-box-d">
  9. <h1 class="title-d" style="text-align:left; font-size: 250%">User Management</h1>
  10. </div>
  11. </div>
  12. </div>
  13. <div class="row">
  14. <div class="col-md-2 offset-1">
  15. <button type="button" class="btn btn-b-n">Private Users</button>
  16. </div>
  17. <div class="col-md-2 offset-2">
  18. <button
  19. @click="routerGoTo('/status/agentUserManagementPage')"
  20. type="button"
  21. class="btn btn-b-n"
  22. >Agents</button>
  23. </div>
  24. </div>
  25. <div class="container">
  26. <div class="d-flex justify-content-between">
  27. <div class="p-2">
  28. <input v-model="searchItem" class="form-control" placeholder="Search ..." />
  29. </div>
  30. </div>
  31. <br />
  32. <table class="table table-bordered">
  33. <thead>
  34. <tr>
  35. <td colspan="10">
  36. <div class="myWell">
  37. <h4>Private Users</h4>
  38. </div>
  39. </td>
  40. </tr>
  41. <tr>
  42. <th>
  43. <b>ID</b>
  44. </th>
  45. <th>
  46. <b>Name</b>
  47. </th>
  48. <th>
  49. <b>Surname</b>
  50. </th>
  51. <th>
  52. <b>Cell Number</b>
  53. </th>
  54. <th>
  55. <b>Telephone Number</b>
  56. </th>
  57. <th>
  58. <b>Email</b>
  59. </th>
  60. <th>
  61. <b>Role</b>
  62. </th>
  63. <th>
  64. <b>Reset Password</b>
  65. </th>
  66. <th>
  67. <b>Modify</b>
  68. </th>
  69. <th>
  70. <b>Remove</b>
  71. </th>
  72. </tr>
  73. </thead>
  74. <tbody>
  75. <tr v-for="(item, i) in DisplayItems" :key="i">
  76. <td>{{ item.id }}</td>
  77. <td>{{ item.name }}</td>
  78. <td>{{ item.surname }}</td>
  79. <td>{{ item.cellNumber }}</td>
  80. <td>{{ item.telephone }}</td>
  81. <td>{{ item.email }}</td>
  82. <td v-if="item.user">{{ item.user.role }}</td>
  83. <td v-else></td>
  84. <td>
  85. <button type="button" class="btn" style="margin:2px; color: #60CBEB">Reset</button>
  86. </td>
  87. <td>
  88. <button
  89. type="button"
  90. data-toggle="modal"
  91. :data-target="'#myModal' + i"
  92. class="btn"
  93. style="margin:2px; color: #60CBEB"
  94. >Edit</button>
  95. <div :id="'myModal' + i" class="modal fade" role="dialog">
  96. <div class="modal-dialog modal-lg">
  97. <div class="modal-content">
  98. <div class="modal-header">
  99. <button type="button" class="close" data-dismiss="modal">&times;</button>
  100. </div>
  101. <div padding-left="20px">
  102. <Individual name="PrivateIndividual" :isAddIndividual="false" :item="item" />
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. </td>
  108. <td>
  109. <button type="button" class="btn" style="margin:2px; color: #60CBEB">Delete</button>
  110. </td>
  111. </tr>
  112. </tbody>
  113. </table>
  114. <div class="d-flex justify-content-between">
  115. <div class="p-1">{{ currentPage + ' / ' + PageCount }}</div>
  116. <div class="p-1">
  117. <BasePagination
  118. :currentPage="currentPage"
  119. :pageCount="PageCount"
  120. @nextPage="pageChangeHandle('next')"
  121. @previousPage="pageChangeHandle('previous')"
  122. @loadPage="pageChangeHandle"
  123. />
  124. </div>
  125. </div>
  126. <br />
  127. </div>
  128. </div>
  129. </template>
  130. <script>
  131. import { mapState, mapActions } from 'vuex';
  132. import _ from 'lodash';
  133. import ItemsPerPageList from '../../../assets/staticData/itemsPerPage';
  134. import BasePagination from '../../shared/basePagination.vue';
  135. import Individual from '../../user/registerPage.vue';
  136. export default {
  137. name: 'userManagementPage',
  138. components: {
  139. BasePagination,
  140. Individual,
  141. },
  142. data() {
  143. return {
  144. sortKey: '',
  145. reverse: false,
  146. searchItem: '',
  147. itemsPerPageList: ItemsPerPageList,
  148. visibleItemsPerPageCount: 0,
  149. currentPage: 1,
  150. item: {},
  151. };
  152. },
  153. methods: {
  154. ...mapActions('register', ['getIndividuals']),
  155. routerGoTo(goTo) {
  156. this.$router.push(goTo);
  157. },
  158. sortBy(sortKey) {
  159. this.reverse = this.sortKey === sortKey ? !this.reverse : false;
  160. this.sortKey = sortKey;
  161. },
  162. async pageChangeHandle(value) {
  163. console.log(value);
  164. switch (value) {
  165. case 'next':
  166. this.currentPage += 1;
  167. break;
  168. case 'previous':
  169. this.currentPage -= 1;
  170. break;
  171. default:
  172. this.currentPage = value;
  173. }
  174. },
  175. onChangeItemsPerPage() {
  176. if (this.currentPage !== 1) {
  177. this.currentPage = 1;
  178. }
  179. },
  180. },
  181. mounted() {
  182. this.getIndividuals();
  183. try {
  184. // to assign initial value to itemsPerPage
  185. if (this.itemsPerPageList && this.itemsPerPageList.length > 0) {
  186. const [startItem] = this.itemsPerPageList;
  187. this.visibleItemsPerPageCount = startItem;
  188. }
  189. } catch (error) {
  190. throw error;
  191. }
  192. },
  193. computed: {
  194. ...mapState('register', ['individuals']),
  195. SortDirection() {
  196. return this.reverse ? 'desc' : 'asc';
  197. },
  198. PageCount() {
  199. return this.visibleItemsPerPageCount !== 0
  200. ? Math.ceil(this.FilteredItems.length / this.visibleItemsPerPageCount)
  201. : 1;
  202. },
  203. FilteredItems() {
  204. const list = _.filter(this.individuals, item => Object.values(item).some(
  205. i => JSON.stringify(i)
  206. .toLowerCase()
  207. .indexOf(this.searchItem) > -1,
  208. ),);
  209. return _.orderBy(list, this.sortKey, this.SortDirection);
  210. },
  211. DisplayItems() {
  212. const list = this.FilteredItems;
  213. const startSlice = (this.currentPage - 1) * this.visibleItemsPerPageCount;
  214. let endSlice = this.currentPage * this.visibleItemsPerPageCount;
  215. if (endSlice > list.length) {
  216. endSlice = list.length;
  217. }
  218. return list.slice(startSlice, endSlice);
  219. },
  220. },
  221. };
  222. </script>
  223. <style>
  224. </style>