@longhongguo/form-create-ant-design-vue 3.2.85 → 3.2.87

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.85",
3
+ "version": "3.2.87",
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",
@@ -1,4 +1,5 @@
1
1
  import { hasProperty } from '@form-create/utils/lib/type'
2
+ import { deepCopy } from '@form-create/utils/lib/deepextend'
2
3
 
3
4
  // 简单的 getValue 函数,根据路径字符串获取嵌套对象的值
4
5
  function getValue(obj, path) {
@@ -105,67 +106,147 @@ export default {
105
106
  const responseTotalPath =
106
107
  rule.props?.paginationResponseTotalPath || 'total'
107
108
 
108
- // 包装 fetch 配置,添加 beforeFetch 钩子来动态注入分页参数
109
+ console.log('[accTable] 分页配置初始化:', {
110
+ hasFetch: !!rule.effect?.fetch,
111
+ paginationConfig,
112
+ pageParamName,
113
+ pageSizeParamName,
114
+ paramType,
115
+ currentPage: pagination.current,
116
+ currentPageSize: pagination.pageSize
117
+ })
118
+
119
+ // 包装 fetch 配置,通过 beforeFetch 钩子动态注入分页参数
109
120
  const originalFetch = rule.effect.fetch
121
+ console.log('[accTable] 原始 fetch 配置:', {
122
+ type: typeof originalFetch,
123
+ isObject: typeof originalFetch === 'object',
124
+ originalFetch
125
+ })
126
+
110
127
  if (typeof originalFetch === 'object') {
111
- // 保存原始 beforeFetch 钩子和分页参数配置到闭包中
112
- const originalBeforeFetch = originalFetch.beforeFetch
128
+ // 保存原始配置和分页参数配置到闭包中
113
129
  const savedParamType = paramType
114
130
  const savedPageParamName = pageParamName
115
131
  const savedPageSizeParamName = pageSizeParamName
132
+ const savedOriginalBeforeFetch = originalFetch.beforeFetch
116
133
 
117
- // 先将初始分页参数添加到配置中(用于首次加载)
118
- const currentPage = pagination.current || 1
119
- const currentPageSize = pagination.pageSize || 10
120
-
121
- if (savedParamType === 'query') {
122
- if (!originalFetch.query) {
123
- originalFetch.query = {}
124
- }
125
- originalFetch.query[savedPageParamName] = currentPage
126
- originalFetch.query[savedPageSizeParamName] = currentPageSize
127
- } else {
128
- if (!originalFetch.data) {
129
- originalFetch.data = {}
130
- }
131
- originalFetch.data[savedPageParamName] = currentPage
132
- originalFetch.data[savedPageSizeParamName] = currentPageSize
133
- }
134
-
135
- // 添加 beforeFetch 钩子来动态更新分页参数(确保每次请求都使用最新值)
134
+ // 添加 beforeFetch 钩子来注入分页参数
136
135
  originalFetch.beforeFetch = (config, { rule: r, api: a }) => {
136
+ console.log('[accTable] beforeFetch 被调用:', {
137
+ configBefore: JSON.parse(JSON.stringify(config)),
138
+ ruleProps: r.props,
139
+ pagination: r.props?.pagination
140
+ })
141
+
137
142
  // 获取当前分页配置
138
143
  const currentPagination = r.props?.pagination
144
+ console.log('[accTable] 当前分页配置:', {
145
+ currentPagination,
146
+ isObject: typeof currentPagination === 'object',
147
+ currentPage: currentPagination?.current,
148
+ currentPageSize: currentPagination?.pageSize
149
+ })
150
+
139
151
  if (currentPagination && typeof currentPagination === 'object') {
140
152
  const currentPage = currentPagination.current || 1
141
153
  const currentPageSize = currentPagination.pageSize || 10
142
154
 
143
- // 确保 config 存在 query 和 data
144
- if (!config.query) {
145
- config.query = {}
146
- }
147
- if (!config.data) {
148
- config.data = {}
149
- }
155
+ console.log('[accTable] 准备添加分页参数:', {
156
+ savedParamType,
157
+ savedPageParamName,
158
+ savedPageSizeParamName,
159
+ currentPage,
160
+ currentPageSize,
161
+ existingQuery: config.query,
162
+ existingData: config.data
163
+ })
150
164
 
151
165
  // 添加分页参数(使用闭包中保存的参数名)
152
166
  if (savedParamType === 'query') {
153
- config.query[savedPageParamName] = currentPage
154
- config.query[savedPageSizeParamName] = currentPageSize
167
+ // 合并已有的 query 参数,确保不覆盖用户自定义的参数
168
+ config.query = {
169
+ ...(config.query || {}),
170
+ [savedPageParamName]: currentPage,
171
+ [savedPageSizeParamName]: currentPageSize
172
+ }
173
+ console.log('[accTable] 添加 query 参数后:', {
174
+ query: config.query
175
+ })
155
176
  } else {
156
- config.data[savedPageParamName] = currentPage
157
- config.data[savedPageSizeParamName] = currentPageSize
177
+ // 合并已有的 data 参数,确保不覆盖用户自定义的参数
178
+ config.data = {
179
+ ...(config.data || {}),
180
+ [savedPageParamName]: currentPage,
181
+ [savedPageSizeParamName]: currentPageSize
182
+ }
183
+ console.log('[accTable] 添加 data 参数后:', {
184
+ data: config.data
185
+ })
158
186
  }
187
+ } else {
188
+ console.warn('[accTable] 分页配置无效,无法添加分页参数:', {
189
+ currentPagination,
190
+ type: typeof currentPagination
191
+ })
159
192
  }
160
193
 
161
194
  // 调用原始的 beforeFetch 钩子(如果存在)
162
195
  if (
163
- originalBeforeFetch &&
164
- typeof originalBeforeFetch === 'function'
196
+ savedOriginalBeforeFetch &&
197
+ typeof savedOriginalBeforeFetch === 'function'
165
198
  ) {
166
- return originalBeforeFetch(config, { rule: r, api: a })
199
+ console.log('[accTable] 调用原始 beforeFetch 钩子')
200
+ return savedOriginalBeforeFetch(config, { rule: r, api: a })
201
+ }
202
+
203
+ console.log('[accTable] beforeFetch 完成,最终 config:', {
204
+ query: config.query,
205
+ data: config.data,
206
+ action: config.action
207
+ })
208
+ }
209
+
210
+ // 初始化时也添加分页参数到配置中
211
+ const currentPage = pagination.current || 1
212
+ const currentPageSize = pagination.pageSize || 10
213
+
214
+ console.log('[accTable] 初始化分页参数到 fetch 配置:', {
215
+ paramType,
216
+ pageParamName,
217
+ pageSizeParamName,
218
+ currentPage,
219
+ currentPageSize
220
+ })
221
+
222
+ if (paramType === 'query') {
223
+ if (!originalFetch.query) {
224
+ originalFetch.query = {}
225
+ }
226
+ originalFetch.query[pageParamName] = currentPage
227
+ originalFetch.query[pageSizeParamName] = currentPageSize
228
+ console.log('[accTable] 初始化后的 query:', originalFetch.query)
229
+ } else {
230
+ if (!originalFetch.data) {
231
+ originalFetch.data = {}
167
232
  }
233
+ originalFetch.data[pageParamName] = currentPage
234
+ originalFetch.data[pageSizeParamName] = currentPageSize
235
+ console.log('[accTable] 初始化后的 data:', originalFetch.data)
168
236
  }
237
+
238
+ console.log('[accTable] 最终 fetch 配置:', {
239
+ action: originalFetch.action,
240
+ method: originalFetch.method,
241
+ query: originalFetch.query,
242
+ data: originalFetch.data,
243
+ hasBeforeFetch: typeof originalFetch.beforeFetch === 'function'
244
+ })
245
+ } else {
246
+ console.warn('[accTable] fetch 配置不是对象类型:', {
247
+ type: typeof originalFetch,
248
+ originalFetch
249
+ })
169
250
  }
170
251
 
171
252
  // 添加分页 onChange 事件处理