@longhongguo/form-create-ant-design-vue 3.2.70 → 3.2.72
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/auto-import.js +3 -1
- package/dist/form-create.esm.js +2 -2
- package/dist/form-create.esm.js.map +1 -1
- package/dist/form-create.js +2 -2
- package/dist/form-create.js.map +1 -1
- package/package.json +1 -1
- package/src/core/alias.js +3 -1
- package/src/core/manager.js +80 -0
- package/src/parsers/spin.js +46 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longhongguo/form-create-ant-design-vue",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.72",
|
|
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",
|
package/src/core/alias.js
CHANGED
package/src/core/manager.js
CHANGED
|
@@ -158,6 +158,86 @@ export default {
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
+
|
|
162
|
+
// 为 aImage 组件自动添加预览拦截,确保始终向父窗口发送预览通知
|
|
163
|
+
if (
|
|
164
|
+
(ctx.rule.type === 'image' || ctx.rule.type === 'aImage') &&
|
|
165
|
+
!ctx.prop.props.preview
|
|
166
|
+
) {
|
|
167
|
+
const sendImagePreviewMessage = function (src) {
|
|
168
|
+
if (window.parent && window.parent !== window) {
|
|
169
|
+
window.parent.postMessage(
|
|
170
|
+
{
|
|
171
|
+
type: 'upload-preview',
|
|
172
|
+
file: {
|
|
173
|
+
url: src || ctx.prop.props.src || ''
|
|
174
|
+
},
|
|
175
|
+
timestamp: Date.now()
|
|
176
|
+
},
|
|
177
|
+
'*'
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// 拦截 Image 组件的预览,发送消息给父窗口并阻止默认预览
|
|
183
|
+
const imageSrc = ctx.prop.props.src || ''
|
|
184
|
+
ctx.prop.props.preview = {
|
|
185
|
+
visible: false,
|
|
186
|
+
src: imageSrc,
|
|
187
|
+
onVisibleChange: (visible, prevVisible) => {
|
|
188
|
+
if (visible && !prevVisible) {
|
|
189
|
+
// 发送预览通知给父窗口
|
|
190
|
+
sendImagePreviewMessage(imageSrc)
|
|
191
|
+
// 返回 false 阻止默认预览显示
|
|
192
|
+
return false
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
} else if (
|
|
197
|
+
(ctx.rule.type === 'image' || ctx.rule.type === 'aImage') &&
|
|
198
|
+
ctx.prop.props.preview
|
|
199
|
+
) {
|
|
200
|
+
// 如果用户已经设置了 preview,包装它以确保先发送消息
|
|
201
|
+
const originalPreview = ctx.prop.props.preview
|
|
202
|
+
const sendImagePreviewMessage = function (src) {
|
|
203
|
+
if (window.parent && window.parent !== window) {
|
|
204
|
+
window.parent.postMessage(
|
|
205
|
+
{
|
|
206
|
+
type: 'upload-preview',
|
|
207
|
+
file: {
|
|
208
|
+
url: src || ctx.prop.props.src || ''
|
|
209
|
+
},
|
|
210
|
+
timestamp: Date.now()
|
|
211
|
+
},
|
|
212
|
+
'*'
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const imageSrc = ctx.prop.props.src || ''
|
|
218
|
+
const originalOnVisibleChange = originalPreview?.onVisibleChange
|
|
219
|
+
|
|
220
|
+
ctx.prop.props.preview = {
|
|
221
|
+
...originalPreview,
|
|
222
|
+
visible: originalPreview.visible || false,
|
|
223
|
+
src: originalPreview.src || imageSrc,
|
|
224
|
+
onVisibleChange: (visible, prevVisible) => {
|
|
225
|
+
if (visible && !prevVisible) {
|
|
226
|
+
// 先发送消息给父窗口
|
|
227
|
+
sendImagePreviewMessage(originalPreview.src || imageSrc)
|
|
228
|
+
}
|
|
229
|
+
// 执行用户自定义的 onVisibleChange
|
|
230
|
+
if (
|
|
231
|
+
originalOnVisibleChange &&
|
|
232
|
+
typeof originalOnVisibleChange === 'function'
|
|
233
|
+
) {
|
|
234
|
+
return originalOnVisibleChange.apply(this, arguments)
|
|
235
|
+
}
|
|
236
|
+
// 默认阻止预览显示
|
|
237
|
+
return false
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
161
241
|
},
|
|
162
242
|
getDefaultOptions() {
|
|
163
243
|
return getConfig()
|
package/src/parsers/spin.js
CHANGED
|
@@ -8,27 +8,31 @@ export default {
|
|
|
8
8
|
ctx.rule.wrap = {}
|
|
9
9
|
}
|
|
10
10
|
ctx.rule.wrap.title = false
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
const props = ctx.prop.props || {}
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
// 读取 containerMode 配置
|
|
15
|
-
const containerMode =
|
|
16
|
-
ctx.rule.containerMode ??
|
|
17
|
-
ctx.rule.props?.containerMode ??
|
|
18
|
-
ctx.prop.props?.containerMode ??
|
|
15
|
+
const containerMode =
|
|
16
|
+
ctx.rule.containerMode ??
|
|
17
|
+
ctx.rule.props?.containerMode ??
|
|
18
|
+
ctx.prop.props?.containerMode ??
|
|
19
19
|
true
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
// 如果不是容器模式,清空 children
|
|
22
22
|
if (!containerMode) {
|
|
23
23
|
ctx.rule.children = []
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
if (!hasProperty(props, 'spinning')) {
|
|
27
|
-
props.spinning =
|
|
27
|
+
props.spinning =
|
|
28
|
+
ctx.prop.props?.spinning ?? ctx.rule.props?.spinning ?? false
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
+
|
|
30
31
|
// 如果没有子组件且不是容器模式,spinning 不应该为 true(避免显示空加载状态)
|
|
31
|
-
const hasChildren =
|
|
32
|
+
const hasChildren =
|
|
33
|
+
ctx.rule.children &&
|
|
34
|
+
Array.isArray(ctx.rule.children) &&
|
|
35
|
+
ctx.rule.children.length > 0
|
|
32
36
|
if (!containerMode && !hasChildren && props.spinning) {
|
|
33
37
|
// 独立模式下如果没有内容,不建议显示加载状态
|
|
34
38
|
// 但这里不强制修改,让用户自己控制
|
|
@@ -36,7 +40,9 @@ export default {
|
|
|
36
40
|
|
|
37
41
|
// 支持从多个位置读取配置
|
|
38
42
|
const bindField =
|
|
39
|
-
ctx.rule.bindField ||
|
|
43
|
+
ctx.rule.bindField ||
|
|
44
|
+
ctx.rule.props?.bindField ||
|
|
45
|
+
ctx.prop.props?.bindField
|
|
40
46
|
let bindMode =
|
|
41
47
|
ctx.rule.bindMode || ctx.rule.props?.bindMode || ctx.prop.props?.bindMode
|
|
42
48
|
|
|
@@ -88,26 +94,26 @@ export default {
|
|
|
88
94
|
|
|
89
95
|
// 确保子组件不被 a-col 包装
|
|
90
96
|
if (ctx.rule.children && Array.isArray(ctx.rule.children)) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
|
97
|
+
ctx.rule.children.forEach((child) => {
|
|
98
|
+
if (
|
|
99
|
+
child &&
|
|
100
|
+
typeof child === 'object' &&
|
|
101
|
+
child.type !== 'DragTool' &&
|
|
102
|
+
child.type !== 'DragBox'
|
|
105
103
|
) {
|
|
106
|
-
|
|
104
|
+
// 只有当 col 未设置或为默认值时才设置
|
|
105
|
+
if (child.col === undefined || child.col === null) {
|
|
106
|
+
child.col = false
|
|
107
|
+
} else if (
|
|
108
|
+
child.col &&
|
|
109
|
+
typeof child.col === 'object' &&
|
|
110
|
+
child.col.show !== false
|
|
111
|
+
) {
|
|
112
|
+
child.col.show = false
|
|
113
|
+
}
|
|
107
114
|
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
115
|
+
})
|
|
116
|
+
}
|
|
111
117
|
}
|
|
112
118
|
},
|
|
113
119
|
render(children, ctx) {
|
|
@@ -130,7 +136,8 @@ export default {
|
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
// 如果有 delay,设置 delay prop
|
|
133
|
-
const delay =
|
|
139
|
+
const delay =
|
|
140
|
+
ctx.rule.delay || ctx.rule.props?.delay || ctx.prop.props?.delay
|
|
134
141
|
if (delay != null) {
|
|
135
142
|
ctx.prop.props.delay = delay
|
|
136
143
|
}
|
|
@@ -147,12 +154,12 @@ export default {
|
|
|
147
154
|
}
|
|
148
155
|
|
|
149
156
|
// 读取 containerMode 配置
|
|
150
|
-
const containerMode =
|
|
151
|
-
ctx.rule.containerMode ??
|
|
152
|
-
ctx.rule.props?.containerMode ??
|
|
153
|
-
ctx.prop.props?.containerMode ??
|
|
157
|
+
const containerMode =
|
|
158
|
+
ctx.rule.containerMode ??
|
|
159
|
+
ctx.rule.props?.containerMode ??
|
|
160
|
+
ctx.prop.props?.containerMode ??
|
|
154
161
|
true
|
|
155
|
-
|
|
162
|
+
|
|
156
163
|
// 如果不是容器模式,不渲染 children,直接使用 defaultRender
|
|
157
164
|
if (!containerMode) {
|
|
158
165
|
return ctx.$render.defaultRender(ctx, undefined)
|
|
@@ -160,9 +167,11 @@ export default {
|
|
|
160
167
|
|
|
161
168
|
// 容器模式:使用传入的 children 参数
|
|
162
169
|
// children 参数已经是渲染好的 vnodes,直接传递给 a-spin
|
|
163
|
-
const childrenNodes =
|
|
170
|
+
const childrenNodes =
|
|
171
|
+
children && Array.isArray(children) ? children : children || []
|
|
164
172
|
|
|
165
173
|
// 将 spin 容器包装在 col 中,确保它占满整行(span: 24)
|
|
174
|
+
// 直接使用 vNode.make 来渲染 a-spin,并传入 childrenNodes(类似 flex 组件的处理方式)
|
|
166
175
|
return ctx.vNode.col(
|
|
167
176
|
{ props: { span: 24 } },
|
|
168
177
|
{
|
|
@@ -171,4 +180,3 @@ export default {
|
|
|
171
180
|
)
|
|
172
181
|
}
|
|
173
182
|
}
|
|
174
|
-
|