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">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, watch } from 'vue';
|
import { ref, onMounted, watch } from 'vue';
|
||||||
import { api } from 'src/boot/axios';
|
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import useUserStore from 'stores/user';
|
import useUserStore from 'stores/user';
|
||||||
|
|
@ -288,6 +287,13 @@ onMounted(async () => {
|
||||||
? await userStore.fetchRoleOption()
|
? await userStore.fetchRoleOption()
|
||||||
: '';
|
: '';
|
||||||
typeStats.value = await userStore.typeStats();
|
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);
|
const res = await branchStore.userStats(formData.value.userType);
|
||||||
if (res) {
|
if (res) {
|
||||||
userStats.value = res;
|
userStats.value = res;
|
||||||
|
|
@ -298,6 +304,10 @@ watch(
|
||||||
() => selectorLabel.value,
|
() => selectorLabel.value,
|
||||||
async (label) => {
|
async (label) => {
|
||||||
mapUserType(label);
|
mapUserType(label);
|
||||||
|
await userStore.fetchList({
|
||||||
|
includeBranch: true,
|
||||||
|
userType: selectorLabel.value ?? undefined,
|
||||||
|
});
|
||||||
const res = await branchStore.userStats(label);
|
const res = await branchStore.userStats(label);
|
||||||
if (res) {
|
if (res) {
|
||||||
userStats.value = res;
|
userStats.value = res;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue