feat: select user type that at least have one
This commit is contained in:
parent
eb56b59f95
commit
a1167dd6a5
1 changed files with 11 additions and 1 deletions
|
|
@ -1,6 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch } from 'vue';
|
||||
import { api } from 'src/boot/axios';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import useUserStore from 'stores/user';
|
||||
|
|
@ -288,6 +287,13 @@ onMounted(async () => {
|
|||
? await userStore.fetchRoleOption()
|
||||
: '';
|
||||
typeStats.value = await userStore.typeStats();
|
||||
|
||||
const firstTypeIncludeUser = Object.entries(typeStats.value || {}).find(
|
||||
(v) => v[1] > 0,
|
||||
);
|
||||
|
||||
firstTypeIncludeUser && (selectorLabel.value = firstTypeIncludeUser[0]);
|
||||
|
||||
const res = await branchStore.userStats(formData.value.userType);
|
||||
if (res) {
|
||||
userStats.value = res;
|
||||
|
|
@ -298,6 +304,10 @@ watch(
|
|||
() => selectorLabel.value,
|
||||
async (label) => {
|
||||
mapUserType(label);
|
||||
await userStore.fetchList({
|
||||
includeBranch: true,
|
||||
userType: selectorLabel.value ?? undefined,
|
||||
});
|
||||
const res = await branchStore.userStats(label);
|
||||
if (res) {
|
||||
userStats.value = res;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue