From 7d22328d6907635f8eb7e7606db65a84d4933608 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 18 Mar 2023 11:02:40 +0800 Subject: [PATCH] =?UTF-8?q?Table=20=E7=BB=84=E4=BB=B6=EF=BC=9A=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AF=B9=E5=AD=97=E5=85=B8=E6=95=B0=E6=8D=AE=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/web/useCrudSchemas.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/hooks/web/useCrudSchemas.ts b/src/hooks/web/useCrudSchemas.ts index 543111ca..66c5eb0a 100644 --- a/src/hooks/web/useCrudSchemas.ts +++ b/src/hooks/web/useCrudSchemas.ts @@ -8,6 +8,7 @@ import { FormSchema } from '@/types/form' import { TableColumn } from '@/types/table' import { DescriptionsSchema } from '@/types/descriptions' import { ComponentOptions, ComponentProps } from '@/types/components' +import { DictTag } from '@/components/DictTag' export type CrudSchema = Omit & { isSearch?: boolean // 是否在查询显示 @@ -151,6 +152,15 @@ const filterTableSchema = (crudSchema: CrudSchema[]): TableColumn[] => { const tableColumns = treeMap(crudSchema, { conversion: (schema: CrudSchema) => { if (schema?.isTable !== false && schema?.table?.show !== false) { + // add by 芋艿:增加对 dict 字典数据的支持 + if (!schema.formatter && schema.dictType) { + schema.formatter = (_: Recordable, __: TableColumn, cellValue: any) => { + return h(DictTag, { + type: schema.dictType!, // ! 表示一定不为空 + value: cellValue + }) + } + } return { ...schema.table, ...schema