feat(form): group list新增添加按钮配置

This commit is contained in:
roymondchen 2025-11-20 18:05:53 +08:00
parent 310054b7d6
commit 3b913c1af4
5 changed files with 15 additions and 6 deletions

View File

@ -41,6 +41,7 @@ export interface FieldProps<T = any> {
disabled?: boolean;
size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
isCompare?: boolean;
}
/**
@ -763,6 +764,10 @@ export interface GroupListConfig extends FormItem {
groupModel: any,
) => boolean | boolean;
moveSpecifyLocation?: boolean;
addButtonConfig?: {
props?: Record<string, any>;
text?: string;
};
[key: string]: any;
}

View File

@ -40,6 +40,7 @@
:is="tagName"
:model="model"
:last-values="lastValues"
:is-compare="isCompare"
@change="onChangeHandler"
@addDiffCount="onAddDiffCount"
></component>
@ -54,6 +55,7 @@
:is="tagName"
:model="model"
:last-values="lastValues"
:is-compare="isCompare"
@change="onChangeHandler"
@addDiffCount="onAddDiffCount"
></component>

View File

@ -33,11 +33,12 @@
<div style="display: flex; justify-content: flex-end; flex: 1">
<TMagicButton
v-if="addable"
type="primary"
:size="config.enableToggleMode ? 'small' : 'default'"
:icon="Plus"
v-bind="config.addButtonConfig?.props || { type: 'primary' }"
:disabled="disabled"
@click="addHandler"
>新增</TMagicButton
>{{ config.addButtonConfig?.text || '新增' }}</TMagicButton
>
</div>
</div>
@ -46,7 +47,7 @@
<script setup lang="ts">
import { computed, inject } from 'vue';
import { Grid } from '@element-plus/icons-vue';
import { Grid, Plus } from '@element-plus/icons-vue';
import { cloneDeep } from 'lodash-es';
import { TMagicButton } from '@tmagic/design';

View File

@ -8,10 +8,11 @@
<div style="width: 100%; display: flex; align-items: center">
<TMagicButton style="padding: 0" link :icon="expand ? CaretBottom : CaretRight" @click="expand = !expand">
</TMagicButton>
<span v-if="config && config.extra" v-html="config.extra" class="m-form-tip"></span>
<slot name="header">
<span style="cursor: pointer" @click="expand = !expand">{{ filter(config.title) }}</span>
</slot>
<span v-if="config && config.extra" v-html="config.extra" class="m-form-tip"></span>
</div>
</template>

View File

@ -64,10 +64,10 @@
v-if="addable"
class="m-form-table-add-button"
size="small"
v-bind="config.addButtonConfig?.props || { type: 'primary' }"
:disabled="disabled"
plain
:icon="Plus"
v-bind="config.addButtonConfig?.props || { type: 'primary' }"
:disabled="disabled"
@click="newHandler()"
>{{ config.addButtonConfig?.text || '新增一行' }}</TMagicButton
>