chore(form): fields组件计算lastValues props

This commit is contained in:
roymondchen 2023-05-16 16:44:26 +08:00
parent a97523e800
commit d0ec2fd588
19 changed files with 22 additions and 2 deletions

View File

@ -32,6 +32,7 @@ const props = defineProps<{
prop: string; prop: string;
disabled?: boolean; disabled?: boolean;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
}>(); }>();
const emit = defineEmits(['change']); const emit = defineEmits(['change']);
@ -85,7 +86,7 @@ if (typeof props.config.options === 'function' && props.model && mForm) {
watchEffect( watchEffect(
() => (options.value = (props.config.options as Function)(mForm, { model: props.model, formValues: mForm.values })), () => (options.value = (props.config.options as Function)(mForm, { model: props.model, formValues: mForm.values })),
); );
} else if (!props.config.options || !props.config.options.length || props.config.remote) { } else if (!props.config.options?.length || props.config.remote) {
Promise.resolve(setRemoteOptions()); Promise.resolve(setRemoteOptions());
} }

View File

@ -27,6 +27,7 @@ const props = defineProps<{
prop: string; prop: string;
disabled?: boolean; disabled?: boolean;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
}>(); }>();
const emit = defineEmits(['change']); const emit = defineEmits(['change']);

View File

@ -29,6 +29,7 @@ const props = defineProps<{
prop: string; prop: string;
disabled?: boolean; disabled?: boolean;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
}>(); }>();
const emit = defineEmits(['change']); const emit = defineEmits(['change']);

View File

@ -23,6 +23,7 @@ const props = defineProps<{
prop: string; prop: string;
disabled?: boolean; disabled?: boolean;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
}>(); }>();
const emit = defineEmits(['change']); const emit = defineEmits(['change']);

View File

@ -27,6 +27,7 @@ const props = defineProps<{
prop: string; prop: string;
disabled?: boolean; disabled?: boolean;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
}>(); }>();
const emit = defineEmits(['change']); const emit = defineEmits(['change']);

View File

@ -29,6 +29,7 @@ const props = defineProps<{
prop: string; prop: string;
disabled?: boolean; disabled?: boolean;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
}>(); }>();
const emit = defineEmits(['change']); const emit = defineEmits(['change']);

View File

@ -31,6 +31,7 @@ const props = defineProps<{
prop: string; prop: string;
disabled?: boolean; disabled?: boolean;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
}>(); }>();
const emit = defineEmits(['change']); const emit = defineEmits(['change']);

View File

@ -13,6 +13,7 @@ const props = defineProps<{
values?: any; values?: any;
name: string; name: string;
prop: string; prop: string;
lastValues?: Record<string, any>;
}>(); }>();
if (props.config.initValue && props.model) { if (props.config.initValue && props.model) {

View File

@ -40,6 +40,7 @@ const props = defineProps<{
prop: string; prop: string;
disabled?: boolean; disabled?: boolean;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
}>(); }>();
const emit = defineEmits(['change']); const emit = defineEmits(['change']);

View File

@ -13,6 +13,7 @@ const props = defineProps<{
values?: any; values?: any;
name: string; name: string;
prop: string; prop: string;
lastValues?: Record<string, any>;
}>(); }>();
useAddField(props.prop); useAddField(props.prop);

View File

@ -34,6 +34,7 @@ const props = defineProps<{
prop: string; prop: string;
disabled?: boolean; disabled?: boolean;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
}>(); }>();
const emit = defineEmits(['change']); const emit = defineEmits(['change']);

View File

@ -32,6 +32,7 @@ const props = defineProps<{
prop: string; prop: string;
disabled?: boolean; disabled?: boolean;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
}>(); }>();
const emit = defineEmits(['change', 'input']); const emit = defineEmits(['change', 'input']);

View File

@ -25,6 +25,7 @@ const props = defineProps<{
prop: string; prop: string;
disabled?: boolean; disabled?: boolean;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
}>(); }>();
const emit = defineEmits(['change']); const emit = defineEmits(['change']);

View File

@ -46,6 +46,7 @@ const props = defineProps<{
prop: string; prop: string;
disabled?: boolean; disabled?: boolean;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
}>(); }>();
const emit = defineEmits(['change']); const emit = defineEmits(['change']);

View File

@ -26,6 +26,7 @@ const props = defineProps<{
prop: string; prop: string;
disabled?: boolean; disabled?: boolean;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
}>(); }>();
const emit = defineEmits(['change']); const emit = defineEmits(['change']);

View File

@ -41,6 +41,7 @@ const props = defineProps<{
prop: string; prop: string;
disabled?: boolean; disabled?: boolean;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
}>(); }>();
const emit = defineEmits(['change', 'input']); const emit = defineEmits(['change', 'input']);

View File

@ -29,6 +29,7 @@ const props = defineProps<{
prop: string; prop: string;
disabled?: boolean; disabled?: boolean;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
}>(); }>();
const emit = defineEmits(['change', 'input']); const emit = defineEmits(['change', 'input']);

View File

@ -25,6 +25,7 @@ const props = defineProps<{
prop: string; prop: string;
disabled?: boolean; disabled?: boolean;
size?: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
lastValues?: Record<string, any>;
}>(); }>();
const emit = defineEmits(['change']); const emit = defineEmits(['change']);

View File

@ -87,6 +87,7 @@ export interface FormItem {
dynamicKey?: string; dynamicKey?: string;
/** 是否需要显示`展开更多配置` */ /** 是否需要显示`展开更多配置` */
expand?: boolean; expand?: boolean;
[key: string]: any;
} }
export interface ContainerCommonConfig { export interface ContainerCommonConfig {
@ -567,6 +568,7 @@ export interface TabPaneConfig {
onTabClick?: (mForm: FormState | undefined, tab: any, data: any) => void; onTabClick?: (mForm: FormState | undefined, tab: any, data: any) => void;
[key: string]: any; [key: string]: any;
} }
export interface TabConfig extends FormItem, ContainerCommonConfig { export interface TabConfig extends FormItem, ContainerCommonConfig {
type: 'tab' | 'dynamic-tab'; type: 'tab' | 'dynamic-tab';
tabType?: string; tabType?: string;
@ -718,6 +720,6 @@ export type ChildConfig =
| DynamicFieldConfig | DynamicFieldConfig
| ComponentConfig; | ComponentConfig;
export type FormConfig = (ChildConfig & { [key: string]: any })[]; export type FormConfig = ChildConfig[];
export type FormValue = Record<string | number, any>; export type FormValue = Record<string | number, any>;