@hzab/list-render 1.10.21-alpha.2 → 1.10.21-alpha.3
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
CHANGED
package/package.json
CHANGED
|
@@ -30,8 +30,9 @@ export interface EditableCellProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
30
30
|
onSave: (field: { type: string; name: string }) => void;
|
|
31
31
|
onCancel: () => void;
|
|
32
32
|
topProps: {
|
|
33
|
-
|
|
33
|
+
tableConf: { hasEdit: boolean | Function };
|
|
34
34
|
editMode: "modal" | "line" | "line-cell" | "cell";
|
|
35
|
+
canEditCallback: (record: Partial<Item> & { key: React.Key }, field: { type: string; name: string }, dataIndex: string) => void;
|
|
35
36
|
};
|
|
36
37
|
children: React.ReactNode;
|
|
37
38
|
}
|
|
@@ -56,8 +57,8 @@ export const EditableCell: React.FC<EditableCellProps> = ({
|
|
|
56
57
|
const field = getField && getField();
|
|
57
58
|
const fPattern = field?.["x-pattern"];
|
|
58
59
|
const fDisplay = field?.["x-display"];
|
|
59
|
-
const { editMode = "modal" } = topProps || {};
|
|
60
|
-
const { hasEdit } = topProps?.
|
|
60
|
+
const { editMode = "modal", canEditCallback } = topProps || {};
|
|
61
|
+
const { hasEdit } = topProps?.tableConf || {};
|
|
61
62
|
const fieldRef = useRef();
|
|
62
63
|
|
|
63
64
|
// 弹窗编辑模式
|
|
@@ -66,7 +67,11 @@ export const EditableCell: React.FC<EditableCellProps> = ({
|
|
|
66
67
|
}
|
|
67
68
|
// 无编辑权限或禁止编辑
|
|
68
69
|
const _hasEdit = hasEdit && typeof hasEdit === "function" ? hasEdit(record, index) : hasEdit !== false;
|
|
69
|
-
let _editable =
|
|
70
|
+
let _editable =
|
|
71
|
+
_hasEdit &&
|
|
72
|
+
editable &&
|
|
73
|
+
!(fPattern === "disabled" || fPattern === "readOnly" || fDisplay === "none") &&
|
|
74
|
+
(canEditCallback ? canEditCallback(record, field, dataIndex) : true);
|
|
70
75
|
if (!_editable) {
|
|
71
76
|
return <td {...restProps}>{children}</td>;
|
|
72
77
|
}
|