@hzab/list-render 1.9.7-beta → 1.9.7-beta2
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/CHANGELOG.md +1 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/card-render/index.less +1 -2
- package/src/common/utils.js +60 -13
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -130,7 +130,7 @@ const listDM = useMemo(
|
|
|
130
130
|
| 属性名称 | 属性类型 | 必须 | 默认值 | 描述 |
|
|
131
131
|
| -------------- | -------- | ---- | ------ | -------------- |
|
|
132
132
|
| CardItemRender | JSX | | | 自定义渲染卡片 |
|
|
133
|
-
|
|
|
133
|
+
| columns | Number | 是 | 3 | 栅格列数 |
|
|
134
134
|
|
|
135
135
|
##### cardConf.colConf[xxx]
|
|
136
136
|
|
package/package.json
CHANGED
package/src/common/utils.js
CHANGED
|
@@ -97,7 +97,7 @@ export function getFieldList(_schema, fieldList = [], opt = {}, isTableSortXIdex
|
|
|
97
97
|
// 解决 schema 字符串可执行代码、变量等
|
|
98
98
|
const properties = Schema.getOrderProperties(schema);
|
|
99
99
|
const { boxList = [] } = opt || {};
|
|
100
|
-
let _boxList = ["FormGrid", "FormGrid.GridColumn"
|
|
100
|
+
let _boxList = ["FormGrid", "FormGrid.GridColumn"];
|
|
101
101
|
if (Array.isArray(boxList)) {
|
|
102
102
|
_boxList = [..._boxList, ...boxList];
|
|
103
103
|
} else if (boxList === false) {
|
|
@@ -202,20 +202,67 @@ export const getOptItByVal = function (val, options, opt) {
|
|
|
202
202
|
* @param {Object} data - 原始数据对象
|
|
203
203
|
* @returns {Object} - 处理后的新对象
|
|
204
204
|
*/
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* 移除表格中标记为inTable:false的字段
|
|
208
|
+
* @param {Object} data - 原始数据
|
|
209
|
+
* @param {Object} [opt={}] - 配置选项
|
|
210
|
+
* @param {Array} [opt.boxList=[]] - 需要递归处理的组件类型列表
|
|
211
|
+
* @returns {Object} 处理后的数据
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
export function removeInTableFalseFields(_schema, opt = {}) {
|
|
215
|
+
// 1. 深拷贝原始数据
|
|
216
|
+
const result = _.cloneDeep(_schema);
|
|
217
|
+
|
|
218
|
+
// 2. 获取schema对象(支持直接传入schema或包含schema的对象)
|
|
219
|
+
const schema = result?.schema || result;
|
|
220
|
+
|
|
221
|
+
// 3. 处理容器组件配置
|
|
222
|
+
const { boxList = [] } = opt;
|
|
223
|
+
const _boxList =
|
|
224
|
+
boxList === false
|
|
225
|
+
? []
|
|
226
|
+
: ["Card", "FormGrid", "ArrayCards", "Collapse", "Tabs", ...(Array.isArray(boxList) ? boxList : [])];
|
|
227
|
+
|
|
228
|
+
// 4. 递归删除inTable:false的字段
|
|
229
|
+
const processProperties = (properties) => {
|
|
230
|
+
if (!properties || typeof properties !== "object") return;
|
|
231
|
+
|
|
232
|
+
Object.keys(properties).forEach((key) => {
|
|
233
|
+
const item = properties[key];
|
|
234
|
+
|
|
235
|
+
// 处理容器组件递归
|
|
236
|
+
if (item["x-component"] && _boxList.includes(item["x-component"])) {
|
|
237
|
+
if (item.properties) {
|
|
238
|
+
processProperties(item.properties);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
// 处理数组类型的子项
|
|
242
|
+
else if (item.items?.properties) {
|
|
243
|
+
processProperties(item.items.properties);
|
|
244
|
+
}
|
|
245
|
+
// 处理普通字段
|
|
246
|
+
else if (item.inTable === false) {
|
|
247
|
+
delete properties[key];
|
|
248
|
+
}
|
|
249
|
+
// 移除x-display
|
|
250
|
+
else if (item["x-display"]) {
|
|
251
|
+
delete item["x-display"];
|
|
216
252
|
}
|
|
217
253
|
});
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// 5. 处理主properties
|
|
257
|
+
if (schema.properties) {
|
|
258
|
+
processProperties(schema.properties);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// 6. 移除form的布局属性
|
|
262
|
+
if (result.form) {
|
|
263
|
+
delete result.form.labelCol;
|
|
264
|
+
delete result.form.wrapperCol;
|
|
218
265
|
}
|
|
219
266
|
|
|
220
267
|
return result;
|
|
221
|
-
}
|
|
268
|
+
}
|