feat(form): table新增新增按钮配置

This commit is contained in:
roymondchen 2025-11-20 11:27:12 +08:00
parent e2708b868b
commit 6a7f80c48d
2 changed files with 15 additions and 3 deletions

View File

@ -728,6 +728,10 @@ export interface TableConfig extends FormItem {
rowKey?: string;
/** table 新增行时前置回调 */
beforeAddRow?: (mForm: FormState | undefined, data: any) => boolean;
addButtonConfig?: {
props?: Record<string, any>;
text?: string;
};
}
export interface GroupListConfig extends FormItem {

View File

@ -60,8 +60,16 @@
>清空</TMagicButton
>
</div>
<TMagicButton v-if="addable" size="small" type="primary" :disabled="disabled" plain @click="newHandler()"
>新增一行</TMagicButton
<TMagicButton
v-if="addable"
class="m-form-table-add-button"
size="small"
v-bind="config.addButtonConfig?.props || { type: 'primary' }"
:disabled="disabled"
plain
:icon="Plus"
@click="newHandler()"
>{{ config.addButtonConfig?.text || '新增一行' }}</TMagicButton
>
</div>
@ -85,7 +93,7 @@
<script setup lang="ts">
import { computed, ref, useTemplateRef } from 'vue';
import { FullScreen, Grid } from '@element-plus/icons-vue';
import { FullScreen, Grid, Plus } from '@element-plus/icons-vue';
import { TMagicButton, TMagicPagination, TMagicTable, TMagicTooltip, TMagicUpload, useZIndex } from '@tmagic/design';