|
@@ -1,13 +1,14 @@
|
|
|
<template>
|
|
<template>
|
|
|
<Flex class="mb-6px" align="center" justify="space-between">
|
|
<Flex class="mb-6px" align="center" justify="space-between">
|
|
|
- <slot name="formTitle"> </slot>
|
|
|
|
|
|
|
+ <FormGroup v-model:value="currentGroup" :groups="getBindValue.schemaGroupNames"></FormGroup>
|
|
|
|
|
+
|
|
|
<FormAction v-bind="getFormActionBindProps" :form-item-props="{ noStyle: true }" @toggle-advanced="handleToggleAdvanced">
|
|
<FormAction v-bind="getFormActionBindProps" :form-item-props="{ noStyle: true }" @toggle-advanced="handleToggleAdvanced">
|
|
|
<template #[item]="data" v-for="item in ['resetBefore', 'submitBefore', 'advanceBefore', 'advanceAfter']">
|
|
<template #[item]="data" v-for="item in ['resetBefore', 'submitBefore', 'advanceBefore', 'advanceAfter']">
|
|
|
<slot :name="item" v-bind="data || {}"></slot>
|
|
<slot :name="item" v-bind="data || {}"></slot>
|
|
|
</template>
|
|
</template>
|
|
|
</FormAction>
|
|
</FormAction>
|
|
|
</Flex>
|
|
</Flex>
|
|
|
- <AForm v-bind="getBindValue" :class="getFormClass" ref="formElRef" :model="formModel" @keypress.enter="handleEnterPress">
|
|
|
|
|
|
|
+ <AForm v-show="currentGroup" v-bind="getBindValue" :class="getFormClass" ref="formElRef" :model="formModel" @keypress.enter="handleEnterPress">
|
|
|
<Row v-bind="getRow">
|
|
<Row v-bind="getRow">
|
|
|
<template v-for="schema in getSchema" :key="schema.field">
|
|
<template v-for="schema in getSchema" :key="schema.field">
|
|
|
<FormItem
|
|
<FormItem
|
|
@@ -42,6 +43,7 @@
|
|
|
import { Form, Row, Flex } from 'ant-design-vue';
|
|
import { Form, Row, Flex } from 'ant-design-vue';
|
|
|
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 FormGroup from './components/FormGroup.vue';
|
|
|
|
|
|
|
|
import { dateItemType } from './helper';
|
|
import { dateItemType } from './helper';
|
|
|
import { dateUtil } from '/@/utils/dateUtil';
|
|
import { dateUtil } from '/@/utils/dateUtil';
|
|
@@ -66,7 +68,7 @@
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
|
name: 'BasicForm',
|
|
name: 'BasicForm',
|
|
|
- components: { FormItem, AForm: Form, Row, FormAction, Flex },
|
|
|
|
|
|
|
+ components: { FormItem, AForm: Form, Row, FormAction, Flex, FormGroup },
|
|
|
props: basicProps,
|
|
props: basicProps,
|
|
|
emits: ['advanced-change', 'reset', 'submit', 'register'],
|
|
emits: ['advanced-change', 'reset', 'submit', 'register'],
|
|
|
setup(props, { emit, attrs }) {
|
|
setup(props, { emit, attrs }) {
|
|
@@ -136,6 +138,7 @@
|
|
|
return bindValue;
|
|
return bindValue;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ const currentGroup = ref();
|
|
|
const getSchema = computed((): FormSchema[] => {
|
|
const getSchema = computed((): FormSchema[] => {
|
|
|
const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any);
|
|
const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any);
|
|
|
for (const schema of schemas) {
|
|
for (const schema of schemas) {
|
|
@@ -184,10 +187,12 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ const schemasByGroup = schemas.filter((schema) => !schema.groupName || schema.groupName === currentGroup.value);
|
|
|
if (unref(getProps).showAdvancedButton) {
|
|
if (unref(getProps).showAdvancedButton) {
|
|
|
- return schemas.filter((schema) => schema.component !== 'Divider') as FormSchema[];
|
|
|
|
|
|
|
+ return schemasByGroup.filter((schema) => schema.component !== 'Divider') as FormSchema[];
|
|
|
} else {
|
|
} else {
|
|
|
- return schemas as FormSchema[];
|
|
|
|
|
|
|
+ return schemasByGroup as FormSchema[];
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -358,6 +363,7 @@
|
|
|
getRow,
|
|
getRow,
|
|
|
getProps,
|
|
getProps,
|
|
|
formElRef,
|
|
formElRef,
|
|
|
|
|
+ currentGroup,
|
|
|
getSchema,
|
|
getSchema,
|
|
|
formActionType: formActionType as any,
|
|
formActionType: formActionType as any,
|
|
|
setFormModel,
|
|
setFormModel,
|