mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
chore: 优化字典hooks使用
This commit is contained in:
@ -40,6 +40,11 @@ export function useDict(dictType: string, immediate: boolean = true) {
|
||||
options.value = data.value.map(dict => ({ label: dict.dictLabel!, value: dict.dictValue! }));
|
||||
}
|
||||
|
||||
function transformDictData(dictValue: string): Api.System.DictData | undefined {
|
||||
if (!data.value.length || !dictValue) return undefined;
|
||||
return data.value.find(dict => dict.dictValue === dictValue);
|
||||
}
|
||||
|
||||
if (immediate) {
|
||||
getData().then(() => {
|
||||
getRecord();
|
||||
@ -64,6 +69,7 @@ export function useDict(dictType: string, immediate: boolean = true) {
|
||||
options,
|
||||
getData,
|
||||
getRecord,
|
||||
getOptions
|
||||
getOptions,
|
||||
transformDictData
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user