From c766b3c62bda34f21f3c3c6f87dce4ca1691d667 Mon Sep 17 00:00:00 2001 From: snowgitea Date: Fri, 3 Jul 2026 14:23:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B9=A6=E7=B1=8D=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20exportColumns=20=E8=A1=A5=E5=85=A84?= =?UTF-8?q?=E4=B8=AA=E7=BC=BA=E5=A4=B1=E5=AD=97=E6=AE=B5=20+=20cover=20for?= =?UTF-8?q?matter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/knowledge/views/book/index.vue | 38 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/modules/knowledge/views/book/index.vue b/src/modules/knowledge/views/book/index.vue index ae630d9..3e0ec4b 100644 --- a/src/modules/knowledge/views/book/index.vue +++ b/src/modules/knowledge/views/book/index.vue @@ -16,7 +16,7 @@ tips="请按照模板填写书籍信息,名称为必填项" /> - + { + const cols: any[] = Table.value?.columns ? [...Table.value.columns] : []; + const base = cols.filter((e: any) => !['selection', 'expand', 'index', 'op'].includes(e.type)); + + // 为 cover 列添加 formatter(导出时 render 不会被调用,需要 formatter 将数组转为文本) + const coverCol = base.find((e: any) => e.prop === 'cover'); + if (coverCol) { + coverCol.formatter = (_row: any, _col: any, value: any) => { + if (Array.isArray(value)) { + return value.join(', '); + } + if (typeof value === 'string') { + try { + const parsed = JSON.parse(value); + return Array.isArray(parsed) ? parsed.join(', ') : value; + } catch { + return value; + } + } + return String(value || ''); + }; + } + + base.push( + { label: '内容简介', prop: 'synopsis', minWidth: 300 }, + { label: '背景故事', prop: 'backgroundStory', minWidth: 300 }, + { label: '标签', prop: 'tags', minWidth: 150 }, + { label: '更新时间', prop: 'updateTime', minWidth: 170 } + ); + + return base; +}); + // cl-upsert 配置 - 新增/编辑表单 const Upsert = useUpsert({ dialog: {