@longhongguo/form-create-ant-design-vue 3.2.89 → 3.2.90
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/parsers/accTable.js +164 -163
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.90",
|
|
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/parsers/accTable.js
CHANGED
|
@@ -97,14 +97,15 @@ export default {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
// 处理分页配置
|
|
100
|
+
const paginationConfig = rule.props?.pagination
|
|
100
101
|
console.log('[accTable] 开始处理分页配置:', {
|
|
101
102
|
hasPaginationProp: hasProperty(props, 'pagination'),
|
|
102
|
-
paginationConfig
|
|
103
|
-
paginationConfigType: typeof
|
|
103
|
+
paginationConfig,
|
|
104
|
+
paginationConfigType: typeof paginationConfig
|
|
104
105
|
})
|
|
105
106
|
|
|
107
|
+
// 处理分页 props(只有在 props 中没有 pagination 时才初始化)
|
|
106
108
|
if (!hasProperty(props, 'pagination')) {
|
|
107
|
-
const paginationConfig = rule.props?.pagination
|
|
108
109
|
console.log('[accTable] 分页配置检查:', {
|
|
109
110
|
paginationConfig,
|
|
110
111
|
isFalse: paginationConfig === false,
|
|
@@ -124,193 +125,193 @@ export default {
|
|
|
124
125
|
...paginationConfig
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
})
|
|
128
|
+
props.pagination = pagination
|
|
129
|
+
} else {
|
|
130
|
+
// 默认不启用分页
|
|
131
|
+
props.pagination = false
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
rule.props?.paginationResponseDataPath || 'data'
|
|
145
|
-
const responseTotalPath =
|
|
146
|
-
rule.props?.paginationResponseTotalPath || 'total'
|
|
147
|
-
|
|
148
|
-
console.log('[accTable] 分页配置初始化:', {
|
|
149
|
-
hasFetch: !!rule.effect?.fetch,
|
|
150
|
-
paginationConfig,
|
|
151
|
-
pageParamName,
|
|
152
|
-
pageSizeParamName,
|
|
153
|
-
paramType,
|
|
154
|
-
currentPage: pagination.current,
|
|
155
|
-
currentPageSize: pagination.pageSize
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
// 包装 fetch 配置,通过 beforeFetch 钩子动态注入分页参数
|
|
159
|
-
const originalFetch = rule.effect.fetch
|
|
160
|
-
console.log('[accTable] 原始 fetch 配置:', {
|
|
161
|
-
type: typeof originalFetch,
|
|
162
|
-
isObject: typeof originalFetch === 'object',
|
|
163
|
-
originalFetch
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
if (typeof originalFetch === 'object') {
|
|
167
|
-
// 保存原始配置和分页参数配置到闭包中
|
|
168
|
-
const savedParamType = paramType
|
|
169
|
-
const savedPageParamName = pageParamName
|
|
170
|
-
const savedPageSizeParamName = pageSizeParamName
|
|
171
|
-
const savedOriginalBeforeFetch = originalFetch.beforeFetch
|
|
172
|
-
|
|
173
|
-
// 添加 beforeFetch 钩子来注入分页参数
|
|
174
|
-
originalFetch.beforeFetch = (config, { rule: r, api: a }) => {
|
|
175
|
-
console.log('[accTable] beforeFetch 被调用:', {
|
|
176
|
-
configBefore: JSON.parse(JSON.stringify(config)),
|
|
177
|
-
ruleProps: r.props,
|
|
178
|
-
pagination: r.props?.pagination
|
|
179
|
-
})
|
|
135
|
+
// 无论 props.pagination 是否已存在,只要满足条件就添加/检查 beforeFetch 钩子
|
|
136
|
+
console.log('[accTable] 检查分页钩子添加条件:', {
|
|
137
|
+
hasFetch: !!rule.effect?.fetch,
|
|
138
|
+
hasPaginationConfig: !!paginationConfig,
|
|
139
|
+
paginationConfigType: typeof paginationConfig,
|
|
140
|
+
paginationConfigValue: paginationConfig,
|
|
141
|
+
paginationCurrent: paginationConfig?.current,
|
|
142
|
+
paginationCurrentDefined: paginationConfig?.current !== undefined
|
|
143
|
+
})
|
|
180
144
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
145
|
+
if (
|
|
146
|
+
rule.effect?.fetch &&
|
|
147
|
+
paginationConfig &&
|
|
148
|
+
typeof paginationConfig === 'object' &&
|
|
149
|
+
paginationConfig.current !== undefined
|
|
150
|
+
) {
|
|
151
|
+
console.log('[accTable] ✅ 满足条件,进入分页请求参数处理逻辑')
|
|
152
|
+
|
|
153
|
+
console.log('[accTable] 进入分页请求参数处理逻辑')
|
|
154
|
+
// 获取分页参数配置
|
|
155
|
+
const pageParamName = rule.props?.paginationPageParam || 'page'
|
|
156
|
+
const pageSizeParamName =
|
|
157
|
+
rule.props?.paginationPageSizeParam || 'pageSize'
|
|
158
|
+
const paramType = rule.props?.paginationParamType || 'query' // 'query' 或 'data'
|
|
159
|
+
const responseDataPath = rule.props?.paginationResponseDataPath || 'data'
|
|
160
|
+
const responseTotalPath =
|
|
161
|
+
rule.props?.paginationResponseTotalPath || 'total'
|
|
162
|
+
|
|
163
|
+
// 获取当前分页对象(从 props 或 paginationConfig)
|
|
164
|
+
const currentPaginationObj = props.pagination || paginationConfig
|
|
165
|
+
|
|
166
|
+
console.log('[accTable] 分页配置初始化:', {
|
|
167
|
+
hasFetch: !!rule.effect?.fetch,
|
|
168
|
+
paginationConfig,
|
|
169
|
+
pageParamName,
|
|
170
|
+
pageSizeParamName,
|
|
171
|
+
paramType,
|
|
172
|
+
currentPage: currentPaginationObj?.current,
|
|
173
|
+
currentPageSize: currentPaginationObj?.pageSize
|
|
174
|
+
})
|
|
189
175
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
currentPage,
|
|
199
|
-
currentPageSize,
|
|
200
|
-
existingQuery: config.query,
|
|
201
|
-
existingData: config.data
|
|
202
|
-
})
|
|
176
|
+
// 包装 fetch 配置,通过 beforeFetch 钩子动态注入分页参数
|
|
177
|
+
const originalFetch = rule.effect.fetch
|
|
178
|
+
console.log('[accTable] 原始 fetch 配置:', {
|
|
179
|
+
type: typeof originalFetch,
|
|
180
|
+
isObject: typeof originalFetch === 'object',
|
|
181
|
+
originalFetch,
|
|
182
|
+
hasBeforeFetch: typeof originalFetch?.beforeFetch === 'function'
|
|
183
|
+
})
|
|
203
184
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
185
|
+
if (typeof originalFetch === 'object') {
|
|
186
|
+
// 保存原始配置和分页参数配置到闭包中
|
|
187
|
+
const savedParamType = paramType
|
|
188
|
+
const savedPageParamName = pageParamName
|
|
189
|
+
const savedPageSizeParamName = pageSizeParamName
|
|
190
|
+
const savedOriginalBeforeFetch = originalFetch.beforeFetch
|
|
191
|
+
|
|
192
|
+
// 只有当前还没有 beforeFetch 钩子,或者 beforeFetch 不是我们添加的时才添加
|
|
193
|
+
// 通过检查 savedOriginalBeforeFetch 是否包含我们的逻辑来判断
|
|
194
|
+
if (
|
|
195
|
+
!savedOriginalBeforeFetch ||
|
|
196
|
+
typeof savedOriginalBeforeFetch !== 'function'
|
|
197
|
+
) {
|
|
198
|
+
// 添加 beforeFetch 钩子来注入分页参数
|
|
199
|
+
originalFetch.beforeFetch = (config, { rule: r, api: a }) => {
|
|
200
|
+
console.log('[accTable] beforeFetch 被调用:', {
|
|
201
|
+
configBefore: JSON.parse(JSON.stringify(config)),
|
|
202
|
+
ruleProps: r.props,
|
|
203
|
+
pagination: r.props?.pagination
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
// 获取当前分页配置
|
|
207
|
+
const currentPagination = r.props?.pagination
|
|
208
|
+
console.log('[accTable] 当前分页配置:', {
|
|
209
|
+
currentPagination,
|
|
210
|
+
isObject: typeof currentPagination === 'object',
|
|
211
|
+
currentPage: currentPagination?.current,
|
|
212
|
+
currentPageSize: currentPagination?.pageSize
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
if (currentPagination && typeof currentPagination === 'object') {
|
|
216
|
+
const currentPage = currentPagination.current || 1
|
|
217
|
+
const currentPageSize = currentPagination.pageSize || 10
|
|
218
|
+
|
|
219
|
+
console.log('[accTable] 准备添加分页参数:', {
|
|
220
|
+
savedParamType,
|
|
221
|
+
savedPageParamName,
|
|
222
|
+
savedPageSizeParamName,
|
|
223
|
+
currentPage,
|
|
224
|
+
currentPageSize,
|
|
225
|
+
existingQuery: config.query,
|
|
226
|
+
existingData: config.data
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
// 添加分页参数(使用闭包中保存的参数名)
|
|
230
|
+
if (savedParamType === 'query') {
|
|
231
|
+
// 合并已有的 query 参数,确保不覆盖用户自定义的参数
|
|
232
|
+
config.query = {
|
|
233
|
+
...(config.query || {}),
|
|
234
|
+
[savedPageParamName]: currentPage,
|
|
235
|
+
[savedPageSizeParamName]: currentPageSize
|
|
225
236
|
}
|
|
237
|
+
console.log('[accTable] 添加 query 参数后:', {
|
|
238
|
+
query: config.query
|
|
239
|
+
})
|
|
226
240
|
} else {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
241
|
+
// 合并已有的 data 参数,确保不覆盖用户自定义的参数
|
|
242
|
+
config.data = {
|
|
243
|
+
...(config.data || {}),
|
|
244
|
+
[savedPageParamName]: currentPage,
|
|
245
|
+
[savedPageSizeParamName]: currentPageSize
|
|
246
|
+
}
|
|
247
|
+
console.log('[accTable] 添加 data 参数后:', {
|
|
248
|
+
data: config.data
|
|
230
249
|
})
|
|
231
250
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
typeof savedOriginalBeforeFetch === 'function'
|
|
237
|
-
) {
|
|
238
|
-
console.log('[accTable] 调用原始 beforeFetch 钩子')
|
|
239
|
-
return savedOriginalBeforeFetch(config, { rule: r, api: a })
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
console.log('[accTable] beforeFetch 完成,最终 config:', {
|
|
243
|
-
query: config.query,
|
|
244
|
-
data: config.data,
|
|
245
|
-
action: config.action
|
|
251
|
+
} else {
|
|
252
|
+
console.warn('[accTable] 分页配置无效,无法添加分页参数:', {
|
|
253
|
+
currentPagination,
|
|
254
|
+
type: typeof currentPagination
|
|
246
255
|
})
|
|
247
256
|
}
|
|
248
257
|
|
|
249
|
-
//
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
pageSizeParamName,
|
|
257
|
-
currentPage,
|
|
258
|
-
currentPageSize
|
|
259
|
-
})
|
|
260
|
-
|
|
261
|
-
if (paramType === 'query') {
|
|
262
|
-
if (!originalFetch.query) {
|
|
263
|
-
originalFetch.query = {}
|
|
264
|
-
}
|
|
265
|
-
originalFetch.query[pageParamName] = currentPage
|
|
266
|
-
originalFetch.query[pageSizeParamName] = currentPageSize
|
|
267
|
-
console.log('[accTable] 初始化后的 query:', originalFetch.query)
|
|
268
|
-
} else {
|
|
269
|
-
if (!originalFetch.data) {
|
|
270
|
-
originalFetch.data = {}
|
|
271
|
-
}
|
|
272
|
-
originalFetch.data[pageParamName] = currentPage
|
|
273
|
-
originalFetch.data[pageSizeParamName] = currentPageSize
|
|
274
|
-
console.log('[accTable] 初始化后的 data:', originalFetch.data)
|
|
258
|
+
// 调用原始的 beforeFetch 钩子(如果存在)
|
|
259
|
+
if (
|
|
260
|
+
savedOriginalBeforeFetch &&
|
|
261
|
+
typeof savedOriginalBeforeFetch === 'function'
|
|
262
|
+
) {
|
|
263
|
+
console.log('[accTable] 调用原始 beforeFetch 钩子')
|
|
264
|
+
return savedOriginalBeforeFetch(config, { rule: r, api: a })
|
|
275
265
|
}
|
|
276
266
|
|
|
277
|
-
console.log('[accTable]
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
data: originalFetch.data,
|
|
282
|
-
hasBeforeFetch: typeof originalFetch.beforeFetch === 'function'
|
|
283
|
-
})
|
|
284
|
-
} else {
|
|
285
|
-
console.warn('[accTable] fetch 配置不是对象类型:', {
|
|
286
|
-
type: typeof originalFetch,
|
|
287
|
-
originalFetch
|
|
267
|
+
console.log('[accTable] beforeFetch 完成,最终 config:', {
|
|
268
|
+
query: config.query,
|
|
269
|
+
data: config.data,
|
|
270
|
+
action: config.action
|
|
288
271
|
})
|
|
289
272
|
}
|
|
273
|
+
}
|
|
274
|
+
console.log('[accTable] beforeFetch 钩子已添加')
|
|
275
|
+
} else {
|
|
276
|
+
console.warn('[accTable] fetch 配置不是对象类型:', {
|
|
277
|
+
type: typeof originalFetch,
|
|
278
|
+
originalFetch
|
|
279
|
+
})
|
|
280
|
+
}
|
|
290
281
|
|
|
291
|
-
|
|
292
|
-
|
|
282
|
+
// 添加分页 onChange 和 onShowSizeChange 事件处理(确保事件处理函数存在)
|
|
283
|
+
const paginationObj = props.pagination || paginationConfig
|
|
284
|
+
if (paginationObj && typeof paginationObj === 'object') {
|
|
285
|
+
if (!paginationObj.onChange) {
|
|
286
|
+
paginationObj.onChange = (page, size) => {
|
|
287
|
+
console.log('[accTable] pagination onChange 被调用:', {
|
|
288
|
+
page,
|
|
289
|
+
size
|
|
290
|
+
})
|
|
293
291
|
// 更新分页配置
|
|
294
292
|
if (rule.props?.pagination) {
|
|
295
293
|
rule.props.pagination.current = page
|
|
296
294
|
rule.props.pagination.pageSize = size
|
|
297
295
|
}
|
|
298
|
-
|
|
299
|
-
// 分页参数已经通过包装的 fetch 函数自动添加,只需要触发重新加载
|
|
296
|
+
// 分页参数已经通过 beforeFetch 钩子自动添加,只需要触发重新加载
|
|
300
297
|
ctx.api.sync(rule)
|
|
301
298
|
setTimeout(() => {
|
|
302
299
|
ctx.api.refresh()
|
|
303
300
|
}, 0)
|
|
304
301
|
}
|
|
302
|
+
}
|
|
305
303
|
|
|
306
|
-
|
|
307
|
-
|
|
304
|
+
if (!paginationObj.onShowSizeChange) {
|
|
305
|
+
paginationObj.onShowSizeChange = (current, size) => {
|
|
306
|
+
console.log('[accTable] pagination onShowSizeChange 被调用:', {
|
|
307
|
+
current,
|
|
308
|
+
size
|
|
309
|
+
})
|
|
308
310
|
if (rule.props?.pagination) {
|
|
309
311
|
rule.props.pagination.current = 1 // 改变每页条数时重置到第一页
|
|
310
312
|
rule.props.pagination.pageSize = size
|
|
311
313
|
}
|
|
312
|
-
|
|
313
|
-
// 分页参数已经通过包装的 fetch 函数自动添加,只需要触发重新加载
|
|
314
|
+
// 分页参数已经通过 beforeFetch 钩子自动添加,只需要触发重新加载
|
|
314
315
|
ctx.api.sync(rule)
|
|
315
316
|
setTimeout(() => {
|
|
316
317
|
ctx.api.refresh()
|
|
@@ -318,10 +319,10 @@ export default {
|
|
|
318
319
|
}
|
|
319
320
|
}
|
|
320
321
|
|
|
321
|
-
props.pagination
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
322
|
+
// 如果 props.pagination 不存在,将 paginationObj 赋值给 props.pagination
|
|
323
|
+
if (!props.pagination) {
|
|
324
|
+
props.pagination = paginationObj
|
|
325
|
+
}
|
|
325
326
|
}
|
|
326
327
|
}
|
|
327
328
|
|