feat: auto select current branch
This commit is contained in:
parent
dcefa3de02
commit
2dac800fad
5 changed files with 81 additions and 66 deletions
|
|
@ -1,13 +1,32 @@
|
|||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, ref, onMounted } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { Icon } from '@iconify/vue';
|
||||
import useMyBranch from 'stores/my-branch';
|
||||
import { getUserId, getRole } from 'src/services/keycloak';
|
||||
|
||||
defineProps<{
|
||||
mini?: boolean;
|
||||
}>();
|
||||
|
||||
onMounted(async () => {
|
||||
const uid = getUserId();
|
||||
const role = getRole();
|
||||
|
||||
if (!uid) return;
|
||||
|
||||
if (role?.includes('system')) {
|
||||
const result = await userBranch.fetchListOptionBranch();
|
||||
if (result && result.total > 0) currentMyBranch.value = result.result[0];
|
||||
}
|
||||
const result = await userBranch.fetchListMyBranch(uid);
|
||||
if (result && result.total > 0) currentMyBranch.value = result.result[0];
|
||||
});
|
||||
|
||||
const router = useRouter();
|
||||
const userBranch = useMyBranch();
|
||||
const { currentMyBranch } = storeToRefs(userBranch);
|
||||
|
||||
const currentRoute = ref<string>('');
|
||||
const currentPath = computed(() => {
|
||||
|
|
@ -175,10 +194,14 @@ function branchSetting() {}
|
|||
style="white-space: nowrap"
|
||||
>
|
||||
<span class="text-weight-bold">
|
||||
{{ 'ชื่อสาขาที่ 1' }}
|
||||
{{
|
||||
($i18n.locale === 'en-US'
|
||||
? currentMyBranch?.nameEN
|
||||
: currentMyBranch?.name) ?? '-'
|
||||
}}
|
||||
</span>
|
||||
<span>
|
||||
{{ 'BR1001' }}
|
||||
{{ currentMyBranch?.code ?? '-' }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue