refactor: 优化数据加载逻辑.

This commit is contained in:
lijiahangmax
2023-12-02 23:36:02 +08:00
parent 9f35fb855d
commit a22f30a8b4
19 changed files with 155 additions and 117 deletions

View File

@@ -45,12 +45,14 @@
//
onBeforeMount(() => {
optionData.value = cacheStore.roles.map(s => {
return {
label: `${s.name} (${s.code})`,
disabled: s.status === RoleStatus.DISABLED,
value: s.id,
};
cacheStore.loadRoles().then(roles => {
optionData.value = roles.map(s => {
return {
label: `${s.name} (${s.code})`,
disabled: s.status === RoleStatus.DISABLED,
value: s.id,
};
});
});
});

View File

@@ -18,7 +18,7 @@
<script lang="ts" setup>
import type { PropType } from 'vue';
import type { SelectOptionData } from '@arco-design/web-vue';
import { computed, ref, onBeforeMount } from 'vue';
import { computed, ref, onMounted } from 'vue';
import { useCacheStore } from '@/store';
import { labelFilter } from '@/types/form';
@@ -43,12 +43,15 @@
const optionData = ref<Array<SelectOptionData>>([]);
//
onBeforeMount(() => {
optionData.value = cacheStore.users.map(s => {
return {
label: `${s.nickname} (${s.username})`,
value: s.id,
};
onMounted(() => {
//
cacheStore.loadUsers().then(users => {
optionData.value = users.map(s => {
return {
label: `${s.nickname} (${s.username})`,
value: s.id,
};
});
});
});