diff --git a/apps/web-antd/src/adapter/vxe-table.ts b/apps/web-antd/src/adapter/vxe-table.ts index 1903e1c..d06b2f6 100644 --- a/apps/web-antd/src/adapter/vxe-table.ts +++ b/apps/web-antd/src/adapter/vxe-table.ts @@ -13,7 +13,7 @@ import { isFunction, isString } from '@vben/utils'; import { Button, Image, Popconfirm, Switch } from 'ant-design-vue'; -import { DictTag } from '#/components/dict-tag'; +import { DictTag, DictTagGroup } from '#/components/dict-tag'; import { $t } from '#/locales'; import { useVbenForm } from './form'; @@ -102,6 +102,22 @@ setupVbenVxeTable({ }, }); + // 表格配置项可以用 cellRender: { name: 'CellDict', props:{dictType: ''} }, + vxeUI.renderer.add('CellDictGroup', { + renderTableDefault(renderOpts, params) { + const { props } = renderOpts; + const { column, row } = params; + if (!props) { + return ''; + } + // 使用 DictTag 组件替代原来的实现 + return h(DictTagGroup, { + type: props.type, + value: row[column.field], + }); + }, + }); + // 表格配置项可以用 cellRender: { name: 'CellSwitch', props: { beforeChange: () => {} } }, // add by 芋艿:from https://github.com/vbenjs/vue-vben-admin/blob/main/playground/src/adapter/vxe-table.ts#L97-L123 vxeUI.renderer.add('CellSwitch', { diff --git a/apps/web-antd/src/components/dict-tag/dict-tag-group.vue b/apps/web-antd/src/components/dict-tag/dict-tag-group.vue new file mode 100644 index 0000000..a8fc370 --- /dev/null +++ b/apps/web-antd/src/components/dict-tag/dict-tag-group.vue @@ -0,0 +1,76 @@ + + + diff --git a/apps/web-antd/src/components/dict-tag/index.ts b/apps/web-antd/src/components/dict-tag/index.ts index 881265a..9f69453 100644 --- a/apps/web-antd/src/components/dict-tag/index.ts +++ b/apps/web-antd/src/components/dict-tag/index.ts @@ -1 +1,2 @@ +export { default as DictTagGroup } from './dict-tag-group.vue'; export { default as DictTag } from './dict-tag.vue';