@zat-design/sisyphus-react 3.13.4-beta.6 → 3.13.5-beta.2
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/ProEditTable/components/RcTable/DraggableTable.js +11 -8
- package/es/ProEditTable/index.js +3 -1
- package/es/ProEditTable/propsType.d.ts +11 -1
- package/es/ProForm/components/combination/Group/hooks/index.d.ts +20 -0
- package/es/ProForm/components/combination/Group/hooks/index.js +161 -0
- package/es/ProForm/components/combination/Group/index.js +2 -1
- package/es/ProForm/components/combination/Group/utils.d.ts +3 -16
- package/es/ProForm/components/combination/Group/utils.js +2 -160
- package/es/ProTable/hooks/useAntdTable.js +8 -7
- package/es/ProTable/propsType.d.ts +6 -0
- package/es/ProUpload/components/ButtonRender.js +3 -0
- package/lib/ProEditTable/components/RcTable/DraggableTable.js +11 -8
- package/lib/ProEditTable/index.js +3 -1
- package/lib/ProEditTable/propsType.d.ts +11 -1
- package/lib/ProForm/components/combination/Group/hooks/index.d.ts +20 -0
- package/lib/ProForm/components/combination/Group/hooks/index.js +169 -0
- package/lib/ProForm/components/combination/Group/index.js +2 -1
- package/lib/ProForm/components/combination/Group/utils.d.ts +3 -16
- package/lib/ProForm/components/combination/Group/utils.js +2 -161
- package/lib/ProTable/hooks/useAntdTable.js +8 -5
- package/lib/ProTable/propsType.d.ts +6 -0
- package/lib/ProUpload/components/ButtonRender.js +3 -0
- package/package.json +1 -1
@@ -72,17 +72,13 @@ var DndWrapper = function DndWrapper(_ref2) {
|
|
72
72
|
value = _ref2.value,
|
73
73
|
onChange = _ref2.onChange,
|
74
74
|
onDrag = _ref2.onDrag,
|
75
|
+
onDragEnd = _ref2.onDragEnd,
|
75
76
|
disabled = _ref2.disabled,
|
76
77
|
children = _ref2.children;
|
77
|
-
var
|
78
|
+
var onDragEndtInside = function onDragEndtInside(event) {
|
78
79
|
var active = event.active,
|
79
80
|
over = event.over;
|
80
81
|
if (active.id !== (over === null || over === void 0 ? void 0 : over.id)) {
|
81
|
-
if (onDrag) {
|
82
|
-
var nextList = onDrag(event, value);
|
83
|
-
onChange(nextList);
|
84
|
-
return;
|
85
|
-
}
|
86
82
|
var activeIndex = value.findIndex(function (i) {
|
87
83
|
return i.rowKey === active.id;
|
88
84
|
});
|
@@ -90,11 +86,16 @@ var DndWrapper = function DndWrapper(_ref2) {
|
|
90
86
|
return i.rowKey === (over === null || over === void 0 ? void 0 : over.id);
|
91
87
|
});
|
92
88
|
var nextValue = arrayMove(value, activeIndex, overIndex);
|
89
|
+
if (onDrag || onDragEnd) {
|
90
|
+
var nextList = onDragEnd ? onDragEnd(event, value, nextValue) : onDrag(event, value, nextValue);
|
91
|
+
onChange(nextList);
|
92
|
+
return;
|
93
|
+
}
|
93
94
|
onChange(nextValue);
|
94
95
|
}
|
95
96
|
};
|
96
97
|
return draggable && !disabled ? _jsx(DndContext, {
|
97
|
-
onDragEnd:
|
98
|
+
onDragEnd: onDragEndtInside,
|
98
99
|
children: _jsx(SortableContext, {
|
99
100
|
items: (value === null || value === void 0 ? void 0 : (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.rowKey) ? value.map(function (i) {
|
100
101
|
return i.rowKey;
|
@@ -130,11 +131,13 @@ var DraggableTable = function DraggableTable(_ref3) {
|
|
130
131
|
handlePageChange = tableProps.handlePageChange;
|
131
132
|
var onChange = draggableProps.onChange,
|
132
133
|
onDrag = draggableProps.onDrag,
|
133
|
-
draggable = draggableProps.draggable
|
134
|
+
draggable = draggableProps.draggable,
|
135
|
+
onDragEnd = draggableProps.onDragEnd;
|
134
136
|
return _jsxs(DndWrapper, {
|
135
137
|
value: value,
|
136
138
|
onChange: onChange,
|
137
139
|
onDrag: onDrag,
|
140
|
+
onDragEnd: onDragEnd,
|
138
141
|
disabled: disabled,
|
139
142
|
draggable: draggable,
|
140
143
|
children: [headerRender ? _jsx("div", {
|
package/es/ProEditTable/index.js
CHANGED
@@ -11,7 +11,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
11
11
|
import "antd/es/form/style";
|
12
12
|
import _Form from "antd/es/form";
|
13
13
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
14
|
-
var _excluded = ["value", "onChange", "onDrag", "className", "columns", "type", "mode", "stripe", "draggable", "virtual", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "toolbarSticky", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "rowKey", "rowDisabled", "rowDraggable", "footerRender", "scroll", "actionDirection", "diffConfig"];
|
14
|
+
var _excluded = ["value", "onChange", "onDrag", "onDragEnd", "className", "columns", "type", "mode", "stripe", "draggable", "virtual", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "toolbarSticky", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "rowKey", "rowDisabled", "rowDraggable", "footerRender", "scroll", "actionDirection", "diffConfig"];
|
15
15
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
16
16
|
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
17
17
|
import { get, isArray, isBoolean, set } from 'lodash';
|
@@ -29,6 +29,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
29
29
|
var value = _ref.value,
|
30
30
|
onChange = _ref.onChange,
|
31
31
|
onDrag = _ref.onDrag,
|
32
|
+
onDragEnd = _ref.onDragEnd,
|
32
33
|
className = _ref.className,
|
33
34
|
columns = _ref.columns,
|
34
35
|
type = _ref.type,
|
@@ -405,6 +406,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
405
406
|
draggableProps: {
|
406
407
|
onChange: onChange,
|
407
408
|
onDrag: onDrag,
|
409
|
+
onDragEnd: onDragEnd,
|
408
410
|
draggable: draggable
|
409
411
|
},
|
410
412
|
tableProps: {
|
@@ -377,8 +377,18 @@ export interface ProEditTableProps<T = any> extends Omit<TableProps<T>, 'onChang
|
|
377
377
|
rowDraggable?: (record?: T) => string | boolean;
|
378
378
|
/**
|
379
379
|
* 拖拽事件处理
|
380
|
+
* @param event 拖拽事件
|
381
|
+
* @param dataSource 当前数据源
|
382
|
+
* @param nextDataSource 拖拽后的数据源
|
380
383
|
*/
|
381
|
-
onDrag?: (event: DragEndEvent, dataSource: T[]) => T[];
|
384
|
+
onDrag?: (event: DragEndEvent, dataSource: T[], nextDataSource: T[]) => T[];
|
385
|
+
/**
|
386
|
+
* 拖拽结束事件处理
|
387
|
+
* @param event 拖拽事件
|
388
|
+
* @param dataSource 当前数据源
|
389
|
+
* @param nextDataSource 拖拽后的数据源
|
390
|
+
*/
|
391
|
+
onDragEnd?: (event: DragEndEvent, dataSource: T[], nextDataSource: T[]) => T[];
|
382
392
|
/**
|
383
393
|
* 引用对象
|
384
394
|
*/
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
|
2
|
+
import { FormInstance } from 'antd';
|
3
|
+
import type { GroupColumnType, GroupType } from '../propsType';
|
4
|
+
export type EventArgs = any[];
|
5
|
+
interface ColumnsTransformerParams {
|
6
|
+
columns: GroupColumnType[];
|
7
|
+
name?: NamePath;
|
8
|
+
names?: NamePath[];
|
9
|
+
value?: any[];
|
10
|
+
onChange: any;
|
11
|
+
namePath?: InternalNamePath;
|
12
|
+
form: FormInstance;
|
13
|
+
index?: number;
|
14
|
+
formDisabled?: boolean;
|
15
|
+
desensitizationKey?: string;
|
16
|
+
groupProps: GroupType;
|
17
|
+
}
|
18
|
+
/** 转换columns */
|
19
|
+
export declare const useTransformColumns: (params: ColumnsTransformerParams) => any[];
|
20
|
+
export {};
|
@@ -0,0 +1,161 @@
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
3
|
+
/* eslint-disable no-lonely-if */
|
4
|
+
import { useRef } from 'react';
|
5
|
+
import { cloneDeep, isEqual } from 'lodash';
|
6
|
+
import { useDeepCompareMemo } from '../../../../utils/useDeepCompareMemo';
|
7
|
+
import { difference } from '../../../../../ProEditTable/utils/tools';
|
8
|
+
import { getReactiveProps, getValueTypeTrans, valueFromEventWrapper } from '../utils';
|
9
|
+
/** 转换columns */
|
10
|
+
export var useTransformColumns = function useTransformColumns(params) {
|
11
|
+
var form = params.form,
|
12
|
+
columns = params.columns,
|
13
|
+
name = params.name,
|
14
|
+
names = params.names,
|
15
|
+
outerIndex = params.index,
|
16
|
+
namePath = params.namePath,
|
17
|
+
value = params.value,
|
18
|
+
internalChange = params.onChange,
|
19
|
+
groupProps = params.groupProps,
|
20
|
+
formDisabled = params.formDisabled,
|
21
|
+
desensitizationKey = params.desensitizationKey;
|
22
|
+
var timerRef = useRef([]);
|
23
|
+
return columns === null || columns === void 0 ? void 0 : columns.flatMap(function (column, index) {
|
24
|
+
var type = column.type,
|
25
|
+
valueType = column.valueType,
|
26
|
+
switchValue = column.switchValue,
|
27
|
+
toISOString = column.toISOString,
|
28
|
+
toCSTString = column.toCSTString,
|
29
|
+
fieldProps = column.fieldProps,
|
30
|
+
normalize = column.normalize,
|
31
|
+
disabled = column.disabled,
|
32
|
+
show = column.show,
|
33
|
+
component = column.component,
|
34
|
+
clearNotShow = column.clearNotShow,
|
35
|
+
desensitization = column.desensitization;
|
36
|
+
var _ref = fieldProps || {},
|
37
|
+
mode = _ref.mode,
|
38
|
+
onChange = _ref.onChange,
|
39
|
+
onFieldChange = _ref.onFieldChange,
|
40
|
+
comDisabled = _ref.disabled,
|
41
|
+
onBlur = _ref.onBlur;
|
42
|
+
var _disabled = disabled || comDisabled;
|
43
|
+
var columnName = names ? names[index] : [].concat(name, index);
|
44
|
+
// 响应式字段改变后的回调
|
45
|
+
var changedCallback = function changedCallback(lastDependency, current) {
|
46
|
+
// 清值防抖 多次刷新时以最后一次为准
|
47
|
+
if (clearNotShow !== false && names) {
|
48
|
+
if ((current === null || current === void 0 ? void 0 : current.show) === false) {
|
49
|
+
clearInterval(timerRef.current[index]);
|
50
|
+
timerRef.current[index] = setTimeout(function () {
|
51
|
+
if (names) {
|
52
|
+
form.resetFields([columnName]);
|
53
|
+
}
|
54
|
+
if (!names && (value === null || value === void 0 ? void 0 : value.length)) {
|
55
|
+
value[index] = null;
|
56
|
+
form.setFieldValue(columnName, _toConsumableArray(value));
|
57
|
+
}
|
58
|
+
}, 200);
|
59
|
+
} else {
|
60
|
+
clearInterval(timerRef.current[index]);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
};
|
64
|
+
// 响应式字段
|
65
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
66
|
+
var reactiveProps = useDeepCompareMemo(function () {
|
67
|
+
return getReactiveProps({
|
68
|
+
form: form,
|
69
|
+
index: index,
|
70
|
+
type: type,
|
71
|
+
namePath: namePath,
|
72
|
+
disabled: _disabled,
|
73
|
+
show: show,
|
74
|
+
component: component,
|
75
|
+
fieldProps: fieldProps,
|
76
|
+
name: columnName,
|
77
|
+
desensitization: desensitization
|
78
|
+
});
|
79
|
+
}, changedCallback, [value, show, fieldProps, _disabled, columnName, type]);
|
80
|
+
if (reactiveProps.show === false) {
|
81
|
+
return [];
|
82
|
+
}
|
83
|
+
var transform = getValueTypeTrans({
|
84
|
+
type: type,
|
85
|
+
valueType: valueType,
|
86
|
+
switchValue: switchValue,
|
87
|
+
toISOString: toISOString,
|
88
|
+
toCSTString: toCSTString,
|
89
|
+
mode: mode
|
90
|
+
});
|
91
|
+
var newValue;
|
92
|
+
var handleChange = function handleChange() {
|
93
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
94
|
+
args[_key] = arguments[_key];
|
95
|
+
}
|
96
|
+
newValue = valueFromEventWrapper(column, args);
|
97
|
+
if (transform === null || transform === void 0 ? void 0 : transform.normalize) {
|
98
|
+
var _transform$normalize;
|
99
|
+
newValue = transform === null || transform === void 0 ? void 0 : (_transform$normalize = transform.normalize) === null || _transform$normalize === void 0 ? void 0 : _transform$normalize.call(transform, newValue);
|
100
|
+
} else if (normalize) {
|
101
|
+
// @ts-ignore
|
102
|
+
newValue = normalize === null || normalize === void 0 ? void 0 : normalize(newValue);
|
103
|
+
}
|
104
|
+
internalChange === null || internalChange === void 0 ? void 0 : internalChange(newValue, args[1], index);
|
105
|
+
var values = form.getFieldValue(namePath);
|
106
|
+
var originRow = (namePath === null || namePath === void 0 ? void 0 : namePath.length) ? cloneDeep(values) : undefined;
|
107
|
+
onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, args);
|
108
|
+
onFieldChange === null || onFieldChange === void 0 ? void 0 : onFieldChange(newValue, values, {
|
109
|
+
index: outerIndex,
|
110
|
+
namePath: namePath,
|
111
|
+
form: form,
|
112
|
+
option: args === null || args === void 0 ? void 0 : args[1]
|
113
|
+
});
|
114
|
+
// 如果是在可编辑表格或formList内部, 储存当前行的值, 并在变更后更新到表单里
|
115
|
+
if ((namePath === null || namePath === void 0 ? void 0 : namePath.length) && !isEqual(originRow, values)) {
|
116
|
+
var _Object$keys, _Object$keys$map;
|
117
|
+
form.setFieldValue(namePath, values);
|
118
|
+
var diff = difference(originRow, values) || {};
|
119
|
+
var validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
|
120
|
+
return [].concat(_toConsumableArray(namePath), [key]);
|
121
|
+
});
|
122
|
+
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
123
|
+
setTimeout(function () {
|
124
|
+
form.validateFields([name].concat(_toConsumableArray(validateFieldKeys)));
|
125
|
+
}, 100);
|
126
|
+
}
|
127
|
+
}
|
128
|
+
};
|
129
|
+
var handleBlur = function handleBlur() {
|
130
|
+
if (!onBlur) return;
|
131
|
+
var values = form.getFieldValue(namePath);
|
132
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
133
|
+
args[_key2] = arguments[_key2];
|
134
|
+
}
|
135
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(args[0], values, {
|
136
|
+
index: outerIndex,
|
137
|
+
namePath: namePath,
|
138
|
+
form: form,
|
139
|
+
option: args === null || args === void 0 ? void 0 : args[1]
|
140
|
+
});
|
141
|
+
};
|
142
|
+
// 内外一个为true则为true
|
143
|
+
var getLastDisabled = function getLastDisabled() {
|
144
|
+
if (Array.isArray(groupProps.disabled)) {
|
145
|
+
return reactiveProps.disabled || groupProps.disabled[index];
|
146
|
+
}
|
147
|
+
return reactiveProps.disabled || groupProps.disabled;
|
148
|
+
};
|
149
|
+
return _objectSpread(_objectSpread(_objectSpread({}, column), {}, {
|
150
|
+
name: columnName
|
151
|
+
}, reactiveProps), {}, {
|
152
|
+
disabled: getLastDisabled(),
|
153
|
+
getValueProps: transform === null || transform === void 0 ? void 0 : transform.getValueProps,
|
154
|
+
fieldProps: _objectSpread(_objectSpread(_objectSpread({}, column === null || column === void 0 ? void 0 : column.fieldProps), reactiveProps === null || reactiveProps === void 0 ? void 0 : reactiveProps.fieldProps), {}, {
|
155
|
+
onChange: handleChange,
|
156
|
+
onBlur: handleBlur,
|
157
|
+
value: value === null || value === void 0 ? void 0 : value[index]
|
158
|
+
})
|
159
|
+
});
|
160
|
+
});
|
161
|
+
};
|
@@ -7,7 +7,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
import React from 'react';
|
8
8
|
import { omit } from 'lodash';
|
9
9
|
import classnames from 'classnames';
|
10
|
-
import { insertSeparator
|
10
|
+
import { insertSeparator } from './utils';
|
11
|
+
import { useTransformColumns } from './hooks';
|
11
12
|
import ProForm from '../../../../ProForm';
|
12
13
|
import ComRender from './component/ComRender';
|
13
14
|
/**
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
|
3
3
|
import { FormInstance } from 'antd';
|
4
|
-
import type { GroupColumnType,
|
4
|
+
import type { GroupColumnType, SpaceType } from './propsType';
|
5
5
|
import type { ProFormColumnType, ReactiveFunction } from '../../render/propsType';
|
6
6
|
export type EventArgs = any[];
|
7
7
|
/**
|
@@ -50,19 +50,6 @@ type ValueTypeGetterParams = Pick<ProFormColumnType, 'valueType' | 'switchValue'
|
|
50
50
|
export declare const getValueTypeTrans: (params: ValueTypeGetterParams) => any;
|
51
51
|
/** 执行所有中间件 返回处理后的值 */
|
52
52
|
export declare const getValueMiddleware: (value: any, callbacks?: any[]) => any;
|
53
|
-
|
54
|
-
|
55
|
-
name?: NamePath;
|
56
|
-
names?: NamePath[];
|
57
|
-
value?: any[];
|
58
|
-
onChange: any;
|
59
|
-
namePath?: InternalNamePath;
|
60
|
-
form: FormInstance;
|
61
|
-
index?: number;
|
62
|
-
formDisabled?: boolean;
|
63
|
-
desensitizationKey?: string;
|
64
|
-
groupProps: GroupType;
|
65
|
-
}
|
66
|
-
/** 转换columns */
|
67
|
-
export declare const useTransformColumns: (params: ColumnsTransformerParams) => any[];
|
53
|
+
/** 获取中间件处理后的value */
|
54
|
+
export declare const valueFromEventWrapper: (column: any, args: any) => any;
|
68
55
|
export {};
|
@@ -1,16 +1,11 @@
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
3
2
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
4
3
|
import "antd/es/button/style";
|
5
4
|
import _Button from "antd/es/button";
|
6
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
7
|
-
|
8
|
-
import { useRef } from 'react';
|
9
|
-
import { cloneDeep, isEqual, isFunction } from 'lodash';
|
6
|
+
import { isFunction } from 'lodash';
|
10
7
|
import { validate } from '@zat-design/utils';
|
11
8
|
import valueTypeMap from '../../../utils/valueType';
|
12
|
-
import { useDeepCompareMemo } from '../../../utils/useDeepCompareMemo';
|
13
|
-
import { difference } from '../../../../ProEditTable/utils/tools';
|
14
9
|
/**
|
15
10
|
* 插入间隔符
|
16
11
|
* @param columns 表单配置数组
|
@@ -177,7 +172,7 @@ export var getValueMiddleware = function getValueMiddleware(value) {
|
|
177
172
|
}, value);
|
178
173
|
};
|
179
174
|
/** 获取中间件处理后的value */
|
180
|
-
var valueFromEventWrapper = function valueFromEventWrapper(column, args) {
|
175
|
+
export var valueFromEventWrapper = function valueFromEventWrapper(column, args) {
|
181
176
|
var getValueFromEvent = column.getValueFromEvent,
|
182
177
|
_column$valuePropName = column.valuePropName,
|
183
178
|
valuePropName = _column$valuePropName === void 0 ? 'value' : _column$valuePropName,
|
@@ -193,157 +188,4 @@ var valueFromEventWrapper = function valueFromEventWrapper(column, args) {
|
|
193
188
|
if (trim) list.push(getTrim);
|
194
189
|
if (upperCase) list.push(getUpperCase);
|
195
190
|
return getValueMiddleware(newValue, list);
|
196
|
-
};
|
197
|
-
/** 转换columns */
|
198
|
-
export var useTransformColumns = function useTransformColumns(params) {
|
199
|
-
var form = params.form,
|
200
|
-
columns = params.columns,
|
201
|
-
name = params.name,
|
202
|
-
names = params.names,
|
203
|
-
outerIndex = params.index,
|
204
|
-
namePath = params.namePath,
|
205
|
-
value = params.value,
|
206
|
-
internalChange = params.onChange,
|
207
|
-
groupProps = params.groupProps,
|
208
|
-
formDisabled = params.formDisabled,
|
209
|
-
desensitizationKey = params.desensitizationKey;
|
210
|
-
var timerRef = useRef([]);
|
211
|
-
return columns === null || columns === void 0 ? void 0 : columns.flatMap(function (column, index) {
|
212
|
-
var type = column.type,
|
213
|
-
valueType = column.valueType,
|
214
|
-
switchValue = column.switchValue,
|
215
|
-
toISOString = column.toISOString,
|
216
|
-
toCSTString = column.toCSTString,
|
217
|
-
fieldProps = column.fieldProps,
|
218
|
-
normalize = column.normalize,
|
219
|
-
disabled = column.disabled,
|
220
|
-
show = column.show,
|
221
|
-
component = column.component,
|
222
|
-
clearNotShow = column.clearNotShow,
|
223
|
-
desensitization = column.desensitization;
|
224
|
-
var _ref = fieldProps || {},
|
225
|
-
mode = _ref.mode,
|
226
|
-
onChange = _ref.onChange,
|
227
|
-
onFieldChange = _ref.onFieldChange,
|
228
|
-
comDisabled = _ref.disabled,
|
229
|
-
onBlur = _ref.onBlur;
|
230
|
-
var _disabled = disabled || comDisabled;
|
231
|
-
var columnName = names ? names[index] : [].concat(name, index);
|
232
|
-
// 响应式字段改变后的回调
|
233
|
-
var changedCallback = function changedCallback(lastDependency, current) {
|
234
|
-
// 清值防抖 多次刷新时以最后一次为准
|
235
|
-
if (clearNotShow !== false && names) {
|
236
|
-
if ((current === null || current === void 0 ? void 0 : current.show) === false) {
|
237
|
-
clearInterval(timerRef.current[index]);
|
238
|
-
timerRef.current[index] = setTimeout(function () {
|
239
|
-
if (names) {
|
240
|
-
form.resetFields([columnName]);
|
241
|
-
}
|
242
|
-
if (!names && (value === null || value === void 0 ? void 0 : value.length)) {
|
243
|
-
value[index] = null;
|
244
|
-
form.setFieldValue(columnName, _toConsumableArray(value));
|
245
|
-
}
|
246
|
-
}, 200);
|
247
|
-
} else {
|
248
|
-
clearInterval(timerRef.current[index]);
|
249
|
-
}
|
250
|
-
}
|
251
|
-
};
|
252
|
-
// 响应式字段
|
253
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
254
|
-
var reactiveProps = useDeepCompareMemo(function () {
|
255
|
-
return getReactiveProps({
|
256
|
-
form: form,
|
257
|
-
index: index,
|
258
|
-
type: type,
|
259
|
-
namePath: namePath,
|
260
|
-
disabled: _disabled,
|
261
|
-
show: show,
|
262
|
-
component: component,
|
263
|
-
fieldProps: fieldProps,
|
264
|
-
name: columnName,
|
265
|
-
desensitization: desensitization
|
266
|
-
});
|
267
|
-
}, changedCallback, [value, show, fieldProps, _disabled, columnName, type]);
|
268
|
-
if (reactiveProps.show === false) {
|
269
|
-
return [];
|
270
|
-
}
|
271
|
-
var transform = getValueTypeTrans({
|
272
|
-
type: type,
|
273
|
-
valueType: valueType,
|
274
|
-
switchValue: switchValue,
|
275
|
-
toISOString: toISOString,
|
276
|
-
toCSTString: toCSTString,
|
277
|
-
mode: mode
|
278
|
-
});
|
279
|
-
var newValue;
|
280
|
-
var handleChange = function handleChange() {
|
281
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
282
|
-
args[_key] = arguments[_key];
|
283
|
-
}
|
284
|
-
newValue = valueFromEventWrapper(column, args);
|
285
|
-
if (transform === null || transform === void 0 ? void 0 : transform.normalize) {
|
286
|
-
var _transform$normalize;
|
287
|
-
newValue = transform === null || transform === void 0 ? void 0 : (_transform$normalize = transform.normalize) === null || _transform$normalize === void 0 ? void 0 : _transform$normalize.call(transform, newValue);
|
288
|
-
} else if (normalize) {
|
289
|
-
// @ts-ignore
|
290
|
-
newValue = normalize === null || normalize === void 0 ? void 0 : normalize(newValue);
|
291
|
-
}
|
292
|
-
internalChange === null || internalChange === void 0 ? void 0 : internalChange(newValue, args[1], index);
|
293
|
-
var values = form.getFieldValue(namePath);
|
294
|
-
var originRow = (namePath === null || namePath === void 0 ? void 0 : namePath.length) ? cloneDeep(values) : undefined;
|
295
|
-
onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, args);
|
296
|
-
onFieldChange === null || onFieldChange === void 0 ? void 0 : onFieldChange(newValue, values, {
|
297
|
-
index: outerIndex,
|
298
|
-
namePath: namePath,
|
299
|
-
form: form,
|
300
|
-
option: args === null || args === void 0 ? void 0 : args[1]
|
301
|
-
});
|
302
|
-
// 如果是在可编辑表格或formList内部, 储存当前行的值, 并在变更后更新到表单里
|
303
|
-
if ((namePath === null || namePath === void 0 ? void 0 : namePath.length) && !isEqual(originRow, values)) {
|
304
|
-
var _Object$keys, _Object$keys$map;
|
305
|
-
form.setFieldValue(namePath, values);
|
306
|
-
var diff = difference(originRow, values) || {};
|
307
|
-
var validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
|
308
|
-
return [].concat(_toConsumableArray(namePath), [key]);
|
309
|
-
});
|
310
|
-
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
311
|
-
setTimeout(function () {
|
312
|
-
form.validateFields([name].concat(_toConsumableArray(validateFieldKeys)));
|
313
|
-
}, 100);
|
314
|
-
}
|
315
|
-
}
|
316
|
-
};
|
317
|
-
var handleBlur = function handleBlur() {
|
318
|
-
if (!onBlur) return;
|
319
|
-
var values = form.getFieldValue(namePath);
|
320
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
321
|
-
args[_key2] = arguments[_key2];
|
322
|
-
}
|
323
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur(args[0], values, {
|
324
|
-
index: outerIndex,
|
325
|
-
namePath: namePath,
|
326
|
-
form: form,
|
327
|
-
option: args === null || args === void 0 ? void 0 : args[1]
|
328
|
-
});
|
329
|
-
};
|
330
|
-
// 内外一个为true则为true
|
331
|
-
var getLastDisabled = function getLastDisabled() {
|
332
|
-
if (Array.isArray(groupProps.disabled)) {
|
333
|
-
return reactiveProps.disabled || groupProps.disabled[index];
|
334
|
-
}
|
335
|
-
return reactiveProps.disabled || groupProps.disabled;
|
336
|
-
};
|
337
|
-
return _objectSpread(_objectSpread(_objectSpread({}, column), {}, {
|
338
|
-
name: columnName
|
339
|
-
}, reactiveProps), {}, {
|
340
|
-
disabled: getLastDisabled(),
|
341
|
-
getValueProps: transform === null || transform === void 0 ? void 0 : transform.getValueProps,
|
342
|
-
fieldProps: _objectSpread(_objectSpread(_objectSpread({}, column === null || column === void 0 ? void 0 : column.fieldProps), reactiveProps === null || reactiveProps === void 0 ? void 0 : reactiveProps.fieldProps), {}, {
|
343
|
-
onChange: handleChange,
|
344
|
-
onBlur: handleBlur,
|
345
|
-
value: value === null || value === void 0 ? void 0 : value[index]
|
346
|
-
})
|
347
|
-
});
|
348
|
-
});
|
349
191
|
};
|
@@ -4,8 +4,6 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
4
|
import "antd/es/message/style";
|
5
5
|
import _message from "antd/es/message";
|
6
6
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
7
|
-
import "antd/es/form/style";
|
8
|
-
import _Form from "antd/es/form";
|
9
7
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
10
8
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
11
9
|
var _excluded = ["page", "filters", "sorter"];
|
@@ -34,6 +32,7 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
34
32
|
total: 0,
|
35
33
|
selectedRecords: [],
|
36
34
|
selectedRowKeys: [],
|
35
|
+
searchValues: undefined,
|
37
36
|
extraFilter: {
|
38
37
|
filters: undefined,
|
39
38
|
sorter: undefined
|
@@ -46,6 +45,7 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
46
45
|
total = _useSetState2$.total,
|
47
46
|
selectedRecords = _useSetState2$.selectedRecords,
|
48
47
|
selectedRowKeys = _useSetState2$.selectedRowKeys,
|
48
|
+
searchValues = _useSetState2$.searchValues,
|
49
49
|
extraFilter = _useSetState2$.extraFilter,
|
50
50
|
allSelected = _useSetState2$.allSelected,
|
51
51
|
setState = _useSetState2[1];
|
@@ -66,9 +66,6 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
66
66
|
transformParams = _useDefaultOptions.transformParams,
|
67
67
|
transformResponse = _useDefaultOptions.transformResponse,
|
68
68
|
disabled = _useDefaultOptions.disabled;
|
69
|
-
// 搜索表单里的值
|
70
|
-
var _searchValues = _Form.useWatch([], form);
|
71
|
-
var searchValues = removeEmptyKeys(_searchValues);
|
72
69
|
var _ref = useRequestOptions || {},
|
73
70
|
defaultParams = _ref.defaultParams;
|
74
71
|
var defaultParam = Array.isArray(defaultParams) ? defaultParams === null || defaultParams === void 0 ? void 0 : defaultParams[0] : defaultParams || {};
|
@@ -193,6 +190,7 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
193
190
|
}, []);
|
194
191
|
// 分页变更
|
195
192
|
var handlePageChange = useCallback(function (current, pageSize) {
|
193
|
+
var _form$getFieldsValue;
|
196
194
|
var page = {
|
197
195
|
pageNum: current,
|
198
196
|
pageSize: pageSize
|
@@ -204,9 +202,10 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
204
202
|
selectedRowKeys: []
|
205
203
|
});
|
206
204
|
}
|
207
|
-
|
205
|
+
var newValues = (_form$getFieldsValue = form.getFieldsValue()) !== null && _form$getFieldsValue !== void 0 ? _form$getFieldsValue : {};
|
206
|
+
run(getTransformParams(_objectSpread(_objectSpread(_objectSpread({
|
208
207
|
page: page
|
209
|
-
}, searchValues), extraFilter)));
|
208
|
+
}, searchValues), newValues), extraFilter)));
|
210
209
|
}, [allSelected, searchValues, extraFilter, data, getTransformParams]);
|
211
210
|
var handleTableChange = useCallback(function (pagination, filters, sorter, extra) {
|
212
211
|
// 跳过分页改变,使用pagination的onChange
|
@@ -247,6 +246,7 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
247
246
|
if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) || isNonEmptyObject(_values) || !isEqual(previousSearchValues, _values)) {
|
248
247
|
previousSearchValues = _values;
|
249
248
|
setState({
|
249
|
+
searchValues: _values,
|
250
250
|
allSelected: false,
|
251
251
|
selectedRecords: [],
|
252
252
|
selectedRowKeys: []
|
@@ -258,6 +258,7 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
258
258
|
}, [extraFilter, page.pageSize, previousPage, getTransformParams]);
|
259
259
|
var resetParams = useCallback(function (page) {
|
260
260
|
setState({
|
261
|
+
searchValues: undefined,
|
261
262
|
allSelected: false,
|
262
263
|
selectedRecords: [],
|
263
264
|
selectedRowKeys: [],
|
@@ -735,6 +735,12 @@ export interface ProTableUseAntdTableType<I, R> {
|
|
735
735
|
* @default []
|
736
736
|
*/
|
737
737
|
selectedRowKeys: Key[];
|
738
|
+
/**
|
739
|
+
* 搜索值
|
740
|
+
* @description 当前表单的搜索条件
|
741
|
+
* @default undefined
|
742
|
+
*/
|
743
|
+
searchValues: I;
|
738
744
|
/**
|
739
745
|
* 额外过滤条件
|
740
746
|
* @description 表单之外的额外过滤条件
|
@@ -92,6 +92,9 @@ var ButtonRender = function ButtonRender(props) {
|
|
92
92
|
children: [_jsx(CloudUploadOutlined, {}), buttonText]
|
93
93
|
})), afterRender ? _jsx("div", {
|
94
94
|
className: "pro-upload-button-inner-right",
|
95
|
+
onClick: function onClick(e) {
|
96
|
+
return e.stopPropagation();
|
97
|
+
},
|
95
98
|
children: afterRender
|
96
99
|
}) : null]
|
97
100
|
})
|
@@ -79,17 +79,13 @@ var DndWrapper = function DndWrapper(_ref2) {
|
|
79
79
|
value = _ref2.value,
|
80
80
|
onChange = _ref2.onChange,
|
81
81
|
onDrag = _ref2.onDrag,
|
82
|
+
onDragEnd = _ref2.onDragEnd,
|
82
83
|
disabled = _ref2.disabled,
|
83
84
|
children = _ref2.children;
|
84
|
-
var
|
85
|
+
var onDragEndtInside = function onDragEndtInside(event) {
|
85
86
|
var active = event.active,
|
86
87
|
over = event.over;
|
87
88
|
if (active.id !== (over === null || over === void 0 ? void 0 : over.id)) {
|
88
|
-
if (onDrag) {
|
89
|
-
var nextList = onDrag(event, value);
|
90
|
-
onChange(nextList);
|
91
|
-
return;
|
92
|
-
}
|
93
89
|
var activeIndex = value.findIndex(function (i) {
|
94
90
|
return i.rowKey === active.id;
|
95
91
|
});
|
@@ -97,11 +93,16 @@ var DndWrapper = function DndWrapper(_ref2) {
|
|
97
93
|
return i.rowKey === (over === null || over === void 0 ? void 0 : over.id);
|
98
94
|
});
|
99
95
|
var nextValue = (0, _sortable.arrayMove)(value, activeIndex, overIndex);
|
96
|
+
if (onDrag || onDragEnd) {
|
97
|
+
var nextList = onDragEnd ? onDragEnd(event, value, nextValue) : onDrag(event, value, nextValue);
|
98
|
+
onChange(nextList);
|
99
|
+
return;
|
100
|
+
}
|
100
101
|
onChange(nextValue);
|
101
102
|
}
|
102
103
|
};
|
103
104
|
return draggable && !disabled ? (0, _jsxRuntime.jsx)(_core.DndContext, {
|
104
|
-
onDragEnd:
|
105
|
+
onDragEnd: onDragEndtInside,
|
105
106
|
children: (0, _jsxRuntime.jsx)(_sortable.SortableContext, {
|
106
107
|
items: (value === null || value === void 0 ? void 0 : (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.rowKey) ? value.map(function (i) {
|
107
108
|
return i.rowKey;
|
@@ -137,11 +138,13 @@ var DraggableTable = function DraggableTable(_ref3) {
|
|
137
138
|
handlePageChange = tableProps.handlePageChange;
|
138
139
|
var onChange = draggableProps.onChange,
|
139
140
|
onDrag = draggableProps.onDrag,
|
140
|
-
draggable = draggableProps.draggable
|
141
|
+
draggable = draggableProps.draggable,
|
142
|
+
onDragEnd = draggableProps.onDragEnd;
|
141
143
|
return (0, _jsxRuntime.jsxs)(DndWrapper, {
|
142
144
|
value: value,
|
143
145
|
onChange: onChange,
|
144
146
|
onDrag: onDrag,
|
147
|
+
onDragEnd: onDragEnd,
|
145
148
|
disabled: disabled,
|
146
149
|
draggable: draggable,
|
147
150
|
children: [headerRender ? (0, _jsxRuntime.jsx)("div", {
|
@@ -26,12 +26,13 @@ var _ProForm = _interopRequireDefault(require("../ProForm"));
|
|
26
26
|
var _empty = _interopRequireDefault(require("../assets/empty.png"));
|
27
27
|
var _locale = _interopRequireWildcard(require("../locale"));
|
28
28
|
var _RcTable = require("./components/RcTable");
|
29
|
-
var _excluded = ["value", "onChange", "onDrag", "className", "columns", "type", "mode", "stripe", "draggable", "virtual", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "toolbarSticky", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "rowKey", "rowDisabled", "rowDraggable", "footerRender", "scroll", "actionDirection", "diffConfig"];
|
29
|
+
var _excluded = ["value", "onChange", "onDrag", "onDragEnd", "className", "columns", "type", "mode", "stripe", "draggable", "virtual", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "toolbarSticky", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "rowKey", "rowDisabled", "rowDraggable", "footerRender", "scroll", "actionDirection", "diffConfig"];
|
30
30
|
var ProEditTable = function ProEditTable(_ref, ref) {
|
31
31
|
var _resetProps$id, _resetProps$id$split, _themeConfig$data2, _resetProps$otherProp;
|
32
32
|
var value = _ref.value,
|
33
33
|
onChange = _ref.onChange,
|
34
34
|
onDrag = _ref.onDrag,
|
35
|
+
onDragEnd = _ref.onDragEnd,
|
35
36
|
className = _ref.className,
|
36
37
|
columns = _ref.columns,
|
37
38
|
type = _ref.type,
|
@@ -408,6 +409,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
408
409
|
draggableProps: {
|
409
410
|
onChange: onChange,
|
410
411
|
onDrag: onDrag,
|
412
|
+
onDragEnd: onDragEnd,
|
411
413
|
draggable: draggable
|
412
414
|
},
|
413
415
|
tableProps: {
|
@@ -377,8 +377,18 @@ export interface ProEditTableProps<T = any> extends Omit<TableProps<T>, 'onChang
|
|
377
377
|
rowDraggable?: (record?: T) => string | boolean;
|
378
378
|
/**
|
379
379
|
* 拖拽事件处理
|
380
|
+
* @param event 拖拽事件
|
381
|
+
* @param dataSource 当前数据源
|
382
|
+
* @param nextDataSource 拖拽后的数据源
|
380
383
|
*/
|
381
|
-
onDrag?: (event: DragEndEvent, dataSource: T[]) => T[];
|
384
|
+
onDrag?: (event: DragEndEvent, dataSource: T[], nextDataSource: T[]) => T[];
|
385
|
+
/**
|
386
|
+
* 拖拽结束事件处理
|
387
|
+
* @param event 拖拽事件
|
388
|
+
* @param dataSource 当前数据源
|
389
|
+
* @param nextDataSource 拖拽后的数据源
|
390
|
+
*/
|
391
|
+
onDragEnd?: (event: DragEndEvent, dataSource: T[], nextDataSource: T[]) => T[];
|
382
392
|
/**
|
383
393
|
* 引用对象
|
384
394
|
*/
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
|
2
|
+
import { FormInstance } from 'antd';
|
3
|
+
import type { GroupColumnType, GroupType } from '../propsType';
|
4
|
+
export type EventArgs = any[];
|
5
|
+
interface ColumnsTransformerParams {
|
6
|
+
columns: GroupColumnType[];
|
7
|
+
name?: NamePath;
|
8
|
+
names?: NamePath[];
|
9
|
+
value?: any[];
|
10
|
+
onChange: any;
|
11
|
+
namePath?: InternalNamePath;
|
12
|
+
form: FormInstance;
|
13
|
+
index?: number;
|
14
|
+
formDisabled?: boolean;
|
15
|
+
desensitizationKey?: string;
|
16
|
+
groupProps: GroupType;
|
17
|
+
}
|
18
|
+
/** 转换columns */
|
19
|
+
export declare const useTransformColumns: (params: ColumnsTransformerParams) => any[];
|
20
|
+
export {};
|
@@ -0,0 +1,169 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports.useTransformColumns = void 0;
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
10
|
+
var _react = require("react");
|
11
|
+
var _lodash = require("lodash");
|
12
|
+
var _useDeepCompareMemo = require("../../../../utils/useDeepCompareMemo");
|
13
|
+
var _tools = require("../../../../../ProEditTable/utils/tools");
|
14
|
+
var _utils = require("../utils");
|
15
|
+
/* eslint-disable no-lonely-if */
|
16
|
+
|
17
|
+
/** 转换columns */
|
18
|
+
var useTransformColumns = exports.useTransformColumns = function useTransformColumns(params) {
|
19
|
+
var form = params.form,
|
20
|
+
columns = params.columns,
|
21
|
+
name = params.name,
|
22
|
+
names = params.names,
|
23
|
+
outerIndex = params.index,
|
24
|
+
namePath = params.namePath,
|
25
|
+
value = params.value,
|
26
|
+
internalChange = params.onChange,
|
27
|
+
groupProps = params.groupProps,
|
28
|
+
formDisabled = params.formDisabled,
|
29
|
+
desensitizationKey = params.desensitizationKey;
|
30
|
+
var timerRef = (0, _react.useRef)([]);
|
31
|
+
return columns === null || columns === void 0 ? void 0 : columns.flatMap(function (column, index) {
|
32
|
+
var type = column.type,
|
33
|
+
valueType = column.valueType,
|
34
|
+
switchValue = column.switchValue,
|
35
|
+
toISOString = column.toISOString,
|
36
|
+
toCSTString = column.toCSTString,
|
37
|
+
fieldProps = column.fieldProps,
|
38
|
+
normalize = column.normalize,
|
39
|
+
disabled = column.disabled,
|
40
|
+
show = column.show,
|
41
|
+
component = column.component,
|
42
|
+
clearNotShow = column.clearNotShow,
|
43
|
+
desensitization = column.desensitization;
|
44
|
+
var _ref = fieldProps || {},
|
45
|
+
mode = _ref.mode,
|
46
|
+
onChange = _ref.onChange,
|
47
|
+
onFieldChange = _ref.onFieldChange,
|
48
|
+
comDisabled = _ref.disabled,
|
49
|
+
onBlur = _ref.onBlur;
|
50
|
+
var _disabled = disabled || comDisabled;
|
51
|
+
var columnName = names ? names[index] : [].concat(name, index);
|
52
|
+
// 响应式字段改变后的回调
|
53
|
+
var changedCallback = function changedCallback(lastDependency, current) {
|
54
|
+
// 清值防抖 多次刷新时以最后一次为准
|
55
|
+
if (clearNotShow !== false && names) {
|
56
|
+
if ((current === null || current === void 0 ? void 0 : current.show) === false) {
|
57
|
+
clearInterval(timerRef.current[index]);
|
58
|
+
timerRef.current[index] = setTimeout(function () {
|
59
|
+
if (names) {
|
60
|
+
form.resetFields([columnName]);
|
61
|
+
}
|
62
|
+
if (!names && (value === null || value === void 0 ? void 0 : value.length)) {
|
63
|
+
value[index] = null;
|
64
|
+
form.setFieldValue(columnName, (0, _toConsumableArray2.default)(value));
|
65
|
+
}
|
66
|
+
}, 200);
|
67
|
+
} else {
|
68
|
+
clearInterval(timerRef.current[index]);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
};
|
72
|
+
// 响应式字段
|
73
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
74
|
+
var reactiveProps = (0, _useDeepCompareMemo.useDeepCompareMemo)(function () {
|
75
|
+
return (0, _utils.getReactiveProps)({
|
76
|
+
form: form,
|
77
|
+
index: index,
|
78
|
+
type: type,
|
79
|
+
namePath: namePath,
|
80
|
+
disabled: _disabled,
|
81
|
+
show: show,
|
82
|
+
component: component,
|
83
|
+
fieldProps: fieldProps,
|
84
|
+
name: columnName,
|
85
|
+
desensitization: desensitization
|
86
|
+
});
|
87
|
+
}, changedCallback, [value, show, fieldProps, _disabled, columnName, type]);
|
88
|
+
if (reactiveProps.show === false) {
|
89
|
+
return [];
|
90
|
+
}
|
91
|
+
var transform = (0, _utils.getValueTypeTrans)({
|
92
|
+
type: type,
|
93
|
+
valueType: valueType,
|
94
|
+
switchValue: switchValue,
|
95
|
+
toISOString: toISOString,
|
96
|
+
toCSTString: toCSTString,
|
97
|
+
mode: mode
|
98
|
+
});
|
99
|
+
var newValue;
|
100
|
+
var handleChange = function handleChange() {
|
101
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
102
|
+
args[_key] = arguments[_key];
|
103
|
+
}
|
104
|
+
newValue = (0, _utils.valueFromEventWrapper)(column, args);
|
105
|
+
if (transform === null || transform === void 0 ? void 0 : transform.normalize) {
|
106
|
+
var _transform$normalize;
|
107
|
+
newValue = transform === null || transform === void 0 ? void 0 : (_transform$normalize = transform.normalize) === null || _transform$normalize === void 0 ? void 0 : _transform$normalize.call(transform, newValue);
|
108
|
+
} else if (normalize) {
|
109
|
+
// @ts-ignore
|
110
|
+
newValue = normalize === null || normalize === void 0 ? void 0 : normalize(newValue);
|
111
|
+
}
|
112
|
+
internalChange === null || internalChange === void 0 ? void 0 : internalChange(newValue, args[1], index);
|
113
|
+
var values = form.getFieldValue(namePath);
|
114
|
+
var originRow = (namePath === null || namePath === void 0 ? void 0 : namePath.length) ? (0, _lodash.cloneDeep)(values) : undefined;
|
115
|
+
onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, args);
|
116
|
+
onFieldChange === null || onFieldChange === void 0 ? void 0 : onFieldChange(newValue, values, {
|
117
|
+
index: outerIndex,
|
118
|
+
namePath: namePath,
|
119
|
+
form: form,
|
120
|
+
option: args === null || args === void 0 ? void 0 : args[1]
|
121
|
+
});
|
122
|
+
// 如果是在可编辑表格或formList内部, 储存当前行的值, 并在变更后更新到表单里
|
123
|
+
if ((namePath === null || namePath === void 0 ? void 0 : namePath.length) && !(0, _lodash.isEqual)(originRow, values)) {
|
124
|
+
var _Object$keys, _Object$keys$map;
|
125
|
+
form.setFieldValue(namePath, values);
|
126
|
+
var diff = (0, _tools.difference)(originRow, values) || {};
|
127
|
+
var validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
|
128
|
+
return [].concat((0, _toConsumableArray2.default)(namePath), [key]);
|
129
|
+
});
|
130
|
+
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
131
|
+
setTimeout(function () {
|
132
|
+
form.validateFields([name].concat((0, _toConsumableArray2.default)(validateFieldKeys)));
|
133
|
+
}, 100);
|
134
|
+
}
|
135
|
+
}
|
136
|
+
};
|
137
|
+
var handleBlur = function handleBlur() {
|
138
|
+
if (!onBlur) return;
|
139
|
+
var values = form.getFieldValue(namePath);
|
140
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
141
|
+
args[_key2] = arguments[_key2];
|
142
|
+
}
|
143
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(args[0], values, {
|
144
|
+
index: outerIndex,
|
145
|
+
namePath: namePath,
|
146
|
+
form: form,
|
147
|
+
option: args === null || args === void 0 ? void 0 : args[1]
|
148
|
+
});
|
149
|
+
};
|
150
|
+
// 内外一个为true则为true
|
151
|
+
var getLastDisabled = function getLastDisabled() {
|
152
|
+
if (Array.isArray(groupProps.disabled)) {
|
153
|
+
return reactiveProps.disabled || groupProps.disabled[index];
|
154
|
+
}
|
155
|
+
return reactiveProps.disabled || groupProps.disabled;
|
156
|
+
};
|
157
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, column), {}, {
|
158
|
+
name: columnName
|
159
|
+
}, reactiveProps), {}, {
|
160
|
+
disabled: getLastDisabled(),
|
161
|
+
getValueProps: transform === null || transform === void 0 ? void 0 : transform.getValueProps,
|
162
|
+
fieldProps: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, column === null || column === void 0 ? void 0 : column.fieldProps), reactiveProps === null || reactiveProps === void 0 ? void 0 : reactiveProps.fieldProps), {}, {
|
163
|
+
onChange: handleChange,
|
164
|
+
onBlur: handleBlur,
|
165
|
+
value: value === null || value === void 0 ? void 0 : value[index]
|
166
|
+
})
|
167
|
+
});
|
168
|
+
});
|
169
|
+
};
|
@@ -14,6 +14,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
14
14
|
var _lodash = require("lodash");
|
15
15
|
var _classnames2 = _interopRequireDefault(require("classnames"));
|
16
16
|
var _utils = require("./utils");
|
17
|
+
var _hooks = require("./hooks");
|
17
18
|
var _ProForm = _interopRequireDefault(require("../../../../ProForm"));
|
18
19
|
var _ComRender = _interopRequireDefault(require("./component/ComRender"));
|
19
20
|
/**
|
@@ -52,7 +53,7 @@ var Group = function Group(props) {
|
|
52
53
|
_option.current[index] = option;
|
53
54
|
onChange(_value, _option.current);
|
54
55
|
};
|
55
|
-
var columnsProps = (0,
|
56
|
+
var columnsProps = (0, _hooks.useTransformColumns)({
|
56
57
|
columns: children,
|
57
58
|
name: name,
|
58
59
|
names: names,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
|
3
3
|
import { FormInstance } from 'antd';
|
4
|
-
import type { GroupColumnType,
|
4
|
+
import type { GroupColumnType, SpaceType } from './propsType';
|
5
5
|
import type { ProFormColumnType, ReactiveFunction } from '../../render/propsType';
|
6
6
|
export type EventArgs = any[];
|
7
7
|
/**
|
@@ -50,19 +50,6 @@ type ValueTypeGetterParams = Pick<ProFormColumnType, 'valueType' | 'switchValue'
|
|
50
50
|
export declare const getValueTypeTrans: (params: ValueTypeGetterParams) => any;
|
51
51
|
/** 执行所有中间件 返回处理后的值 */
|
52
52
|
export declare const getValueMiddleware: (value: any, callbacks?: any[]) => any;
|
53
|
-
|
54
|
-
|
55
|
-
name?: NamePath;
|
56
|
-
names?: NamePath[];
|
57
|
-
value?: any[];
|
58
|
-
onChange: any;
|
59
|
-
namePath?: InternalNamePath;
|
60
|
-
form: FormInstance;
|
61
|
-
index?: number;
|
62
|
-
formDisabled?: boolean;
|
63
|
-
desensitizationKey?: string;
|
64
|
-
groupProps: GroupType;
|
65
|
-
}
|
66
|
-
/** 转换columns */
|
67
|
-
export declare const useTransformColumns: (params: ColumnsTransformerParams) => any[];
|
53
|
+
/** 获取中间件处理后的value */
|
54
|
+
export declare const valueFromEventWrapper: (column: any, args: any) => any;
|
68
55
|
export {};
|
@@ -5,20 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
6
6
|
});
|
7
7
|
exports.defaultGetValueFromEvent = defaultGetValueFromEvent;
|
8
|
-
exports.
|
9
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
8
|
+
exports.valueFromEventWrapper = exports.transformNamesString = exports.isUpperCase = exports.insertSeparator = exports.getValueTypeTrans = exports.getValueMiddleware = exports.getReactiveProps = void 0;
|
10
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
11
10
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
12
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
13
|
-
var _react = require("react");
|
14
12
|
var _lodash = require("lodash");
|
15
13
|
var _utils = require("@zat-design/utils");
|
16
14
|
var _antd = require("antd");
|
17
15
|
var _valueType = _interopRequireDefault(require("../../../utils/valueType"));
|
18
|
-
var _useDeepCompareMemo = require("../../../utils/useDeepCompareMemo");
|
19
|
-
var _tools = require("../../../../ProEditTable/utils/tools");
|
20
|
-
/* eslint-disable no-lonely-if */
|
21
|
-
|
22
16
|
/**
|
23
17
|
* 插入间隔符
|
24
18
|
* @param columns 表单配置数组
|
@@ -185,7 +179,7 @@ var getValueMiddleware = exports.getValueMiddleware = function getValueMiddlewar
|
|
185
179
|
}, value);
|
186
180
|
};
|
187
181
|
/** 获取中间件处理后的value */
|
188
|
-
var valueFromEventWrapper = function valueFromEventWrapper(column, args) {
|
182
|
+
var valueFromEventWrapper = exports.valueFromEventWrapper = function valueFromEventWrapper(column, args) {
|
189
183
|
var getValueFromEvent = column.getValueFromEvent,
|
190
184
|
_column$valuePropName = column.valuePropName,
|
191
185
|
valuePropName = _column$valuePropName === void 0 ? 'value' : _column$valuePropName,
|
@@ -201,157 +195,4 @@ var valueFromEventWrapper = function valueFromEventWrapper(column, args) {
|
|
201
195
|
if (trim) list.push(getTrim);
|
202
196
|
if (upperCase) list.push(getUpperCase);
|
203
197
|
return getValueMiddleware(newValue, list);
|
204
|
-
};
|
205
|
-
/** 转换columns */
|
206
|
-
var useTransformColumns = exports.useTransformColumns = function useTransformColumns(params) {
|
207
|
-
var form = params.form,
|
208
|
-
columns = params.columns,
|
209
|
-
name = params.name,
|
210
|
-
names = params.names,
|
211
|
-
outerIndex = params.index,
|
212
|
-
namePath = params.namePath,
|
213
|
-
value = params.value,
|
214
|
-
internalChange = params.onChange,
|
215
|
-
groupProps = params.groupProps,
|
216
|
-
formDisabled = params.formDisabled,
|
217
|
-
desensitizationKey = params.desensitizationKey;
|
218
|
-
var timerRef = (0, _react.useRef)([]);
|
219
|
-
return columns === null || columns === void 0 ? void 0 : columns.flatMap(function (column, index) {
|
220
|
-
var type = column.type,
|
221
|
-
valueType = column.valueType,
|
222
|
-
switchValue = column.switchValue,
|
223
|
-
toISOString = column.toISOString,
|
224
|
-
toCSTString = column.toCSTString,
|
225
|
-
fieldProps = column.fieldProps,
|
226
|
-
normalize = column.normalize,
|
227
|
-
disabled = column.disabled,
|
228
|
-
show = column.show,
|
229
|
-
component = column.component,
|
230
|
-
clearNotShow = column.clearNotShow,
|
231
|
-
desensitization = column.desensitization;
|
232
|
-
var _ref = fieldProps || {},
|
233
|
-
mode = _ref.mode,
|
234
|
-
onChange = _ref.onChange,
|
235
|
-
onFieldChange = _ref.onFieldChange,
|
236
|
-
comDisabled = _ref.disabled,
|
237
|
-
onBlur = _ref.onBlur;
|
238
|
-
var _disabled = disabled || comDisabled;
|
239
|
-
var columnName = names ? names[index] : [].concat(name, index);
|
240
|
-
// 响应式字段改变后的回调
|
241
|
-
var changedCallback = function changedCallback(lastDependency, current) {
|
242
|
-
// 清值防抖 多次刷新时以最后一次为准
|
243
|
-
if (clearNotShow !== false && names) {
|
244
|
-
if ((current === null || current === void 0 ? void 0 : current.show) === false) {
|
245
|
-
clearInterval(timerRef.current[index]);
|
246
|
-
timerRef.current[index] = setTimeout(function () {
|
247
|
-
if (names) {
|
248
|
-
form.resetFields([columnName]);
|
249
|
-
}
|
250
|
-
if (!names && (value === null || value === void 0 ? void 0 : value.length)) {
|
251
|
-
value[index] = null;
|
252
|
-
form.setFieldValue(columnName, (0, _toConsumableArray2.default)(value));
|
253
|
-
}
|
254
|
-
}, 200);
|
255
|
-
} else {
|
256
|
-
clearInterval(timerRef.current[index]);
|
257
|
-
}
|
258
|
-
}
|
259
|
-
};
|
260
|
-
// 响应式字段
|
261
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
262
|
-
var reactiveProps = (0, _useDeepCompareMemo.useDeepCompareMemo)(function () {
|
263
|
-
return getReactiveProps({
|
264
|
-
form: form,
|
265
|
-
index: index,
|
266
|
-
type: type,
|
267
|
-
namePath: namePath,
|
268
|
-
disabled: _disabled,
|
269
|
-
show: show,
|
270
|
-
component: component,
|
271
|
-
fieldProps: fieldProps,
|
272
|
-
name: columnName,
|
273
|
-
desensitization: desensitization
|
274
|
-
});
|
275
|
-
}, changedCallback, [value, show, fieldProps, _disabled, columnName, type]);
|
276
|
-
if (reactiveProps.show === false) {
|
277
|
-
return [];
|
278
|
-
}
|
279
|
-
var transform = getValueTypeTrans({
|
280
|
-
type: type,
|
281
|
-
valueType: valueType,
|
282
|
-
switchValue: switchValue,
|
283
|
-
toISOString: toISOString,
|
284
|
-
toCSTString: toCSTString,
|
285
|
-
mode: mode
|
286
|
-
});
|
287
|
-
var newValue;
|
288
|
-
var handleChange = function handleChange() {
|
289
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
290
|
-
args[_key] = arguments[_key];
|
291
|
-
}
|
292
|
-
newValue = valueFromEventWrapper(column, args);
|
293
|
-
if (transform === null || transform === void 0 ? void 0 : transform.normalize) {
|
294
|
-
var _transform$normalize;
|
295
|
-
newValue = transform === null || transform === void 0 ? void 0 : (_transform$normalize = transform.normalize) === null || _transform$normalize === void 0 ? void 0 : _transform$normalize.call(transform, newValue);
|
296
|
-
} else if (normalize) {
|
297
|
-
// @ts-ignore
|
298
|
-
newValue = normalize === null || normalize === void 0 ? void 0 : normalize(newValue);
|
299
|
-
}
|
300
|
-
internalChange === null || internalChange === void 0 ? void 0 : internalChange(newValue, args[1], index);
|
301
|
-
var values = form.getFieldValue(namePath);
|
302
|
-
var originRow = (namePath === null || namePath === void 0 ? void 0 : namePath.length) ? (0, _lodash.cloneDeep)(values) : undefined;
|
303
|
-
onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, args);
|
304
|
-
onFieldChange === null || onFieldChange === void 0 ? void 0 : onFieldChange(newValue, values, {
|
305
|
-
index: outerIndex,
|
306
|
-
namePath: namePath,
|
307
|
-
form: form,
|
308
|
-
option: args === null || args === void 0 ? void 0 : args[1]
|
309
|
-
});
|
310
|
-
// 如果是在可编辑表格或formList内部, 储存当前行的值, 并在变更后更新到表单里
|
311
|
-
if ((namePath === null || namePath === void 0 ? void 0 : namePath.length) && !(0, _lodash.isEqual)(originRow, values)) {
|
312
|
-
var _Object$keys, _Object$keys$map;
|
313
|
-
form.setFieldValue(namePath, values);
|
314
|
-
var diff = (0, _tools.difference)(originRow, values) || {};
|
315
|
-
var validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
|
316
|
-
return [].concat((0, _toConsumableArray2.default)(namePath), [key]);
|
317
|
-
});
|
318
|
-
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
319
|
-
setTimeout(function () {
|
320
|
-
form.validateFields([name].concat((0, _toConsumableArray2.default)(validateFieldKeys)));
|
321
|
-
}, 100);
|
322
|
-
}
|
323
|
-
}
|
324
|
-
};
|
325
|
-
var handleBlur = function handleBlur() {
|
326
|
-
if (!onBlur) return;
|
327
|
-
var values = form.getFieldValue(namePath);
|
328
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
329
|
-
args[_key2] = arguments[_key2];
|
330
|
-
}
|
331
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur(args[0], values, {
|
332
|
-
index: outerIndex,
|
333
|
-
namePath: namePath,
|
334
|
-
form: form,
|
335
|
-
option: args === null || args === void 0 ? void 0 : args[1]
|
336
|
-
});
|
337
|
-
};
|
338
|
-
// 内外一个为true则为true
|
339
|
-
var getLastDisabled = function getLastDisabled() {
|
340
|
-
if (Array.isArray(groupProps.disabled)) {
|
341
|
-
return reactiveProps.disabled || groupProps.disabled[index];
|
342
|
-
}
|
343
|
-
return reactiveProps.disabled || groupProps.disabled;
|
344
|
-
};
|
345
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, column), {}, {
|
346
|
-
name: columnName
|
347
|
-
}, reactiveProps), {}, {
|
348
|
-
disabled: getLastDisabled(),
|
349
|
-
getValueProps: transform === null || transform === void 0 ? void 0 : transform.getValueProps,
|
350
|
-
fieldProps: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, column === null || column === void 0 ? void 0 : column.fieldProps), reactiveProps === null || reactiveProps === void 0 ? void 0 : reactiveProps.fieldProps), {}, {
|
351
|
-
onChange: handleChange,
|
352
|
-
onBlur: handleBlur,
|
353
|
-
value: value === null || value === void 0 ? void 0 : value[index]
|
354
|
-
})
|
355
|
-
});
|
356
|
-
});
|
357
198
|
};
|
@@ -39,6 +39,7 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
39
39
|
total: 0,
|
40
40
|
selectedRecords: [],
|
41
41
|
selectedRowKeys: [],
|
42
|
+
searchValues: undefined,
|
42
43
|
extraFilter: {
|
43
44
|
filters: undefined,
|
44
45
|
sorter: undefined
|
@@ -51,6 +52,7 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
51
52
|
total = _useSetState2$.total,
|
52
53
|
selectedRecords = _useSetState2$.selectedRecords,
|
53
54
|
selectedRowKeys = _useSetState2$.selectedRowKeys,
|
55
|
+
searchValues = _useSetState2$.searchValues,
|
54
56
|
extraFilter = _useSetState2$.extraFilter,
|
55
57
|
allSelected = _useSetState2$.allSelected,
|
56
58
|
setState = _useSetState2[1];
|
@@ -71,9 +73,6 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
71
73
|
transformParams = _useDefaultOptions.transformParams,
|
72
74
|
transformResponse = _useDefaultOptions.transformResponse,
|
73
75
|
disabled = _useDefaultOptions.disabled;
|
74
|
-
// 搜索表单里的值
|
75
|
-
var _searchValues = _antd.Form.useWatch([], form);
|
76
|
-
var searchValues = (0, _utils.removeEmptyKeys)(_searchValues);
|
77
76
|
var _ref = useRequestOptions || {},
|
78
77
|
defaultParams = _ref.defaultParams;
|
79
78
|
var defaultParam = Array.isArray(defaultParams) ? defaultParams === null || defaultParams === void 0 ? void 0 : defaultParams[0] : defaultParams || {};
|
@@ -198,6 +197,7 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
198
197
|
}, []);
|
199
198
|
// 分页变更
|
200
199
|
var handlePageChange = (0, _react.useCallback)(function (current, pageSize) {
|
200
|
+
var _form$getFieldsValue;
|
201
201
|
var page = {
|
202
202
|
pageNum: current,
|
203
203
|
pageSize: pageSize
|
@@ -209,9 +209,10 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
209
209
|
selectedRowKeys: []
|
210
210
|
});
|
211
211
|
}
|
212
|
-
|
212
|
+
var newValues = (_form$getFieldsValue = form.getFieldsValue()) !== null && _form$getFieldsValue !== void 0 ? _form$getFieldsValue : {};
|
213
|
+
run(getTransformParams((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({
|
213
214
|
page: page
|
214
|
-
}, searchValues), extraFilter)));
|
215
|
+
}, searchValues), newValues), extraFilter)));
|
215
216
|
}, [allSelected, searchValues, extraFilter, data, getTransformParams]);
|
216
217
|
var handleTableChange = (0, _react.useCallback)(function (pagination, filters, sorter, extra) {
|
217
218
|
// 跳过分页改变,使用pagination的onChange
|
@@ -252,6 +253,7 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
252
253
|
if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) || (0, _utils.isNonEmptyObject)(_values) || !(0, _lodash.isEqual)(previousSearchValues, _values)) {
|
253
254
|
previousSearchValues = _values;
|
254
255
|
setState({
|
256
|
+
searchValues: _values,
|
255
257
|
allSelected: false,
|
256
258
|
selectedRecords: [],
|
257
259
|
selectedRowKeys: []
|
@@ -263,6 +265,7 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
263
265
|
}, [extraFilter, page.pageSize, previousPage, getTransformParams]);
|
264
266
|
var resetParams = (0, _react.useCallback)(function (page) {
|
265
267
|
setState({
|
268
|
+
searchValues: undefined,
|
266
269
|
allSelected: false,
|
267
270
|
selectedRecords: [],
|
268
271
|
selectedRowKeys: [],
|
@@ -735,6 +735,12 @@ export interface ProTableUseAntdTableType<I, R> {
|
|
735
735
|
* @default []
|
736
736
|
*/
|
737
737
|
selectedRowKeys: Key[];
|
738
|
+
/**
|
739
|
+
* 搜索值
|
740
|
+
* @description 当前表单的搜索条件
|
741
|
+
* @default undefined
|
742
|
+
*/
|
743
|
+
searchValues: I;
|
738
744
|
/**
|
739
745
|
* 额外过滤条件
|
740
746
|
* @description 表单之外的额外过滤条件
|
@@ -96,6 +96,9 @@ var ButtonRender = function ButtonRender(props) {
|
|
96
96
|
children: [(0, _jsxRuntime.jsx)(_icons.CloudUploadOutlined, {}), buttonText]
|
97
97
|
})), afterRender ? (0, _jsxRuntime.jsx)("div", {
|
98
98
|
className: "pro-upload-button-inner-right",
|
99
|
+
onClick: function onClick(e) {
|
100
|
+
return e.stopPropagation();
|
101
|
+
},
|
99
102
|
children: afterRender
|
100
103
|
}) : null]
|
101
104
|
})
|