@longhongguo/form-create-ant-design-vue 3.2.83 → 3.2.84
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.84",
|
|
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,10 +1,23 @@
|
|
|
1
1
|
import { hasProperty } from '@form-create/utils/lib/type'
|
|
2
2
|
|
|
3
|
+
// 简单的 getValue 函数,根据路径字符串获取嵌套对象的值
|
|
4
|
+
function getValue(obj, path) {
|
|
5
|
+
if (!obj || !path) return undefined
|
|
6
|
+
const keys = path.split('.')
|
|
7
|
+
let value = obj
|
|
8
|
+
for (const key of keys) {
|
|
9
|
+
if (value == null) return undefined
|
|
10
|
+
value = value[key]
|
|
11
|
+
}
|
|
12
|
+
return value
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
export default {
|
|
4
16
|
name: 'accTable',
|
|
5
17
|
mergeProp(ctx) {
|
|
6
18
|
const props = ctx.prop.props || {}
|
|
7
19
|
const rule = ctx.rule
|
|
20
|
+
const api = ctx.api
|
|
8
21
|
|
|
9
22
|
// 初始化列配置
|
|
10
23
|
if (!hasProperty(props, 'columns')) {
|
|
@@ -70,7 +83,7 @@ export default {
|
|
|
70
83
|
if (paginationConfig === false) {
|
|
71
84
|
props.pagination = false
|
|
72
85
|
} else if (paginationConfig && typeof paginationConfig === 'object') {
|
|
73
|
-
|
|
86
|
+
const pagination = {
|
|
74
87
|
current: paginationConfig.current || 1,
|
|
75
88
|
pageSize: paginationConfig.pageSize || 10,
|
|
76
89
|
total: paginationConfig.total || 0,
|
|
@@ -79,12 +92,133 @@ export default {
|
|
|
79
92
|
showTotal: paginationConfig.showTotal,
|
|
80
93
|
...paginationConfig
|
|
81
94
|
}
|
|
95
|
+
|
|
96
|
+
// 如果启用了分页且有远程数据源(fetch effect),添加 onChange 事件处理
|
|
97
|
+
if (rule.effect?.fetch && paginationConfig.current !== undefined) {
|
|
98
|
+
// 获取分页参数配置
|
|
99
|
+
const pageParamName = rule.props?.paginationPageParam || 'page'
|
|
100
|
+
const pageSizeParamName =
|
|
101
|
+
rule.props?.paginationPageSizeParam || 'pageSize'
|
|
102
|
+
const paramType = rule.props?.paginationParamType || 'query' // 'query' 或 'data'
|
|
103
|
+
const responseDataPath =
|
|
104
|
+
rule.props?.paginationResponseDataPath || 'data'
|
|
105
|
+
const responseTotalPath =
|
|
106
|
+
rule.props?.paginationResponseTotalPath || 'total'
|
|
107
|
+
|
|
108
|
+
// 添加分页 onChange 事件处理
|
|
109
|
+
pagination.onChange = (page, size) => {
|
|
110
|
+
// 更新分页配置
|
|
111
|
+
if (rule.props?.pagination) {
|
|
112
|
+
rule.props.pagination.current = page
|
|
113
|
+
rule.props.pagination.pageSize = size
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// 更新 fetch 参数
|
|
117
|
+
if (rule.effect?.fetch) {
|
|
118
|
+
const fetchConfig = rule.effect.fetch
|
|
119
|
+
if (typeof fetchConfig === 'object') {
|
|
120
|
+
if (paramType === 'query') {
|
|
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
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 添加 onShowSizeChange 事件处理(改变每页条数时)
|
|
147
|
+
pagination.onShowSizeChange = (current, size) => {
|
|
148
|
+
if (rule.props?.pagination) {
|
|
149
|
+
rule.props.pagination.current = 1 // 改变每页条数时重置到第一页
|
|
150
|
+
rule.props.pagination.pageSize = size
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (rule.effect?.fetch) {
|
|
154
|
+
const fetchConfig = rule.effect.fetch
|
|
155
|
+
if (typeof fetchConfig === 'object') {
|
|
156
|
+
if (paramType === 'query') {
|
|
157
|
+
if (!fetchConfig.query) {
|
|
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
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
props.pagination = pagination
|
|
82
180
|
} else {
|
|
83
181
|
// 默认不启用分页
|
|
84
182
|
props.pagination = false
|
|
85
183
|
}
|
|
86
184
|
}
|
|
87
185
|
|
|
186
|
+
// 处理远程数据响应,解析总记录数和数据列表
|
|
187
|
+
if (rule.effect?.fetch && rule.props?.pagination) {
|
|
188
|
+
const fetchData = ctx.effectData('fetch')
|
|
189
|
+
if (fetchData && fetchData.value) {
|
|
190
|
+
const responseDataPath =
|
|
191
|
+
rule.props?.paginationResponseDataPath || 'data'
|
|
192
|
+
const responseTotalPath =
|
|
193
|
+
rule.props?.paginationResponseTotalPath || 'total'
|
|
194
|
+
|
|
195
|
+
try {
|
|
196
|
+
// 解析数据列表
|
|
197
|
+
const dataList = getValue(fetchData.value, responseDataPath)
|
|
198
|
+
if (Array.isArray(dataList)) {
|
|
199
|
+
props.dataSource = dataList
|
|
200
|
+
rule.value = dataList
|
|
201
|
+
rule.props.dataSource = dataList
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// 解析总记录数
|
|
205
|
+
const total = getValue(fetchData.value, responseTotalPath)
|
|
206
|
+
if (
|
|
207
|
+
typeof total === 'number' &&
|
|
208
|
+
rule.props.pagination &&
|
|
209
|
+
typeof rule.props.pagination === 'object'
|
|
210
|
+
) {
|
|
211
|
+
rule.props.pagination.total = total
|
|
212
|
+
if (props.pagination && typeof props.pagination === 'object') {
|
|
213
|
+
props.pagination.total = total
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
} catch (e) {
|
|
217
|
+
console.warn('accTable parse response error:', e)
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
88
222
|
// 设置其他常用配置
|
|
89
223
|
if (hasProperty(rule.props, 'bordered')) {
|
|
90
224
|
props.bordered = rule.props.bordered
|