mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-24 18:40:22 +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 FormItem from './components/FormItem.vue';
|
||||||
import FormAction from './components/FormAction.vue';
|
import FormAction from './components/FormAction.vue';
|
||||||
|
|
||||||
import { dateItemType } from './helper';
|
import { dateItemType, isIncludeSimpleComponents } from './helper';
|
||||||
import { dateUtil } from '@/utils/dateUtil';
|
import { dateUtil } from '@/utils/dateUtil';
|
||||||
|
|
||||||
import { deepMerge } from '@/utils';
|
import { deepMerge } from '@/utils';
|
||||||
@ -163,7 +163,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (unref(getProps).showAdvancedButton) {
|
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 {
|
} else {
|
||||||
return cloneDeep(schemas as FormSchema[]);
|
return cloneDeep(schemas as FormSchema[]);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
import { getSlot } from '@/utils/helper/tsxHelper';
|
import { getSlot } from '@/utils/helper/tsxHelper';
|
||||||
import {
|
import {
|
||||||
createPlaceholderMessage,
|
createPlaceholderMessage,
|
||||||
|
isIncludeSimpleComponents,
|
||||||
NO_AUTO_LINK_COMPONENTS,
|
NO_AUTO_LINK_COMPONENTS,
|
||||||
setComponentRuleType,
|
setComponentRuleType,
|
||||||
} from '../helper';
|
} from '../helper';
|
||||||
@ -89,7 +90,7 @@
|
|||||||
if (isFunction(componentProps)) {
|
if (isFunction(componentProps)) {
|
||||||
componentProps = componentProps({ schema, tableAction, formModel, formActionType }) ?? {};
|
componentProps = componentProps({ schema, tableAction, formModel, formActionType }) ?? {};
|
||||||
}
|
}
|
||||||
if (schema.component === 'Divider') {
|
if (isIncludeSimpleComponents(schema.component)) {
|
||||||
componentProps = Object.assign(
|
componentProps = Object.assign(
|
||||||
{ type: 'horizontal' },
|
{ type: 'horizontal' },
|
||||||
{
|
{
|
||||||
|
@ -95,3 +95,9 @@ export const NO_AUTO_LINK_COMPONENTS: ComponentType[] = [
|
|||||||
'ImageUpload',
|
'ImageUpload',
|
||||||
'ApiSelect',
|
'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 { unref, toRaw, nextTick } from 'vue';
|
||||||
import { isArray, isFunction, isObject, isString, isDef, isNil } from '@/utils/is';
|
import { isArray, isFunction, isObject, isString, isDef, isNil } from '@/utils/is';
|
||||||
import { deepMerge } from '@/utils';
|
import { deepMerge } from '@/utils';
|
||||||
import { dateItemType, handleInputNumberValue, defaultValueComponents } from '../helper';
|
import {
|
||||||
|
dateItemType,
|
||||||
|
handleInputNumberValue,
|
||||||
|
defaultValueComponents,
|
||||||
|
isIncludeSimpleComponents,
|
||||||
|
} from '../helper';
|
||||||
import { dateUtil } from '@/utils/dateUtil';
|
import { dateUtil } from '@/utils/dateUtil';
|
||||||
import { cloneDeep, set, uniqBy, get } from 'lodash-es';
|
import { cloneDeep, set, uniqBy, get } from 'lodash-es';
|
||||||
import { error } from '@/utils/log';
|
import { error } from '@/utils/log';
|
||||||
@ -245,7 +250,8 @@ export function useFormEvents({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const hasField = updateData.every(
|
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) {
|
if (!hasField) {
|
||||||
@ -267,7 +273,8 @@ export function useFormEvents({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const hasField = updateData.every(
|
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) {
|
if (!hasField) {
|
||||||
@ -309,7 +316,7 @@ export function useFormEvents({
|
|||||||
const currentFieldsValue = getFieldsValue();
|
const currentFieldsValue = getFieldsValue();
|
||||||
schemas.forEach((item) => {
|
schemas.forEach((item) => {
|
||||||
if (
|
if (
|
||||||
item.component != 'Divider' &&
|
!isIncludeSimpleComponents(item.component) &&
|
||||||
Reflect.has(item, 'field') &&
|
Reflect.has(item, 'field') &&
|
||||||
item.field &&
|
item.field &&
|
||||||
!isNil(item.defaultValue) &&
|
!isNil(item.defaultValue) &&
|
||||||
|
Loading…
Reference in New Issue
Block a user