@hzab/list-render 1.12.1 → 1.12.3-alpha.0
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/package.json +4 -5
- package/src/FilterTag/index.less +15 -0
- package/src/FilterTag/index.tsx +58 -0
- package/src/card-render/index.jsx +20 -16
- package/src/list-render.jsx +12 -1
- package/src/table-render/index.jsx +7 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hzab/list-render",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.3-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src",
|
|
6
6
|
"scripts": {
|
|
@@ -44,9 +44,7 @@
|
|
|
44
44
|
"react": "^17.0.2",
|
|
45
45
|
"react-dom": "^17.0.2",
|
|
46
46
|
"react-router-dom": "^6.8.1",
|
|
47
|
-
"typescript": "^4.9.4"
|
|
48
|
-
"@hzab/edit-table": "^0.0.1",
|
|
49
|
-
"@silevis/reactgrid": "^4.1.17"
|
|
47
|
+
"typescript": "^4.9.4"
|
|
50
48
|
},
|
|
51
49
|
"peerDependencies": {
|
|
52
50
|
"@formily/core": "2.3.1",
|
|
@@ -62,7 +60,8 @@
|
|
|
62
60
|
"c-formily-antd": "2.3.1",
|
|
63
61
|
"lodash": ">=4.17.21",
|
|
64
62
|
"react": ">=16.8.0",
|
|
65
|
-
"react-dom": ">=16.8.0"
|
|
63
|
+
"react-dom": ">=16.8.0",
|
|
64
|
+
"@hzab/edit-table": "^0.0.1"
|
|
66
65
|
},
|
|
67
66
|
"directories": {
|
|
68
67
|
"lib": "lib"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import "./index.less";
|
|
3
|
+
import { Tag } from "antd";
|
|
4
|
+
import { getVal } from "@hzab/list-render/src/common/utils";
|
|
5
|
+
function hasValue(val) {
|
|
6
|
+
return val !== null && val !== undefined;
|
|
7
|
+
}
|
|
8
|
+
const FilterTag = (props: any) => {
|
|
9
|
+
const { searchQuery, schema, queryRef } = props;
|
|
10
|
+
const [worldList, setWorldList] = useState<any>([]);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (queryRef) {
|
|
13
|
+
const list = [];
|
|
14
|
+
const fieldSchemas = queryRef.current?.formRef?.current?.formRender?.fields;
|
|
15
|
+
for (let key in schema?.schema?.properties) {
|
|
16
|
+
const field = schema?.schema?.properties[key];
|
|
17
|
+
if (hasValue(searchQuery[key])) {
|
|
18
|
+
let val = getVal({ ...field, ...fieldSchemas[field?.name] }, searchQuery, {
|
|
19
|
+
fieldSchema: fieldSchemas?.[field?.name],
|
|
20
|
+
});
|
|
21
|
+
list.push({
|
|
22
|
+
label: field?.title,
|
|
23
|
+
value: val,
|
|
24
|
+
filed: key,
|
|
25
|
+
filedValue: searchQuery[key],
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
setWorldList(list);
|
|
30
|
+
}
|
|
31
|
+
}, [searchQuery, schema, queryRef]);
|
|
32
|
+
const onClose = (e, item) => {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
queryRef.current?.formRef?.current?.formRender.setValues({
|
|
35
|
+
[item?.filed]: null,
|
|
36
|
+
});
|
|
37
|
+
setWorldList((pre) => pre?.filter((el) => el?.filed != item?.filed));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className="has-filter">
|
|
42
|
+
{worldList?.map((item) => {
|
|
43
|
+
return (
|
|
44
|
+
<Tag
|
|
45
|
+
className="has-filter-tag"
|
|
46
|
+
closable
|
|
47
|
+
onClose={(e) => {
|
|
48
|
+
onClose(e, item);
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
{item?.label}:{item?.value}
|
|
52
|
+
</Tag>
|
|
53
|
+
);
|
|
54
|
+
})}
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
export default FilterTag;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { useEffect, useState, useMemo, useCallback, useRef } from "react";
|
|
2
|
-
import { Table, Button, Popconfirm, Tooltip, Checkbox, Popover, Spin } from "antd";
|
|
2
|
+
import { Table, Button, Popconfirm, Tooltip, Checkbox, Popover, Spin, Empty } from "antd";
|
|
3
3
|
import { QuestionCircleOutlined, FilterOutlined, SettingOutlined } from "@ant-design/icons";
|
|
4
4
|
import _ from "lodash";
|
|
5
5
|
import DetailRender from "@hzab/schema-descriptions";
|
|
6
6
|
import { removeInTableFalseFields } from "../common/utils";
|
|
7
7
|
import "./index.less";
|
|
8
|
-
import { use } from "react";
|
|
9
8
|
|
|
10
9
|
const scenario = "table-render";
|
|
11
10
|
|
|
@@ -105,20 +104,25 @@ function CardRender(props) {
|
|
|
105
104
|
|
|
106
105
|
return (
|
|
107
106
|
<Spin spinning={loading}>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
<div className="item-render-card
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
107
|
+
{
|
|
108
|
+
props.list?.length > 0 ?
|
|
109
|
+
<div className="card-render-wrap" style={{ gridTemplateColumns: `repeat(${columns}, 1fr` }}>
|
|
110
|
+
{props.list?.map((item, index) => {
|
|
111
|
+
return (
|
|
112
|
+
<div key={item["id"]} className="item-render-card">
|
|
113
|
+
{props.hasAction !== false ? (
|
|
114
|
+
<div className="item-render-card-title">{getColRender(item, index)}</div>
|
|
115
|
+
) : null}
|
|
116
|
+
<div className="item-render-card-content">
|
|
117
|
+
<ItemRender item={item} index={index} />
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
})}
|
|
122
|
+
</div> : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE}></Empty>
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
122
126
|
</Spin>
|
|
123
127
|
|
|
124
128
|
);
|
package/src/list-render.jsx
CHANGED
|
@@ -13,7 +13,7 @@ import TableRender from "./table-render";
|
|
|
13
13
|
import CardRender from "./card-render";
|
|
14
14
|
import FormModal from "./FormModal";
|
|
15
15
|
import DetailModal from "./DetailModal";
|
|
16
|
-
|
|
16
|
+
import FilterTag from "./FilterTag"
|
|
17
17
|
import { objToFormData } from "./common/utils";
|
|
18
18
|
import {
|
|
19
19
|
setURLObjectQueryParam,
|
|
@@ -60,6 +60,7 @@ const ListRender = forwardRef(function (props, parentRef) {
|
|
|
60
60
|
* 自定义设置url query对象参数的key
|
|
61
61
|
* */
|
|
62
62
|
appendUrlQueryKey = URL_PARAM_NAME,
|
|
63
|
+
hasFilterTag = false
|
|
63
64
|
} = props;
|
|
64
65
|
const { isAllSelect = false, isAllSelectKey = "isAllSelect" } = props.paginationConf || {};
|
|
65
66
|
|
|
@@ -83,6 +84,7 @@ const ListRender = forwardRef(function (props, parentRef) {
|
|
|
83
84
|
const getListSourceRef = useRef();
|
|
84
85
|
const [showSearch, setShowSearch] = useState(true);
|
|
85
86
|
const tableRef = useRef({});
|
|
87
|
+
const [searchQuery, setSearchQuery] = useState({})
|
|
86
88
|
|
|
87
89
|
useImperativeHandle(parentRef, () => ({
|
|
88
90
|
getList,
|
|
@@ -95,6 +97,7 @@ const ListRender = forwardRef(function (props, parentRef) {
|
|
|
95
97
|
onCreate,
|
|
96
98
|
onEdit,
|
|
97
99
|
onDel,
|
|
100
|
+
tableRef
|
|
98
101
|
}));
|
|
99
102
|
|
|
100
103
|
const { schema = {}, config = {}, model = {}, msgConf = {}, filters } = props;
|
|
@@ -263,6 +266,7 @@ const ListRender = forwardRef(function (props, parentRef) {
|
|
|
263
266
|
* @returns
|
|
264
267
|
*/
|
|
265
268
|
function onQueryFormSubmit(query, isReset) {
|
|
269
|
+
setSearchQuery(query)
|
|
266
270
|
// 是否开启 url query
|
|
267
271
|
if (appendUrlQuery) {
|
|
268
272
|
if (isReset) {
|
|
@@ -492,6 +496,13 @@ const ListRender = forwardRef(function (props, parentRef) {
|
|
|
492
496
|
)}
|
|
493
497
|
</div>
|
|
494
498
|
</div>
|
|
499
|
+
{
|
|
500
|
+
hasFilterTag && <FilterTag
|
|
501
|
+
searchQuery={searchQuery}
|
|
502
|
+
schema={schema}
|
|
503
|
+
queryRef={queryRef}
|
|
504
|
+
></FilterTag>
|
|
505
|
+
}
|
|
495
506
|
{Slots.HeaderOthersSuffix && <Slots.HeaderOthersSuffix onSearch={onSearch} getList={getList} />}
|
|
496
507
|
{layout === "card" ? (
|
|
497
508
|
<CardRender
|
|
@@ -10,6 +10,7 @@ import { createForm, onFormValuesChange, onFieldValueChange } from "@formily/cor
|
|
|
10
10
|
|
|
11
11
|
import EnumRender from "@hzab/formily-result-utils/src/components/EnumRender";
|
|
12
12
|
import { SHOW_MODE_TYPES } from "@hzab/formily-result-utils/src/common/constant";
|
|
13
|
+
import CellEditTable from "@hzab/edit-table"
|
|
13
14
|
import { FormilyField } from "../components/Formily/FormilyField";
|
|
14
15
|
// getColRender 使用 observer 包裹一层 column 的 render 函数,解决数据无法响应的问题
|
|
15
16
|
import { getColRender } from "../common/formily-utils";
|
|
@@ -17,7 +18,6 @@ import { getVal, getFieldList } from "../common/utils";
|
|
|
17
18
|
import { handleReactions } from "../common/handleReactions";
|
|
18
19
|
|
|
19
20
|
import { useEditTable, EditableCell } from "../components/Formily/FormilyEditTable";
|
|
20
|
-
import CellEditTable from "@hzab/edit-table"
|
|
21
21
|
import "./index.less";
|
|
22
22
|
|
|
23
23
|
const scenario = "table-render";
|
|
@@ -38,8 +38,10 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
38
38
|
} = config || {};
|
|
39
39
|
const { editMode = "modal" } = topProps || {};
|
|
40
40
|
const isEditTable = editMode !== "modal";
|
|
41
|
+
const cellEditTableRef = useRef()
|
|
41
42
|
useImperativeHandle(tableRef, () => ({
|
|
42
43
|
onEditByTable,
|
|
44
|
+
cellEditTableRef
|
|
43
45
|
}));
|
|
44
46
|
|
|
45
47
|
const [columns, setColumns] = useState([]);
|
|
@@ -192,11 +194,13 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
192
194
|
</span>
|
|
193
195
|
);
|
|
194
196
|
}
|
|
197
|
+
|
|
195
198
|
const childSelectList = fieldSchemas?.[field?.name]?.dataSource?.map((el) => ({
|
|
196
199
|
...el,
|
|
197
200
|
label: el?.[field?.["x-component-props"]?.["fieldNames"]?.["label"]] || el?.label,
|
|
198
201
|
value: el?.[field?.["x-component-props"]?.["fieldNames"]?.["value"]] || el?.value,
|
|
199
202
|
}))
|
|
203
|
+
|
|
200
204
|
return {
|
|
201
205
|
getField: () => field,
|
|
202
206
|
editable: true,
|
|
@@ -214,6 +218,7 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
214
218
|
cellProps: field.cellProps,
|
|
215
219
|
children: handleChildColumns(field?.children),
|
|
216
220
|
render: getColRender(colRender),
|
|
221
|
+
required: field?.required
|
|
217
222
|
}
|
|
218
223
|
|
|
219
224
|
})?.filter((el) => (el))
|
|
@@ -440,6 +445,7 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
440
445
|
) : null}
|
|
441
446
|
{
|
|
442
447
|
isCellEditTable ? <CellEditTable
|
|
448
|
+
ref={cellEditTableRef}
|
|
443
449
|
{...tableProps}
|
|
444
450
|
{...cellEditTableProps}
|
|
445
451
|
{...props}
|