@longhongguo/form-create-ant-design-vue 3.2.89 → 3.2.91
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 +175 -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.91",
|
|
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,204 @@ 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
|
+
// 在闭包中保存 rule 的引用,因为 beforeFetch 只接收 (config, {api}) 参数
|
|
192
|
+
const savedRule = rule
|
|
193
|
+
|
|
194
|
+
// 检查是否已经添加过我们的 beforeFetch 钩子(通过检查函数是否包含特定标记)
|
|
195
|
+
const isOurBeforeFetch =
|
|
196
|
+
savedOriginalBeforeFetch &&
|
|
197
|
+
savedOriginalBeforeFetch._accTablePaginationHook === true
|
|
198
|
+
|
|
199
|
+
if (!isOurBeforeFetch) {
|
|
200
|
+
// 添加 beforeFetch 钩子来注入分页参数
|
|
201
|
+
// 注意:form-create 的 beforeFetch 只接收 (config, {api}) 参数,没有 rule
|
|
202
|
+
originalFetch.beforeFetch = (config, { api }) => {
|
|
203
|
+
console.log('[accTable] beforeFetch 被调用:', {
|
|
204
|
+
configAction: config?.action,
|
|
205
|
+
hasApi: !!api,
|
|
206
|
+
ruleProps: savedRule?.props,
|
|
207
|
+
pagination: savedRule?.props?.pagination
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
// 从闭包中获取当前分页配置
|
|
211
|
+
const currentPagination = savedRule?.props?.pagination
|
|
212
|
+
console.log('[accTable] 当前分页配置:', {
|
|
213
|
+
currentPagination,
|
|
214
|
+
isObject: typeof currentPagination === 'object',
|
|
215
|
+
currentPage: currentPagination?.current,
|
|
216
|
+
currentPageSize: currentPagination?.pageSize
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
if (currentPagination && typeof currentPagination === 'object') {
|
|
220
|
+
const currentPage = currentPagination.current || 1
|
|
221
|
+
const currentPageSize = currentPagination.pageSize || 10
|
|
222
|
+
|
|
223
|
+
console.log('[accTable] 准备添加分页参数:', {
|
|
224
|
+
savedParamType,
|
|
225
|
+
savedPageParamName,
|
|
226
|
+
savedPageSizeParamName,
|
|
227
|
+
currentPage,
|
|
228
|
+
currentPageSize,
|
|
229
|
+
existingQuery: config.query,
|
|
230
|
+
existingData: config.data
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
// 添加分页参数(使用闭包中保存的参数名)
|
|
234
|
+
if (savedParamType === 'query') {
|
|
235
|
+
// 合并已有的 query 参数,确保不覆盖用户自定义的参数
|
|
236
|
+
config.query = {
|
|
237
|
+
...(config.query || {}),
|
|
238
|
+
[savedPageParamName]: currentPage,
|
|
239
|
+
[savedPageSizeParamName]: currentPageSize
|
|
225
240
|
}
|
|
241
|
+
console.log('[accTable] 添加 query 参数后:', {
|
|
242
|
+
query: config.query
|
|
243
|
+
})
|
|
226
244
|
} else {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
245
|
+
// 合并已有的 data 参数,确保不覆盖用户自定义的参数
|
|
246
|
+
config.data = {
|
|
247
|
+
...(config.data || {}),
|
|
248
|
+
[savedPageParamName]: currentPage,
|
|
249
|
+
[savedPageSizeParamName]: currentPageSize
|
|
250
|
+
}
|
|
251
|
+
console.log('[accTable] 添加 data 参数后:', {
|
|
252
|
+
data: config.data
|
|
230
253
|
})
|
|
231
254
|
}
|
|
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
|
|
255
|
+
} else {
|
|
256
|
+
console.warn('[accTable] 分页配置无效,无法添加分页参数:', {
|
|
257
|
+
currentPagination,
|
|
258
|
+
type: typeof currentPagination
|
|
246
259
|
})
|
|
247
260
|
}
|
|
248
261
|
|
|
249
|
-
//
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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)
|
|
262
|
+
// 调用原始的 beforeFetch 钩子(如果存在)
|
|
263
|
+
// 原始钩子可能也只接收 (config, {api}) 参数
|
|
264
|
+
if (
|
|
265
|
+
savedOriginalBeforeFetch &&
|
|
266
|
+
typeof savedOriginalBeforeFetch === 'function'
|
|
267
|
+
) {
|
|
268
|
+
console.log('[accTable] 调用原始 beforeFetch 钩子')
|
|
269
|
+
return savedOriginalBeforeFetch(config, { api })
|
|
275
270
|
}
|
|
276
271
|
|
|
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
|
|
272
|
+
console.log('[accTable] beforeFetch 完成,最终 config:', {
|
|
273
|
+
query: config.query,
|
|
274
|
+
data: config.data,
|
|
275
|
+
action: config.action
|
|
288
276
|
})
|
|
289
277
|
}
|
|
290
278
|
|
|
291
|
-
//
|
|
292
|
-
|
|
279
|
+
// 标记这是我们添加的钩子,避免重复添加
|
|
280
|
+
originalFetch.beforeFetch._accTablePaginationHook = true
|
|
281
|
+
console.log('[accTable] ✅ beforeFetch 钩子已添加并标记')
|
|
282
|
+
} else {
|
|
283
|
+
console.log('[accTable] ⚠️ beforeFetch 钩子已存在,跳过添加')
|
|
284
|
+
}
|
|
285
|
+
console.log('[accTable] beforeFetch 钩子处理完成')
|
|
286
|
+
} else {
|
|
287
|
+
console.warn('[accTable] fetch 配置不是对象类型:', {
|
|
288
|
+
type: typeof originalFetch,
|
|
289
|
+
originalFetch
|
|
290
|
+
})
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// 添加分页 onChange 和 onShowSizeChange 事件处理(确保事件处理函数存在)
|
|
294
|
+
const paginationObj = props.pagination || paginationConfig
|
|
295
|
+
if (paginationObj && typeof paginationObj === 'object') {
|
|
296
|
+
if (!paginationObj.onChange) {
|
|
297
|
+
paginationObj.onChange = (page, size) => {
|
|
298
|
+
console.log('[accTable] pagination onChange 被调用:', {
|
|
299
|
+
page,
|
|
300
|
+
size
|
|
301
|
+
})
|
|
293
302
|
// 更新分页配置
|
|
294
303
|
if (rule.props?.pagination) {
|
|
295
304
|
rule.props.pagination.current = page
|
|
296
305
|
rule.props.pagination.pageSize = size
|
|
297
306
|
}
|
|
298
|
-
|
|
299
|
-
// 分页参数已经通过包装的 fetch 函数自动添加,只需要触发重新加载
|
|
307
|
+
// 分页参数已经通过 beforeFetch 钩子自动添加,只需要触发重新加载
|
|
300
308
|
ctx.api.sync(rule)
|
|
301
309
|
setTimeout(() => {
|
|
302
310
|
ctx.api.refresh()
|
|
303
311
|
}, 0)
|
|
304
312
|
}
|
|
313
|
+
}
|
|
305
314
|
|
|
306
|
-
|
|
307
|
-
|
|
315
|
+
if (!paginationObj.onShowSizeChange) {
|
|
316
|
+
paginationObj.onShowSizeChange = (current, size) => {
|
|
317
|
+
console.log('[accTable] pagination onShowSizeChange 被调用:', {
|
|
318
|
+
current,
|
|
319
|
+
size
|
|
320
|
+
})
|
|
308
321
|
if (rule.props?.pagination) {
|
|
309
322
|
rule.props.pagination.current = 1 // 改变每页条数时重置到第一页
|
|
310
323
|
rule.props.pagination.pageSize = size
|
|
311
324
|
}
|
|
312
|
-
|
|
313
|
-
// 分页参数已经通过包装的 fetch 函数自动添加,只需要触发重新加载
|
|
325
|
+
// 分页参数已经通过 beforeFetch 钩子自动添加,只需要触发重新加载
|
|
314
326
|
ctx.api.sync(rule)
|
|
315
327
|
setTimeout(() => {
|
|
316
328
|
ctx.api.refresh()
|
|
@@ -318,10 +330,10 @@ export default {
|
|
|
318
330
|
}
|
|
319
331
|
}
|
|
320
332
|
|
|
321
|
-
props.pagination
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
333
|
+
// 如果 props.pagination 不存在,将 paginationObj 赋值给 props.pagination
|
|
334
|
+
if (!props.pagination) {
|
|
335
|
+
props.pagination = paginationObj
|
|
336
|
+
}
|
|
325
337
|
}
|
|
326
338
|
}
|
|
327
339
|
|