@longhongguo/form-create-ant-design-vue 3.2.71 → 3.2.73

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.71",
3
+ "version": "3.2.73",
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",
@@ -51,7 +51,7 @@
51
51
  "dependencies": {
52
52
  "@form-create/component-antdv-frame": "^3.2.31",
53
53
  "@form-create/component-antdv-group": "^3.2.31",
54
- "@form-create/component-antdv-upload": "^3.2.31",
54
+ "@longhongguo/component-antdv-upload": "^3.2.41",
55
55
  "@form-create/component-subform": "^3.1.34",
56
56
  "@longhongguo/form-create-core": "latest",
57
57
  "@form-create/core": "^3.2.33",
@@ -1,4 +1,4 @@
1
- import upload from '@form-create/component-antdv-upload/src/index'
1
+ import upload from '@longhongguo/component-antdv-upload/src/index'
2
2
  import frame from '@form-create/component-antdv-frame/src/index'
3
3
  import group from '@form-create/component-antdv-group/src/index'
4
4
  import subForm from '@form-create/component-subform/src/index'
package/src/core/alias.js CHANGED
@@ -37,5 +37,7 @@ export default {
37
37
  group: 'fcGroup',
38
38
  array: 'fcGroup',
39
39
  subForm: 'fcSubForm',
40
- object: 'fcSubForm'
40
+ object: 'fcSubForm',
41
+ image: PRE + 'Image',
42
+ aImage: PRE + 'Image'
41
43
  }
package/src/core/index.js CHANGED
@@ -6,6 +6,7 @@ import FormCreateFactory from '@longhongguo/form-create-core/src/index'
6
6
  import makers from './maker'
7
7
  import '../style/index.css'
8
8
  import '../style/icon.css'
9
+ import '@longhongguo/component-antdv-upload/dist/index.css'
9
10
  import extendApi from './api'
10
11
  import modelFields from './modelFields'
11
12
  import required from './provider'
@@ -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()
@@ -92,40 +92,6 @@ export default {
92
92
  ctx.rule.children = []
93
93
  }
94
94
 
95
- // 检查是否有真实的子组件(用于判断是否需要自适应)
96
- const hasRealChildren =
97
- ctx.rule.children &&
98
- Array.isArray(ctx.rule.children) &&
99
- ctx.rule.children.some((child) => {
100
- if (!child || typeof child !== 'object') return false
101
- return child.type !== 'DragTool' && child.type !== 'DragBox'
102
- })
103
-
104
- // 如果有子组件,设置 wrap 的 class 和样式让整个布局自适应内容
105
- if (hasRealChildren) {
106
- // 添加 class 用于样式控制
107
- if (!ctx.rule.wrap.class) {
108
- ctx.rule.wrap.class = ''
109
- }
110
- const wrapClass =
111
- typeof ctx.rule.wrap.class === 'string'
112
- ? ctx.rule.wrap.class.split(' ').filter(Boolean)
113
- : Array.isArray(ctx.rule.wrap.class)
114
- ? ctx.rule.wrap.class
115
- : []
116
- if (!wrapClass.includes('_fc-spin-wrap-fit')) {
117
- wrapClass.push('_fc-spin-wrap-fit')
118
- ctx.rule.wrap.class = wrapClass.join(' ')
119
- }
120
-
121
- // 设置样式
122
- if (!ctx.rule.wrap.style) {
123
- ctx.rule.wrap.style = {}
124
- }
125
- ctx.rule.wrap.style.width = 'fit-content'
126
- ctx.rule.wrap.style.display = 'inline-block'
127
- }
128
-
129
95
  // 确保子组件不被 a-col 包装
130
96
  if (ctx.rule.children && Array.isArray(ctx.rule.children)) {
131
97
  ctx.rule.children.forEach((child) => {
@@ -204,36 +170,10 @@ export default {
204
170
  const childrenNodes =
205
171
  children && Array.isArray(children) ? children : children || []
206
172
 
207
- // 检查是否有子组件(排除设计器内部组件)
208
- const hasRealChildren =
209
- childrenNodes &&
210
- Array.isArray(childrenNodes) &&
211
- childrenNodes.some((node) => {
212
- if (!node || typeof node !== 'object') return false
213
- const nodeType = node.type?.name || node.type
214
- return nodeType !== 'DragTool' && nodeType !== 'DragBox'
215
- })
216
-
217
- // 添加 class 标识,用于样式控制(当有子组件时)
218
- if (hasRealChildren) {
219
- if (!ctx.prop.class) {
220
- ctx.prop.class = []
221
- }
222
- if (!Array.isArray(ctx.prop.class)) {
223
- ctx.prop.class = [ctx.prop.class]
224
- }
225
- if (!ctx.prop.class.includes('_fc-spin-container')) {
226
- ctx.prop.class.push('_fc-spin-container')
227
- }
228
- }
229
-
230
- // 始终包装在 col 中
231
- // 通过 CSS 类让有子组件时自适应内容
173
+ // 将 spin 容器包装在 col 中,确保它占满整行(span: 24)
174
+ // 直接使用 vNode.make 来渲染 a-spin,并传入 childrenNodes(类似 flex 组件的处理方式)
232
175
  return ctx.vNode.col(
233
- {
234
- props: { span: 24 },
235
- class: hasRealChildren ? '_fc-spin-col-fit' : ''
236
- },
176
+ { props: { span: 24 } },
237
177
  {
238
178
  default: () => [ctx.vNode.make('a-spin', ctx.prop, childrenNodes)]
239
179
  }
@@ -501,45 +501,3 @@
501
501
  .ant-flex._fc-flex-vertical > .ant-form-item {
502
502
  width: var(--fc-child-width, 100%) !important;
503
503
  }
504
-
505
- /* Spin 容器自适应子组件尺寸 - 让整个布局链自适应 */
506
- /* 通过 form-item 的 class 控制整个布局 */
507
- .ant-form-item._fc-spin-wrap-fit {
508
- width: fit-content !important;
509
- display: inline-block !important;
510
- }
511
-
512
- .ant-form-item._fc-spin-wrap-fit .ant-form-item-control {
513
- width: fit-content !important;
514
- flex: none !important;
515
- }
516
-
517
- .ant-form-item._fc-spin-wrap-fit .ant-form-item-control-input {
518
- width: fit-content !important;
519
- }
520
-
521
- .ant-form-item._fc-spin-wrap-fit .ant-form-item-control-input-content {
522
- width: fit-content !important;
523
- display: inline-block !important;
524
- }
525
-
526
- /* col 自适应 */
527
- .ant-form-item._fc-spin-wrap-fit .ant-col._fc-spin-col-fit {
528
- width: fit-content !important;
529
- flex: 0 0 auto !important;
530
- max-width: 100% !important;
531
- }
532
-
533
- /* Spin 组件自适应 */
534
- .ant-form-item._fc-spin-wrap-fit .ant-spin._fc-spin-container {
535
- display: inline-block !important;
536
- width: fit-content !important;
537
- height: fit-content !important;
538
- }
539
-
540
- /* 确保 Spin 容器内的内容决定容器大小 */
541
- .ant-form-item._fc-spin-wrap-fit .ant-spin._fc-spin-container .ant-spin-container {
542
- display: inline-block !important;
543
- width: fit-content !important;
544
- height: fit-content !important;
545
- }