Debounce dashboard user project search

This commit is contained in:
sas.fajri
2026-05-08 09:57:19 +07:00
parent 85f8b0fae0
commit b6969acc37
2 changed files with 15 additions and 3 deletions

View File

@@ -97,11 +97,17 @@ module.exports = {
this.password = ''
}
},
projectKeyword(val) {
this.$store.dispatch('dashboard_user/search_project', { search: val || '' })
projectKeyword(val, old) {
let next = (val || '').trim()
let prev = (old || '').trim()
if (next === prev) return
this.thrSearchProject(next)
}
},
methods: {
thrSearchProject: _.debounce(function(keyword) {
this.$store.dispatch('dashboard_user/search_project', { search: keyword || '' })
}, 300),
closeDialogSuccess() {
this.$store.commit('dashboard_user/update_dialog_success', false)
this.refreshList()

View File

@@ -72,8 +72,11 @@ module.exports = {
projectSearch: {
get() { return this.$store.state.dashboard_user.project_keyword },
set(val) {
let next = (val || '').trim()
let prev = (this.$store.state.dashboard_user.project_keyword || '').trim()
if (next === prev) return
this.$store.commit('dashboard_user/update_project_keyword', val)
this.$store.dispatch('dashboard_user/search_project', { search: val || '' })
this.thrSearchProject(next)
}
},
projectItems() {
@@ -85,6 +88,9 @@ module.exports = {
}
},
methods: {
thrSearchProject: _.debounce(function(keyword) {
this.$store.dispatch('dashboard_user/search_project', { search: keyword || '' })
}, 300),
doSearch() {
this.$store.dispatch('dashboard_user/search', {
username: this.username || '',