@nocobase/client-v2 2.2.0-alpha.1 → 2.2.0-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/es/PluginSettingsManager.d.ts +33 -0
- package/es/RouteRepository.d.ts +21 -6
- package/es/components/category-tabs/SortableCategoryTabs.d.ts +55 -0
- package/es/components/category-tabs/index.d.ts +9 -0
- package/es/components/form/JsonTextArea.d.ts +2 -1
- package/es/components/form/TypedVariableInput.d.ts +22 -4
- package/es/components/form/VariableJsonTextArea.d.ts +19 -0
- package/es/components/form/filter/CollectionFilterItem.d.ts +11 -1
- package/es/components/form/filter/index.d.ts +2 -0
- package/es/components/form/index.d.ts +1 -0
- package/es/components/index.d.ts +2 -0
- package/es/flow/actions/afterSuccess.d.ts +8 -1
- package/es/flow/actions/index.d.ts +1 -1
- package/es/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.d.ts +2 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutMenuFlowUtils.d.ts +2 -1
- package/es/flow/admin-shell/admin-layout/AdminLayoutMenuModels.d.ts +2 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutMenuUtils.d.ts +3 -2
- package/es/flow/admin-shell/admin-layout/AdminLayoutSlotModels.d.ts +5 -0
- package/es/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.d.ts +6 -0
- package/es/flow/components/FieldAssignRulesEditor.d.ts +3 -1
- package/es/flow/components/FieldAssignValueInput.d.ts +2 -0
- package/es/flow/index.d.ts +1 -0
- package/es/flow/models/base/GridModel.d.ts +1 -1
- package/es/flow/models/blocks/filter-form/FilterFormBlockModel.d.ts +5 -0
- package/es/flow/models/blocks/form/FormBlockModel.d.ts +4 -0
- package/es/flow/models/blocks/form/submitHandler.d.ts +1 -1
- package/es/flow/models/blocks/form/value-runtime/rules.d.ts +21 -0
- package/es/flow/models/blocks/form/value-runtime/runtime.d.ts +30 -0
- package/es/flow/models/blocks/form/value-runtime/types.d.ts +2 -2
- package/es/flow/models/blocks/js-block/JSBlock.d.ts +1 -0
- package/es/flow/models/blocks/table/TableActionsColumnModel.d.ts +1 -0
- package/es/flow/models/blocks/table/TableBlockModel.d.ts +1 -0
- package/es/flow/models/blocks/table/dragSort/dragSortHooks.d.ts +1 -1
- package/es/flow/models/blocks/table/dragSort/dragSortSettings.d.ts +2 -1
- package/es/flow/models/blocks/table/dragSort/dragSortUtils.d.ts +6 -4
- package/es/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.d.ts +2 -0
- package/es/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.d.ts +6 -0
- package/es/flow/resolveViewParamsToViewList.d.ts +1 -1
- package/es/flow/utils/dataScopeRowSnapshot.d.ts +59 -0
- package/es/flow/utils/dateTimeDisplayProps.d.ts +49 -0
- package/es/flow/utils/formValueDeps.d.ts +32 -0
- package/es/flow-compat/FieldValidation.d.ts +2 -1
- package/es/index.d.ts +2 -1
- package/es/index.mjs +233 -137
- package/lib/index.js +234 -138
- package/package.json +7 -7
- package/src/PluginSettingsManager.ts +53 -0
- package/src/RouteRepository.ts +126 -24
- package/src/__tests__/PluginSettingsManager.test.ts +13 -0
- package/src/__tests__/RouteRepository.test.ts +216 -0
- package/src/__tests__/browserChecker.test.ts +61 -0
- package/src/__tests__/exports.test.ts +16 -0
- package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +199 -0
- package/src/__tests__/plugin-manager.test.tsx +44 -2
- package/src/__tests__/settings-center.test.tsx +40 -1
- package/src/collection-manager/field-configure.ts +1 -1
- package/src/collection-manager/interfaces/id.ts +1 -1
- package/src/collection-manager/interfaces/m2m.tsx +2 -2
- package/src/collection-manager/interfaces/m2o.tsx +2 -2
- package/src/collection-manager/interfaces/nanoid.ts +1 -1
- package/src/collection-manager/interfaces/o2m.tsx +2 -2
- package/src/collection-manager/interfaces/obo.tsx +2 -2
- package/src/collection-manager/interfaces/oho.tsx +2 -2
- package/src/collection-manager/interfaces/properties/index.ts +2 -2
- package/src/collection-manager/interfaces/uuid.ts +1 -1
- package/src/components/AppComponents.tsx +19 -3
- package/src/components/README.md +7 -1
- package/src/components/README.zh-CN.md +6 -1
- package/src/components/category-tabs/SortableCategoryTabs.tsx +210 -0
- package/src/components/category-tabs/index.ts +10 -0
- package/src/components/form/JsonTextArea.tsx +21 -11
- package/src/components/form/TypedVariableInput.tsx +416 -93
- package/src/components/form/VariableJsonTextArea.tsx +175 -0
- package/src/components/form/__tests__/JsonTextArea.test.tsx +43 -0
- package/src/components/form/__tests__/TypedVariableInput.test.tsx +268 -9
- package/src/components/form/__tests__/VariableJsonTextArea.test.tsx +86 -0
- package/src/components/form/filter/CollectionFilterItem.tsx +32 -7
- package/src/components/form/filter/__tests__/CollectionFilterItem.test.tsx +38 -0
- package/src/components/form/filter/index.ts +2 -0
- package/src/components/form/index.tsx +1 -0
- package/src/components/index.ts +2 -0
- package/src/flow/__tests__/FlowRoute.test.tsx +443 -5
- package/src/flow/__tests__/getKey.test.ts +7 -0
- package/src/flow/__tests__/resolveViewParamsToViewList.test.ts +34 -0
- package/src/flow/actions/__tests__/afterSuccess.test.ts +73 -0
- package/src/flow/actions/__tests__/dataScopeFilter.test.ts +58 -0
- package/src/flow/actions/__tests__/dataScopeFormValueClear.test.ts +1022 -0
- package/src/flow/actions/__tests__/fieldLinkageRules.scopeDepth.test.ts +150 -1
- package/src/flow/actions/__tests__/linkageAssignField.legacy.test.ts +135 -0
- package/src/flow/actions/__tests__/linkageRules.hiddenSync.restore.test.ts +19 -5
- package/src/flow/actions/__tests__/linkageRules.subFormSetFieldProps.test.ts +92 -0
- package/src/flow/actions/__tests__/openView.defineProps.route.test.tsx +104 -0
- package/src/flow/actions/__tests__/subFormFieldLinkageRules.inputArgs.test.ts +2 -2
- package/src/flow/actions/afterSuccess.tsx +142 -3
- package/src/flow/actions/customVariable.tsx +1 -2
- package/src/flow/actions/dataScopeFilter.ts +10 -0
- package/src/flow/actions/dateTimeFormat.tsx +42 -28
- package/src/flow/actions/index.ts +1 -1
- package/src/flow/actions/linkageRules.tsx +123 -35
- package/src/flow/actions/linkageRulesFormValueRefresh.ts +22 -130
- package/src/flow/actions/openView.tsx +38 -4
- package/src/flow/actions/runjs.tsx +2 -14
- package/src/flow/actions/validation.tsx +62 -30
- package/src/flow/admin-shell/BaseLayoutModel.tsx +25 -3
- package/src/flow/admin-shell/BaseLayoutRouteCoordinator.ts +5 -2
- package/src/flow/admin-shell/__tests__/AdminLayoutRouteCoordinator.test.ts +13 -0
- package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +34 -10
- package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.test.tsx +310 -0
- package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.tsx +44 -8
- package/src/flow/admin-shell/admin-layout/AdminLayoutMenuFlowUtils.ts +5 -3
- package/src/flow/admin-shell/admin-layout/AdminLayoutMenuModels.tsx +61 -9
- package/src/flow/admin-shell/admin-layout/AdminLayoutMenuUtils.tsx +71 -8
- package/src/flow/admin-shell/admin-layout/AdminLayoutModel.tsx +1 -1
- package/src/flow/admin-shell/admin-layout/AdminLayoutSlotModels.tsx +23 -9
- package/src/flow/admin-shell/admin-layout/HelpLite.tsx +1 -3
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutComponent.test.tsx +188 -0
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutMenuModels.test.ts +99 -0
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutModel.test.tsx +82 -0
- package/src/flow/admin-shell/admin-layout/__tests__/TopbarActionsBar.test.tsx +166 -2
- package/src/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.test.ts +20 -0
- package/src/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.ts +33 -5
- package/src/flow/components/DefaultValue.tsx +1 -2
- package/src/flow/components/DynamicFlowsIcon.tsx +447 -126
- package/src/flow/components/FieldAssignRulesEditor.tsx +128 -21
- package/src/flow/components/FieldAssignValueInput.tsx +10 -5
- package/src/flow/components/FlowRoute.tsx +56 -11
- package/src/flow/components/__tests__/DynamicFlowsIcon.test.tsx +148 -2
- package/src/flow/components/__tests__/FieldAssignRulesEditor.test.tsx +508 -4
- package/src/flow/components/__tests__/fieldAssignOptions.test.ts +151 -3
- package/src/flow/components/code-editor/__tests__/useCodeRunner.test.tsx +2 -17
- package/src/flow/components/code-editor/hooks/useCodeRunner.ts +2 -14
- package/src/flow/components/code-editor/runjsDiagnostics.ts +8 -45
- package/src/flow/components/fieldAssignOptions.ts +155 -27
- package/src/flow/flows/editMarkdownFlow.tsx +1 -1
- package/src/flow/getViewDiffAndUpdateHidden.tsx +1 -0
- package/src/flow/index.ts +2 -1
- package/src/flow/internal/utils/operatorSchemaHelper.ts +15 -1
- package/src/flow/models/actions/JSActionModel.tsx +2 -7
- package/src/flow/models/actions/JSCollectionActionModel.tsx +2 -7
- package/src/flow/models/actions/JSItemActionModel.tsx +2 -7
- package/src/flow/models/actions/JSRecordActionModel.tsx +2 -7
- package/src/flow/models/base/ActionModel.tsx +12 -1
- package/src/flow/models/base/ActionModelCore.tsx +6 -4
- package/src/flow/models/base/GridModel.tsx +38 -7
- package/src/flow/models/base/PageModel/PageModel.tsx +4 -1
- package/src/flow/models/base/PageModel/__tests__/PageModel.test.ts +28 -4
- package/src/flow/models/base/__tests__/ActionModel.test.ts +83 -0
- package/src/flow/models/base/__tests__/ActionModelCore.render.test.tsx +37 -0
- package/src/flow/models/base/__tests__/GridModel.dragSnapshotContainer.test.ts +239 -1
- package/src/flow/models/base/__tests__/transformRowsToSingleColumn.test.ts +48 -0
- package/src/flow/models/blocks/filter-form/FilterFormBlockModel.tsx +31 -3
- package/src/flow/models/blocks/filter-form/FilterFormJSActionModel.tsx +2 -7
- package/src/flow/models/blocks/filter-form/__tests__/defaultValues.wiring.test.ts +77 -0
- package/src/flow/models/blocks/filter-form/fields/FilterFormCustomFieldModel.tsx +1 -1
- package/src/flow/models/blocks/filter-manager/flow-actions/__tests__/customizeFilterRender.test.tsx +56 -1
- package/src/flow/models/blocks/form/EditFormModel.tsx +1 -0
- package/src/flow/models/blocks/form/FormActionModel.tsx +1 -1
- package/src/flow/models/blocks/form/FormBlockModel.tsx +7 -0
- package/src/flow/models/blocks/form/JSFormActionModel.tsx +2 -7
- package/src/flow/models/blocks/form/__tests__/FormBlockModel.test.tsx +17 -0
- package/src/flow/models/blocks/form/__tests__/submitHandler.test.ts +54 -1
- package/src/flow/models/blocks/form/submitHandler.ts +17 -3
- package/src/flow/models/blocks/form/value-runtime/__tests__/runtime.test.ts +940 -75
- package/src/flow/models/blocks/form/value-runtime/rules.ts +445 -13
- package/src/flow/models/blocks/form/value-runtime/runtime.ts +348 -13
- package/src/flow/models/blocks/form/value-runtime/types.ts +2 -2
- package/src/flow/models/blocks/js-block/JSBlock.tsx +225 -9
- package/src/flow/models/blocks/js-block/__tests__/JSBlockModel.test.tsx +150 -0
- package/src/flow/models/blocks/table/JSColumnModel.tsx +1 -9
- package/src/flow/models/blocks/table/TableActionsColumnModel.tsx +36 -13
- package/src/flow/models/blocks/table/TableBlockModel.tsx +38 -17
- package/src/flow/models/blocks/table/TableColumnModel.tsx +36 -3
- package/src/flow/models/blocks/table/__tests__/TableActionsColumnModel.test.tsx +111 -1
- package/src/flow/models/blocks/table/__tests__/TableBlockModel.dragSort.test.ts +127 -0
- package/src/flow/models/blocks/table/__tests__/TableBlockModel.mobileSettingsButtons.test.tsx +78 -0
- package/src/flow/models/blocks/table/__tests__/TableBlockModel.rowSelection.test.tsx +1 -0
- package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +159 -1
- package/src/flow/models/blocks/table/dragSort/dragSortHooks.tsx +28 -17
- package/src/flow/models/blocks/table/dragSort/dragSortSettings.ts +13 -6
- package/src/flow/models/blocks/table/dragSort/dragSortUtils.ts +15 -2
- package/src/flow/models/fields/AssociationFieldModel/AssociationFieldModel.tsx +1 -1
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableFieldModel.tsx +29 -6
- package/src/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.tsx +16 -4
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.tsx +141 -19
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableField.tsx +13 -1
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/__tests__/SubTableColumnModel.rowRecord.test.ts +197 -0
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/__tests__/SubTableFieldModel.reset.test.ts +180 -0
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/index.tsx +6 -4
- package/src/flow/models/fields/AssociationFieldModel/__tests__/AssociationFieldModel.updateAssociation.test.ts +72 -0
- package/src/flow/models/fields/AssociationFieldModel/__tests__/RecordPickerFieldModel.itemContext.test.ts +23 -0
- package/src/flow/models/fields/ClickableFieldModel.tsx +5 -0
- package/src/flow/models/fields/DisplayDateTimeFieldModel.tsx +29 -1
- package/src/flow/models/fields/InputFieldModel.tsx +40 -2
- package/src/flow/models/fields/JSEditableFieldModel.tsx +2 -11
- package/src/flow/models/fields/JSFieldModel.tsx +2 -7
- package/src/flow/models/fields/JSItemModel.tsx +2 -14
- package/src/flow/models/fields/SelectFieldModel.tsx +6 -4
- package/src/flow/models/fields/TextareaFieldModel.tsx +49 -3
- package/src/flow/models/fields/__tests__/DisplayDateTimeFieldModel.test.tsx +96 -0
- package/src/flow/models/fields/__tests__/InputFieldModel.test.tsx +117 -1
- package/src/flow/models/fields/__tests__/SelectFieldModel.test.tsx +43 -0
- package/src/flow/models/fields/__tests__/TextareaFieldModel.test.tsx +100 -0
- package/src/flow/models/topbar/TopbarActionModel.tsx +93 -10
- package/src/flow/resolveViewParamsToViewList.tsx +11 -3
- package/src/flow/utils/__tests__/dateTimeFormat.test.ts +258 -0
- package/src/flow/utils/dataScopeFormValueClear.ts +218 -81
- package/src/flow/utils/dataScopeRowSnapshot.ts +616 -0
- package/src/flow/utils/dateTimeDisplayProps.ts +135 -0
- package/src/flow/utils/formValueDeps.ts +170 -0
- package/src/flow-compat/FieldValidation.tsx +122 -60
- package/src/flow-compat/Popover.tsx +43 -4
- package/src/flow-compat/__tests__/Popover.test.tsx +34 -0
- package/src/index.ts +8 -1
- package/src/layout-manager/__tests__/LayoutRoute.test.tsx +41 -1
- package/src/nocobase-buildin-plugin/index.tsx +44 -14
- package/src/settings-center/AdminSettingsLayout.tsx +10 -2
- package/src/settings-center/SystemSettingsPage.tsx +1 -2
- package/src/settings-center/plugin-manager/PluginCard.tsx +2 -2
- package/src/settings-center/plugin-manager/index.tsx +3 -0
- package/src/settings-center/utils.tsx +0 -6
|
@@ -19,16 +19,23 @@ export function useDragSortBodyWrapper(
|
|
|
19
19
|
model: TableBlockModel,
|
|
20
20
|
dataSourceRef: React.MutableRefObject<any>,
|
|
21
21
|
getRowKeyFunc: (record: any) => string | number,
|
|
22
|
+
dragSortFieldName?: string,
|
|
22
23
|
) {
|
|
24
|
+
const expandedRowKeys = model.props.expandedRowKeys;
|
|
25
|
+
const defaultExpandAllRows = model.props.defaultExpandAllRows;
|
|
26
|
+
const resource = model.resource;
|
|
27
|
+
const filterTargetKey = model.collection.filterTargetKey;
|
|
28
|
+
const message = (model as { ctx?: { message?: { error?: (content: string) => void } } }).ctx?.message;
|
|
29
|
+
|
|
23
30
|
return useMemo(() => {
|
|
24
|
-
if (!
|
|
31
|
+
if (!dragSortFieldName) {
|
|
25
32
|
return (props) => <tbody {...props} />;
|
|
26
33
|
}
|
|
27
34
|
|
|
28
35
|
const flattenTreeData = (data: any[]) => {
|
|
29
36
|
const result: any[] = [];
|
|
30
|
-
const expandedKeys = new Set((
|
|
31
|
-
const includeAll = !!
|
|
37
|
+
const expandedKeys = new Set((expandedRowKeys || []).map((key) => (key == null ? key : String(key))));
|
|
38
|
+
const includeAll = !!defaultExpandAllRows;
|
|
32
39
|
|
|
33
40
|
const walk = (nodes: any[]) => {
|
|
34
41
|
if (!nodes?.length) return;
|
|
@@ -73,22 +80,22 @@ export function useDragSortBodyWrapper(
|
|
|
73
80
|
}
|
|
74
81
|
|
|
75
82
|
if (from && to) {
|
|
76
|
-
|
|
83
|
+
resource
|
|
77
84
|
.runAction('move', {
|
|
78
85
|
method: 'post',
|
|
79
86
|
params: {
|
|
80
|
-
sourceId: getRowKey(from,
|
|
81
|
-
targetId: getRowKey(to,
|
|
82
|
-
sortField:
|
|
87
|
+
sourceId: getRowKey(from, filterTargetKey),
|
|
88
|
+
targetId: getRowKey(to, filterTargetKey),
|
|
89
|
+
sortField: dragSortFieldName,
|
|
83
90
|
},
|
|
84
91
|
})
|
|
85
92
|
.then(() => {
|
|
86
|
-
|
|
93
|
+
resource.refresh();
|
|
87
94
|
})
|
|
88
95
|
.catch((error) => {
|
|
89
96
|
console.error('Move failed:', error);
|
|
90
97
|
// Show a user-facing error message if the message system is available
|
|
91
|
-
|
|
98
|
+
message?.error?.(error?.message || 'Move failed');
|
|
92
99
|
});
|
|
93
100
|
}
|
|
94
101
|
};
|
|
@@ -104,13 +111,14 @@ export function useDragSortBodyWrapper(
|
|
|
104
111
|
);
|
|
105
112
|
};
|
|
106
113
|
}, [
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
model.collection.filterTargetKey,
|
|
114
|
+
dataSourceRef,
|
|
115
|
+
defaultExpandAllRows,
|
|
116
|
+
dragSortFieldName,
|
|
117
|
+
expandedRowKeys,
|
|
118
|
+
filterTargetKey,
|
|
113
119
|
getRowKeyFunc,
|
|
120
|
+
message,
|
|
121
|
+
resource,
|
|
114
122
|
]);
|
|
115
123
|
}
|
|
116
124
|
|
|
@@ -124,7 +132,10 @@ export function useDragSortRowComponent(dragSort: boolean) {
|
|
|
124
132
|
}
|
|
125
133
|
|
|
126
134
|
export function initDragSortParams(model: TableBlockModel) {
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
const dragSortFieldName = model.getDragSortFieldName();
|
|
136
|
+
if (dragSortFieldName) {
|
|
137
|
+
model.resource.setSort([dragSortFieldName]);
|
|
138
|
+
} else if (model.props.dragSort && model.props.dragSortBy) {
|
|
139
|
+
model.resource.setSort(Array.isArray(model.props.globalSort) ? model.props.globalSort : []);
|
|
129
140
|
}
|
|
130
141
|
}
|
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
|
|
10
10
|
import { tExpr } from '@nocobase/flow-engine';
|
|
11
11
|
import type { TableBlockModel } from '../TableBlockModel';
|
|
12
|
-
import { convertFieldsToOptions, getSortFields } from './dragSortUtils';
|
|
12
|
+
import { convertFieldsToOptions, getSortFields, hasSortField } from './dragSortUtils';
|
|
13
|
+
|
|
14
|
+
function getFallbackSort(model: TableBlockModel): string[] {
|
|
15
|
+
return Array.isArray(model.props.globalSort) ? model.props.globalSort : [];
|
|
16
|
+
}
|
|
13
17
|
|
|
14
18
|
export const dragSortSettings = {
|
|
15
19
|
title: tExpr('Enable drag and drop sorting'),
|
|
@@ -17,9 +21,12 @@ export const dragSortSettings = {
|
|
|
17
21
|
defaultParams: {
|
|
18
22
|
dragSort: false,
|
|
19
23
|
},
|
|
20
|
-
|
|
24
|
+
handler(ctx, params) {
|
|
21
25
|
const model = ctx.model as TableBlockModel;
|
|
22
26
|
model.setProps('dragSort', params.dragSort);
|
|
27
|
+
if (!params.dragSort) {
|
|
28
|
+
model.resource.setSort(getFallbackSort(model));
|
|
29
|
+
}
|
|
23
30
|
|
|
24
31
|
// Note: automatic configuration of the drag sort field has been removed;
|
|
25
32
|
// users now configure `dragSortBy` explicitly via `dragSortBySettings`.
|
|
@@ -45,6 +52,7 @@ export const dragSortBySettings = {
|
|
|
45
52
|
key: 'dragSortBy',
|
|
46
53
|
props: {
|
|
47
54
|
options,
|
|
55
|
+
allowClear: true,
|
|
48
56
|
placeholder: ctx.t('Select field'),
|
|
49
57
|
},
|
|
50
58
|
};
|
|
@@ -54,9 +62,8 @@ export const dragSortBySettings = {
|
|
|
54
62
|
},
|
|
55
63
|
handler(ctx, params) {
|
|
56
64
|
const model = ctx.model as TableBlockModel;
|
|
57
|
-
model.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
65
|
+
const dragSortBy = hasSortField(model.collection, params.dragSortBy) ? params.dragSortBy : null;
|
|
66
|
+
model.setProps('dragSortBy', dragSortBy);
|
|
67
|
+
model.resource.setSort(dragSortBy ? [dragSortBy] : getFallbackSort(model));
|
|
61
68
|
},
|
|
62
69
|
};
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { Collection } from '@nocobase/flow-engine';
|
|
10
|
+
import type { Collection, CollectionField } from '@nocobase/flow-engine';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* 从 collection 中获取所有 sort 类型的字段
|
|
@@ -24,6 +24,19 @@ export function getSortFields(collection: Collection | undefined) {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
export function getSortField(
|
|
28
|
+
collection: Collection | undefined,
|
|
29
|
+
fieldName?: string | null,
|
|
30
|
+
): CollectionField | undefined {
|
|
31
|
+
if (!collection || !fieldName) return undefined;
|
|
32
|
+
|
|
33
|
+
return getSortFields(collection).find((field) => field.name === fieldName);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function hasSortField(collection: Collection | undefined, fieldName?: string | null): boolean {
|
|
37
|
+
return !!getSortField(collection, fieldName);
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
/**
|
|
28
41
|
* 获取 collection 中第一个可用的 sort 字段
|
|
29
42
|
* @param collection - 集合对象
|
|
@@ -39,7 +52,7 @@ export function getFirstSortField(collection: Collection | undefined) {
|
|
|
39
52
|
* @param fields - 字段数组
|
|
40
53
|
* @returns 选项数组
|
|
41
54
|
*/
|
|
42
|
-
export function convertFieldsToOptions(fields:
|
|
55
|
+
export function convertFieldsToOptions(fields: CollectionField[]) {
|
|
43
56
|
return fields.map((field) => ({
|
|
44
57
|
label: field?.uiSchema?.title || field?.name,
|
|
45
58
|
value: field?.name,
|
|
@@ -11,7 +11,7 @@ import { FormItemModel } from '../../blocks/form/FormItemModel';
|
|
|
11
11
|
import { FieldModel } from '../../base/FieldModel';
|
|
12
12
|
export class AssociationFieldModel extends FieldModel {
|
|
13
13
|
operator = '$eq';
|
|
14
|
-
updateAssociation =
|
|
14
|
+
updateAssociation = false;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
AssociationFieldModel.registerFlow({
|
|
@@ -203,6 +203,8 @@ const DisplayTable = (props) => {
|
|
|
203
203
|
onSelectExitRecordClick,
|
|
204
204
|
resetPage,
|
|
205
205
|
allowCreate,
|
|
206
|
+
formValuesChangeEmitter,
|
|
207
|
+
onResetFieldValue,
|
|
206
208
|
} = props;
|
|
207
209
|
const [currentPage, setCurrentPage] = useState(1);
|
|
208
210
|
const [currentPageSize, setCurrentPageSize] = useState(pageSize);
|
|
@@ -223,6 +225,18 @@ const DisplayTable = (props) => {
|
|
|
223
225
|
resetPage && setCurrentPage(1);
|
|
224
226
|
}, [resetPage]);
|
|
225
227
|
|
|
228
|
+
useEffect(() => {
|
|
229
|
+
if (!formValuesChangeEmitter?.on || !formValuesChangeEmitter?.off || !onResetFieldValue) return;
|
|
230
|
+
const listener = () => {
|
|
231
|
+
onResetFieldValue();
|
|
232
|
+
setTableData([]);
|
|
233
|
+
};
|
|
234
|
+
formValuesChangeEmitter.on('onFieldReset', listener);
|
|
235
|
+
return () => {
|
|
236
|
+
formValuesChangeEmitter.off('onFieldReset', listener);
|
|
237
|
+
};
|
|
238
|
+
}, [formValuesChangeEmitter, onResetFieldValue]);
|
|
239
|
+
|
|
226
240
|
const pagination = useMemo(() => {
|
|
227
241
|
return {
|
|
228
242
|
current: currentPage, // 当前页码
|
|
@@ -237,7 +251,7 @@ const DisplayTable = (props) => {
|
|
|
237
251
|
return t('Total {{count}} items', { count: total });
|
|
238
252
|
},
|
|
239
253
|
} as any;
|
|
240
|
-
}, [currentPage, currentPageSize, tableData]);
|
|
254
|
+
}, [currentPage, currentPageSize, tableData, t]);
|
|
241
255
|
|
|
242
256
|
const columns = useMemo(() => {
|
|
243
257
|
const cols = adjustColumnOrder(
|
|
@@ -421,10 +435,6 @@ export class PopupSubTableFieldModel extends AssociationFieldModel {
|
|
|
421
435
|
currentPageSize,
|
|
422
436
|
});
|
|
423
437
|
};
|
|
424
|
-
// 监听表单reset
|
|
425
|
-
this.context.blockModel.emitter.on('onFieldReset', () => {
|
|
426
|
-
this.props?.onChange([]);
|
|
427
|
-
});
|
|
428
438
|
}
|
|
429
439
|
}
|
|
430
440
|
|
|
@@ -457,8 +467,21 @@ export class PopupSubTableFieldModel extends AssociationFieldModel {
|
|
|
457
467
|
}
|
|
458
468
|
|
|
459
469
|
public render() {
|
|
470
|
+
const fieldPathArray = this.context.fieldPathArray ?? this.parent?.context?.fieldPathArray;
|
|
471
|
+
const onResetFieldValue = () => {
|
|
472
|
+
const value = [];
|
|
473
|
+
this.setProps({ value });
|
|
474
|
+
this.context.blockModel?.setFieldValue?.(fieldPathArray, value);
|
|
475
|
+
};
|
|
460
476
|
return (
|
|
461
|
-
<DisplayTable
|
|
477
|
+
<DisplayTable
|
|
478
|
+
{...this.props}
|
|
479
|
+
collection={this.collection}
|
|
480
|
+
baseColumns={this.getBaseColumns(this)}
|
|
481
|
+
model={this}
|
|
482
|
+
formValuesChangeEmitter={this.context.blockModel?.emitter}
|
|
483
|
+
onResetFieldValue={onResetFieldValue}
|
|
484
|
+
/>
|
|
462
485
|
);
|
|
463
486
|
}
|
|
464
487
|
}
|
|
@@ -99,6 +99,18 @@ export function collectAssociationHydrationCandidates(options: {
|
|
|
99
99
|
return candidates;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
export function getAssociationHydrationNamePath(model: any) {
|
|
103
|
+
return model?.context?.fieldPathArray ?? model?.context?.fieldPath ?? model?.props?.name;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function getAssociationHydrationSetterContext(model: any) {
|
|
107
|
+
if (typeof model?.context?.setFormValue === 'function') {
|
|
108
|
+
return model.context;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return model?.context?.blockModel?.context;
|
|
112
|
+
}
|
|
113
|
+
|
|
102
114
|
function markAssociationHydrationDone(statusMap: Map<string, HydrateStatus>, tkKey: string | null | undefined) {
|
|
103
115
|
if (!tkKey) return;
|
|
104
116
|
statusMap.set(tkKey, 'done');
|
|
@@ -245,8 +257,8 @@ const LazySelect = (props: Readonly<LazySelectProps>) => {
|
|
|
245
257
|
});
|
|
246
258
|
if (!candidates.length) return;
|
|
247
259
|
|
|
248
|
-
const namePath = model
|
|
249
|
-
const
|
|
260
|
+
const namePath = getAssociationHydrationNamePath(model);
|
|
261
|
+
const setterCtx: any = getAssociationHydrationSetterContext(model);
|
|
250
262
|
|
|
251
263
|
candidates.forEach(({ item, tk, tkKey }) => {
|
|
252
264
|
void (async () => {
|
|
@@ -268,8 +280,8 @@ const LazySelect = (props: Readonly<LazySelectProps>) => {
|
|
|
268
280
|
})
|
|
269
281
|
: merge;
|
|
270
282
|
|
|
271
|
-
if (
|
|
272
|
-
await
|
|
283
|
+
if (setterCtx && typeof setterCtx.setFormValue === 'function' && namePath != null) {
|
|
284
|
+
await setterCtx.setFormValue(namePath, nextValue, {
|
|
273
285
|
source: 'default',
|
|
274
286
|
markExplicit: false,
|
|
275
287
|
triggerEvent: false,
|
package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.tsx
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
observer,
|
|
27
27
|
FlowModelProvider,
|
|
28
28
|
FlowErrorFallback,
|
|
29
|
+
extractUsedVariablePaths,
|
|
29
30
|
} from '@nocobase/flow-engine';
|
|
30
31
|
import { TableColumnProps, Tooltip, Input, Space, Divider } from 'antd';
|
|
31
32
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
@@ -37,6 +38,14 @@ import { FieldDeletePlaceholder, CustomWidth, normalizeTableColumnWidth } from '
|
|
|
37
38
|
import { buildDynamicNamePath } from '../../../blocks/form/dynamicNamePath';
|
|
38
39
|
import { getSubTableRowIdentity } from './rowIdentity';
|
|
39
40
|
import { getFieldBindingUse, rebuildFieldSubModel } from '../../../../internal/utils/rebuildFieldSubModel';
|
|
41
|
+
import {
|
|
42
|
+
buildCurrentItemTitle,
|
|
43
|
+
createAssociationItemChainContextPropertyOptions,
|
|
44
|
+
createItemChainGetter,
|
|
45
|
+
createParentItemAccessorsFromContext,
|
|
46
|
+
createRootItemChain,
|
|
47
|
+
type ItemChain,
|
|
48
|
+
} from '../itemChain';
|
|
40
49
|
|
|
41
50
|
export const SUB_TABLE_COLUMN_FIELD_COMPONENT_CONTEXT = 'subTableColumn';
|
|
42
51
|
|
|
@@ -180,6 +189,25 @@ const handleModelName = (modelName) => {
|
|
|
180
189
|
return modelName;
|
|
181
190
|
};
|
|
182
191
|
|
|
192
|
+
const DATA_SCOPE_FLOW_KEYS = ['selectSettings', 'cascadeSelectSettings'];
|
|
193
|
+
|
|
194
|
+
function hasFormValueDrivenDataScope(filter: any) {
|
|
195
|
+
if (!filter) return false;
|
|
196
|
+
try {
|
|
197
|
+
const usage = extractUsedVariablePaths(filter) || {};
|
|
198
|
+
return ['item', 'formValues'].some((name) => Object.prototype.hasOwnProperty.call(usage, name));
|
|
199
|
+
} catch {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function hasFormValueDrivenDataScopeField(fieldModel: any) {
|
|
205
|
+
return DATA_SCOPE_FLOW_KEYS.some((flowKey) => {
|
|
206
|
+
const params = fieldModel?.getStepParams?.(flowKey, 'dataScope');
|
|
207
|
+
return hasFormValueDrivenDataScope(params?.filter);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
183
211
|
const MemoFieldRenderer = React.memo(FieldModelRenderer, (prev, next) => {
|
|
184
212
|
return prev.value === next.value && prev.model === next.model;
|
|
185
213
|
});
|
|
@@ -203,6 +231,20 @@ export function getLatestSubTableRowRecord(form: any, fieldIndex: unknown, fallb
|
|
|
203
231
|
return typeof latestRecord === 'undefined' ? fallbackRecord : latestRecord;
|
|
204
232
|
}
|
|
205
233
|
|
|
234
|
+
export function buildSubTableColumnNamePath(
|
|
235
|
+
fieldPath: Array<string | number>,
|
|
236
|
+
rowIdx: number,
|
|
237
|
+
namePath: string | number,
|
|
238
|
+
rowFieldIndex: unknown,
|
|
239
|
+
): Array<string | number> {
|
|
240
|
+
const currentRowPath = buildRowPathFromFieldIndex(rowFieldIndex);
|
|
241
|
+
if (currentRowPath?.length) {
|
|
242
|
+
return [...currentRowPath, namePath];
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return [...fieldPath, rowIdx, namePath];
|
|
246
|
+
}
|
|
247
|
+
|
|
206
248
|
function shouldCommitImmediately(value: any) {
|
|
207
249
|
if (Array.isArray(value)) {
|
|
208
250
|
return true;
|
|
@@ -344,11 +386,23 @@ const MemoCell: React.FC<CellProps> = React.memo(
|
|
|
344
386
|
{parent.mapSubModels('field', (action: FieldModel) => {
|
|
345
387
|
const fieldPath = action.context.fieldPath.split('.');
|
|
346
388
|
const namePath = fieldPath.pop();
|
|
389
|
+
if (typeof namePath === 'undefined') {
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
const fieldNamePath = buildSubTableColumnNamePath(fieldPath, rowIdx, namePath, rowFork?.context?.fieldIndex);
|
|
393
|
+
const formItemName = buildDynamicNamePath([...fieldPath, rowIdx, namePath], parentFieldIndex);
|
|
347
394
|
|
|
348
395
|
const fork: any = action.createFork({}, `${id}`);
|
|
349
396
|
fork.context.defineProperty('currentObject', { get: () => record });
|
|
397
|
+
fork.context.defineProperty('fieldPathArray', {
|
|
398
|
+
get: () => fieldNamePath,
|
|
399
|
+
cache: false,
|
|
400
|
+
});
|
|
350
401
|
if (rowFork) {
|
|
402
|
+
const itemOptions = rowFork.context.getPropertyOptions?.('item');
|
|
403
|
+
const { value: _value, ...itemOptionsWithoutValue } = (itemOptions || {}) as any;
|
|
351
404
|
fork.context.defineProperty('item', {
|
|
405
|
+
...itemOptionsWithoutValue,
|
|
352
406
|
get: () => rowFork.context.item,
|
|
353
407
|
cache: false,
|
|
354
408
|
});
|
|
@@ -384,7 +438,7 @@ const MemoCell: React.FC<CellProps> = React.memo(
|
|
|
384
438
|
<FormItem
|
|
385
439
|
{...parent.props}
|
|
386
440
|
key={id}
|
|
387
|
-
name={
|
|
441
|
+
name={formItemName}
|
|
388
442
|
style={{ marginBottom: 0 }}
|
|
389
443
|
showLabel={false}
|
|
390
444
|
disabled={
|
|
@@ -445,6 +499,57 @@ export class SubTableColumnModel<
|
|
|
445
499
|
static renderMode = ModelRenderMode.RenderFunction;
|
|
446
500
|
static fieldComponentContext = SUB_TABLE_COLUMN_FIELD_COMPONENT_CONTEXT;
|
|
447
501
|
|
|
502
|
+
private getAssociationField() {
|
|
503
|
+
return (this.parent as any)?.context?.collectionField;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
private getParentFormValues() {
|
|
507
|
+
return (this.context?.blockModel as any)?.context?.formValues;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
private createParentItemAccessors(parentItemAccessor?: () => ItemChain | undefined) {
|
|
511
|
+
const baseAccessors = createParentItemAccessorsFromContext({
|
|
512
|
+
parentContextAccessor: () => (this.parent as any)?.context,
|
|
513
|
+
fallbackParentPropertiesAccessor: () => this.getParentFormValues(),
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
if (!parentItemAccessor) {
|
|
517
|
+
return baseAccessors;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
return {
|
|
521
|
+
parentPropertiesAccessor: (ctx?: any) =>
|
|
522
|
+
parentItemAccessor()?.value ?? baseAccessors.parentPropertiesAccessor(ctx),
|
|
523
|
+
parentItemMetaAccessor: baseAccessors.parentItemMetaAccessor,
|
|
524
|
+
parentItemResolverAccessor: baseAccessors.parentItemResolverAccessor,
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
private createRowItemContextPropertyOptions(
|
|
529
|
+
options: {
|
|
530
|
+
resolverPropertiesAccessor?: () => unknown;
|
|
531
|
+
parentItemAccessor?: () => ItemChain | undefined;
|
|
532
|
+
showParentIndex?: boolean;
|
|
533
|
+
} = {},
|
|
534
|
+
) {
|
|
535
|
+
const associationField = this.getAssociationField();
|
|
536
|
+
|
|
537
|
+
return createAssociationItemChainContextPropertyOptions({
|
|
538
|
+
t: this.context.t,
|
|
539
|
+
title: buildCurrentItemTitle(this.context.t, associationField, this.props?.name),
|
|
540
|
+
showIndex: true,
|
|
541
|
+
showParentIndex:
|
|
542
|
+
options.showParentIndex ??
|
|
543
|
+
(Array.isArray((this.parent as any)?.context?.fieldIndex) &&
|
|
544
|
+
(this.parent as any).context.fieldIndex.length > 0),
|
|
545
|
+
collectionAccessor: () => (this.parent as any)?.collection ?? associationField?.targetCollection ?? null,
|
|
546
|
+
propertiesAccessor: (ctx) => ctx?.item?.value,
|
|
547
|
+
resolverPropertiesAccessor: options.resolverPropertiesAccessor ?? (() => undefined),
|
|
548
|
+
parentCollectionAccessor: () => associationField?.collection,
|
|
549
|
+
parentAccessors: this.createParentItemAccessors(options.parentItemAccessor),
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
|
|
448
553
|
renderHiddenInConfig() {
|
|
449
554
|
return <FieldWithoutPermissionPlaceholder targetModel={this} />;
|
|
450
555
|
}
|
|
@@ -505,6 +610,14 @@ export class SubTableColumnModel<
|
|
|
505
610
|
).some(Boolean);
|
|
506
611
|
}
|
|
507
612
|
|
|
613
|
+
get hasFormValueDrivenDataScopeColumn() {
|
|
614
|
+
return (
|
|
615
|
+
this.parent?.mapSubModels('columns', (column: SubTableColumnModel) => {
|
|
616
|
+
return hasFormValueDrivenDataScopeField(column?.subModels?.field);
|
|
617
|
+
}) || []
|
|
618
|
+
).some(Boolean);
|
|
619
|
+
}
|
|
620
|
+
|
|
508
621
|
onInit(options: any): void {
|
|
509
622
|
super.onInit(options);
|
|
510
623
|
this.context.defineProperty('resourceName', {
|
|
@@ -516,6 +629,10 @@ export class SubTableColumnModel<
|
|
|
516
629
|
this.context.defineProperty('actionName', {
|
|
517
630
|
get: () => 'view',
|
|
518
631
|
});
|
|
632
|
+
this.context.defineProperty('item', {
|
|
633
|
+
get: () => undefined,
|
|
634
|
+
...this.createRowItemContextPropertyOptions(),
|
|
635
|
+
});
|
|
519
636
|
this.emitter.on('onSubModelAdded', (subModel: FieldModel) => {
|
|
520
637
|
if (this.collectionField) {
|
|
521
638
|
subModel.setProps(this.collectionField.getComponentProps());
|
|
@@ -673,25 +790,30 @@ export class SubTableColumnModel<
|
|
|
673
790
|
value: [...baseArr, `${associationKey}:${rowIndex}`],
|
|
674
791
|
});
|
|
675
792
|
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
793
|
+
const getRowRecord = () => {
|
|
794
|
+
const form = (fork.context as any)?.form || (this.context?.blockModel as any)?.context?.form;
|
|
795
|
+
return getLatestSubTableRowRecord(form, fork.context.fieldIndex, record);
|
|
796
|
+
};
|
|
797
|
+
const getParentItem = () => {
|
|
798
|
+
const parentItemCtx = (parentItem ?? (this.parent as any)?.context?.item) as ItemChain | undefined;
|
|
799
|
+
return parentItemCtx ?? createRootItemChain(this.getParentFormValues());
|
|
800
|
+
};
|
|
801
|
+
const getRowItem = createItemChainGetter({
|
|
802
|
+
valueAccessor: getRowRecord,
|
|
803
|
+
parentItemAccessor: getParentItem,
|
|
804
|
+
indexAccessor: () => (Number.isFinite(rowIndex) ? rowIndex : undefined),
|
|
805
|
+
lengthAccessor: () => {
|
|
683
806
|
const list = (this.parent as any)?.props?.value;
|
|
684
|
-
|
|
685
|
-
return {
|
|
686
|
-
index: Number.isFinite(rowIndex) ? rowIndex : undefined,
|
|
687
|
-
length,
|
|
688
|
-
__is_new__: isNew,
|
|
689
|
-
__is_stored__: isStored,
|
|
690
|
-
value: rowRecord,
|
|
691
|
-
parentItem: parentItemCtx,
|
|
692
|
-
};
|
|
807
|
+
return Array.isArray(list) ? list.length : undefined;
|
|
693
808
|
},
|
|
694
|
-
|
|
809
|
+
});
|
|
810
|
+
fork.context.defineProperty('item', {
|
|
811
|
+
get: getRowItem,
|
|
812
|
+
...this.createRowItemContextPropertyOptions({
|
|
813
|
+
resolverPropertiesAccessor: getRowRecord,
|
|
814
|
+
parentItemAccessor: getParentItem,
|
|
815
|
+
showParentIndex: baseArr.length > 0,
|
|
816
|
+
}),
|
|
695
817
|
});
|
|
696
818
|
return fork;
|
|
697
819
|
})();
|
|
@@ -707,7 +829,7 @@ export class SubTableColumnModel<
|
|
|
707
829
|
rowFork={rowFork}
|
|
708
830
|
memoKey={cellModeKey}
|
|
709
831
|
width={this.props.width}
|
|
710
|
-
commitOnChange={this.hasFormulaColumn}
|
|
832
|
+
commitOnChange={this.hasFormulaColumn || this.hasFormValueDrivenDataScopeColumn}
|
|
711
833
|
/>
|
|
712
834
|
);
|
|
713
835
|
};
|
|
@@ -70,6 +70,7 @@ export function SubTableField(props) {
|
|
|
70
70
|
getCurrentValue,
|
|
71
71
|
fieldPathArray,
|
|
72
72
|
formValuesChangeEmitter,
|
|
73
|
+
onResetFieldValue,
|
|
73
74
|
} = props;
|
|
74
75
|
const [currentPage, setCurrentPage] = useState(1);
|
|
75
76
|
const [currentPageSize, setCurrentPageSize] = useState(pageSize);
|
|
@@ -97,6 +98,17 @@ export function SubTableField(props) {
|
|
|
97
98
|
formValuesChangeEmitter.off('formValuesChange', listener);
|
|
98
99
|
};
|
|
99
100
|
}, [fieldPathArray, formValuesChangeEmitter]);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (!formValuesChangeEmitter?.on || !formValuesChangeEmitter?.off || !onResetFieldValue) return;
|
|
103
|
+
const listener = () => {
|
|
104
|
+
onResetFieldValue();
|
|
105
|
+
forceRefresh((v) => v + 1);
|
|
106
|
+
};
|
|
107
|
+
formValuesChangeEmitter.on('onFieldReset', listener);
|
|
108
|
+
return () => {
|
|
109
|
+
formValuesChangeEmitter.off('onFieldReset', listener);
|
|
110
|
+
};
|
|
111
|
+
}, [formValuesChangeEmitter, onResetFieldValue]);
|
|
100
112
|
const applyValue = React.useCallback((nextValue: any) => onChange?.(normalizeSubTableRows(nextValue)), [onChange]);
|
|
101
113
|
const getLatestValue = React.useCallback(() => normalizeSubTableRows(getCurrentValue()), [getCurrentValue]);
|
|
102
114
|
useEffect(() => {
|
|
@@ -125,7 +137,7 @@ export function SubTableField(props) {
|
|
|
125
137
|
return t('Total {{count}} items', { count: total });
|
|
126
138
|
},
|
|
127
139
|
} as any;
|
|
128
|
-
}, [currentPage, currentPageSize, currentValue.length]);
|
|
140
|
+
}, [currentPage, currentPageSize, currentValue.length, t]);
|
|
129
141
|
|
|
130
142
|
// 新增一行
|
|
131
143
|
const handleAdd = () => {
|