mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-03-13 07:20:52 +08:00
feat: 字典(DictTag)支持fallback属性(未匹配到字典项时的回显)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { Component as ComponentType } from 'vue';
|
||||
|
||||
import type { DictData } from '#/api/system/dict/dict-data-model';
|
||||
import type { DictFallback } from '#/components/dict/src/type';
|
||||
|
||||
import { h } from 'vue';
|
||||
|
||||
@@ -149,16 +150,26 @@ export function renderDictTags(
|
||||
);
|
||||
}
|
||||
|
||||
export interface RenderDictOptions {
|
||||
fallback?: DictFallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示字典标签 一般是table使用
|
||||
* @param value 值
|
||||
* @param dictName dictName
|
||||
* @returns tag
|
||||
*/
|
||||
export function renderDict(value: number | string, dictName: string) {
|
||||
export function renderDict(
|
||||
value: number | string,
|
||||
dictName: string,
|
||||
options?: RenderDictOptions,
|
||||
) {
|
||||
const { fallback } = options ?? {};
|
||||
const dictInfo = getDictOptions(dictName);
|
||||
return renderDictTag(value, dictInfo);
|
||||
return <DictTag dicts={dictInfo} fallback={fallback} value={value}></DictTag>;
|
||||
}
|
||||
|
||||
export function renderIconSpan(
|
||||
icon: ComponentType,
|
||||
value: string,
|
||||
|
||||
Reference in New Issue
Block a user