diff --git a/CHANGELOG.md b/CHANGELOG.md index f4a99672..0a7193c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,12 @@ - 流程表达式 follow后端更新 - websocket功能(默认关闭) - useVbenForm 增加 TimeRangePicker(时间区间选择) 组件 +- 字典(DictTag)支持fallback属性(未匹配到字典项时的回显) **REFACTOR** - Modal/Drawer中使用VxeTable tooltip需要设置更高的z-index 防止被遮挡 +- 字典(DictTag)使用tsx写法重构 **OTHERS** diff --git a/apps/web-antd/src/components/dict/src/index.vue b/apps/web-antd/src/components/dict/src/index.vue index 1edd1274..8078f095 100644 --- a/apps/web-antd/src/components/dict/src/index.vue +++ b/apps/web-antd/src/components/dict/src/index.vue @@ -1,62 +1,134 @@ - - - diff --git a/apps/web-antd/src/components/dict/src/type.d.ts b/apps/web-antd/src/components/dict/src/type.d.ts new file mode 100644 index 00000000..dcc96dac --- /dev/null +++ b/apps/web-antd/src/components/dict/src/type.d.ts @@ -0,0 +1,5 @@ +/** + * fallback的渲染 + * 可返回 字符串/Vnode + */ +export type DictFallback = ((current: number | string) => VNode) | string; diff --git a/apps/web-antd/src/utils/render.tsx b/apps/web-antd/src/utils/render.tsx index 419daf31..0a7f9931 100644 --- a/apps/web-antd/src/utils/render.tsx +++ b/apps/web-antd/src/utils/render.tsx @@ -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 ; } + export function renderIconSpan( icon: ComponentType, value: string,