@longhongguo/form-create-ant-design-vue 3.2.84 → 3.2.86
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.
|
|
3
|
+
"version": "3.2.86",
|
|
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
|
@@ -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) {
|
|
@@ -93,7 +94,7 @@ export default {
|
|
|
93
94
|
...paginationConfig
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
// 如果启用了分页且有远程数据源(fetch effect),添加 onChange
|
|
97
|
+
// 如果启用了分页且有远程数据源(fetch effect),添加 onChange 事件处理和初始化分页参数
|
|
97
98
|
if (rule.effect?.fetch && paginationConfig.current !== undefined) {
|
|
98
99
|
// 获取分页参数配置
|
|
99
100
|
const pageParamName = rule.props?.paginationPageParam || 'page'
|
|
@@ -105,6 +106,55 @@ export default {
|
|
|
105
106
|
const responseTotalPath =
|
|
106
107
|
rule.props?.paginationResponseTotalPath || 'total'
|
|
107
108
|
|
|
109
|
+
// 包装 fetch 配置,将其包装成函数以动态注入分页参数
|
|
110
|
+
const originalFetch = rule.effect.fetch
|
|
111
|
+
if (typeof originalFetch === 'object') {
|
|
112
|
+
// 保存原始配置和分页参数配置到闭包中
|
|
113
|
+
const savedOriginalFetch = { ...originalFetch }
|
|
114
|
+
const savedParamType = paramType
|
|
115
|
+
const savedPageParamName = pageParamName
|
|
116
|
+
const savedPageSizeParamName = pageSizeParamName
|
|
117
|
+
|
|
118
|
+
// 将整个 fetch 配置包装成函数,使其每次调用时都能获取最新的分页参数
|
|
119
|
+
rule.effect.fetch = (r, a) => {
|
|
120
|
+
// 先调用原始的 action(如果是函数)获取基础配置
|
|
121
|
+
let baseOption = savedOriginalFetch
|
|
122
|
+
if (typeof savedOriginalFetch.action === 'function') {
|
|
123
|
+
const actionResult = savedOriginalFetch.action(r, a)
|
|
124
|
+
if (actionResult && typeof actionResult === 'object') {
|
|
125
|
+
baseOption = { ...savedOriginalFetch, ...actionResult }
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// 使用扩展运算符创建新配置,保留所有原始属性(包括函数)
|
|
130
|
+
const fetchOption = { ...baseOption }
|
|
131
|
+
|
|
132
|
+
// 获取当前分页配置
|
|
133
|
+
const currentPagination = r.props?.pagination
|
|
134
|
+
if (currentPagination && typeof currentPagination === 'object') {
|
|
135
|
+
const currentPage = currentPagination.current || 1
|
|
136
|
+
const currentPageSize = currentPagination.pageSize || 10
|
|
137
|
+
|
|
138
|
+
// 确保 fetchOption 存在 query 和 data,并合并已有值
|
|
139
|
+
if (savedParamType === 'query') {
|
|
140
|
+
fetchOption.query = {
|
|
141
|
+
...(baseOption.query || {}),
|
|
142
|
+
[savedPageParamName]: currentPage,
|
|
143
|
+
[savedPageSizeParamName]: currentPageSize
|
|
144
|
+
}
|
|
145
|
+
} else {
|
|
146
|
+
fetchOption.data = {
|
|
147
|
+
...(baseOption.data || {}),
|
|
148
|
+
[savedPageParamName]: currentPage,
|
|
149
|
+
[savedPageSizeParamName]: currentPageSize
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return fetchOption
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
108
158
|
// 添加分页 onChange 事件处理
|
|
109
159
|
pagination.onChange = (page, size) => {
|
|
110
160
|
// 更新分页配置
|
|
@@ -113,34 +163,11 @@ export default {
|
|
|
113
163
|
rule.props.pagination.pageSize = size
|
|
114
164
|
}
|
|
115
165
|
|
|
116
|
-
//
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
// 通过 query 参数传递
|
|
122
|
-
if (!fetchConfig.query) {
|
|
123
|
-
fetchConfig.query = {}
|
|
124
|
-
}
|
|
125
|
-
fetchConfig.query[pageParamName] = page
|
|
126
|
-
fetchConfig.query[pageSizeParamName] = size
|
|
127
|
-
} else {
|
|
128
|
-
// 通过 data 参数传递
|
|
129
|
-
if (!fetchConfig.data) {
|
|
130
|
-
fetchConfig.data = {}
|
|
131
|
-
}
|
|
132
|
-
fetchConfig.data[pageParamName] = page
|
|
133
|
-
fetchConfig.data[pageSizeParamName] = size
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// 触发 fetch 重新加载:通过触发 effect 来重新运行 fetch
|
|
137
|
-
ctx.api.sync(rule)
|
|
138
|
-
// 延迟触发 refresh 以确保配置已更新
|
|
139
|
-
setTimeout(() => {
|
|
140
|
-
ctx.api.refresh()
|
|
141
|
-
}, 0)
|
|
142
|
-
}
|
|
143
|
-
}
|
|
166
|
+
// 分页参数已经通过包装的 fetch 函数自动添加,只需要触发重新加载
|
|
167
|
+
ctx.api.sync(rule)
|
|
168
|
+
setTimeout(() => {
|
|
169
|
+
ctx.api.refresh()
|
|
170
|
+
}, 0)
|
|
144
171
|
}
|
|
145
172
|
|
|
146
173
|
// 添加 onShowSizeChange 事件处理(改变每页条数时)
|
|
@@ -150,29 +177,11 @@ export default {
|
|
|
150
177
|
rule.props.pagination.pageSize = size
|
|
151
178
|
}
|
|
152
179
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
fetchConfig.query = {}
|
|
159
|
-
}
|
|
160
|
-
fetchConfig.query[pageParamName] = 1
|
|
161
|
-
fetchConfig.query[pageSizeParamName] = size
|
|
162
|
-
} else {
|
|
163
|
-
if (!fetchConfig.data) {
|
|
164
|
-
fetchConfig.data = {}
|
|
165
|
-
}
|
|
166
|
-
fetchConfig.data[pageParamName] = 1
|
|
167
|
-
fetchConfig.data[pageSizeParamName] = size
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
ctx.api.sync(rule)
|
|
171
|
-
setTimeout(() => {
|
|
172
|
-
ctx.api.refresh()
|
|
173
|
-
}, 0)
|
|
174
|
-
}
|
|
175
|
-
}
|
|
180
|
+
// 分页参数已经通过包装的 fetch 函数自动添加,只需要触发重新加载
|
|
181
|
+
ctx.api.sync(rule)
|
|
182
|
+
setTimeout(() => {
|
|
183
|
+
ctx.api.refresh()
|
|
184
|
+
}, 0)
|
|
176
185
|
}
|
|
177
186
|
}
|
|
178
187
|
|