refactor: replace requestClient with useDictStore for fetching dictionary options in api-dict component

pull/54/head
chenminjie 2024-11-29 18:32:26 +08:00
parent 3938f1bdda
commit 9f649b9565
1 changed files with 5 additions and 4 deletions

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, type PropType } from 'vue'; import { computed, type PropType } from 'vue';
import { requestClient } from '#/api/request'; import { useDictStore } from '@vben/stores';
import { ApiCheckboxGroup, ApiRadioGroup, ApiSelect } from '..'; import { ApiCheckboxGroup, ApiRadioGroup, ApiSelect } from '..';
@ -42,9 +42,10 @@ const DictComponent = computed(() => {
return ApiSelect; return ApiSelect;
}); });
const fetch = () => { const fetch = () => {
return requestClient.post('/sys/dict/getByDictType', { return new Promise<OptionsItem[]>((resolve) => {
dictType: props.code, const dict = useDictStore().getDictOptions(props.code!);
...props.params, const options: OptionsItem[] = dict as OptionsItem[];
resolve(options);
}); });
}; };
</script> </script>