refactor: replace requestClient with useDictStore for fetching dictionary options in api-dict component
parent
3938f1bdda
commit
9f649b9565
|
|
@ -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>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue