|
|
@@ -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,21 +100,48 @@
|
|
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('registerIndividual', ['getAgents']),
|
|
|
144
|
+
|
|
111
|
145
|
addNewAgent({ commit }) {
|
|
112
|
146
|
axios
|
|
113
|
147
|
.post('/api/agent')
|
|
|
@@ -117,12 +151,69 @@ export default {
|
|
117
|
151
|
routerGoTo(goTo) {
|
|
118
|
152
|
this.$router.push(goTo);
|
|
119
|
153
|
},
|
|
|
154
|
+ sortBy(sortKey) {
|
|
|
155
|
+ this.reverse = this.sortKey === sortKey ? !this.reverse : false;
|
|
|
156
|
+ this.sortKey = sortKey;
|
|
|
157
|
+ },
|
|
|
158
|
+ async pageChangeHandle(value) {
|
|
|
159
|
+ console.log(value);
|
|
|
160
|
+ switch (value) {
|
|
|
161
|
+ case 'next':
|
|
|
162
|
+ this.currentPage += 1;
|
|
|
163
|
+ break;
|
|
|
164
|
+ case 'previous':
|
|
|
165
|
+ this.currentPage -= 1;
|
|
|
166
|
+ break;
|
|
|
167
|
+ default:
|
|
|
168
|
+ this.currentPage = value;
|
|
|
169
|
+ }
|
|
|
170
|
+ },
|
|
|
171
|
+ onChangeItemsPerPage() {
|
|
|
172
|
+ if (this.currentPage !== 1) {
|
|
|
173
|
+ this.currentPage = 1;
|
|
|
174
|
+ }
|
|
|
175
|
+ },
|
|
120
|
176
|
},
|
|
121
|
177
|
mounted() {
|
|
122
|
178
|
this.getAgents();
|
|
|
179
|
+ try {
|
|
|
180
|
+ // to assign initial value to itemsPerPage
|
|
|
181
|
+ if (this.itemsPerPageList && this.itemsPerPageList.length > 0) {
|
|
|
182
|
+ const [startItem] = this.itemsPerPageList;
|
|
|
183
|
+ this.visibleItemsPerPageCount = startItem;
|
|
|
184
|
+ }
|
|
|
185
|
+ } catch (error) {
|
|
|
186
|
+ throw error;
|
|
|
187
|
+ }
|
|
123
|
188
|
},
|
|
124
|
189
|
computed: {
|
|
125
|
190
|
...mapState('registerIndividual', ['agents']),
|
|
|
191
|
+
|
|
|
192
|
+ SortDirection() {
|
|
|
193
|
+ return this.reverse ? 'desc' : 'asc';
|
|
|
194
|
+ },
|
|
|
195
|
+ PageCount() {
|
|
|
196
|
+ return this.visibleItemsPerPageCount !== 0
|
|
|
197
|
+ ? Math.ceil(this.FilteredItems.length / this.visibleItemsPerPageCount)
|
|
|
198
|
+ : 1;
|
|
|
199
|
+ },
|
|
|
200
|
+ FilteredItems() {
|
|
|
201
|
+ const list = _.filter(this.individuals, item => Object.values(item).some(
|
|
|
202
|
+ i => JSON.stringify(i)
|
|
|
203
|
+ .toLowerCase()
|
|
|
204
|
+ .indexOf(this.searchItem) > -1,
|
|
|
205
|
+ ),);
|
|
|
206
|
+ return _.orderBy(list, this.sortKey, this.SortDirection);
|
|
|
207
|
+ },
|
|
|
208
|
+ DisplayItems() {
|
|
|
209
|
+ const list = this.FilteredItems;
|
|
|
210
|
+ const startSlice = (this.currentPage - 1) * this.visibleItemsPerPageCount;
|
|
|
211
|
+ let endSlice = this.currentPage * this.visibleItemsPerPageCount;
|
|
|
212
|
+ if (endSlice > list.length) {
|
|
|
213
|
+ endSlice = list.length;
|
|
|
214
|
+ }
|
|
|
215
|
+ return list.slice(startSlice, endSlice);
|
|
|
216
|
+ },
|
|
126
|
217
|
},
|
|
127
|
218
|
};
|
|
128
|
219
|
</script>
|