|
18 | 18 | <template> |
19 | 19 | <loading-outlined v-if="loadingTable" class="main-loading-spinner" /> |
20 | 20 | <div v-else> |
21 | | - <div style="width: 100%; display: flex; margin-bottom: 10px"> |
| 21 | + <div style="width: 100%; display: flex; margin-bottom: 20px"> |
22 | 22 | <a-button type="dashed" @click="exportRolePermissions" style="width: 100%"> |
23 | 23 | <template #icon><download-outlined /></template> |
24 | 24 | {{ $t('label.export.rules') }} |
25 | 25 | </a-button> |
26 | 26 | </div> |
| 27 | + <a-input-search |
| 28 | + v-model:value="searchRule" |
| 29 | + :placeholder="$t('label.rolepermissiontab.searchbar')" |
| 30 | + background-color="gray" |
| 31 | + style="width: 100%; margin-bottom: 10px; display: inline-block" |
| 32 | + enter-button |
| 33 | + @search="searchRulePermission" |
| 34 | + /> |
27 | 35 | <div v-if="updateTable" class="loading-overlay"> |
28 | 36 | <loading-outlined /> |
29 | 37 | </div> |
| 38 | + |
30 | 39 | <div |
31 | 40 | class="rules-list ant-list ant-list-bordered" |
32 | 41 | :class="{'rules-list--overflow-hidden' : updateTable}" > |
@@ -137,7 +146,8 @@ export default { |
137 | 146 | newRuleDescription: '', |
138 | 147 | newRuleSelectError: false, |
139 | 148 | drag: false, |
140 | | - apis: [] |
| 149 | + apis: [], |
| 150 | + searchRule: '' |
141 | 151 | } |
142 | 152 | }, |
143 | 153 | created () { |
@@ -172,6 +182,7 @@ export default { |
172 | 182 | if (!this.resource.id) return |
173 | 183 | api('listRolePermissions', { roleid: this.resource.id }).then(response => { |
174 | 184 | this.rules = response.listrolepermissionsresponse.rolepermission |
| 185 | + this.totalRules = this.rules |
175 | 186 | }).catch(error => { |
176 | 187 | this.$notifyError(error) |
177 | 188 | }).finally(() => { |
@@ -258,6 +269,19 @@ export default { |
258 | 269 | hiddenElement.download = this.resource.name + '_' + this.resource.type + '.csv' |
259 | 270 | hiddenElement.click() |
260 | 271 | hiddenElement.remove() |
| 272 | + }, |
| 273 | + searchRulePermission (searchValue) { |
| 274 | + searchValue = searchValue.toLowerCase() |
| 275 | + if (!searchValue) { |
| 276 | + this.rules = this.totalRules |
| 277 | + } else { |
| 278 | + this.updateTable = true |
| 279 | + const searchRules = this.totalRules.filter((rule) => rule.rule.toLowerCase().includes(searchValue)) |
| 280 | + this.rules = searchRules |
| 281 | + setTimeout(() => { |
| 282 | + this.updateTable = false |
| 283 | + }) |
| 284 | + } |
261 | 285 | } |
262 | 286 | } |
263 | 287 | } |
|
0 commit comments