From 7e6105d6493458865c43dbf8b839f4f4f606c085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E4=BB=99=E9=83=BD=E6=B2=A1=E7=94=A8?= <615206459@qq.com> Date: Thu, 14 Dec 2023 21:53:22 +0800 Subject: [PATCH] =?UTF-8?q?table=20dict=20=E6=B7=BB=E5=8A=A0=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/crud/src/utils/parse.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/crud/src/utils/parse.tsx b/packages/crud/src/utils/parse.tsx index 1214b4b..d551a3b 100644 --- a/packages/crud/src/utils/parse.tsx +++ b/packages/crud/src/utils/parse.tsx @@ -24,14 +24,14 @@ export function parseTableDict(value: any, item: ClTable.Column) { const { style } = useConfig(); // 选项列表 - const options: DictOptions = cloneDeep(getValue(item.dict || [])); + const list: DictOptions = cloneDeep(getValue(item.dict || [])); // 字符串分隔符 const separator = item.dictSeparator === undefined ? "," : item.dictSeparator; // 设置颜色 if (item.dictColor) { - options.forEach((e, i) => { + list.forEach((e, i) => { if (!e.color) { e.color = style.colors[i]; } @@ -55,10 +55,13 @@ export function parseTableDict(value: any, item: ClTable.Column) { } // 返回值 - const list = values + const result = values .filter((e) => e !== undefined && e !== null && e !== "") .map((v) => { - const d = deepFind(v, options) || { label: v, value: v }; + const d = deepFind(v, list, { allLevels: item.dictAllLevels }) || { + label: v, + value: v + }; delete d.children; return d; @@ -66,10 +69,10 @@ export function parseTableDict(value: any, item: ClTable.Column) { // 格式化返回 if (item.dictFormatter) { - return item.dictFormatter(list); + return item.dictFormatter(result); } else { // tag 返回 - return list.map((e) => { + return result.map((e) => { return h( , e,