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

View File

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

View File

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

View File

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

View File

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