@hzab/list-render 1.9.8 → 1.10.0-beta
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 +8 -0
- package/README.md +47 -45
- package/package.json +4 -1
- package/src/common/constant.ts +2 -0
- package/src/common/handleQuerySchema.ts +80 -0
- package/src/components/Formily/FormilyField.tsx +1 -1
- package/src/list-render.jsx +46 -14
- package/src/query-render/index.jsx +3 -1
- package/src/table-render/index.jsx +15 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# @hzab/list-render@1.10.0
|
|
2
|
+
|
|
3
|
+
feat: 表单、分页参数变化时设置到url query,首次进入页面时会使用url query中的参数进行回显、请求
|
|
4
|
+
|
|
5
|
+
# @hzab/list-render@1.9.9
|
|
6
|
+
|
|
7
|
+
fix: Tags、PrefixNode 使用 @hzab/formily-result-utils 组件 EnumRender 实现
|
|
8
|
+
|
|
1
9
|
# @hzab/list-render@1.9.8
|
|
2
10
|
|
|
3
11
|
feat: 去除 schema x-display 属性 去除 labelCol wrapperCol 属性
|
package/README.md
CHANGED
|
@@ -49,58 +49,60 @@ const listDM = useMemo(
|
|
|
49
49
|
|
|
50
50
|
### InfoPanel Attributes
|
|
51
51
|
|
|
52
|
-
| 属性名称 | 属性类型
|
|
53
|
-
| ---------------------------
|
|
52
|
+
| 属性名称 | 属性类型 | 必须 | 默认值 | 描述 |
|
|
53
|
+
| --------------------------- |------------------|-----| --------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
54
54
|
| layout | string | 否 | default | 列表渲染类型格式 |
|
|
55
55
|
| className | string | 否 | - | 外层 div className |
|
|
56
56
|
| idKey | string | 否 | id | 唯一值字段的 key |
|
|
57
57
|
| schema | Object | 是 | - | 字段描述文件,包含各个字段的信息 |
|
|
58
58
|
| model | Object | 是 | - | 数据模型,包含 CURD 接口信息,传入 DataModel 的实例 |
|
|
59
59
|
| isPatchUpdate | boolean | 否 | false | 编辑提交接口是否使用 patch 发起请求 |
|
|
60
|
-
| list | Array |
|
|
61
|
-
| closeAutoRequest | Boolean |
|
|
62
|
-
| hasQuery | Boolean |
|
|
63
|
-
| verticalHeader | Boolean |
|
|
64
|
-
| search | String |
|
|
65
|
-
| filters | Array |
|
|
66
|
-
| queryConf | Object |
|
|
67
|
-
| createText | String/ReactNote |
|
|
68
|
-
| hasCreate | Boolean |
|
|
69
|
-
| hasAction | Boolean |
|
|
70
|
-
| hasEdit | Boolean/Function |
|
|
71
|
-
| hasDel | Boolean/Function |
|
|
72
|
-
| hasDetail | Boolean/Function |
|
|
73
|
-
| hasDelTips | String/Function |
|
|
74
|
-
| tableConf | Object |
|
|
75
|
-
| tableProps | Object |
|
|
76
|
-
| cardConf | Object |
|
|
77
|
-
| cardProps | Object |
|
|
78
|
-
| fetchOnEdit | Boolean |
|
|
79
|
-
| fetchById | Boolean |
|
|
80
|
-
| modalMode | string |
|
|
81
|
-
| modalConf | Object |
|
|
82
|
-
| modalDetailProps | Object |
|
|
83
|
-
| modalFormProps | Object |
|
|
84
|
-
| modalProps | Object |
|
|
85
|
-
| schemaScope | Object |
|
|
86
|
-
| components | Object |
|
|
87
|
-
| detailComponents | Object |
|
|
88
|
-
| hasPagination | Boolean |
|
|
89
|
-
| paginationConf | Object |
|
|
90
|
-
| formInitialValues | Object |
|
|
91
|
-
| Slots | Object |
|
|
92
|
-
| getFieldListOpt | Object |
|
|
93
|
-
| onGetListEnd | Function |
|
|
94
|
-
| onCreateSuc | Function |
|
|
95
|
-
| onEditSuc | Function |
|
|
96
|
-
| onDelSuc | Function |
|
|
97
|
-
| onFormModalClose | Function |
|
|
98
|
-
| modalFormMount | Function |
|
|
99
|
-
| msgConf | Object |
|
|
100
|
-
| i18n | Object |
|
|
101
|
-
| queryFormInitialValues | Object |
|
|
102
|
-
| queryFormIsExtendModelQuery | Boolean |
|
|
60
|
+
| list | Array | | - | 本地数据源 |
|
|
61
|
+
| closeAutoRequest | Boolean | | false | 是否关闭加载完毕后自动发起请求。true 时组件 didMount 不自动发起请求 |
|
|
62
|
+
| hasQuery | Boolean | | true | 是否包含搜索、筛选框、搜索按钮等 |
|
|
63
|
+
| verticalHeader | Boolean | | false | 搜索项和新增按钮是否处于不同的行等 |
|
|
64
|
+
| search | String | | - | 传入空字符串时,不包含搜索框;传入非空字符串时,显示搜索框,同时传入的字符串作为搜索框的占位符 |
|
|
65
|
+
| filters | Array | | [] | 字符串数组,可以包含要筛选的字段 key 值(schema 中的 name),或者字符串 '$timerange'(时间范围筛选专用) |
|
|
66
|
+
| queryConf | Object | | {} | 设置 query 参数的 key |
|
|
67
|
+
| createText | String/ReactNote | | 新增 | 新增按钮文案 |
|
|
68
|
+
| hasCreate | Boolean | | true | 是否显示新增按钮 |
|
|
69
|
+
| hasAction | Boolean | | true | 是否在表格的最右增加一个“操作”列;hasAction 为 true 时,下面的 hasEdit/hasDel 才会生效 |
|
|
70
|
+
| hasEdit | Boolean/Function | | true | 是否显示编辑按钮,可传入回调控制当前行是否显示 |
|
|
71
|
+
| hasDel | Boolean/Function | | true | 是否显示删除按钮,可传入回调控制当前行是否显示 |
|
|
72
|
+
| hasDetail | Boolean/Function | | true | 是否显示详情按钮,可传入回调控制当前行是否显示 |
|
|
73
|
+
| hasDelTips | String/Function | | "确认删除该项?" | 删除按钮自定义提示,可传入回调根据当前行数据显示对应提示 |
|
|
74
|
+
| tableConf | Object | | {} | Table 相关配置 |
|
|
75
|
+
| tableProps | Object | | {} | 直接传给 Table 的 props,相关 API 可直接参考 antd table 组件 |
|
|
76
|
+
| cardConf | Object | | {} | Card 相关配置 |
|
|
77
|
+
| cardProps | Object | | {} | 直接传给 cardRender 的 props,因内部渲染使用的的是详情组件,相关 API 可直接参考 @hzab/schema-descriptions 组件 |
|
|
78
|
+
| fetchOnEdit | Boolean | | true | 展示编辑弹框时,是否会调用一次详情接口进行回填;若为 false,则会使用表格列表接口返回的 row 数据进行回填 |
|
|
79
|
+
| fetchById | Boolean | | true | 编辑中的详情请求,是否使用 id 作为入参的 key |
|
|
80
|
+
| modalMode | string | | dialog | 新增/编辑表单、详情 展示模式: dialog drawer |
|
|
81
|
+
| modalConf | Object | | {} | modal/Drawer 配置对象 |
|
|
82
|
+
| modalDetailProps | Object | | {} | modal descriptions 配置对象 |
|
|
83
|
+
| modalFormProps | Object | | {} | modal/drawer fromRender 配置对象 |
|
|
84
|
+
| modalProps | Object | | {} | modal/drawer 配置对象 |
|
|
85
|
+
| schemaScope | Object | | {} | formRender schemaScope props |
|
|
86
|
+
| components | Object | | {} | formRender components props 自定义组件 |
|
|
87
|
+
| detailComponents | Object | | {} | descriptions components props 自定义组件 |
|
|
88
|
+
| hasPagination | Boolean | | true | 是否显示分页 |
|
|
89
|
+
| paginationConf | Object | | {} | 可自定义 Pagination props,进行 pagination 相关设置 |
|
|
90
|
+
| formInitialValues | Object | | {} | 给新增、编辑对话框中的表单增加默认值 |
|
|
91
|
+
| Slots | Object | | {} | 组件插槽 |
|
|
92
|
+
| getFieldListOpt | Object | | {} | getFieldList opt 参数 |
|
|
93
|
+
| onGetListEnd | Function | | - | 请求列表成功返回的回调 |
|
|
94
|
+
| onCreateSuc | Function | | - | 新增成功返回的回调 |
|
|
95
|
+
| onEditSuc | Function | | - | 编辑成功返回的回调 |
|
|
96
|
+
| onDelSuc | Function | | - | 删除成功返回的回调 |
|
|
97
|
+
| onFormModalClose | Function | | - | 表单弹窗关闭回调 |
|
|
98
|
+
| modalFormMount | Function | | - | 新增、编辑弹窗 Form 渲染完成回调 |
|
|
99
|
+
| msgConf | Object | | {} | 新增、编辑、删除、列表查询,详情查询的报错 msg 提示设置 |
|
|
100
|
+
| i18n | Object | | {} | 文案配置 |
|
|
101
|
+
| queryFormInitialValues | Object | | {} | 列表上方查询 Form 默认值 |
|
|
102
|
+
| queryFormIsExtendModelQuery | Boolean | | false | 列表上方查询 Form 默认值是否继承 data-model.query 置 |
|
|
103
103
|
| useFormData | boolean | 否 | | 是否使用 form data 提交数据 |
|
|
104
|
+
| appendUrlQuery | boolean | 否 | true | 筛选条件改变时是否将参数(对象形式)设置到url query中 |
|
|
105
|
+
| appendUrlQueryKey | string | 否 | URL_PARAM_NAME = "defaultSearchParams" | 自定义设置url query对象参数的key |
|
|
104
106
|
|
|
105
107
|
- fetchOnEdit 展示编辑弹框时,是否会调用一次详情接口进行回填(某些场景下,列表接口只返回部分部分字段,只有详情接口会返回全部字段);若为 false,则会使用表格列表接口返回的 row 数据进行回填
|
|
106
108
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hzab/list-render",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0-beta",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "webpack serve -c ./config/webpack.config.js --env local",
|
|
8
8
|
"build": "webpack -c ./config/webpack.config.js --env production",
|
|
9
|
+
"publish-beta": "npm publish --beta",
|
|
9
10
|
"publish-patch": "npm version patch && npm publish --access public",
|
|
10
11
|
"publish-minor": "npm version minor && npm publish --access public",
|
|
11
12
|
"publish-major": "npm version major && npm publish --access public"
|
|
@@ -22,6 +23,7 @@
|
|
|
22
23
|
"@ant-design/icons": "^4.8.1",
|
|
23
24
|
"@hzab/data-model": "^1.7.4",
|
|
24
25
|
"@hzab/form-render": "^1.6.12",
|
|
26
|
+
"@hzab/formily-result-utils": "^1.2.0",
|
|
25
27
|
"@hzab/schema-descriptions": "^1.3.0",
|
|
26
28
|
"@hzab/webpack-config": "^0.7.2",
|
|
27
29
|
"@types/react": "^17.0.62",
|
|
@@ -42,6 +44,7 @@
|
|
|
42
44
|
"@formily/reactive-react": "2.3.1",
|
|
43
45
|
"@hzab/data-model": ">=1.7.4",
|
|
44
46
|
"@hzab/form-render": ">=1.0.0",
|
|
47
|
+
"@hzab/formily-result-utils": ">=1.2.0",
|
|
45
48
|
"@hzab/schema-descriptions": ">=1.0.0",
|
|
46
49
|
"antd": "4.x",
|
|
47
50
|
"axios": ">=1.4.0",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
2
|
import { getFieldMap } from "./utils";
|
|
3
3
|
import { isRunStr, handleSchemaStrVal, isScopeKey as formIsScopeKey, getScopeKeyVal } from '@hzab/form-render/src/common/schema-handler';
|
|
4
|
+
import { URL_PARAM_NAME } from "./constant";
|
|
4
5
|
|
|
5
6
|
export const handleQuerySchema = (opt) => {
|
|
6
7
|
const { schema, search, filters, onSearch, replaceComList, schemaScope } = opt || {};
|
|
@@ -299,4 +300,83 @@ export const getValByScope = (strKey, schemaScope = {}) => {
|
|
|
299
300
|
}
|
|
300
301
|
};
|
|
301
302
|
|
|
303
|
+
/**
|
|
304
|
+
* 将对象序列化后写入 URL query 中
|
|
305
|
+
* @param obj 要存储的对象(保持原始类型)
|
|
306
|
+
* @param paramName query 参数名
|
|
307
|
+
*/
|
|
308
|
+
export function setURLObjectQueryParam<T extends object>(obj: T, paramName = URL_PARAM_NAME): void {
|
|
309
|
+
try {
|
|
310
|
+
if (typeof window === "undefined") return;
|
|
311
|
+
|
|
312
|
+
const href = window.location.href;
|
|
313
|
+
const [origin, hash = ""] = href.split("#");
|
|
314
|
+
const [path, queryString = ""] = hash.split("?");
|
|
315
|
+
const searchParams = new URLSearchParams(queryString);
|
|
316
|
+
const encoded = encodeURIComponent(JSON.stringify(obj));
|
|
317
|
+
|
|
318
|
+
searchParams.set(paramName, encoded);
|
|
319
|
+
|
|
320
|
+
const newHash = `${path}?${searchParams.toString()}`;
|
|
321
|
+
|
|
322
|
+
window.history.replaceState({}, "", `${origin}#${newHash}`);
|
|
323
|
+
} catch (e) {
|
|
324
|
+
console.error(`[setURLObjectQueryParam] 设置失败:`, e);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* 从当前URL中删除指定的查询参数(不刷新页面)
|
|
330
|
+
* 专门处理哈希路由中的查询参数
|
|
331
|
+
* @param key 要删除的查询参数名称
|
|
332
|
+
*/
|
|
333
|
+
export function removeURLObjectQueryParam(key: string): void {
|
|
334
|
+
if (typeof window === "undefined") return;
|
|
335
|
+
|
|
336
|
+
try {
|
|
337
|
+
const href = window.location.href;
|
|
338
|
+
const [origin, hash = ""] = href.split("#");
|
|
339
|
+
const [hashPath, queryString = ""] = hash.split("?");
|
|
340
|
+
const searchParams = new URLSearchParams(queryString);
|
|
341
|
+
|
|
342
|
+
searchParams.delete(key);
|
|
343
|
+
|
|
344
|
+
// 重建哈希部分
|
|
345
|
+
let newHash = hashPath;
|
|
346
|
+
if (searchParams.toString()) {
|
|
347
|
+
newHash += `?${searchParams.toString()}`;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const newUrl = `${origin}${newHash ? `#${newHash}` : ''}`;
|
|
351
|
+
|
|
352
|
+
window.history.replaceState({}, "", newUrl);
|
|
353
|
+
} catch (e) {
|
|
354
|
+
console.error(`[removeURLObjectQueryParam] 删除失败:`, e);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* 从 URL 中解析序列化的对象
|
|
359
|
+
* @param paramName query 参数名
|
|
360
|
+
* @returns 还原的对象(如果不存在返回 null)
|
|
361
|
+
*/
|
|
362
|
+
export function getURLObjectQueryParam<T = any>(paramName = URL_PARAM_NAME): T | Record<string, any> {
|
|
363
|
+
// 返回空对象是为了防止在合并对象时报错导致页面空白
|
|
364
|
+
if (typeof window === "undefined") return {};
|
|
365
|
+
|
|
366
|
+
const href = window.location.href;
|
|
367
|
+
const [, hash = ""] = href.split("#");
|
|
368
|
+
const [, queryString = ""] = hash.split("?");
|
|
369
|
+
const searchParams = new URLSearchParams(queryString);
|
|
370
|
+
const encoded = searchParams.get(paramName);
|
|
371
|
+
|
|
372
|
+
if (!encoded) return null;
|
|
373
|
+
|
|
374
|
+
try {
|
|
375
|
+
return JSON.parse(decodeURIComponent(encoded)) as T;
|
|
376
|
+
} catch (e) {
|
|
377
|
+
console.error(`[getURLObjectQueryParam] 解析失败:`, e);
|
|
378
|
+
return {};
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
302
382
|
export default handleQuerySchema;
|
package/src/list-render.jsx
CHANGED
|
@@ -15,6 +15,8 @@ import FormModal from "./FormModal";
|
|
|
15
15
|
import DetailModal from "./DetailModal";
|
|
16
16
|
|
|
17
17
|
import { objToFormData } from "./common/utils";
|
|
18
|
+
import { setURLObjectQueryParam, getURLObjectQueryParam, removeURLObjectQueryParam } from "./common/handleQuerySchema";
|
|
19
|
+
import { URL_PARAM_NAME } from "./common/constant";
|
|
18
20
|
|
|
19
21
|
import "./index.less";
|
|
20
22
|
|
|
@@ -43,6 +45,16 @@ const ListRender = forwardRef(function (props, parentRef) {
|
|
|
43
45
|
* 表单提交是否使用 FormData 格式
|
|
44
46
|
*/
|
|
45
47
|
useFormData: _useFormData,
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 筛选条件改变时是否将参数(对象形式)设置到url query中
|
|
51
|
+
* */
|
|
52
|
+
appendUrlQuery = true,
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 自定义设置url query对象参数的key
|
|
56
|
+
* */
|
|
57
|
+
appendUrlQueryKey = URL_PARAM_NAME
|
|
46
58
|
} = props;
|
|
47
59
|
const pageSizeOptions = props.paginationConf?.pageSizeOptions || pageSizeOptionMap[props.layout] || [10, 20, 50, 100];
|
|
48
60
|
// const [pageSizeOptions, setPageSizeOptions] = useState(
|
|
@@ -86,19 +98,30 @@ const ListRender = forwardRef(function (props, parentRef) {
|
|
|
86
98
|
// }, [layout]);
|
|
87
99
|
|
|
88
100
|
useEffect(() => {
|
|
101
|
+
const getUrlQuery = appendUrlQuery ? getURLObjectQueryParam(appendUrlQueryKey) : {};
|
|
102
|
+
|
|
89
103
|
if (model) {
|
|
90
104
|
if (!model.query) {
|
|
91
105
|
model.query = {};
|
|
92
106
|
} else {
|
|
107
|
+
model.query.pageNum = 1;
|
|
108
|
+
|
|
93
109
|
modelQueryRef.current = model?.query;
|
|
94
110
|
paginationQueryRef.current = {
|
|
95
|
-
pageNum: model?.query?.pageNum
|
|
96
|
-
pageSize: model?.query?.pageSize
|
|
111
|
+
pageNum: getUrlQuery?.pageNum || model?.query?.pageNum || paginationQueryRef.current?.pageNum,
|
|
112
|
+
pageSize: getUrlQuery?.pageSize || model?.query?.pageSize || paginationQueryRef.current?.pageSize,
|
|
97
113
|
};
|
|
98
114
|
}
|
|
99
|
-
model.query.pageNum = 1;
|
|
100
115
|
}
|
|
101
|
-
|
|
116
|
+
|
|
117
|
+
// 延迟获取表单实例
|
|
118
|
+
Promise.resolve().then(() => {
|
|
119
|
+
if (queryRef.current && queryRef.current?.formRef?.current.formRender) {
|
|
120
|
+
queryRef.current.formRef.current.formRender?.setValues(getUrlQuery)
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
!props.closeAutoRequest && getList({ ...(modelQueryRef.current || {}), ...getUrlQuery });
|
|
102
125
|
}, []);
|
|
103
126
|
|
|
104
127
|
useEffect(() => {
|
|
@@ -155,7 +178,6 @@ const ListRender = forwardRef(function (props, parentRef) {
|
|
|
155
178
|
}
|
|
156
179
|
|
|
157
180
|
model.query = mergedQueries;
|
|
158
|
-
|
|
159
181
|
// 取消上一次请求
|
|
160
182
|
getListSourceRef.current?.cancel({ code: 601, message: "取消上一次请求" });
|
|
161
183
|
|
|
@@ -195,11 +217,20 @@ const ListRender = forwardRef(function (props, parentRef) {
|
|
|
195
217
|
// model.query.pageNum = page;
|
|
196
218
|
// model.query.pageSize = size;
|
|
197
219
|
paginationQueryRef.current = { pageNum: page, pageSize: size };
|
|
220
|
+
|
|
221
|
+
if (appendUrlQuery) {
|
|
222
|
+
const getUrlQuery = getURLObjectQueryParam(appendUrlQueryKey);
|
|
223
|
+
setURLObjectQueryParam({ ...getUrlQuery, ...paginationQueryRef.current }, appendUrlQueryKey)
|
|
224
|
+
}
|
|
198
225
|
getList();
|
|
199
226
|
}
|
|
200
227
|
|
|
201
|
-
function onSearch(quer, source) {
|
|
228
|
+
function onSearch(quer, source, isReset = false) {
|
|
202
229
|
const query = source === "queryRender" ? { ...quer } : { ...formQueryRef.current, ...quer };
|
|
230
|
+
|
|
231
|
+
// 重置操作时不赋值
|
|
232
|
+
if (!isReset && appendUrlQuery) setURLObjectQueryParam(query, appendUrlQueryKey);
|
|
233
|
+
|
|
203
234
|
if (model && !model.query) {
|
|
204
235
|
model.query = {};
|
|
205
236
|
}
|
|
@@ -214,6 +245,10 @@ const ListRender = forwardRef(function (props, parentRef) {
|
|
|
214
245
|
getList(query);
|
|
215
246
|
}
|
|
216
247
|
|
|
248
|
+
function handleFormReset() {
|
|
249
|
+
appendUrlQuery && removeURLObjectQueryParam(appendUrlQueryKey)
|
|
250
|
+
}
|
|
251
|
+
|
|
217
252
|
function forceUpdate() {
|
|
218
253
|
setList((l) => _.cloneDeep(l));
|
|
219
254
|
}
|
|
@@ -363,15 +398,12 @@ const ListRender = forwardRef(function (props, parentRef) {
|
|
|
363
398
|
search={props.search}
|
|
364
399
|
filters={props.filters}
|
|
365
400
|
config={props.queryConf}
|
|
366
|
-
queryFormInitialValues={
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
...model.query,
|
|
371
|
-
}
|
|
372
|
-
: queryFormInitialValues
|
|
373
|
-
}
|
|
401
|
+
queryFormInitialValues={{
|
|
402
|
+
...queryFormInitialValues,
|
|
403
|
+
...(queryFormIsExtendModelQuery ? model.query : {}),
|
|
404
|
+
}}
|
|
374
405
|
onSearch={onSearch}
|
|
406
|
+
onReset={handleFormReset}
|
|
375
407
|
schemaScope={props.schemaScope}
|
|
376
408
|
components={props.components}
|
|
377
409
|
i18n={i18n}
|
|
@@ -54,9 +54,11 @@ function QueryRender(props, parentRef) {
|
|
|
54
54
|
|
|
55
55
|
function onReset() {
|
|
56
56
|
formRef.current?.formRender?.reset();
|
|
57
|
-
props.
|
|
57
|
+
props.onReset?.();
|
|
58
|
+
props.onSearch && props.onSearch(_.cloneDeep(formRef?.current?.formRender?.values), "queryRender", true);
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
|
|
60
62
|
return (
|
|
61
63
|
<div className="query-render">
|
|
62
64
|
{Object.keys(schema?.schema?.properties || {}).length > 0 ? (
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { useEffect, useState, useMemo, useCallback, useRef } from "react";
|
|
2
2
|
import { Table, Button, Popconfirm, Tooltip, Checkbox, Popover } from "antd";
|
|
3
|
-
import { Schema } from "@formily/json-schema";
|
|
4
3
|
import { QuestionCircleOutlined, FilterOutlined, SettingOutlined } from "@ant-design/icons";
|
|
5
4
|
import _ from "lodash";
|
|
6
5
|
|
|
6
|
+
import EnumRender from "@hzab/formily-result-utils/src/components/EnumRender";
|
|
7
|
+
import { SHOW_MODE_TYPES } from "@hzab/formily-result-utils/src/common/constant";
|
|
7
8
|
import { FormilyField } from "../components/Formily/FormilyField";
|
|
8
|
-
import Tags from "../components/Tags";
|
|
9
|
-
import PrefixNode from "../components/PrefixNode";
|
|
10
9
|
// getColRender 使用 observer 包裹一层 column 的 render 函数,解决数据无法响应的问题
|
|
11
10
|
import { getColRender } from "../common/formily-utils";
|
|
12
11
|
import { getVal, getFieldList } from "../common/utils";
|
|
@@ -106,7 +105,7 @@ function TableRender(props) {
|
|
|
106
105
|
};
|
|
107
106
|
} else {
|
|
108
107
|
colRender = function (text, record, index, ...args) {
|
|
109
|
-
const { width, ellipsis, emptyValue, showTags, showPrefixNode } = _colConf || {};
|
|
108
|
+
const { width, ellipsis, emptyValue, showTags, showPrefixNode, showMode, enumRenderProps } = _colConf || {};
|
|
110
109
|
const schemaDefaultValue = fieldSchemas[name]?.componentProps?.emptyValue;
|
|
111
110
|
const defaultValue = emptyValue ?? schemaDefaultValue ?? tableEmptyValue ?? "";
|
|
112
111
|
|
|
@@ -130,25 +129,22 @@ function TableRender(props) {
|
|
|
130
129
|
</Tooltip>
|
|
131
130
|
);
|
|
132
131
|
}
|
|
133
|
-
|
|
134
|
-
if (showTags) {
|
|
135
|
-
// field 通过 fieldSchemas 获取最新的 field 数据
|
|
136
|
-
return (
|
|
137
|
-
<Tags
|
|
138
|
-
value={_.get(record, name)}
|
|
139
|
-
config={typeof showTags === "object" ? showTags : undefined}
|
|
140
|
-
field={{ ...field, ...fieldSchemas?.[name] }}
|
|
141
|
-
/>
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
// 使用 前缀节点 渲染内容
|
|
145
|
-
if (showPrefixNode || (showPrefixNode !== false && comName === "Switch")) {
|
|
132
|
+
|
|
133
|
+
if (showMode || showTags || showPrefixNode || (showPrefixNode !== false && comName === "Switch")) {
|
|
146
134
|
// field 通过 fieldSchemas 获取最新的 field 数据
|
|
135
|
+
let _showMode = showMode;
|
|
136
|
+
if (showTags) {
|
|
137
|
+
_showMode = SHOW_MODE_TYPES.tags;
|
|
138
|
+
} else if (showPrefixNode) {
|
|
139
|
+
_showMode = SHOW_MODE_TYPES.prefixNode;
|
|
140
|
+
}
|
|
141
|
+
|
|
147
142
|
return (
|
|
148
|
-
<
|
|
143
|
+
<EnumRender
|
|
144
|
+
showMode={_showMode}
|
|
149
145
|
value={_.get(record, name)}
|
|
150
|
-
config={typeof showPrefixNode === "object" ? showPrefixNode : undefined}
|
|
151
146
|
field={{ ...field, ...fieldSchemas?.[name] }}
|
|
147
|
+
{...enumRenderProps}
|
|
152
148
|
/>
|
|
153
149
|
);
|
|
154
150
|
}
|