瀏覽代碼

merging

master
Kobus 5 年之前
父節點
當前提交
042bb002c9

+ 92
- 2
src/components/admin/status/agentsUserManagementPage.vue 查看文件

@@ -28,6 +28,11 @@
28 28
     <br />
29 29
     <br />
30 30
     <div class="container">
31
+      <div class="d-flex justify-content-between">
32
+        <div class="p-2">
33
+          <input v-model="searchItem" class="form-control" placeholder="Search ..." />
34
+        </div>
35
+      </div>
31 36
       <table class="table table-bordered">
32 37
         <thead>
33 38
           <tr>
@@ -62,7 +67,9 @@
62 67
         <tbody>
63 68
           <tr>
64 69
             <td colspan="10">
65
-              <h5>Agents</h5>
70
+              <div class="myWell">
71
+                <h4>Agents</h4>
72
+              </div>
66 73
             </td>
67 74
           </tr>
68 75
           <tr v-for="(item, i) in agents" :key="i">
@@ -93,18 +100,44 @@
93 100
           </tr>
94 101
         </tbody>
95 102
       </table>
103
+      <div class="d-flex justify-content-between">
104
+        <div class="p-1">{{ currentPage + ' / ' + PageCount }}</div>
105
+        <div class="p-1">
106
+          <BasePagination
107
+            :currentPage="currentPage"
108
+            :pageCount="PageCount"
109
+            @nextPage="pageChangeHandle('next')"
110
+            @previousPage="pageChangeHandle('previous')"
111
+            @loadPage="pageChangeHandle"
112
+          />
113
+        </div>
114
+      </div>
96 115
     </div>
97 116
     <br />
98 117
   </div>
99 118
 </template>
119
+
100 120
 <script>
101 121
 import { mapState, mapActions } from 'vuex';
102 122
 import axios from 'axios';
123
+import _ from 'lodash';
124
+import ItemsPerPageList from '../../../assets/staticData/itemsPerPage';
125
+import BasePagination from '../../shared/basePagination.vue';
103 126
 
104 127
 export default {
105 128
   name: 'agentManagementPage',
129
+  components: {
130
+    BasePagination,
131
+  },
106 132
   data() {
107
-    return {};
133
+    return {
134
+      sortKey: '',
135
+      reverse: false,
136
+      searchItem: '',
137
+      itemsPerPageList: ItemsPerPageList,
138
+      visibleItemsPerPageCount: 0,
139
+      currentPage: 1,
140
+    };
108 141
   },
109 142
   methods: {
110 143
     ...mapActions('register', ['getAgents']),
@@ -117,12 +150,69 @@ export default {
117 150
     routerGoTo(goTo) {
118 151
       this.$router.push(goTo);
119 152
     },
153
+    sortBy(sortKey) {
154
+      this.reverse = this.sortKey === sortKey ? !this.reverse : false;
155
+      this.sortKey = sortKey;
156
+    },
157
+    async pageChangeHandle(value) {
158
+      console.log(value);
159
+      switch (value) {
160
+        case 'next':
161
+          this.currentPage += 1;
162
+          break;
163
+        case 'previous':
164
+          this.currentPage -= 1;
165
+          break;
166
+        default:
167
+          this.currentPage = value;
168
+      }
169
+    },
170
+    onChangeItemsPerPage() {
171
+      if (this.currentPage !== 1) {
172
+        this.currentPage = 1;
173
+      }
174
+    },
120 175
   },
121 176
   mounted() {
122 177
     this.getAgents();
178
+    try {
179
+      // to assign initial value to itemsPerPage
180
+      if (this.itemsPerPageList && this.itemsPerPageList.length > 0) {
181
+        const [startItem] = this.itemsPerPageList;
182
+        this.visibleItemsPerPageCount = startItem;
183
+      }
184
+    } catch (error) {
185
+      throw error;
186
+    }
123 187
   },
124 188
   computed: {
125 189
     ...mapState('register', ['agents']),
190
+
191
+    SortDirection() {
192
+      return this.reverse ? 'desc' : 'asc';
193
+    },
194
+    PageCount() {
195
+      return this.visibleItemsPerPageCount !== 0
196
+        ? Math.ceil(this.FilteredItems.length / this.visibleItemsPerPageCount)
197
+        : 1;
198
+    },
199
+    FilteredItems() {
200
+      const list = _.filter(this.individuals, item => Object.values(item).some(
201
+          i => JSON.stringify(i)
202
+              .toLowerCase()
203
+              .indexOf(this.searchItem) > -1,
204
+        ),);
205
+      return _.orderBy(list, this.sortKey, this.SortDirection);
206
+    },
207
+    DisplayItems() {
208
+      const list = this.FilteredItems;
209
+      const startSlice = (this.currentPage - 1) * this.visibleItemsPerPageCount;
210
+      let endSlice = this.currentPage * this.visibleItemsPerPageCount;
211
+      if (endSlice > list.length) {
212
+        endSlice = list.length;
213
+      }
214
+      return list.slice(startSlice, endSlice);
215
+    },
126 216
   },
127 217
 };
128 218
 </script>

+ 94
- 6
src/components/admin/status/userManagementPage.vue 查看文件

@@ -22,9 +22,12 @@
22 22
         >Agents</button>
23 23
       </div>
24 24
     </div>
25
-    <br />
26
-    <br />
27 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>
28 31
       <table class="table table-bordered">
29 32
         <thead>
30 33
           <tr>
@@ -59,10 +62,12 @@
59 62
         <tbody>
60 63
           <tr>
61 64
             <td colspan="10">
62
-              <h5>Private Users</h5>
65
+              <div class="myWell">
66
+                <h4>Private Users</h4>
67
+              </div>
63 68
             </td>
64 69
           </tr>
65
-          <tr v-for="(item, i) in individuals" :key="i">
70
+          <tr v-for="(item, i) in DisplayItems" :key="i">
66 71
             <td>{{ item.id }}</td>
67 72
             <td>{{ item.name }}</td>
68 73
             <td>{{ item.surname }}</td>
@@ -86,29 +91,112 @@
86 91
           </tr>
87 92
         </tbody>
88 93
       </table>
94
+      <div class="d-flex justify-content-between">
95
+        <div class="p-1">{{ currentPage + ' / ' + PageCount }}</div>
96
+        <div class="p-1">
97
+          <BasePagination
98
+            :currentPage="currentPage"
99
+            :pageCount="PageCount"
100
+            @nextPage="pageChangeHandle('next')"
101
+            @previousPage="pageChangeHandle('previous')"
102
+            @loadPage="pageChangeHandle"
103
+          />
104
+        </div>
105
+      </div>
106
+      <br />
89 107
     </div>
90
-    <br />
91 108
   </div>
92 109
 </template>
110
+
93 111
 <script>
94 112
 import { mapState, mapActions } from 'vuex';
113
+import _ from 'lodash';
114
+import ItemsPerPageList from '../../../assets/staticData/itemsPerPage';
115
+import BasePagination from '../../shared/basePagination.vue';
95 116
 
96 117
 export default {
97 118
   name: 'userManagementPage',
119
+  components: {
120
+    BasePagination,
121
+  },
98 122
   data() {
99
-    return {};
123
+    return {
124
+      sortKey: '',
125
+      reverse: false,
126
+      searchItem: '',
127
+      itemsPerPageList: ItemsPerPageList,
128
+      visibleItemsPerPageCount: 0,
129
+      currentPage: 1,
130
+    };
100 131
   },
101 132
   methods: {
102 133
     ...mapActions('register', ['getIndividuals']),
103 134
     routerGoTo(goTo) {
104 135
       this.$router.push(goTo);
105 136
     },
137
+    sortBy(sortKey) {
138
+      this.reverse = this.sortKey === sortKey ? !this.reverse : false;
139
+      this.sortKey = sortKey;
140
+    },
141
+    async pageChangeHandle(value) {
142
+      console.log(value);
143
+      switch (value) {
144
+        case 'next':
145
+          this.currentPage += 1;
146
+          break;
147
+        case 'previous':
148
+          this.currentPage -= 1;
149
+          break;
150
+        default:
151
+          this.currentPage = value;
152
+      }
153
+    },
154
+    onChangeItemsPerPage() {
155
+      if (this.currentPage !== 1) {
156
+        this.currentPage = 1;
157
+      }
158
+    },
106 159
   },
107 160
   mounted() {
108 161
     this.getIndividuals();
162
+    try {
163
+      // to assign initial value to itemsPerPage
164
+      if (this.itemsPerPageList && this.itemsPerPageList.length > 0) {
165
+        const [startItem] = this.itemsPerPageList;
166
+        this.visibleItemsPerPageCount = startItem;
167
+      }
168
+    } catch (error) {
169
+      throw error;
170
+    }
109 171
   },
110 172
   computed: {
111 173
     ...mapState('register', ['individuals']),
174
+
175
+    SortDirection() {
176
+      return this.reverse ? 'desc' : 'asc';
177
+    },
178
+    PageCount() {
179
+      return this.visibleItemsPerPageCount !== 0
180
+        ? Math.ceil(this.FilteredItems.length / this.visibleItemsPerPageCount)
181
+        : 1;
182
+    },
183
+    FilteredItems() {
184
+      const list = _.filter(this.individuals, item => Object.values(item).some(
185
+          i => JSON.stringify(i)
186
+              .toLowerCase()
187
+              .indexOf(this.searchItem) > -1,
188
+        ),);
189
+      return _.orderBy(list, this.sortKey, this.SortDirection);
190
+    },
191
+    DisplayItems() {
192
+      const list = this.FilteredItems;
193
+      const startSlice = (this.currentPage - 1) * this.visibleItemsPerPageCount;
194
+      let endSlice = this.currentPage * this.visibleItemsPerPageCount;
195
+      if (endSlice > list.length) {
196
+        endSlice = list.length;
197
+      }
198
+      return list.slice(startSlice, endSlice);
199
+    },
112 200
   },
113 201
 };
114 202
 </script>

+ 0
- 11
src/components/shared/navBar.vue 查看文件

@@ -192,17 +192,6 @@
192 192
               </span>
193 193
               <span v-else></span>
194 194
             </li>
195
-            <li class="nav-item dropdown" v-if="!isLoggedIn">
196
-              <a
197
-                class="nav-link"
198
-                @click="routerGoTo('/status/agentUserManagementPage')"
199
-                id="navbarDropdown"
200
-                role="button"
201
-                data-toggle="dropdown"
202
-                aria-haspopup="true"
203
-                aria-expanded="false"
204
-              >Test</a>
205
-            </li>
206 195
           </ul>
207 196
         </div>
208 197
       </div>

Loading…
取消
儲存