@@ -3,7 +3,14 @@ import { onMounted, ref, nextTick } from 'vue'
33import { dynamicFormTypeOptions } from ' @/components/mk-dynamics-form/constant'
44import VisibilityConstructor from ' ./visibility/index.vue'
55import BasicInfoConstructor from ' ./BasicInfoConstructor.vue'
6- import type { DynamicFormConstructorExpose , DynamicFormConstructorOption , DynamicFormConstructorState , FormField , VisibilityFieldOption , VisibilityRules } from ' ../type'
6+ import type {
7+ DynamicFormConstructorExpose ,
8+ DynamicFormConstructorOption ,
9+ DynamicFormConstructorState ,
10+ FormField ,
11+ VisibilityFieldOption ,
12+ VisibilityRules ,
13+ } from ' ../type'
714
815interface VisibilityConstructorExpose {
916 getData: () => VisibilityRules | null
@@ -17,8 +24,20 @@ defineOptions({ name: 'MkDynamicsFormConstructor', inheritAttrs: false })
1724defineEmits <{ (event : ' update:modelValue' , value : Partial <FormField >): void }>()
1825
1926const props = withDefaults (
20- defineProps <{ modelValue? : Partial <FormField >; fieldTypeOptions? : DynamicFormConstructorOption []; enableVisibility? : boolean ; leftOptions? : VisibilityFieldOption [] }>(),
21- { enableVisibility: false , fieldTypeOptions : () => dynamicFormTypeOptions .map ((item ) => ({ label: item .label , value: ` ${item .value }Constructor ` })) },
27+ defineProps <{
28+ modelValue? : Partial <FormField >
29+ // “基本信息”中可选的组件类型;不传时使用全部默认类型,value 使用带 Constructor 后缀的配置器名称。
30+ fieldTypeOptions? : DynamicFormConstructorOption []
31+ // 是否展示“显隐设置”页签,默认关闭。
32+ enableVisibility? : boolean
33+ // “显隐设置”中条件左侧可引用的变量,启用显隐设置时使用;变量类型和选项用于匹配比较方式及值输入控件。
34+ // 由调用方提供可引用范围,例如上游节点字段、当前字段之前的表单字段,不控制可选的组件类型。
35+ leftOptions? : VisibilityFieldOption []
36+ }>(),
37+ {
38+ enableVisibility: false ,
39+ fieldTypeOptions : () => dynamicFormTypeOptions .map ((item ) => ({ label: item .label , value: ` ${item .value }Constructor ` })),
40+ },
2241)
2342
2443const activeTab = ref (' basic' )
@@ -68,14 +87,18 @@ defineExpose({ getData, validate, render })
6887 </script >
6988
7089<template >
71- <el-tabs v-if =" enableVisibility" v-model =" activeTab" >
72- <el-tab-pane label =" 基本信息" name =" basic" >
73- <BasicInfoConstructor ref="basicRef" v-model =" formData " :input-type-list =" fieldTypeOptions " v-bind =" $attrs " />
74- </el-tab-pane >
75- <el-tab-pane label =" 显隐设置" name =" visibility" >
76- <VisibilityConstructor ref="visibilityRef" :initial-value =" visibilityRules " :left-options =" leftOptions " />
77- </el-tab-pane >
78- </el-tabs >
90+ <div v-if =" enableVisibility" class =" flex max-h-[inherit] min-h-0 flex-col" >
91+ <el-tabs v-model =" activeTab" class =" shrink-0" >
92+ <el-tab-pane label =" 基本信息" name =" basic" />
93+ <el-tab-pane label =" 显隐设置" name =" visibility" />
94+ </el-tabs >
95+
96+ <!-- 导航固定,内容独立滚动;两个表单保持挂载,供统一回填、取值和校验。 -->
97+ <el-scrollbar class =" mk-scrollbar-right mt-4 flex h-auto! min-h-0 flex-auto flex-col" wrap-class =" h-auto! min-h-0 flex-auto" >
98+ <BasicInfoConstructor v-show =" activeTab === ' basic' " ref="basicRef" v-model =" formData " :input-type-list =" fieldTypeOptions " v-bind =" $attrs " />
99+ <VisibilityConstructor v-show =" activeTab === ' visibility' " ref="visibilityRef" :initial-value =" visibilityRules " :left-options =" leftOptions " />
100+ </el-scrollbar >
101+ </div >
79102
80103 <BasicInfoConstructor v-else ref="basicRef" v-model =" formData " :input-type-list =" fieldTypeOptions " v-bind =" $attrs " />
81104</template >
0 commit comments