@longhongguo/form-create-ant-design-vue 3.2.56 → 3.2.59
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/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/manager.js +39 -1
- package/src/parsers/flex.js +41 -3
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.59",
|
|
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/manager.js
CHANGED
|
@@ -84,6 +84,25 @@ export default {
|
|
|
84
84
|
)
|
|
85
85
|
})
|
|
86
86
|
|
|
87
|
+
// 检查父容器是否是 flex 类型,如果是,自动设置 col: false 避免被 a-col 包装
|
|
88
|
+
// 需要在合并完 col 后再检查,确保能覆盖默认值
|
|
89
|
+
if (ctx.parent && ctx.parent.rule) {
|
|
90
|
+
const parentType = ctx.parent.rule.type
|
|
91
|
+
const parentMenu = ctx.parent.rule._menu
|
|
92
|
+
if (
|
|
93
|
+
parentType === 'flex' ||
|
|
94
|
+
parentType === 'a-flex' ||
|
|
95
|
+
parentMenu?.name === 'flex'
|
|
96
|
+
) {
|
|
97
|
+
// 如果父容器是 flex,强制设置 col 为 false,禁用 col 包装
|
|
98
|
+
ctx.prop.col = false
|
|
99
|
+
// 同时设置 rule.col 以确保在 makeWrap 中也能识别
|
|
100
|
+
if (ctx.rule) {
|
|
101
|
+
ctx.rule.col = false
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
87
106
|
// 为 upload 组件自动添加 onPreview,确保始终向父窗口发送预览通知
|
|
88
107
|
if (ctx.rule.type === 'upload' && !ctx.prop.props.onPreview) {
|
|
89
108
|
const sendPreviewMessage = function (file) {
|
|
@@ -205,6 +224,21 @@ export default {
|
|
|
205
224
|
const cls = rule.wrap.class
|
|
206
225
|
delete rule.wrap.class
|
|
207
226
|
delete rule.wrap.title
|
|
227
|
+
|
|
228
|
+
// 检查父容器是否是 flex 类型,如果是,强制禁用 col 包装
|
|
229
|
+
let shouldDisableCol = false
|
|
230
|
+
if (ctx.parent && ctx.parent.rule) {
|
|
231
|
+
const parentType = ctx.parent.rule.type
|
|
232
|
+
const parentMenu = ctx.parent.rule._menu
|
|
233
|
+
if (
|
|
234
|
+
parentType === 'flex' ||
|
|
235
|
+
parentType === 'a-flex' ||
|
|
236
|
+
parentMenu?.name === 'flex'
|
|
237
|
+
) {
|
|
238
|
+
shouldDisableCol = true
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
208
242
|
const item = isFalse(rule.wrap.show)
|
|
209
243
|
? children
|
|
210
244
|
: this.$r(
|
|
@@ -234,7 +268,11 @@ export default {
|
|
|
234
268
|
...(isTitle ? { label: () => this.makeInfo(rule, uni, ctx) } : {})
|
|
235
269
|
}
|
|
236
270
|
)
|
|
237
|
-
|
|
271
|
+
// 如果父容器是 flex,或者 layout 是 inline,或者 col 被显式禁用,则不使用 col 包装
|
|
272
|
+
return layout === 'inline' ||
|
|
273
|
+
isFalse(_col) ||
|
|
274
|
+
isFalse(col.show) ||
|
|
275
|
+
shouldDisableCol
|
|
238
276
|
? item
|
|
239
277
|
: this.makeCol(rule, uni, [item])
|
|
240
278
|
},
|
package/src/parsers/flex.js
CHANGED
|
@@ -62,14 +62,45 @@ export default {
|
|
|
62
62
|
alignItems: _ai,
|
|
63
63
|
...otherStyles
|
|
64
64
|
} = existingStyle
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
|
|
66
|
+
// 确保 flex 容器占满整行,设置 width: 100%
|
|
67
|
+
if (!ctx.prop.props.style) {
|
|
68
|
+
ctx.prop.props.style = {}
|
|
69
|
+
}
|
|
70
|
+
ctx.prop.props.style = {
|
|
71
|
+
width: '100%',
|
|
72
|
+
...otherStyles,
|
|
73
|
+
...ctx.prop.props.style
|
|
67
74
|
}
|
|
68
75
|
|
|
69
76
|
// 确保 children 存在
|
|
70
77
|
if (!ctx.rule.children) {
|
|
71
78
|
ctx.rule.children = []
|
|
72
79
|
}
|
|
80
|
+
|
|
81
|
+
// 为 flex 容器的所有子组件设置 col: false,避免被 a-col 包装
|
|
82
|
+
// 这样可以确保子组件直接作为 flex 子项,而不是占满整行
|
|
83
|
+
if (ctx.rule.children && Array.isArray(ctx.rule.children)) {
|
|
84
|
+
ctx.rule.children.forEach((child) => {
|
|
85
|
+
if (
|
|
86
|
+
child &&
|
|
87
|
+
typeof child === 'object' &&
|
|
88
|
+
!child.type === 'DragTool' &&
|
|
89
|
+
!child.type === 'DragBox'
|
|
90
|
+
) {
|
|
91
|
+
// 只有当 col 未设置或为默认值时才设置
|
|
92
|
+
if (child.col === undefined || child.col === null) {
|
|
93
|
+
child.col = false
|
|
94
|
+
} else if (
|
|
95
|
+
child.col &&
|
|
96
|
+
typeof child.col === 'object' &&
|
|
97
|
+
child.col.show !== false
|
|
98
|
+
) {
|
|
99
|
+
child.col.show = false
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
}
|
|
73
104
|
},
|
|
74
105
|
render(children, ctx) {
|
|
75
106
|
// 使用 Ant Design Vue 的 Flex 组件
|
|
@@ -83,6 +114,13 @@ export default {
|
|
|
83
114
|
// children 会通过 form-create 的机制自动渲染
|
|
84
115
|
const childrenNodes = children || []
|
|
85
116
|
|
|
86
|
-
|
|
117
|
+
// 将 flex 容器包装在 col 中,确保它占满整行(span: 24)
|
|
118
|
+
// 这样 flex 容器才能有足够的宽度,子项才能自适应展示
|
|
119
|
+
return ctx.vNode.col(
|
|
120
|
+
{ props: { span: 24 } },
|
|
121
|
+
{
|
|
122
|
+
default: () => [ctx.vNode.make('a-flex', prop, childrenNodes)]
|
|
123
|
+
}
|
|
124
|
+
)
|
|
87
125
|
}
|
|
88
126
|
}
|