feat: exportColumns posters 列添加 formatter 数组转文本
This commit is contained in:
@@ -286,6 +286,25 @@ const exportColumns = computed(() => {
|
|||||||
const cols: any[] = Table?.columns ? [...Table.columns] : [];
|
const cols: any[] = Table?.columns ? [...Table.columns] : [];
|
||||||
const base = cols.filter((e: any) => !['selection', 'expand', 'index', 'op'].includes(e.type));
|
const base = cols.filter((e: any) => !['selection', 'expand', 'index', 'op'].includes(e.type));
|
||||||
|
|
||||||
|
// 为 posters 列添加 formatter(导出时 render 不会被调用,需要 formatter 将数组转为文本)
|
||||||
|
const postersCol = base.find((e: any) => e.prop === 'posters');
|
||||||
|
if (postersCol) {
|
||||||
|
postersCol.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(
|
base.push(
|
||||||
{ label: '国家', prop: 'country', width: 100 },
|
{ label: '国家', prop: 'country', width: 100 },
|
||||||
{ label: '语言', prop: 'language', width: 100 },
|
{ label: '语言', prop: 'language', width: 100 },
|
||||||
|
|||||||
Reference in New Issue
Block a user