From c37e46cff4018a315c1e53449c0e4bd8becff751 Mon Sep 17 00:00:00 2001 From: Cindy Chang Date: Thu, 8 Aug 2024 16:37:03 +0800 Subject: [PATCH] WIP #325 --- src/stores/acctMgmt.ts | 1 + .../AccountAdmin/AccountAdmin.vue | 19 ++++++++++--------- .../ModalAccountEditCreate.vue | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/stores/acctMgmt.ts b/src/stores/acctMgmt.ts index c8fd62b..48c2473 100644 --- a/src/stores/acctMgmt.ts +++ b/src/stores/acctMgmt.ts @@ -60,6 +60,7 @@ export default defineStore('acctMgmtStore', { */ setCurrentViewingUser(username: string) { const userFind: User | undefined = this.allUserAccoutList.find(user => user.username === username); + console.log('userFind', userFind); this.currentViewingUser = userFind || { username: '', detail: {} }; }, /** diff --git a/src/views/AccountManagement/AccountAdmin/AccountAdmin.vue b/src/views/AccountManagement/AccountAdmin/AccountAdmin.vue index 2c4fafc..3f381bd 100644 --- a/src/views/AccountManagement/AccountAdmin/AccountAdmin.vue +++ b/src/views/AccountManagement/AccountAdmin/AccountAdmin.vue @@ -173,16 +173,16 @@ export default { }; const moveCurrentLoginUserToFirstRow = () => { - const currentLoginUsername = loginUserData.value.username; if(infiniteAcctData.value && infiniteAcctData.value.length){ - const index = allAccountResponsive.value.findIndex(user => user.username === currentLoginUsername); - - if (index !== -1) { - // 移除匹配的對象(現正登入的使用者)並將其插入到 infiniteAcctData 陣列的第一位 - const [loginUser] = allAccountResponsive.value[index]; - infiniteAcctData.value.unshift(loginUser); + const loginUser = acctMgmtStore.allUserAccoutList.find(user => user.username === loginUserData.value.username); + const index = infiniteAcctData.value.findIndex(user => user.username=== loginUserData.value.username); + if(loginUser){ + infiniteAcctData.value.unshift(infiniteAcctData.value.splice(index, 1)[0]); + console.log('第一個infiniteAcctData.value[0]', infiniteAcctData.value[0], 'loginUserData.value.username', loginUserData.value.username); + console.log('infiniteAcctData.value[index]',infiniteAcctData.value[index] ); } - } + } + }; const moveJustCreateUserToFirstRow = () => { @@ -190,7 +190,7 @@ export default { const index = acctMgmtStore.allUserAccoutList.findIndex(user => user.username === acctMgmtStore.justCreateUsername); if (index !== -1) { // 移除匹配的對象(剛剛新增的使用者)並將其插入到陣列的第一位 - const [justCreateUser] = acctMgmtStore.allUserAccoutList.splice(index, 1); + const [justCreateUser] = acctMgmtStore.allUserAccoutList[index]; infiniteAcctData.value.unshift(justCreateUser); } } @@ -248,6 +248,7 @@ export default { }; const onEditButtonClick = userNameToEdit => { + console.log('onEditButtonClick userNameToEdit', userNameToEdit); acctMgmtStore.setCurrentViewingUser(userNameToEdit); modalStore.openModal(MODAL_ACCT_EDIT); } diff --git a/src/views/AccountManagement/ModalAccountEditCreate.vue b/src/views/AccountManagement/ModalAccountEditCreate.vue index 89541d9..9b21b91 100644 --- a/src/views/AccountManagement/ModalAccountEditCreate.vue +++ b/src/views/AccountManagement/ModalAccountEditCreate.vue @@ -179,7 +179,7 @@ export default defineComponent({ const isEditable = ref(true); - // 自從加入這段 watch 之後,填寫密碼欄位之時,就不會胡亂清空掉 account 或是 full name 蘭為了。 + // 自從加入這段 watch 之後,填寫密碼欄位之時,就不會胡亂清空掉 account 或是 full name 欄位了。 watch(whichCurrentModal, (newVal) => { if (newVal === MODAL_CREATE_NEW) { inputUserAccount.value = '';