From ed30f06ae128163342c029ec4da1b551933a34d0 Mon Sep 17 00:00:00 2001 From: xingyu Date: Fri, 6 Jan 2023 17:20:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20xtable=E5=A2=9E=E5=8A=A0=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/plugins/vxeTable/renderer/index.tsx | 1 + .../src/plugins/vxeTable/renderer/preview.tsx | 34 +++++++++++++++++++ .../src/views/infra/fileList/fileList.data.ts | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 yudao-ui-admin-vue3/src/plugins/vxeTable/renderer/preview.tsx diff --git a/yudao-ui-admin-vue3/src/plugins/vxeTable/renderer/index.tsx b/yudao-ui-admin-vue3/src/plugins/vxeTable/renderer/index.tsx index 2a510c3877..744e46c341 100644 --- a/yudao-ui-admin-vue3/src/plugins/vxeTable/renderer/index.tsx +++ b/yudao-ui-admin-vue3/src/plugins/vxeTable/renderer/index.tsx @@ -4,3 +4,4 @@ import './dict' import './html' import './link' import './img' +import './preview' diff --git a/yudao-ui-admin-vue3/src/plugins/vxeTable/renderer/preview.tsx b/yudao-ui-admin-vue3/src/plugins/vxeTable/renderer/preview.tsx new file mode 100644 index 0000000000..3cb1270b7b --- /dev/null +++ b/yudao-ui-admin-vue3/src/plugins/vxeTable/renderer/preview.tsx @@ -0,0 +1,34 @@ +import { VXETable } from 'vxe-table' +import { ElImage, ElLink } from 'element-plus' + +// 图片渲染 +VXETable.renderer.add('XPreview', { + // 默认显示模板 + renderDefault(_renderOpts, params) { + const { row, column } = params + if (row.type.indexOf('image/') === 0) { + return ( + + ) + } else if (row.type.indexOf('video/') === 0) { + return ( + + ) + } else { + return ( + + {row[column.field]} + + ) + } + } +}) diff --git a/yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts b/yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts index 509de4f480..cc05160144 100644 --- a/yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts +++ b/yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts @@ -23,7 +23,7 @@ const crudSchemas = reactive({ field: 'url', table: { cellRender: { - name: 'XImg' + name: 'XPreview' } } },