@hzab/list-render 1.10.20-alpha.6 → 1.10.21-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 +4 -0
- package/README.md +0 -7
- package/package.json +5 -5
- package/src/components/Formily/{--FormilyEditTable.tsx → FormilyEditTable.tsx} +11 -77
- package/src/list-render.jsx +2 -8
- package/src/table-render/index.jsx +148 -129
- package/src/EditArrayTable/index.less +0 -11
- package/src/EditArrayTable/index.tsx +0 -272
- package/src/components/Formily/FormilyEditTable/EditTableCell.tsx +0 -158
- package/src/components/Formily/FormilyEditTable/EditTableRow.tsx +0 -75
- package/src/components/Formily/FormilyEditTable/index.tsx +0 -217
- 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 -270
- package/src/components/Formily/useComponents.tsx +0 -82
- package/src/table-render/TableActions.tsx +0 -95
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -107,13 +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-cell 编辑整行,操作按钮在单元格;
|
|
116
|
-
- cell 编辑指定单元格
|
|
117
110
|
|
|
118
111
|
#### tableConf
|
|
119
112
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hzab/list-render",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.21-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src",
|
|
6
6
|
"scripts": {
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"license": "ISC",
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@ant-design/icons": "^4.8.1",
|
|
28
|
-
"@hzab/data-model": "^
|
|
29
|
-
"@hzab/form-render": "^1.
|
|
28
|
+
"@hzab/data-model": "^1.7.4",
|
|
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",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@formily/react": "2.3.1",
|
|
52
52
|
"@formily/reactive-react": "2.3.1",
|
|
53
53
|
"@hzab/data-model": ">=1.7.4",
|
|
54
|
-
"@hzab/form-render": ">=1.
|
|
54
|
+
"@hzab/form-render": ">=1.0.0",
|
|
55
55
|
"@hzab/formily-result-utils": ">=1.2.0",
|
|
56
56
|
"@hzab/schema-descriptions": ">=1.0.0",
|
|
57
57
|
"@hzab/utils": ">=1.0.7",
|
|
@@ -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: () => {
|
|
@@ -100,9 +30,9 @@ export interface EditableCellProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
100
30
|
onSave: (field: { type: string; name: string }) => void;
|
|
101
31
|
onCancel: () => void;
|
|
102
32
|
topProps: {
|
|
103
|
-
|
|
33
|
+
tableConf: { hasEdit: boolean | Function };
|
|
104
34
|
editMode: "modal" | "line" | "line-cell" | "cell";
|
|
105
|
-
|
|
35
|
+
canEditCallback: (record: Partial<Item> & { key: React.Key }, field: { type: string; name: string }, dataIndex: string) => void;
|
|
106
36
|
};
|
|
107
37
|
children: React.ReactNode;
|
|
108
38
|
}
|
|
@@ -127,17 +57,21 @@ export const EditableCell: React.FC<EditableCellProps> = ({
|
|
|
127
57
|
const field = getField && getField();
|
|
128
58
|
const fPattern = field?.["x-pattern"];
|
|
129
59
|
const fDisplay = field?.["x-display"];
|
|
130
|
-
const { editMode = "modal",
|
|
131
|
-
const { hasEdit } = topProps?.
|
|
60
|
+
const { editMode = "modal", canEditCallback } = topProps || {};
|
|
61
|
+
const { hasEdit } = topProps?.tableConf || {};
|
|
132
62
|
const fieldRef = useRef();
|
|
133
63
|
|
|
134
64
|
// 弹窗编辑模式
|
|
135
|
-
if (editMode === "modal"
|
|
65
|
+
if (editMode === "modal") {
|
|
136
66
|
return <td {...restProps}>{children}</td>;
|
|
137
67
|
}
|
|
138
68
|
// 无编辑权限或禁止编辑
|
|
139
69
|
const _hasEdit = hasEdit && typeof hasEdit === "function" ? hasEdit(record, index) : hasEdit !== false;
|
|
140
|
-
let _editable =
|
|
70
|
+
let _editable =
|
|
71
|
+
_hasEdit &&
|
|
72
|
+
editable &&
|
|
73
|
+
!(fPattern === "disabled" || fPattern === "readOnly" || fDisplay === "none") &&
|
|
74
|
+
(canEditCallback ? canEditCallback(record, field, dataIndex) : true);
|
|
141
75
|
if (!_editable) {
|
|
142
76
|
return <td {...restProps}>{children}</td>;
|
|
143
77
|
}
|
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,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,19 +16,14 @@ 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";
|
|
20
|
-
import TableActions from "./TableActions";
|
|
19
|
+
import { useEditTable, EditableCell } from "../components/Formily/FormilyEditTable";
|
|
21
20
|
|
|
22
21
|
import "./index.less";
|
|
23
22
|
|
|
24
23
|
const scenario = "table-render";
|
|
25
24
|
|
|
26
25
|
const TableRender = forwardRef(function (props, tableRef) {
|
|
27
|
-
const { topProps, config = {}, query = {}, i18n, setList
|
|
28
|
-
const propsSchema = schema?.schema;
|
|
26
|
+
const { topProps, config = {}, query = {}, i18n, setList } = props;
|
|
29
27
|
const { tableDel = "删除", tableEdit = "编辑", tableDelTip = "确认删除该项?", tableDetail = "详情" } = i18n || {};
|
|
30
28
|
const {
|
|
31
29
|
dragColConf = {},
|
|
@@ -37,36 +35,23 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
37
35
|
isShowTableFilter = false,
|
|
38
36
|
isTableSortXIdex = false,
|
|
39
37
|
} = config || {};
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const rowFormMapRef = useRef(new Map());
|
|
43
|
-
const editingInofRef = useRef({
|
|
44
|
-
editingRowId: "",
|
|
45
|
-
editingKey: "",
|
|
46
|
-
});
|
|
47
|
-
|
|
38
|
+
const { editMode = "modal" } = topProps || {};
|
|
39
|
+
const isEditTable = editMode !== "modal";
|
|
48
40
|
useImperativeHandle(tableRef, () => ({
|
|
49
41
|
onEditByTable,
|
|
50
42
|
}));
|
|
51
43
|
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
_setList(props.list);
|
|
54
|
-
// 数据清除问题,避免分页数据量持续累计过于庞大
|
|
55
|
-
rowFormMapRef.current.clear();
|
|
56
|
-
}, [props.list]);
|
|
57
|
-
|
|
58
44
|
const [columns, setColumns] = useState([]);
|
|
59
45
|
const [columnList, setColumnList] = useState([]);
|
|
60
46
|
const DragHandle = SortableHandle(() => <MenuOutlined style={{ cursor: "grab", color: "#999" }} />);
|
|
61
47
|
|
|
62
|
-
const SortableItem = SortableElement((props) => <
|
|
48
|
+
const SortableItem = SortableElement((props) => <tr {...props} />);
|
|
63
49
|
const SortableBody = SortableContainer((props) => <tbody {...props} />);
|
|
64
50
|
|
|
65
51
|
const onSortEnd = ({ oldIndex, newIndex }) => {
|
|
66
52
|
if (oldIndex !== newIndex) {
|
|
67
53
|
const newData = arrayMoveImmutable(props.list.slice(), oldIndex, newIndex).filter((el) => !!el);
|
|
68
54
|
setList([...newData]);
|
|
69
|
-
_setList([...newData]);
|
|
70
55
|
dargEndBack && dargEndBack(newData, query);
|
|
71
56
|
}
|
|
72
57
|
};
|
|
@@ -86,27 +71,38 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
86
71
|
fieldSchemas: {},
|
|
87
72
|
});
|
|
88
73
|
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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({
|
|
94
91
|
idKey: props.idKey,
|
|
95
92
|
columns,
|
|
96
93
|
onEdit: props.onEdit,
|
|
97
94
|
onEditSubmit: props.onEditSubmit,
|
|
95
|
+
formRender,
|
|
98
96
|
components: props.components,
|
|
99
97
|
schemaScope: props.schemaScope,
|
|
100
98
|
topProps: props.topProps,
|
|
101
|
-
rowFormMapRef,
|
|
102
|
-
editingInofRef,
|
|
103
99
|
});
|
|
104
100
|
|
|
105
101
|
useEffect(() => {
|
|
106
|
-
if (!
|
|
102
|
+
if (!(props.schema && props.schema.properties)) {
|
|
107
103
|
return;
|
|
108
104
|
}
|
|
109
|
-
const fieldList = getFieldList(
|
|
105
|
+
const fieldList = getFieldList(props.schema, [], { ...props.getFieldListOpt, formilyRef }, isTableSortXIdex);
|
|
110
106
|
const columns = [];
|
|
111
107
|
|
|
112
108
|
// 序号列
|
|
@@ -129,34 +125,16 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
129
125
|
}
|
|
130
126
|
|
|
131
127
|
const { Slots = {} } = props;
|
|
132
|
-
const _fieldList = fieldList
|
|
128
|
+
const _fieldList = handleReactions(fieldList, {
|
|
129
|
+
scope: props.schemaScope,
|
|
130
|
+
formilyRef,
|
|
131
|
+
});
|
|
133
132
|
_fieldList.forEach((field, colIndex) => {
|
|
134
133
|
const fieldSchemas = formilyRef.current?.fields;
|
|
135
|
-
if (!field["x-decorator-props"]) {
|
|
136
|
-
field["x-decorator-props"] = {};
|
|
137
|
-
}
|
|
138
|
-
// 存储原始的 pattern,用于行内编辑还原数据
|
|
139
|
-
field["x-decorator-props"]._sourcePattern = field["x-pattern"];
|
|
140
134
|
if (field.inTable !== false) {
|
|
141
135
|
const { name, title } = field;
|
|
142
136
|
const comName = field["x-component"];
|
|
143
137
|
|
|
144
|
-
const decoratorProps = field["x-decorator-props"] || {};
|
|
145
|
-
let _title = isFunction(title) ? title() : title;
|
|
146
|
-
if (_colConf?.title) {
|
|
147
|
-
_title = isFunction(_colConf?.title) ? _colConf?.title() : _colConf?.title;
|
|
148
|
-
}
|
|
149
|
-
if (decoratorProps.tooltip) {
|
|
150
|
-
_title = (
|
|
151
|
-
<span className="col-title-tooltip-wrap inline-block-max-w">
|
|
152
|
-
{_title}
|
|
153
|
-
<Tooltip className="col-title-tooltip" title={decoratorProps.tooltip}>
|
|
154
|
-
<QuestionCircleOutlined className="col-title-tooltip-icon" />
|
|
155
|
-
</Tooltip>
|
|
156
|
-
</span>
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
138
|
let _colConf = {};
|
|
161
139
|
|
|
162
140
|
if (props.config?.colConf && props.config?.colConf[name]) {
|
|
@@ -226,6 +204,22 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
226
204
|
};
|
|
227
205
|
}
|
|
228
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
|
+
|
|
229
223
|
columns.push({
|
|
230
224
|
// field, // HACK: 直接传入 field 在 title 传入 ReactNode,内部深克隆导致页面报错白屏。使用函数获取解决
|
|
231
225
|
getField: () => field,
|
|
@@ -252,23 +246,71 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
252
246
|
title: "操作",
|
|
253
247
|
key: "_$actions",
|
|
254
248
|
render: getColRender(function (text, record, index) {
|
|
255
|
-
const {
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
249
|
+
const { onEdit, onDel, onSearch, getList } = props;
|
|
250
|
+
const slotProps = { text, record, index, onEdit: onEdit, onDel: onDel, onSearch, getList };
|
|
251
|
+
|
|
252
|
+
if (Slots?.tableActionsSlot) {
|
|
253
|
+
return <Slots.tableActionsSlot {...slotProps} />;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const { editMode = "modal" } = props.topProps || {};
|
|
257
|
+
// 编辑按钮权限
|
|
258
|
+
const _hasEdit =
|
|
259
|
+
editMode !== "cell" &&
|
|
260
|
+
editMode !== "line-cell" &&
|
|
261
|
+
(hasEdit && typeof hasEdit === "function" ? hasEdit(record, index) : hasEdit !== false);
|
|
262
|
+
|
|
263
|
+
//详情按钮权限
|
|
264
|
+
const _hasDetail =
|
|
265
|
+
hasDetail && typeof hasDetail === "function" ? hasDetail(record, index) : hasDetail !== false;
|
|
266
|
+
|
|
267
|
+
//删除按钮权限
|
|
268
|
+
const _hasDel = hasDel && typeof hasDel === "function" ? hasDel(record, index) : hasDel !== false;
|
|
269
|
+
|
|
270
|
+
//删除按钮提示
|
|
271
|
+
const delTips =
|
|
272
|
+
hasDelTips && typeof hasDelTips === "function" ? hasDelTips(record, index) : hasDelTips || tableDelTip;
|
|
273
|
+
|
|
274
|
+
return (
|
|
275
|
+
<div style={{ width: _colConf?.width, maxWidth: "100%" }}>
|
|
276
|
+
{Slots?.actionPrefixSlot && <Slots.actionPrefixSlot {...slotProps} />}
|
|
277
|
+
{_hasDetail ? (
|
|
278
|
+
<Button
|
|
279
|
+
type="link"
|
|
280
|
+
onClick={() => {
|
|
281
|
+
props.onDetail && props.onDetail(record, index);
|
|
282
|
+
}}
|
|
283
|
+
>
|
|
284
|
+
{tableDetail}
|
|
285
|
+
</Button>
|
|
286
|
+
) : null}
|
|
287
|
+
{_hasEdit ? (
|
|
288
|
+
<Button
|
|
289
|
+
type="link"
|
|
290
|
+
onClick={() => {
|
|
291
|
+
props.onEdit && props.onEdit(record, index);
|
|
292
|
+
}}
|
|
293
|
+
>
|
|
294
|
+
{tableEdit}
|
|
295
|
+
</Button>
|
|
296
|
+
) : null}
|
|
297
|
+
{Slots?.actionCenterSlot && <Slots.actionCenterSlot {...slotProps} />}
|
|
298
|
+
{_hasDel ? (
|
|
299
|
+
<Popconfirm
|
|
300
|
+
placement="topRight"
|
|
301
|
+
title={delTips}
|
|
302
|
+
onConfirm={() => {
|
|
303
|
+
props.onDel && props.onDel(record, index);
|
|
304
|
+
}}
|
|
305
|
+
>
|
|
306
|
+
<Button type="link" danger>
|
|
307
|
+
{tableDel}
|
|
308
|
+
</Button>
|
|
309
|
+
</Popconfirm>
|
|
310
|
+
) : null}
|
|
311
|
+
{Slots?.actionSuffixSlot && <Slots.actionSuffixSlot {...slotProps} />}
|
|
312
|
+
</div>
|
|
313
|
+
);
|
|
272
314
|
}),
|
|
273
315
|
});
|
|
274
316
|
}
|
|
@@ -285,7 +327,12 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
285
327
|
}
|
|
286
328
|
setColumns(columns);
|
|
287
329
|
setColumnList(columns);
|
|
288
|
-
}, [
|
|
330
|
+
}, [props.schema, props.config]);
|
|
331
|
+
|
|
332
|
+
// 解决 FormilyField 中无相关参数报错的问题。自定义参数都从这里传入
|
|
333
|
+
const reactionOpts = {
|
|
334
|
+
scenario: scenario,
|
|
335
|
+
};
|
|
289
336
|
|
|
290
337
|
const onChange = (e, col) => {
|
|
291
338
|
if (e.target.checked) {
|
|
@@ -299,68 +346,38 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
299
346
|
};
|
|
300
347
|
|
|
301
348
|
const tableProps = {
|
|
302
|
-
ref: antdTableRef,
|
|
303
349
|
className: "table-render",
|
|
304
350
|
rowKey: props.idKey || "id",
|
|
305
351
|
rowSelection: config?.rowSelection,
|
|
306
352
|
columns: columns,
|
|
307
|
-
dataSource:
|
|
353
|
+
dataSource: props.list,
|
|
308
354
|
pagination: false,
|
|
309
355
|
scroll: config.scroll,
|
|
310
356
|
expandable: config.expandable,
|
|
311
357
|
loading: props.loading,
|
|
312
|
-
|
|
313
|
-
onRow: (record, index) => {
|
|
314
|
-
const _onRow = config?.onRow ?? props.tableProps?.onRow;
|
|
315
|
-
const _onRowRes = _onRow && _onRow(record, index);
|
|
316
|
-
return {
|
|
317
|
-
..._onRowRes,
|
|
318
|
-
record,
|
|
319
|
-
index,
|
|
320
|
-
id: record[props.idKey || "id"],
|
|
321
|
-
rowFormMapRef,
|
|
322
|
-
editingInofRef,
|
|
323
|
-
components: props.components,
|
|
324
|
-
topProps,
|
|
325
|
-
onEditSave,
|
|
326
|
-
};
|
|
327
|
-
},
|
|
358
|
+
onRow: config?.onRow,
|
|
328
359
|
topProps: props.topProps,
|
|
360
|
+
...props.tableProps,
|
|
329
361
|
};
|
|
330
362
|
|
|
331
|
-
|
|
363
|
+
if (isDargTable) {
|
|
364
|
+
tableProps.components = {
|
|
365
|
+
body: {
|
|
366
|
+
wrapper: DraggableContainer,
|
|
367
|
+
row: DraggableBodyRow,
|
|
368
|
+
},
|
|
369
|
+
};
|
|
370
|
+
}
|
|
332
371
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
372
|
+
if (isEditTable) {
|
|
373
|
+
tableProps.columns = mergedColumns;
|
|
374
|
+
tableProps.components = {
|
|
336
375
|
body: {
|
|
337
376
|
...tableProps?.components?.body,
|
|
338
377
|
cell: EditableCell,
|
|
339
|
-
row: isDargTable
|
|
340
|
-
? ({ rowFormMapRef, components, topProps, ...props }) => {
|
|
341
|
-
// 拖拽
|
|
342
|
-
return (
|
|
343
|
-
<DraggableBodyRow {...props}>
|
|
344
|
-
<EditTableRow rowFormMapRef={rowFormMapRef} components={components} topProps={topProps} {...props} />
|
|
345
|
-
</DraggableBodyRow>
|
|
346
|
-
);
|
|
347
|
-
}
|
|
348
|
-
: EditTableRow,
|
|
349
|
-
...(isDargTable
|
|
350
|
-
? {
|
|
351
|
-
wrapper: DraggableContainer,
|
|
352
|
-
}
|
|
353
|
-
: {}),
|
|
354
378
|
},
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
);
|
|
358
|
-
tableProps.components = tableComponents;
|
|
359
|
-
|
|
360
|
-
// 解决 FormilyField 中无相关参数报错的问题。自定义参数都从这里传入
|
|
361
|
-
const reactionOpts = {
|
|
362
|
-
scenario: scenario,
|
|
363
|
-
};
|
|
379
|
+
};
|
|
380
|
+
}
|
|
364
381
|
|
|
365
382
|
return (
|
|
366
383
|
<div className="table-render-wrap">
|
|
@@ -404,24 +421,26 @@ const TableRender = forwardRef(function (props, tableRef) {
|
|
|
404
421
|
</Popover>
|
|
405
422
|
</div>
|
|
406
423
|
) : null}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
424
|
+
{isEditTable ? (
|
|
425
|
+
<FormProvider form={formRender}>
|
|
426
|
+
<Form layout="vertical">
|
|
427
|
+
<FormConsumer>{() => <Table {...tableProps} />}</FormConsumer>
|
|
428
|
+
</Form>
|
|
429
|
+
</FormProvider>
|
|
430
|
+
) : (
|
|
413
431
|
<Table {...tableProps} />
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
schema={
|
|
432
|
+
)}
|
|
433
|
+
<FormilyField
|
|
434
|
+
schema={props.schema}
|
|
417
435
|
formilyRef={formilyRef}
|
|
418
436
|
components={props.components}
|
|
437
|
+
topProps={topProps}
|
|
419
438
|
schemaScope={{
|
|
420
439
|
...reactionOpts,
|
|
421
440
|
...props.schemaScope,
|
|
422
441
|
}}
|
|
423
442
|
reactionOpts={reactionOpts}
|
|
424
|
-
/>
|
|
443
|
+
/>
|
|
425
444
|
</div>
|
|
426
445
|
);
|
|
427
446
|
});
|