#334 fixed v-if=isAdmin
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<ul class="w-full min-h-10">
|
<ul class="w-full min-h-10">
|
||||||
<!-- 這裡不使用迴圈是因為src值用變數的話會沒辦法顯示svg -->
|
<!-- 這裡不使用迴圈是因為src值用變數的話會沒辦法顯示svg -->
|
||||||
<li id="btn_acct_mgmt"
|
<li v-if="isAdmin" id="btn_acct_mgmt"
|
||||||
class="w-full h-[40px] flex py-2 px-4 hover:text-[#000000] hover:bg-[#F1F5F9] cursor-pointer
|
class="w-full h-[40px] flex py-2 px-4 hover:text-[#000000] hover:bg-[#F1F5F9] cursor-pointer
|
||||||
items-center" @click="onBtnAcctMgmtClick">
|
items-center" @click="onBtnAcctMgmtClick">
|
||||||
<span class="w-[24px] h-[24px] flex"><img src="@/assets/icon-crown.svg" alt="accountManagement"></span>
|
<span class="w-[24px] h-[24px] flex"><img src="@/assets/icon-crown.svg" alt="accountManagement"></span>
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { computed, } from 'vue';
|
import { computed, onMounted, ref, } from 'vue';
|
||||||
import { mapActions, mapState, storeToRefs } from 'pinia';
|
import { mapActions, mapState, storeToRefs } from 'pinia';
|
||||||
import i18next from '@/i18n/i18n';
|
import i18next from '@/i18n/i18n';
|
||||||
import LoginStore from '@/stores/login.ts';
|
import LoginStore from '@/stores/login.ts';
|
||||||
@@ -42,6 +42,7 @@ import { leaveFilter, leaveConformance } from '@/module/alertModal.js';
|
|||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
const { logOut } = LoginStore();
|
const { logOut } = LoginStore();
|
||||||
|
const loginStore = LoginStore();
|
||||||
const allMapDataStore = AllMapDataStore();
|
const allMapDataStore = AllMapDataStore();
|
||||||
const conformanceStore = ConformanceStore();
|
const conformanceStore = ConformanceStore();
|
||||||
const acctMgmtStore = AcctMgmtStore();
|
const acctMgmtStore = AcctMgmtStore();
|
||||||
@@ -49,11 +50,31 @@ export default {
|
|||||||
const { conformanceLogTempCheckId } = storeToRefs(conformanceStore);
|
const { conformanceLogTempCheckId } = storeToRefs(conformanceStore);
|
||||||
|
|
||||||
const isAcctMenuOpen = computed(() => acctMgmtStore.isAcctMenuOpen);
|
const isAcctMenuOpen = computed(() => acctMgmtStore.isAcctMenuOpen);
|
||||||
|
const loginUserData = ref(null);
|
||||||
|
const currentViewingUserDetail = computed(() => acctMgmtStore.currentViewingUser.detail);
|
||||||
|
const isAdmin = ref(false);
|
||||||
|
|
||||||
return { logOut, tempFilterId,
|
const getIsAdminValue = async () => {
|
||||||
|
await loginStore.getUserData();
|
||||||
|
loginUserData.value = loginStore.userData;
|
||||||
|
await acctMgmtStore.getUserDetail(loginUserData.value.username);
|
||||||
|
if(currentViewingUserDetail.value.roles.find(role => role.code === 'admin')) {
|
||||||
|
isAdmin.value = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await getIsAdminValue();
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
logOut,
|
||||||
|
tempFilterId,
|
||||||
conformanceLogTempCheckId,
|
conformanceLogTempCheckId,
|
||||||
allMapDataStore, conformanceStore,
|
allMapDataStore,
|
||||||
|
conformanceStore,
|
||||||
isAcctMenuOpen,
|
isAcctMenuOpen,
|
||||||
|
isAdmin,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ export default {
|
|||||||
const { conformanceLogTempCheckId, conformanceFilterTempCheckId, conformanceFileName } = storeToRefs(conformanceStore);
|
const { conformanceLogTempCheckId, conformanceFilterTempCheckId, conformanceFileName } = storeToRefs(conformanceStore);
|
||||||
|
|
||||||
const toggleIsAcctMenuOpen = () => {
|
const toggleIsAcctMenuOpen = () => {
|
||||||
console.log('head clicked', );
|
|
||||||
acctMgmtStore.toggleIsAcctMenuOpen();
|
acctMgmtStore.toggleIsAcctMenuOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export default defineStore('acctMgmtStore', {
|
|||||||
isAcctMenuOpen: false,
|
isAcctMenuOpen: false,
|
||||||
currentViewingUser: {
|
currentViewingUser: {
|
||||||
username: '',
|
username: '',
|
||||||
detail: {} as EditDetail,
|
detail: {},
|
||||||
} as User,
|
} as User,
|
||||||
response: {
|
response: {
|
||||||
deleteAccount: null,
|
deleteAccount: null,
|
||||||
@@ -60,7 +60,6 @@ export default defineStore('acctMgmtStore', {
|
|||||||
*/
|
*/
|
||||||
setCurrentViewingUser(username: string) {
|
setCurrentViewingUser(username: string) {
|
||||||
const userFind: User | undefined = this.allUserAccoutList.find(user => user.username === username);
|
const userFind: User | undefined = this.allUserAccoutList.find(user => user.username === username);
|
||||||
console.log('userFind', userFind);
|
|
||||||
this.currentViewingUser = userFind || { username: '', detail: {} };
|
this.currentViewingUser = userFind || { username: '', detail: {} };
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user