diff --git a/packages/table/src/PopoverColumn.vue b/packages/table/src/PopoverColumn.vue index 531b1a65..c38a49c1 100644 --- a/packages/table/src/PopoverColumn.vue +++ b/packages/table/src/PopoverColumn.vue @@ -16,7 +16,9 @@ :data="(config.prop && scope.row[config.prop]) || []" > diff --git a/packages/table/src/TextColumn.vue b/packages/table/src/TextColumn.vue index 231e3f21..b9448c1e 100644 --- a/packages/table/src/TextColumn.vue +++ b/packages/table/src/TextColumn.vue @@ -29,7 +29,7 @@ type="primary" @click="config.handler?.(scope.row)" > - + {{ config.buttonText || '扩展配置' }} @@ -55,9 +55,9 @@ v-else-if="config.action === 'tag' && config.prop" :type="typeof config.type === 'function' ? config.type(scope.row[config.prop], scope.row) : config.type" close-transition - >{{ formatter(config, scope.row) }}{{ formatter(config, scope.row, { index: scope.$index }) }} -
+
diff --git a/packages/table/src/schema.ts b/packages/table/src/schema.ts index 6b70e256..76753643 100644 --- a/packages/table/src/schema.ts +++ b/packages/table/src/schema.ts @@ -51,7 +51,7 @@ export interface ColumnConfig { name?: string; showHeader?: boolean; table?: ColumnConfig[]; - formatter?: 'datetime' | ((item: any, row: T) => any); + formatter?: 'datetime' | ((item: any, row: T, data: { index: number }) => any); popover?: { placement?: | 'auto' diff --git a/packages/table/src/utils.ts b/packages/table/src/utils.ts index 0eb34aba..b6456c90 100644 --- a/packages/table/src/utils.ts +++ b/packages/table/src/utils.ts @@ -20,7 +20,7 @@ import { datetimeFormatter } from '@tmagic/form'; import type { ColumnConfig } from './schema'; -export const formatter = (item: ColumnConfig, row: any) => { +export const formatter = (item: ColumnConfig, row: any, data: { index: number }) => { if (!item.prop) return ''; if (item.formatter) { @@ -29,7 +29,7 @@ export const formatter = (item: ColumnConfig, row: any) => { item.formatter = (value: string) => datetimeFormatter(value); } try { - return item.formatter(row[item.prop], row); + return item.formatter(row[item.prop], row, data); } catch (e) { return row[item.prop]; }