@longhongguo/form-create-ant-design-vue 3.2.68 → 3.2.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longhongguo/form-create-ant-design-vue",
3
- "version": "3.2.68",
3
+ "version": "3.2.70",
4
4
  "description": "AntDesignVue版本低代码表单|FormCreate 是一个可以通过 JSON 生成具有动态渲染、数据收集、验证和提交功能的低代码表单生成组件。支持6个UI框架,适配移动端,并且支持生成任何 Vue 组件。内置20种常用表单组件和自定义组件,再复杂的表单都可以轻松搞定。",
5
5
  "main": "./dist/form-create.min.js",
6
6
  "module": "./dist/form-create.esm.js",
@@ -10,9 +10,29 @@ export default {
10
10
  ctx.rule.wrap.title = false
11
11
 
12
12
  const props = ctx.prop.props || {}
13
+
14
+ // 读取 containerMode 配置
15
+ const containerMode =
16
+ ctx.rule.containerMode ??
17
+ ctx.rule.props?.containerMode ??
18
+ ctx.prop.props?.containerMode ??
19
+ true
20
+
21
+ // 如果不是容器模式,清空 children
22
+ if (!containerMode) {
23
+ ctx.rule.children = []
24
+ }
25
+
13
26
  if (!hasProperty(props, 'spinning')) {
14
27
  props.spinning = ctx.prop.props?.spinning ?? ctx.rule.props?.spinning ?? false
15
28
  }
29
+
30
+ // 如果没有子组件且不是容器模式,spinning 不应该为 true(避免显示空加载状态)
31
+ const hasChildren = ctx.rule.children && Array.isArray(ctx.rule.children) && ctx.rule.children.length > 0
32
+ if (!containerMode && !hasChildren && props.spinning) {
33
+ // 独立模式下如果没有内容,不建议显示加载状态
34
+ // 但这里不强制修改,让用户自己控制
35
+ }
16
36
 
17
37
  // 支持从多个位置读取配置
18
38
  const bindField =
@@ -59,14 +79,36 @@ export default {
59
79
  }
60
80
  }
61
81
 
62
- // 确保子组件不被 a-col 包装
63
- if (ctx.rule.children && Array.isArray(ctx.rule.children)) {
82
+ // 只在容器模式下处理 children
83
+ if (containerMode) {
84
+ // 确保 children 存在
85
+ if (!ctx.rule.children) {
86
+ ctx.rule.children = []
87
+ }
88
+
89
+ // 确保子组件不被 a-col 包装
90
+ if (ctx.rule.children && Array.isArray(ctx.rule.children)) {
64
91
  ctx.rule.children.forEach((child) => {
65
- if (child && typeof child === 'object' && child.col !== false) {
66
- child.col = false
92
+ if (
93
+ child &&
94
+ typeof child === 'object' &&
95
+ child.type !== 'DragTool' &&
96
+ child.type !== 'DragBox'
97
+ ) {
98
+ // 只有当 col 未设置或为默认值时才设置
99
+ if (child.col === undefined || child.col === null) {
100
+ child.col = false
101
+ } else if (
102
+ child.col &&
103
+ typeof child.col === 'object' &&
104
+ child.col.show !== false
105
+ ) {
106
+ child.col.show = false
107
+ }
67
108
  }
68
109
  })
69
110
  }
111
+ }
70
112
  },
71
113
  render(children, ctx) {
72
114
  // 获取 spinning 状态
@@ -100,14 +142,33 @@ export default {
100
142
  }
101
143
 
102
144
  // 设置类型为 a-spin
103
- ctx.prop.type = 'a-spin'
145
+ if (ctx.prop.type === 'spin') {
146
+ ctx.prop.type = 'a-spin'
147
+ }
104
148
 
105
- // 如果有子组件,渲染子组件,否则渲染默认内容
106
- const childrenNodes = children && Array.isArray(children) && children.length > 0
107
- ? children
108
- : null
149
+ // 读取 containerMode 配置
150
+ const containerMode =
151
+ ctx.rule.containerMode ??
152
+ ctx.rule.props?.containerMode ??
153
+ ctx.prop.props?.containerMode ??
154
+ true
155
+
156
+ // 如果不是容器模式,不渲染 children,直接使用 defaultRender
157
+ if (!containerMode) {
158
+ return ctx.$render.defaultRender(ctx, undefined)
159
+ }
160
+
161
+ // 容器模式:使用传入的 children 参数
162
+ // children 参数已经是渲染好的 vnodes,直接传递给 a-spin
163
+ const childrenNodes = children && Array.isArray(children) ? children : (children || [])
109
164
 
110
- return ctx.vNode.make('a-spin', ctx.prop, childrenNodes)
165
+ // spin 容器包装在 col 中,确保它占满整行(span: 24)
166
+ return ctx.vNode.col(
167
+ { props: { span: 24 } },
168
+ {
169
+ default: () => [ctx.vNode.make('a-spin', ctx.prop, childrenNodes)]
170
+ }
171
+ )
111
172
  }
112
173
  }
113
174