feat(table): 支持type: index的序号列

This commit is contained in:
roymondchen 2025-02-18 19:40:28 +08:00
parent 6e2b5aea47
commit 6f2c6b151d
2 changed files with 9 additions and 2 deletions

View File

@ -8,7 +8,12 @@
:prop="config.prop"
>
<template v-slot="scope">
<TMagicForm v-if="config.type && editState[scope.$index]" label-width="0" :model="editState[scope.$index]">
<div v-if="config.type === 'index'">
{{
config.pageIndex && config.pageSize ? config.pageIndex * config.pageSize + scope.$index + 1 : scope.$index + 1
}}
</div>
<TMagicForm v-else-if="config.type && editState[scope.$index]" label-width="0" :model="editState[scope.$index]">
<m-form-container
:prop="config.prop"
:rules="config.rules"

View File

@ -34,6 +34,8 @@ export interface ColumnActionConfig {
}
export interface ColumnConfig<T = any> {
pageIndex?: number;
pageSize?: number;
form?: FormConfig;
rules?: any;
values?: FormValue;
@ -43,7 +45,7 @@ export interface ColumnConfig<T = any> {
fixed?: 'left' | 'right' | boolean;
width?: number | string;
actions?: ColumnActionConfig[];
type?: 'popover' | 'expand' | 'component' | string | ((value: any, row: T) => string);
type?: 'popover' | 'expand' | 'component' | 'index' | string | ((value: any, row: T) => string);
text?: string;
prop?: string;
name?: string;