From a6a1d4edf37fe49c545d363cf990560c445b1631 Mon Sep 17 00:00:00 2001 From: "sas.fajri" Date: Fri, 8 May 2026 09:53:32 +0700 Subject: [PATCH] Align dashboard user search with staff pattern --- .../components/oneDashboardUserMcuList.vue | 21 ++----------------- .../modules/dashboard_user.js | 21 ++----------------- 2 files changed, 4 insertions(+), 38 deletions(-) diff --git a/test/vuex/dashboard-user-mcu/components/oneDashboardUserMcuList.vue b/test/vuex/dashboard-user-mcu/components/oneDashboardUserMcuList.vue index cbf1e53..7c45f6b 100644 --- a/test/vuex/dashboard-user-mcu/components/oneDashboardUserMcuList.vue +++ b/test/vuex/dashboard-user-mcu/components/oneDashboardUserMcuList.vue @@ -38,9 +38,6 @@ -
- -
@@ -64,10 +61,6 @@ module.exports = { computed: { users() { return this.$store.state.dashboard_user.users }, isLoading() { return this.$store.state.dashboard_user.search_status == 1 }, - totalPages() { - let p = this.$store.state.dashboard_user.total_pages - return p > 0 ? p : 1 - }, username: { get() { return this.$store.state.dashboard_user.search_username }, set(val) { this.$store.commit('dashboard_user/update_search_username', val) } @@ -89,24 +82,14 @@ module.exports = { return Object.assign({}, p, { label: p.project_number + ' - ' + p.project_name }) }) return base.concat(records) - }, - pageSync: { - get() { return this.$store.state.dashboard_user.page }, - set(val) { - let nextPage = Number(val) || 1 - let currentPage = Number(this.$store.state.dashboard_user.page) || 1 - if (nextPage === currentPage) return - this.$store.commit('dashboard_user/update_page', nextPage) - this.doSearch(nextPage) - } } }, methods: { - doSearch(page) { + doSearch() { this.$store.dispatch('dashboard_user/search', { username: this.username || '', project: this.project && this.project.mcu_id ? this.project.mcu_id : 'all', - page: page || 1, + page: 1, limit: this.$store.state.dashboard_user.limit }) }, diff --git a/test/vuex/dashboard-user-mcu/modules/dashboard_user.js b/test/vuex/dashboard-user-mcu/modules/dashboard_user.js index ea72b7d..38b47ea 100644 --- a/test/vuex/dashboard-user-mcu/modules/dashboard_user.js +++ b/test/vuex/dashboard-user-mcu/modules/dashboard_user.js @@ -13,8 +13,6 @@ export default { limit: 20, total_rows: 0, total_pages: 0, - last_search_signature: '', - last_search_at: 0, search_status: 0, save_status: 0, save_error_message: '', @@ -32,8 +30,6 @@ export default { update_limit(state, val) { state.limit = val }, update_total_rows(state, val) { state.total_rows = val }, update_total_pages(state, val) { state.total_pages = val }, - update_last_search_signature(state, val) { state.last_search_signature = val }, - update_last_search_at(state, val) { state.last_search_at = val }, update_search_status(state, val) { state.search_status = val }, update_save_status(state, val) { state.save_status = val }, update_save_error_message(state, val) { state.save_error_message = val }, @@ -42,23 +38,10 @@ export default { }, actions: { async search(context, prm) { - let normalized = { - username: (prm && prm.username ? prm.username : '').trim(), - project: (prm && prm.project ? prm.project : 'all'), - page: Number(prm && prm.page ? prm.page : context.state.page) || 1, - limit: Number(prm && prm.limit ? prm.limit : context.state.limit) || 20 - } - let signature = JSON.stringify(normalized) - let now = Date.now() - if (signature === context.state.last_search_signature && (now - context.state.last_search_at) < 1000) { - return { status: 'SKIP' } - } - context.commit('update_last_search_signature', signature) - context.commit('update_last_search_at', now) context.commit('update_search_status', 1) try { - let payload = Object.assign({}, normalized, { token: one_token() }) - let resp = await api.search(payload) + prm.token = one_token() + let resp = await api.search(prm) if (resp.status != 'OK') { context.commit('update_search_status', 3) context.commit('update_save_error_message', resp.message)