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

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.67",
3
+ "version": "3.2.68",
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
@@ -30,6 +30,7 @@ export default {
30
30
  flex: PRE + 'Flex',
31
31
  space: PRE + 'Space',
32
32
  'space-compact': PRE + 'SpaceCompact',
33
+ spin: PRE + 'Spin',
33
34
  tree: PRE + 'Tree',
34
35
  autoComplete: PRE + 'AutoComplete',
35
36
  transfer: PRE + 'Transfer',
package/src/core/maker.js CHANGED
@@ -106,6 +106,10 @@ function useSpace(maker) {
106
106
  maker.space = creatorFactory('space')
107
107
  }
108
108
 
109
+ function useSpin(maker) {
110
+ maker.spin = creatorFactory('spin')
111
+ }
112
+
109
113
  useAlias(maker)
110
114
  useSlider(maker)
111
115
  useFrame(maker)
@@ -116,5 +120,6 @@ useCusUserSelect(maker)
116
120
  useText(maker)
117
121
  useFlex(maker)
118
122
  useSpace(maker)
123
+ useSpin(maker)
119
124
 
120
125
  export default maker
@@ -56,29 +56,19 @@ export default {
56
56
  if (is.Function(parsedFn)) {
57
57
  // 包装 loadData 函数
58
58
  props.loadData = function (selectedOptions) {
59
- console.log('[Cascader loadData] ========== 开始 ==========')
60
- console.log('[Cascader loadData] selectedOptions:', selectedOptions)
61
-
62
59
  if (!selectedOptions || selectedOptions.length === 0) return
63
60
 
64
61
  const targetOption = selectedOptions[selectedOptions.length - 1]
65
- console.log('[Cascader loadData] targetOption:', targetOption)
66
62
 
67
63
  if (targetOption?.isLeaf === true) {
68
- console.log('[Cascader loadData] 是叶子节点,直接返回')
69
64
  return
70
65
  }
71
66
 
72
67
  const options = props.options || []
73
- console.log('[Cascader loadData] 当前 options:', options)
74
- console.log('[Cascader loadData] props.options:', props.options)
75
68
 
76
69
  // 创建 updateOptions 函数,完全按照 effect.fetch 的方式
77
70
  // 关键:effect.fetch 使用 deepSet(inject.getProp(), 'props.options', val) 然后 api.sync(rule)
78
71
  const updateOptions = () => {
79
- console.log(
80
- '[Cascader updateOptions] ========== 开始更新 =========='
81
- )
82
72
  // 关键:创建新数组时,同时创建新对象,确保引用完全改变
83
73
  // 这样可以触发 Vue 的响应式更新,即使对象属性被修改了
84
74
  const currentOptions = props.options || []
@@ -92,38 +82,17 @@ export default {
92
82
  item.id === targetOption.id ||
93
83
  item === targetOption
94
84
  )
95
- console.log('[Cascader updateOptions] targetIndex:', targetIndex)
96
85
  }
97
86
 
98
87
  const newOptions = currentOptions.map((item, index) => {
99
88
  // 如果是 targetOption,创建包含所有修改的新对象
100
89
  if (index === targetIndex && targetOption) {
101
90
  const newTarget = { ...targetOption }
102
- console.log('[Cascader updateOptions] 创建新对象:', newTarget)
103
- console.log(
104
- '[Cascader updateOptions] newTarget.loading:',
105
- newTarget.loading
106
- )
107
- console.log(
108
- '[Cascader updateOptions] newTarget.children:',
109
- newTarget.children
110
- )
111
91
  return newTarget
112
92
  }
113
93
  // 其他对象创建新引用(浅拷贝即可)
114
94
  return { ...item }
115
95
  })
116
- console.log('[Cascader updateOptions] 新数组:', newOptions)
117
- if (targetIndex >= 0 && newOptions[targetIndex]) {
118
- console.log(
119
- '[Cascader updateOptions] 新数组[targetIndex]:',
120
- newOptions[targetIndex]
121
- )
122
- console.log(
123
- '[Cascader updateOptions] 新数组[targetIndex].loading:',
124
- newOptions[targetIndex].loading
125
- )
126
- }
127
96
 
128
97
  // 完全按照 effect.fetch 的方式:使用 deepSet 在响应式对象上设置值
129
98
  // effect.fetch 使用: deepSet(inject.getProp(), 'props.options', val)
@@ -133,9 +102,6 @@ export default {
133
102
  if (fetchData) {
134
103
  // 关键:在 fetchData 上设置,就像 effect.fetch 那样
135
104
  deepSet(fetchData, 'props.options', newOptions)
136
- console.log(
137
- '[Cascader updateOptions] deepSet(fetchData, props.options) 完成'
138
- )
139
105
  }
140
106
 
141
107
  // 同时直接更新 props.options(这是最终传递给组件的值)
@@ -151,38 +117,25 @@ export default {
151
117
  ctxRef.rule.props.options = newOptions
152
118
  }
153
119
 
154
- console.log(
155
- '[Cascader updateOptions] 所有位置已同步,props.options:',
156
- props.options
157
- )
158
-
159
120
  // 调用 api.sync 触发更新,就像 effect.fetch 那样
160
121
  if (api && rule) {
161
- console.log('[Cascader updateOptions] 调用 api.sync')
162
122
  api.sync(rule)
163
123
  }
164
124
 
165
125
  // 刷新组件
166
126
  if (ctxRef.$handle) {
167
- console.log('[Cascader updateOptions] 调用 refresh')
168
127
  ctxRef.$handle.refresh()
169
128
  }
170
-
171
- console.log(
172
- '[Cascader updateOptions] ========== 更新完成 =========='
173
- )
174
129
  }
175
130
 
176
131
  // 关键:在调用用户函数之前,立即设置 loading 并更新
177
132
  // 这样确保 loading 状态能立即显示
178
133
  if (targetOption) {
179
- console.log('[Cascader loadData] 设置 loading = true')
180
134
  targetOption.loading = true
181
135
  updateOptions()
182
136
  }
183
137
 
184
138
  // 调用用户函数
185
- console.log('[Cascader loadData] 调用用户函数')
186
139
  const result = parsedFn.call(
187
140
  this,
188
141
  selectedOptions,
@@ -191,20 +144,14 @@ export default {
191
144
  api,
192
145
  rule
193
146
  )
194
- console.log('[Cascader loadData] 用户函数返回值:', result)
195
147
 
196
148
  // 如果用户函数返回 Promise,等待完成
197
149
  if (result && typeof result.then === 'function') {
198
- console.log('[Cascader loadData] 用户函数返回 Promise')
199
150
  return result.finally(() => {
200
- console.log(
201
- '[Cascader loadData] Promise 完成,调用 updateOptions'
202
- )
203
151
  updateOptions()
204
152
  })
205
153
  }
206
154
 
207
- console.log('[Cascader loadData] ========== 结束 ==========')
208
155
  return result
209
156
  }
210
157
  }
@@ -15,6 +15,7 @@ import cusStoreSelect from './cusStoreSelect'
15
15
  import cusUserSelect from './cusUserSelect'
16
16
  import flex from './flex'
17
17
  import space from './space'
18
+ import spin from './spin'
18
19
 
19
20
  export default [
20
21
  checkbox,
@@ -33,5 +34,6 @@ export default [
33
34
  cusStoreSelect,
34
35
  cusUserSelect,
35
36
  flex,
36
- space
37
+ space,
38
+ spin
37
39
  ]
@@ -0,0 +1,113 @@
1
+ import { hasProperty } from '@form-create/utils/lib/type'
2
+
3
+ export default {
4
+ name: 'spin',
5
+ mergeProp(ctx) {
6
+ // 确保不显示标题
7
+ if (!ctx.rule.wrap) {
8
+ ctx.rule.wrap = {}
9
+ }
10
+ ctx.rule.wrap.title = false
11
+
12
+ const props = ctx.prop.props || {}
13
+ if (!hasProperty(props, 'spinning')) {
14
+ props.spinning = ctx.prop.props?.spinning ?? ctx.rule.props?.spinning ?? false
15
+ }
16
+
17
+ // 支持从多个位置读取配置
18
+ const bindField =
19
+ ctx.rule.bindField || ctx.rule.props?.bindField || ctx.prop.props?.bindField
20
+ let bindMode =
21
+ ctx.rule.bindMode || ctx.rule.props?.bindMode || ctx.prop.props?.bindMode
22
+
23
+ // 如果没有设置 bindMode,根据是否有 bindField 自动判断
24
+ if (!bindMode) {
25
+ if (bindField) {
26
+ bindMode = 'field'
27
+ } else {
28
+ bindMode = 'static'
29
+ }
30
+ }
31
+
32
+ // 如果配置了 bindField(绑定单个字段),使用 loadData 来实现动态绑定
33
+ if (bindMode === 'field' && bindField) {
34
+ const loadDataConfig = {
35
+ attr: bindField,
36
+ to: 'props.spinning',
37
+ modify: true,
38
+ wait: 300,
39
+ watch: true
40
+ }
41
+
42
+ // 添加到 effect 中(避免重复添加)
43
+ if (!ctx.rule.effect) {
44
+ ctx.rule.effect = {}
45
+ }
46
+ if (!ctx.rule.effect.loadData) {
47
+ ctx.rule.effect.loadData = []
48
+ }
49
+ // 检查是否已存在相同的配置,避免重复添加
50
+ const exists = ctx.rule.effect.loadData.some(
51
+ (item) => item.attr === bindField && item.to === 'props.spinning'
52
+ )
53
+ if (!exists) {
54
+ ctx.rule.effect.loadData.push(loadDataConfig)
55
+ // 手动触发 effect 来确保 loadData provider 被调用
56
+ if (ctx.$handle && ctx.$handle.effect) {
57
+ ctx.$handle.effect(ctx, 'loaded')
58
+ }
59
+ }
60
+ }
61
+
62
+ // 确保子组件不被 a-col 包装
63
+ if (ctx.rule.children && Array.isArray(ctx.rule.children)) {
64
+ ctx.rule.children.forEach((child) => {
65
+ if (child && typeof child === 'object' && child.col !== false) {
66
+ child.col = false
67
+ }
68
+ })
69
+ }
70
+ },
71
+ render(children, ctx) {
72
+ // 获取 spinning 状态
73
+ const props = ctx.prop.props || {}
74
+ const spinning = props.spinning || false
75
+
76
+ // 设置组件类型为 a-spin
77
+ if (!ctx.prop.props) {
78
+ ctx.prop.props = {}
79
+ }
80
+
81
+ // 映射 props
82
+ ctx.prop.props.spinning = spinning
83
+
84
+ // 如果有 tip,设置 tip prop
85
+ const tip = ctx.rule.tip || ctx.rule.props?.tip || ctx.prop.props?.tip
86
+ if (tip) {
87
+ ctx.prop.props.tip = tip
88
+ }
89
+
90
+ // 如果有 delay,设置 delay prop
91
+ const delay = ctx.rule.delay || ctx.rule.props?.delay || ctx.prop.props?.delay
92
+ if (delay != null) {
93
+ ctx.prop.props.delay = delay
94
+ }
95
+
96
+ // 如果有 size,设置 size prop
97
+ const size = ctx.rule.size || ctx.rule.props?.size || ctx.prop.props?.size
98
+ if (size) {
99
+ ctx.prop.props.size = size
100
+ }
101
+
102
+ // 设置类型为 a-spin
103
+ ctx.prop.type = 'a-spin'
104
+
105
+ // 如果有子组件,渲染子组件,否则渲染默认内容
106
+ const childrenNodes = children && Array.isArray(children) && children.length > 0
107
+ ? children
108
+ : null
109
+
110
+ return ctx.vNode.make('a-spin', ctx.prop, childrenNodes)
111
+ }
112
+ }
113
+
package/types/maker.d.ts CHANGED
@@ -66,7 +66,8 @@ declare enum MakerName {
66
66
  'cusUserSelect',
67
67
  'userSelect',
68
68
  'flex',
69
- 'space'
69
+ 'space',
70
+ 'spin'
70
71
  }
71
72
 
72
73
  type Maker = {