@hzab/list-render 1.10.20-alpha.0 → 1.10.20
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 +4 -0
- package/README.md +0 -10
- package/package.json +3 -3
- package/src/components/Formily/{--FormilyEditTable.tsx → FormilyEditTable.tsx} +3 -74
- package/src/list-render.jsx +2 -8
- package/src/pagination-render/index.less +54 -11
- package/src/table-render/index.jsx +83 -117
- package/src/EditArrayTable/index.less +0 -11
- package/src/EditArrayTable/index.tsx +0 -198
- package/src/components/Formily/FormilyEditTable/EditTableCell.tsx +0 -157
- package/src/components/Formily/FormilyEditTable/EditTableRow.tsx +0 -71
- package/src/components/Formily/FormilyEditTable/index.tsx +0 -229
- package/src/components/Formily/FormilyEditTable/type.d.ts +0 -6
- package/src/components/Formily/FormilyEditTable/useTableFormilyContext.ts +0 -17
- package/src/components/Formily/SchemaToArrayTable.ts +0 -266
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -107,16 +107,6 @@ const listDM = useMemo(
|
|
|
107
107
|
| onEditReqVerify | Function | 否 | - | 编辑态保存时额外的规则校验函数,返回 Promise 的 resolve 或 reject 用于继续执行或停止执行 |
|
|
108
108
|
|
|
109
109
|
- fetchOnEdit 展示编辑弹框时,是否会调用一次详情接口进行回填(某些场景下,列表接口只返回部分部分字段,只有详情接口会返回全部字段);若为 false,则会使用表格列表接口返回的 row 数据进行回填
|
|
110
|
-
- editMode
|
|
111
|
-
- modal 弹窗/抽屉编辑;
|
|
112
|
-
- table-edit 整个 table 一起编辑;
|
|
113
|
-
- table-edit-show 整个 table 可 一起编辑,直接显示表单;
|
|
114
|
-
- line 编辑整行,编辑按钮在操作列;
|
|
115
|
-
- line-show 编辑整行,直接显示表单,编辑按钮在操作列;
|
|
116
|
-
- line-cell 编辑整行,操作按钮在单元格;
|
|
117
|
-
- line-cell-show 编辑整行,直接显示表单,操作按钮在单元格;
|
|
118
|
-
- cell 编辑指定单元格
|
|
119
|
-
- cell-show 编辑指定单元格,直接显示表单
|
|
120
110
|
|
|
121
111
|
#### tableConf
|
|
122
112
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hzab/list-render",
|
|
3
|
-
"version": "1.10.20
|
|
3
|
+
"version": "1.10.20",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src",
|
|
6
6
|
"scripts": {
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@ant-design/icons": "^4.8.1",
|
|
28
28
|
"@hzab/data-model": "^1.7.4",
|
|
29
|
-
"@hzab/form-render": "^1.
|
|
29
|
+
"@hzab/form-render": "^1.6.12",
|
|
30
30
|
"@hzab/formily-result-utils": "^1.2.0",
|
|
31
31
|
"@hzab/permissions": "^1.0.0",
|
|
32
32
|
"@hzab/schema-descriptions": "^1.3.0",
|
|
33
|
-
"@hzab/utils": "^1.0.16",
|
|
34
33
|
"@hzab/webpack-config": "^0.7.2",
|
|
34
|
+
"@hzab/utils": "^1.0.7",
|
|
35
35
|
"@types/react": "^17.0.62",
|
|
36
36
|
"@types/react-dom": "^17.0.20",
|
|
37
37
|
"antd": "^4.24.12",
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import React, { useState, useCallback, useRef, useEffect
|
|
1
|
+
import React, { useState, useCallback, useRef, useEffect } from "react";
|
|
2
2
|
import { Card, Slider, Rate, Form, Button } from "antd";
|
|
3
3
|
import { EditOutlined, CheckOutlined, CloseOutlined } from "@ant-design/icons";
|
|
4
|
-
import { createForm, onFormValuesChange, onFieldValueChange } from "@formily/core";
|
|
5
4
|
import { createSchemaField, FormProvider, FormConsumer } from "@formily/react";
|
|
6
|
-
|
|
7
5
|
import { cloneDeep } from "lodash";
|
|
8
6
|
|
|
9
7
|
import { antdComponents, customComponents } from "@hzab/form-render";
|
|
@@ -15,74 +13,6 @@ export interface Item {
|
|
|
15
13
|
address: string;
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
export interface EditableRowProps extends React.HTMLAttributes<HTMLElement> {
|
|
19
|
-
SchemaField: any;
|
|
20
|
-
getField: () => {
|
|
21
|
-
type: string;
|
|
22
|
-
name: string;
|
|
23
|
-
};
|
|
24
|
-
editing: boolean;
|
|
25
|
-
dataIndex: string;
|
|
26
|
-
title: any;
|
|
27
|
-
inputType: "number" | "text";
|
|
28
|
-
record: Item;
|
|
29
|
-
index: number;
|
|
30
|
-
editable: boolean;
|
|
31
|
-
onEdit: (record: Partial<Item> & { key: React.Key }, dataIndex: string, opt: Object) => void;
|
|
32
|
-
onSave: (field: { type: string; name: string }) => void;
|
|
33
|
-
onCancel: () => void;
|
|
34
|
-
topProps: {
|
|
35
|
-
config: { hasEdit: boolean | Function };
|
|
36
|
-
editMode: "modal" | "line" | "line-cell" | "cell";
|
|
37
|
-
formConf: any;
|
|
38
|
-
};
|
|
39
|
-
children: React.ReactNode;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const EditableRow: React.FC<EditableRowProps> = ({
|
|
43
|
-
SchemaField,
|
|
44
|
-
getField,
|
|
45
|
-
editing,
|
|
46
|
-
dataIndex,
|
|
47
|
-
title,
|
|
48
|
-
inputType,
|
|
49
|
-
record,
|
|
50
|
-
index,
|
|
51
|
-
onEdit,
|
|
52
|
-
onSave,
|
|
53
|
-
onCancel,
|
|
54
|
-
editable,
|
|
55
|
-
topProps,
|
|
56
|
-
children,
|
|
57
|
-
...restProps
|
|
58
|
-
}) => {
|
|
59
|
-
const { formConf = {} } = topProps || {};
|
|
60
|
-
const formRender = useMemo(
|
|
61
|
-
() =>
|
|
62
|
-
createForm({
|
|
63
|
-
initialValues: record,
|
|
64
|
-
// 禁用状态(注意,自定义组件组件自行获取对应的状态)
|
|
65
|
-
readOnly: formConf.readOnly,
|
|
66
|
-
disabled: formConf.disabled,
|
|
67
|
-
...(formConf.formOptions || {}),
|
|
68
|
-
effects(...args) {
|
|
69
|
-
formConf.onFormValuesChange && onFormValuesChange(formConf.onFormValuesChange);
|
|
70
|
-
formConf.onFieldValueChange && onFieldValueChange("*", formConf.onFieldValueChange);
|
|
71
|
-
formConf.formOptions?.effects && formConf.formOptions?.effects(...args);
|
|
72
|
-
},
|
|
73
|
-
}),
|
|
74
|
-
[],
|
|
75
|
-
);
|
|
76
|
-
// return <tr {...restProps}>{children}</tr>;
|
|
77
|
-
return (
|
|
78
|
-
<FormProvider form={formRender}>
|
|
79
|
-
<Form layout="vertical" component={false}>
|
|
80
|
-
<FormConsumer>{() => <tr {...restProps}>{children}</tr>}</FormConsumer>
|
|
81
|
-
</Form>
|
|
82
|
-
</FormProvider>
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
16
|
export interface EditableCellProps extends React.HTMLAttributes<HTMLElement> {
|
|
87
17
|
SchemaField: any;
|
|
88
18
|
getField: () => {
|
|
@@ -102,7 +32,6 @@ export interface EditableCellProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
102
32
|
topProps: {
|
|
103
33
|
config: { hasEdit: boolean | Function };
|
|
104
34
|
editMode: "modal" | "line" | "line-cell" | "cell";
|
|
105
|
-
isEditCell: (record) => boolean;
|
|
106
35
|
};
|
|
107
36
|
children: React.ReactNode;
|
|
108
37
|
}
|
|
@@ -127,12 +56,12 @@ export const EditableCell: React.FC<EditableCellProps> = ({
|
|
|
127
56
|
const field = getField && getField();
|
|
128
57
|
const fPattern = field?.["x-pattern"];
|
|
129
58
|
const fDisplay = field?.["x-display"];
|
|
130
|
-
const { editMode = "modal"
|
|
59
|
+
const { editMode = "modal" } = topProps || {};
|
|
131
60
|
const { hasEdit } = topProps?.config || {};
|
|
132
61
|
const fieldRef = useRef();
|
|
133
62
|
|
|
134
63
|
// 弹窗编辑模式
|
|
135
|
-
if (editMode === "modal"
|
|
64
|
+
if (editMode === "modal") {
|
|
136
65
|
return <td {...restProps}>{children}</td>;
|
|
137
66
|
}
|
|
138
67
|
// 无编辑权限或禁止编辑
|
package/src/list-render.jsx
CHANGED
|
@@ -10,7 +10,6 @@ import axiosI, { isCancel, getCancelTokenSource } from "@hzab/data-model/src/axi
|
|
|
10
10
|
import QueryRender from "./query-render";
|
|
11
11
|
import Pagination from "./pagination-render";
|
|
12
12
|
import TableRender from "./table-render";
|
|
13
|
-
import EditArrayTable from "./EditArrayTable";
|
|
14
13
|
import CardRender from "./card-render";
|
|
15
14
|
import FormModal from "./FormModal";
|
|
16
15
|
import DetailModal from "./DetailModal";
|
|
@@ -203,7 +202,6 @@ const ListRender = forwardRef(function (props, parentRef) {
|
|
|
203
202
|
setTotal(res.pagination?.total);
|
|
204
203
|
props.onGetListEnd && props.onGetListEnd(res);
|
|
205
204
|
setListLoading(false);
|
|
206
|
-
return res;
|
|
207
205
|
})
|
|
208
206
|
.catch((err) => {
|
|
209
207
|
// 兼容新老版本 data-model isCancel 取法
|
|
@@ -456,9 +454,6 @@ const ListRender = forwardRef(function (props, parentRef) {
|
|
|
456
454
|
setShowSearch(!showSearch);
|
|
457
455
|
};
|
|
458
456
|
|
|
459
|
-
const CTableRender =
|
|
460
|
-
props.editMode === "table-edit" || props.editMode === "table-edit-show" ? EditArrayTable : TableRender;
|
|
461
|
-
|
|
462
457
|
return (
|
|
463
458
|
<div className={`list-render ${props.className}`}>
|
|
464
459
|
<div className={`list-header ${props.verticalHeader ? "vertical-header" : ""}`}>
|
|
@@ -521,10 +516,10 @@ const ListRender = forwardRef(function (props, parentRef) {
|
|
|
521
516
|
) : null}
|
|
522
517
|
|
|
523
518
|
{layout === "default" ? (
|
|
524
|
-
<
|
|
519
|
+
<TableRender
|
|
525
520
|
idKey={idKey}
|
|
526
521
|
ref={tableRef}
|
|
527
|
-
schema={schema}
|
|
522
|
+
schema={schema?.schema}
|
|
528
523
|
list={list}
|
|
529
524
|
config={props.tableConf}
|
|
530
525
|
hasAction={props.hasAction}
|
|
@@ -545,7 +540,6 @@ const ListRender = forwardRef(function (props, parentRef) {
|
|
|
545
540
|
i18n={i18n}
|
|
546
541
|
onEditSubmit={onEditSubmit}
|
|
547
542
|
topProps={props}
|
|
548
|
-
handleMessage={handleMessage}
|
|
549
543
|
/>
|
|
550
544
|
) : null}
|
|
551
545
|
|
|
@@ -1,11 +1,54 @@
|
|
|
1
|
-
.pagination-render-wrap {
|
|
2
|
-
display: flex;
|
|
3
|
-
justify-content: flex-end;
|
|
4
|
-
align-items: center;
|
|
5
|
-
padding-top: 20px;
|
|
6
|
-
.pagination-render {
|
|
7
|
-
li {
|
|
8
|
-
margin-bottom: 8px;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
1
|
+
.pagination-render-wrap {
|
|
2
|
+
display: flex;
|
|
3
|
+
justify-content: flex-end;
|
|
4
|
+
align-items: center;
|
|
5
|
+
padding-top: 20px;
|
|
6
|
+
.pagination-render {
|
|
7
|
+
li {
|
|
8
|
+
margin-bottom: 8px;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
.pagination-infinity {
|
|
12
|
+
.ant-pagination-options {
|
|
13
|
+
.rc-virtual-list-holder-inner {
|
|
14
|
+
.ant-select-item {
|
|
15
|
+
&:last-child {
|
|
16
|
+
.ant-select-item-option-content {
|
|
17
|
+
position: relative;
|
|
18
|
+
color: transparent;
|
|
19
|
+
&::after {
|
|
20
|
+
color: rgba(0, 0, 0, 0.85);
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
transition: background 0.3s ease;
|
|
23
|
+
content: "全部";
|
|
24
|
+
position: absolute;
|
|
25
|
+
left: 0;
|
|
26
|
+
top: 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
.pagination-infinity-checked {
|
|
35
|
+
.ant-pagination-options {
|
|
36
|
+
.ant-select-selector {
|
|
37
|
+
.ant-select-selection-item {
|
|
38
|
+
position: relative;
|
|
39
|
+
color: transparent;
|
|
40
|
+
&::after {
|
|
41
|
+
color: rgba(0, 0, 0, 0.85);
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
transition: background 0.3s ease;
|
|
44
|
+
content: "全部";
|
|
45
|
+
position: absolute;
|
|
46
|
+
left: 0;
|
|
47
|
+
top: 0;
|
|
48
|
+
visibility: visible;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { useEffect, useState, useRef, forwardRef, useImperativeHandle
|
|
1
|
+
import { useEffect, useState, useMemo, useRef, forwardRef, useImperativeHandle } from "react";
|
|
2
2
|
import { Form, Table, Button, Popconfirm, Tooltip, Checkbox, Popover } from "antd";
|
|
3
3
|
import { QuestionCircleOutlined, FilterOutlined, SettingOutlined, MenuOutlined } from "@ant-design/icons";
|
|
4
4
|
import { SortableContainer, SortableElement, SortableHandle } from "react-sortable-hoc";
|
|
5
5
|
import { arrayMoveImmutable } from "array-move";
|
|
6
6
|
import _, { isFunction } from "lodash";
|
|
7
7
|
|
|
8
|
+
import { FormProvider, FormConsumer } from "@formily/react";
|
|
9
|
+
import { createForm, onFormValuesChange, onFieldValueChange } from "@formily/core";
|
|
10
|
+
|
|
8
11
|
import EnumRender from "@hzab/formily-result-utils/src/components/EnumRender";
|
|
9
12
|
import { SHOW_MODE_TYPES } from "@hzab/formily-result-utils/src/common/constant";
|
|
10
13
|
import { FormilyField } from "../components/Formily/FormilyField";
|
|
@@ -13,64 +16,42 @@ import { getColRender } from "../common/formily-utils";
|
|
|
13
16
|
import { getVal, getFieldList } from "../common/utils";
|
|
14
17
|
import { handleReactions } from "../common/handleReactions";
|
|
15
18
|
|
|
16
|
-
import { useEditTable } from "../components/Formily/FormilyEditTable";
|
|
17
|
-
import { EditTableRow } from "../components/Formily/FormilyEditTable/EditTableRow";
|
|
18
|
-
import { EditableCell } from "../components/Formily/FormilyEditTable/EditTableCell";
|
|
19
|
-
import { TableFormilyContext } from "../components/Formily/FormilyEditTable/useTableFormilyContext";
|
|
19
|
+
import { useEditTable, EditableCell } from "../components/Formily/FormilyEditTable";
|
|
20
20
|
|
|
21
21
|
import "./index.less";
|
|
22
22
|
|
|
23
23
|
const scenario = "table-render";
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
* 编辑按钮隐藏
|
|
27
|
-
*/
|
|
28
|
-
const editModeHideList = ["cell", "line-cell", "table-line-show"];
|
|
29
|
-
|
|
30
25
|
const TableRender = forwardRef(function (props, tableRef) {
|
|
31
|
-
const { topProps, config = {}, query = {}, i18n, setList
|
|
32
|
-
const propsSchema = schema?.schema;
|
|
26
|
+
const { topProps, config = {}, query = {}, i18n, setList } = props;
|
|
33
27
|
const { tableDel = "删除", tableEdit = "编辑", tableDelTip = "确认删除该项?", tableDetail = "详情" } = i18n || {};
|
|
34
28
|
const {
|
|
35
29
|
dragColConf = {},
|
|
36
30
|
isDargTable,
|
|
37
31
|
dargEndBack,
|
|
38
|
-
orderColType
|
|
32
|
+
orderColType,
|
|
39
33
|
orderColWidth,
|
|
40
34
|
tableEmptyValue,
|
|
41
35
|
isShowTableFilter = false,
|
|
42
36
|
isTableSortXIdex = false,
|
|
43
37
|
} = config || {};
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const rowFormMapRef = useRef(new Map());
|
|
47
|
-
const editingInofRef = useRef({
|
|
48
|
-
editingRowId: "",
|
|
49
|
-
editingKey: "",
|
|
50
|
-
});
|
|
51
|
-
|
|
38
|
+
const { editMode = "modal" } = topProps || {};
|
|
39
|
+
const isEditTable = editMode !== "modal";
|
|
52
40
|
useImperativeHandle(tableRef, () => ({
|
|
53
41
|
onEditByTable,
|
|
54
42
|
}));
|
|
55
43
|
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
_setList(props.list);
|
|
58
|
-
// 数据清除问题,避免分页数据量持续累计过于庞大
|
|
59
|
-
rowFormMapRef.current.clear();
|
|
60
|
-
}, [props.list]);
|
|
61
|
-
|
|
62
44
|
const [columns, setColumns] = useState([]);
|
|
63
45
|
const [columnList, setColumnList] = useState([]);
|
|
64
46
|
const DragHandle = SortableHandle(() => <MenuOutlined style={{ cursor: "grab", color: "#999" }} />);
|
|
65
47
|
|
|
66
|
-
const SortableItem = SortableElement((props) => <
|
|
48
|
+
const SortableItem = SortableElement((props) => <tr {...props} />);
|
|
67
49
|
const SortableBody = SortableContainer((props) => <tbody {...props} />);
|
|
68
50
|
|
|
69
51
|
const onSortEnd = ({ oldIndex, newIndex }) => {
|
|
70
52
|
if (oldIndex !== newIndex) {
|
|
71
53
|
const newData = arrayMoveImmutable(props.list.slice(), oldIndex, newIndex).filter((el) => !!el);
|
|
72
54
|
setList([...newData]);
|
|
73
|
-
_setList([...newData]);
|
|
74
55
|
dargEndBack && dargEndBack(newData, query);
|
|
75
56
|
}
|
|
76
57
|
};
|
|
@@ -90,27 +71,38 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
90
71
|
fieldSchemas: {},
|
|
91
72
|
});
|
|
92
73
|
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
74
|
+
const formRender = useMemo(
|
|
75
|
+
() =>
|
|
76
|
+
createForm({
|
|
77
|
+
initialValues: props.initialValues,
|
|
78
|
+
// 禁用状态(注意,自定义组件组件自行获取对应的状态)
|
|
79
|
+
readOnly: props.readOnly,
|
|
80
|
+
disabled: props.disabled,
|
|
81
|
+
...(props.formOptions || {}),
|
|
82
|
+
effects(...args) {
|
|
83
|
+
props.onFormValuesChange && onFormValuesChange(props.onFormValuesChange);
|
|
84
|
+
props.onFieldValueChange && onFieldValueChange("*", props.onFieldValueChange);
|
|
85
|
+
props.formOptions?.effects && props.formOptions?.effects(...args);
|
|
86
|
+
},
|
|
87
|
+
}),
|
|
88
|
+
[],
|
|
89
|
+
);
|
|
90
|
+
const { onEdit: onEditByTable, mergedColumns } = useEditTable({
|
|
98
91
|
idKey: props.idKey,
|
|
99
92
|
columns,
|
|
100
93
|
onEdit: props.onEdit,
|
|
101
94
|
onEditSubmit: props.onEditSubmit,
|
|
95
|
+
formRender,
|
|
102
96
|
components: props.components,
|
|
103
97
|
schemaScope: props.schemaScope,
|
|
104
98
|
topProps: props.topProps,
|
|
105
|
-
rowFormMapRef,
|
|
106
|
-
editingInofRef,
|
|
107
99
|
});
|
|
108
100
|
|
|
109
101
|
useEffect(() => {
|
|
110
|
-
if (!
|
|
102
|
+
if (!(props.schema && props.schema.properties)) {
|
|
111
103
|
return;
|
|
112
104
|
}
|
|
113
|
-
const fieldList = getFieldList(
|
|
105
|
+
const fieldList = getFieldList(props.schema, [], { ...props.getFieldListOpt, formilyRef }, isTableSortXIdex);
|
|
114
106
|
const columns = [];
|
|
115
107
|
|
|
116
108
|
// 序号列
|
|
@@ -139,28 +131,10 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
139
131
|
});
|
|
140
132
|
_fieldList.forEach((field, colIndex) => {
|
|
141
133
|
const fieldSchemas = formilyRef.current?.fields;
|
|
142
|
-
if (!field["x-decorator-props"]) {
|
|
143
|
-
field["x-decorator-props"] = {};
|
|
144
|
-
}
|
|
145
|
-
// 存储原始的 pattern,用于行内编辑还原数据
|
|
146
|
-
field["x-decorator-props"]._sourcePattern = field["x-pattern"];
|
|
147
134
|
if (field.inTable !== false) {
|
|
148
135
|
const { name, title } = field;
|
|
149
136
|
const comName = field["x-component"];
|
|
150
137
|
|
|
151
|
-
const decoratorProps = field["x-decorator-props"] || {};
|
|
152
|
-
let _title = title;
|
|
153
|
-
if (decoratorProps.tooltip) {
|
|
154
|
-
_title = (
|
|
155
|
-
<span className="col-title-tooltip-wrap inline-block-max-w">
|
|
156
|
-
{_title}
|
|
157
|
-
<Tooltip className="col-title-tooltip" title={decoratorProps.tooltip}>
|
|
158
|
-
<QuestionCircleOutlined className="col-title-tooltip-icon" />
|
|
159
|
-
</Tooltip>
|
|
160
|
-
</span>
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
138
|
let _colConf = {};
|
|
165
139
|
|
|
166
140
|
if (props.config?.colConf && props.config?.colConf[name]) {
|
|
@@ -230,6 +204,22 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
230
204
|
};
|
|
231
205
|
}
|
|
232
206
|
|
|
207
|
+
let _title = isFunction(title) ? title() : title;
|
|
208
|
+
if (_colConf?.title) {
|
|
209
|
+
_title = isFunction(_colConf?.title) ? _colConf?.title() : _colConf?.title;
|
|
210
|
+
}
|
|
211
|
+
const decoratorProps = field["x-decorator-props"] || {};
|
|
212
|
+
if (decoratorProps.tooltip) {
|
|
213
|
+
_title = (
|
|
214
|
+
<span className="col-title-tooltip-wrap inline-block-max-w">
|
|
215
|
+
{_title}
|
|
216
|
+
<Tooltip className="col-title-tooltip" title={decoratorProps.tooltip}>
|
|
217
|
+
<QuestionCircleOutlined className="col-title-tooltip-icon" />
|
|
218
|
+
</Tooltip>
|
|
219
|
+
</span>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
233
223
|
columns.push({
|
|
234
224
|
// field, // HACK: 直接传入 field 在 title 传入 ReactNode,内部深克隆导致页面报错白屏。使用函数获取解决
|
|
235
225
|
getField: () => field,
|
|
@@ -237,8 +227,8 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
237
227
|
..._colConf,
|
|
238
228
|
onCell: (record, rowIndex) =>
|
|
239
229
|
_colConf?.onCell?.({ ...record, _field: { ...field, ...(fieldSchemas?.[name] || {}) } }, rowIndex) || {},
|
|
240
|
-
// 函数式传入,解决 title ReactNode
|
|
241
|
-
title: () =>
|
|
230
|
+
// 函数式传入,解决 title ReactNode 传入报错问题(table 组件内部对 columns 进行 lodash.deepClone 导致 ReactNode 变成对象无法正常渲染) Uncaught TypeError: this.queryFeedbacks is not a function
|
|
231
|
+
title: () => _title,
|
|
242
232
|
key: name,
|
|
243
233
|
dataIndex: name,
|
|
244
234
|
render: getColRender(colRender),
|
|
@@ -266,7 +256,8 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
266
256
|
const { editMode = "modal" } = props.topProps || {};
|
|
267
257
|
// 编辑按钮权限
|
|
268
258
|
const _hasEdit =
|
|
269
|
-
|
|
259
|
+
editMode !== "cell" &&
|
|
260
|
+
editMode !== "line-cell" &&
|
|
270
261
|
(hasEdit && typeof hasEdit === "function" ? hasEdit(record, index) : hasEdit !== false);
|
|
271
262
|
|
|
272
263
|
//详情按钮权限
|
|
@@ -298,10 +289,6 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
298
289
|
type="link"
|
|
299
290
|
onClick={() => {
|
|
300
291
|
props.onEdit && props.onEdit(record, index);
|
|
301
|
-
if (editMode == "line") {
|
|
302
|
-
// 整行编辑,编辑按钮在操作列的模式下表单数据回填
|
|
303
|
-
return onEditByTable(record, record[props.idKey]);
|
|
304
|
-
}
|
|
305
292
|
}}
|
|
306
293
|
>
|
|
307
294
|
{tableEdit}
|
|
@@ -340,7 +327,12 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
340
327
|
}
|
|
341
328
|
setColumns(columns);
|
|
342
329
|
setColumnList(columns);
|
|
343
|
-
}, [
|
|
330
|
+
}, [props.schema, props.config]);
|
|
331
|
+
|
|
332
|
+
// 解决 FormilyField 中无相关参数报错的问题。自定义参数都从这里传入
|
|
333
|
+
const reactionOpts = {
|
|
334
|
+
scenario: scenario,
|
|
335
|
+
};
|
|
344
336
|
|
|
345
337
|
const onChange = (e, col) => {
|
|
346
338
|
if (e.target.checked) {
|
|
@@ -354,66 +346,38 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
354
346
|
};
|
|
355
347
|
|
|
356
348
|
const tableProps = {
|
|
357
|
-
ref: antdTableRef,
|
|
358
349
|
className: "table-render",
|
|
359
350
|
rowKey: props.idKey || "id",
|
|
360
351
|
rowSelection: config?.rowSelection,
|
|
361
352
|
columns: columns,
|
|
362
|
-
dataSource:
|
|
353
|
+
dataSource: props.list,
|
|
363
354
|
pagination: false,
|
|
364
355
|
scroll: config.scroll,
|
|
365
356
|
expandable: config.expandable,
|
|
366
357
|
loading: props.loading,
|
|
367
|
-
onRow:
|
|
368
|
-
const _onRowRes = config?.onRow && config?.onRow(record, index);
|
|
369
|
-
return {
|
|
370
|
-
..._onRowRes,
|
|
371
|
-
record,
|
|
372
|
-
id: record[props.idKey || "id"],
|
|
373
|
-
rowFormMapRef,
|
|
374
|
-
editingInofRef,
|
|
375
|
-
components: props.components,
|
|
376
|
-
topProps,
|
|
377
|
-
onEditSave,
|
|
378
|
-
};
|
|
379
|
-
},
|
|
358
|
+
onRow: config?.onRow,
|
|
380
359
|
topProps: props.topProps,
|
|
381
360
|
...props.tableProps,
|
|
382
361
|
};
|
|
383
362
|
|
|
384
|
-
|
|
363
|
+
if (isDargTable) {
|
|
364
|
+
tableProps.components = {
|
|
365
|
+
body: {
|
|
366
|
+
wrapper: DraggableContainer,
|
|
367
|
+
row: DraggableBodyRow,
|
|
368
|
+
},
|
|
369
|
+
};
|
|
370
|
+
}
|
|
385
371
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
372
|
+
if (isEditTable) {
|
|
373
|
+
tableProps.columns = mergedColumns;
|
|
374
|
+
tableProps.components = {
|
|
389
375
|
body: {
|
|
390
376
|
...tableProps?.components?.body,
|
|
391
377
|
cell: EditableCell,
|
|
392
|
-
row: isDargTable
|
|
393
|
-
? ({ rowFormMapRef, components, topProps, ...props }) => {
|
|
394
|
-
// 拖拽
|
|
395
|
-
return (
|
|
396
|
-
<DraggableBodyRow {...props}>
|
|
397
|
-
<EditTableRow rowFormMapRef={rowFormMapRef} components={components} topProps={topProps} {...props} />
|
|
398
|
-
</DraggableBodyRow>
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
: EditTableRow,
|
|
402
|
-
...(isDargTable
|
|
403
|
-
? {
|
|
404
|
-
wrapper: DraggableContainer,
|
|
405
|
-
}
|
|
406
|
-
: {}),
|
|
407
378
|
},
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
);
|
|
411
|
-
tableProps.components = tableComponents;
|
|
412
|
-
|
|
413
|
-
// 解决 FormilyField 中无相关参数报错的问题。自定义参数都从这里传入
|
|
414
|
-
const reactionOpts = {
|
|
415
|
-
scenario: scenario,
|
|
416
|
-
};
|
|
379
|
+
};
|
|
380
|
+
}
|
|
417
381
|
|
|
418
382
|
return (
|
|
419
383
|
<div className="table-render-wrap">
|
|
@@ -457,24 +421,26 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
457
421
|
</Popover>
|
|
458
422
|
</div>
|
|
459
423
|
) : null}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
424
|
+
{isEditTable ? (
|
|
425
|
+
<FormProvider form={formRender}>
|
|
426
|
+
<Form layout="vertical">
|
|
427
|
+
<FormConsumer>{() => <Table {...tableProps} />}</FormConsumer>
|
|
428
|
+
</Form>
|
|
429
|
+
</FormProvider>
|
|
430
|
+
) : (
|
|
466
431
|
<Table {...tableProps} />
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
schema={
|
|
432
|
+
)}
|
|
433
|
+
<FormilyField
|
|
434
|
+
schema={props.schema}
|
|
470
435
|
formilyRef={formilyRef}
|
|
471
436
|
components={props.components}
|
|
437
|
+
topProps={topProps}
|
|
472
438
|
schemaScope={{
|
|
473
439
|
...reactionOpts,
|
|
474
440
|
...props.schemaScope,
|
|
475
441
|
}}
|
|
476
442
|
reactionOpts={reactionOpts}
|
|
477
|
-
/>
|
|
443
|
+
/>
|
|
478
444
|
</div>
|
|
479
445
|
);
|
|
480
446
|
});
|