feat(form): 展开更多支持配置函数

This commit is contained in:
roymondchen 2022-10-28 14:33:06 +08:00
parent 0ca0abf2da
commit 9fd8385651
2 changed files with 11 additions and 4 deletions

View File

@ -97,7 +97,9 @@
</template>
<div style="text-align: center" v-if="config.expand && type !== 'fieldset'">
<TMagicButton text @click="expandHandler">{{ expand ? '收起配置' : '展开更多配置' }}</TMagicButton>
<TMagicButton type="primary" size="small" text @click="expandHandler">{{
expand ? '收起配置' : '展开更多配置'
}}</TMagicButton>
</div>
</div>
</template>
@ -177,11 +179,12 @@ const type = computed((): string => {
});
const display = computed((): boolean => {
if (props.config.display === 'expand') {
const value = displayFunction(mForm, props.config.display, props);
if (value === 'expand') {
return expand.value;
}
return displayFunction(mForm, props.config.display, props);
return value;
});
const itemLabelWidth = computed(() => props.config.labelWidth || props.labelWidth);

View File

@ -197,6 +197,10 @@ export const filterFunction = (mForm: FormState | undefined, config: any, props:
};
export const display = function (mForm: FormState | undefined, config: any, props: any) {
if (config === 'expand') {
return config;
}
if (typeof config === 'function') {
return filterFunction(mForm, config, props);
}