mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-24 10:33:50 +08:00
feat(Form): 在Form将BasicTitle识做为Divider一样的处理 (#3371)
* feat(Form): 在Form将BasicTitle识做为Divider一样的处理 * refactor: 抽离是否存在SimpleComponents的校验逻辑 --------- Co-authored-by: gavin-james <meaganlindesy1258@gmail.com> Co-authored-by: invalid w <wangjuesix@gmail.com>
This commit is contained in:
parent
dde3652b7d
commit
cd71e60dd1
@ -47,7 +47,7 @@
|
||||
import FormItem from './components/FormItem.vue';
|
||||
import FormAction from './components/FormAction.vue';
|
||||
|
||||
import { dateItemType } from './helper';
|
||||
import { dateItemType, isIncludeSimpleComponents } from './helper';
|
||||
import { dateUtil } from '@/utils/dateUtil';
|
||||
|
||||
import { deepMerge } from '@/utils';
|
||||
@ -163,7 +163,9 @@
|
||||
}
|
||||
}
|
||||
if (unref(getProps).showAdvancedButton) {
|
||||
return cloneDeep(schemas.filter((schema) => schema.component !== 'Divider') as FormSchema[]);
|
||||
return cloneDeep(
|
||||
schemas.filter((schema) => !isIncludeSimpleComponents(schema.component)) as FormSchema[],
|
||||
);
|
||||
} else {
|
||||
return cloneDeep(schemas as FormSchema[]);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
import { getSlot } from '@/utils/helper/tsxHelper';
|
||||
import {
|
||||
createPlaceholderMessage,
|
||||
isIncludeSimpleComponents,
|
||||
NO_AUTO_LINK_COMPONENTS,
|
||||
setComponentRuleType,
|
||||
} from '../helper';
|
||||
@ -89,7 +90,7 @@
|
||||
if (isFunction(componentProps)) {
|
||||
componentProps = componentProps({ schema, tableAction, formModel, formActionType }) ?? {};
|
||||
}
|
||||
if (schema.component === 'Divider') {
|
||||
if (isIncludeSimpleComponents(schema.component)) {
|
||||
componentProps = Object.assign(
|
||||
{ type: 'horizontal' },
|
||||
{
|
||||
|
@ -95,3 +95,9 @@ export const NO_AUTO_LINK_COMPONENTS: ComponentType[] = [
|
||||
'ImageUpload',
|
||||
'ApiSelect',
|
||||
];
|
||||
|
||||
export const simpleComponents = ['Divider', 'BasicTitle'];
|
||||
|
||||
export function isIncludeSimpleComponents(component?: ComponentType) {
|
||||
return simpleComponents.includes(component || '');
|
||||
}
|
||||
|
@ -4,7 +4,12 @@ import type { NamePath } from 'ant-design-vue/lib/form/interface';
|
||||
import { unref, toRaw, nextTick } from 'vue';
|
||||
import { isArray, isFunction, isObject, isString, isDef, isNil } from '@/utils/is';
|
||||
import { deepMerge } from '@/utils';
|
||||
import { dateItemType, handleInputNumberValue, defaultValueComponents } from '../helper';
|
||||
import {
|
||||
dateItemType,
|
||||
handleInputNumberValue,
|
||||
defaultValueComponents,
|
||||
isIncludeSimpleComponents,
|
||||
} from '../helper';
|
||||
import { dateUtil } from '@/utils/dateUtil';
|
||||
import { cloneDeep, set, uniqBy, get } from 'lodash-es';
|
||||
import { error } from '@/utils/log';
|
||||
@ -245,7 +250,8 @@ export function useFormEvents({
|
||||
}
|
||||
|
||||
const hasField = updateData.every(
|
||||
(item) => item.component === 'Divider' || (Reflect.has(item, 'field') && item.field),
|
||||
(item) =>
|
||||
isIncludeSimpleComponents(item.component) || (Reflect.has(item, 'field') && item.field),
|
||||
);
|
||||
|
||||
if (!hasField) {
|
||||
@ -267,7 +273,8 @@ export function useFormEvents({
|
||||
}
|
||||
|
||||
const hasField = updateData.every(
|
||||
(item) => item.component === 'Divider' || (Reflect.has(item, 'field') && item.field),
|
||||
(item) =>
|
||||
isIncludeSimpleComponents(item.component) || (Reflect.has(item, 'field') && item.field),
|
||||
);
|
||||
|
||||
if (!hasField) {
|
||||
@ -309,7 +316,7 @@ export function useFormEvents({
|
||||
const currentFieldsValue = getFieldsValue();
|
||||
schemas.forEach((item) => {
|
||||
if (
|
||||
item.component != 'Divider' &&
|
||||
!isIncludeSimpleComponents(item.component) &&
|
||||
Reflect.has(item, 'field') &&
|
||||
item.field &&
|
||||
!isNil(item.defaultValue) &&
|
||||
|
Loading…
Reference in New Issue
Block a user