@hzab/list-render 1.10.21-alpha.3 → 1.10.21-alpha.4
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,5 +1,5 @@
|
|
|
1
1
|
import { MinusSquareOutlined, PlusCircleOutlined } from "@ant-design/icons";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
2
|
+
import { useEffect, useState, memo } from "react";
|
|
3
3
|
import "./index.less";
|
|
4
4
|
export const ExpandListTemplate = (props) => {
|
|
5
5
|
const [expand, setExpand] = useState<boolean>(false);
|
|
@@ -7,14 +7,18 @@ export const ExpandListTemplate = (props) => {
|
|
|
7
7
|
const { Slots, setExpandKeys, expandKeys }: any = item;
|
|
8
8
|
const onExpand = (isExpand) => {
|
|
9
9
|
item?.setNewDataSource((pre) => {
|
|
10
|
+
const tempPre = [...pre];
|
|
11
|
+
const childrenIds = props?.record?.children?.map((el) => el?.groupId);
|
|
10
12
|
if (isExpand) {
|
|
11
13
|
const findIndex = pre?.findIndex((el) => el?.groupId == props?.record?.groupId);
|
|
12
|
-
pre
|
|
13
|
-
|
|
14
|
+
const filterList = pre?.filter((el) => childrenIds?.includes(el?.groupId)) || [];
|
|
15
|
+
if (filterList?.length == 0) {
|
|
16
|
+
tempPre.splice(findIndex + 1, 0, ...(props?.record?.children || []));
|
|
17
|
+
}
|
|
18
|
+
return [...tempPre];
|
|
14
19
|
}
|
|
15
|
-
const childrenIds = props?.record?.children?.map((el) => el?.groupId);
|
|
16
20
|
|
|
17
|
-
return
|
|
21
|
+
return tempPre?.filter((el) => !childrenIds?.includes(el?.groupId));
|
|
18
22
|
});
|
|
19
23
|
};
|
|
20
24
|
useEffect(() => {
|
|
@@ -29,7 +33,6 @@ export const ExpandListTemplate = (props) => {
|
|
|
29
33
|
// setExpand(props?.record?.expand);
|
|
30
34
|
}, [props?.record]);
|
|
31
35
|
|
|
32
|
-
// console.log(props,"propspropsprops2",Slots[item?.columnId]);
|
|
33
36
|
const colRender = function (text, record) {
|
|
34
37
|
const Slot = Slots[item?.columnId];
|
|
35
38
|
const slotProps = {
|
|
@@ -51,7 +54,7 @@ export const ExpandListTemplate = (props) => {
|
|
|
51
54
|
props.record["expand"] = !expand;
|
|
52
55
|
setExpandKeys((preExpandKeys) => {
|
|
53
56
|
if (preExpandKeys?.includes(props?.record?.groupId)) {
|
|
54
|
-
return preExpandKeys?.filter((el) => el
|
|
57
|
+
return preExpandKeys?.filter((el) => el != props?.record?.groupId);
|
|
55
58
|
}
|
|
56
59
|
return [...preExpandKeys, props?.record?.groupId];
|
|
57
60
|
});
|
|
@@ -64,6 +67,12 @@ export const ExpandListTemplate = (props) => {
|
|
|
64
67
|
className="expandList-template-icon"
|
|
65
68
|
onClick={() => {
|
|
66
69
|
props.record["expand"] = !expand;
|
|
70
|
+
setExpandKeys((preExpandKeys) => {
|
|
71
|
+
if (preExpandKeys?.includes(props?.record?.groupId)) {
|
|
72
|
+
return preExpandKeys?.filter((el) => el != props?.record?.groupId);
|
|
73
|
+
}
|
|
74
|
+
return [...preExpandKeys, props?.record?.groupId];
|
|
75
|
+
});
|
|
67
76
|
setExpand(!expand);
|
|
68
77
|
onExpand(!expand);
|
|
69
78
|
}}
|
|
@@ -192,8 +192,8 @@ export const WidthWrap = (opt: any, edit = false) => {
|
|
|
192
192
|
}, [cell]);
|
|
193
193
|
|
|
194
194
|
const echoValue = useMemo(() => {
|
|
195
|
-
if(!cell?.getField){
|
|
196
|
-
return
|
|
195
|
+
if (!cell?.getField) {
|
|
196
|
+
return;
|
|
197
197
|
}
|
|
198
198
|
return getVal(
|
|
199
199
|
{ ...(cell?.getField && cell?.getField()), enum: cell?.getField()?.enum || cell?.values },
|
|
@@ -205,7 +205,6 @@ export const WidthWrap = (opt: any, edit = false) => {
|
|
|
205
205
|
<div
|
|
206
206
|
style={{ width: "100%", height: "100%", display: "flex", alignItems: "center" }}
|
|
207
207
|
onDoubleClick={(e) => {
|
|
208
|
-
console.log(cell,"c222ellcellcellcellcell");
|
|
209
208
|
if (cell?.nonEditable) {
|
|
210
209
|
return;
|
|
211
210
|
}
|
|
@@ -107,7 +107,7 @@ export default function CellEditTable(props: any) {
|
|
|
107
107
|
const columnsItem = tableColumns[ind];
|
|
108
108
|
const cellItem = item[el];
|
|
109
109
|
let type: any = columnsItem?.type ?? "text";
|
|
110
|
-
if (!rowSelection && ind == 0
|
|
110
|
+
if (!rowSelection && ind == 0) {
|
|
111
111
|
type = "ExpandListTemplate";
|
|
112
112
|
}
|
|
113
113
|
if (rowSelection && ind == 1) {
|
|
@@ -130,7 +130,7 @@ export default function CellEditTable(props: any) {
|
|
|
130
130
|
return {
|
|
131
131
|
...columnsItem,
|
|
132
132
|
record: item,
|
|
133
|
-
rowId: item
|
|
133
|
+
rowId: item[rowKey] || columnsItem?.type,
|
|
134
134
|
type: type,
|
|
135
135
|
nonEditable: columnsItem?.nonEditable,
|
|
136
136
|
text: String(cellItem || ""),
|
|
@@ -153,14 +153,11 @@ export default function CellEditTable(props: any) {
|
|
|
153
153
|
}),
|
|
154
154
|
};
|
|
155
155
|
});
|
|
156
|
-
setRows([...headerList, ...tempDataSource]);
|
|
156
|
+
setRows(_.uniqBy([...headerList, ...tempDataSource], "rowId"));
|
|
157
157
|
}, [newDataSource, tableColumns, rowSelection]);
|
|
158
|
-
console.log(rows, "rowsrows");
|
|
159
158
|
|
|
160
159
|
// 单元格编辑回调
|
|
161
160
|
const handleCellsChanged = (changes) => {
|
|
162
|
-
console.log(changes, "changeschangeschanges");
|
|
163
|
-
|
|
164
161
|
setRows((prevRows) => {
|
|
165
162
|
changes.forEach((change) => {
|
|
166
163
|
const changeRowIdx = prevRows.findIndex((el) => el.rowId == change.rowId);
|
|
@@ -361,7 +361,7 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
361
361
|
|
|
362
362
|
const tableProps = {
|
|
363
363
|
className: "table-render",
|
|
364
|
-
rowKey: props
|
|
364
|
+
rowKey: props?.idKey || "id",
|
|
365
365
|
rowSelection: config?.rowSelection,
|
|
366
366
|
columns: columns,
|
|
367
367
|
dataSource: props.list,
|