@zat-design/sisyphus-react 3.11.6 → 3.11.7
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/BaseTable.js +19 -9
- package/es/ProEditTable/index.js +24 -15
- package/es/ProEditTable/propsType.d.ts +0 -1
- package/es/ProEditTable/utils/tools.d.ts +2 -2
- package/es/ProEditTable/utils/tools.js +4 -11
- package/es/ProEditTable/utils/useEditTableError.d.ts +7 -0
- package/es/ProEditTable/utils/useEditTableError.js +81 -0
- package/es/ProEnum/hooks/useEnumRequest.js +2 -1
- package/es/ProEnum/index.js +2 -1
- package/es/ProForm/components/combination/ProModalSelect/hooks/useRequestList.js +2 -1
- package/es/ProForm/components/combination/ProModalSelect/index.js +49 -44
- package/es/ProForm/components/combination/ProRangeLimit/index.d.ts +4 -0
- package/es/ProForm/components/combination/ProRangeLimit/index.js +4 -2
- package/es/ProForm/components/combination/ProTimeLimit/index.d.ts +4 -0
- package/es/ProForm/components/combination/ProTimeLimit/index.js +4 -2
- package/es/ProForm/components/render/RenderFields.d.ts +2 -0
- package/es/ProForm/components/render/RenderFields.js +5 -2
- package/es/ProForm/components/render/propsType.d.ts +4 -0
- package/es/ProSelect/index.js +2 -1
- package/es/ProTable/hooks/useAntdTable.js +9 -2
- package/es/ProTabs/index.js +2 -1
- package/es/ProTree/components/ProTree.js +2 -1
- package/es/ProTree/components/ProTreeSelect/index.js +2 -1
- package/es/ProTreeModal/index.js +2 -1
- package/lib/ProEditTable/components/RcTable/BaseTable.js +19 -9
- package/lib/ProEditTable/index.js +24 -15
- package/lib/ProEditTable/propsType.d.ts +0 -1
- package/lib/ProEditTable/utils/tools.d.ts +2 -2
- package/lib/ProEditTable/utils/tools.js +4 -11
- package/lib/ProEditTable/utils/useEditTableError.d.ts +7 -0
- package/lib/ProEditTable/utils/useEditTableError.js +88 -0
- package/lib/ProEnum/hooks/useEnumRequest.js +2 -1
- package/lib/ProEnum/index.js +2 -1
- package/lib/ProForm/components/combination/ProModalSelect/hooks/useRequestList.js +2 -1
- package/lib/ProForm/components/combination/ProModalSelect/index.js +49 -44
- package/lib/ProForm/components/combination/ProRangeLimit/index.d.ts +4 -0
- package/lib/ProForm/components/combination/ProRangeLimit/index.js +4 -2
- package/lib/ProForm/components/combination/ProTimeLimit/index.d.ts +4 -0
- package/lib/ProForm/components/combination/ProTimeLimit/index.js +4 -2
- package/lib/ProForm/components/render/RenderFields.d.ts +2 -0
- package/lib/ProForm/components/render/RenderFields.js +5 -2
- package/lib/ProForm/components/render/propsType.d.ts +4 -0
- package/lib/ProSelect/index.js +2 -1
- package/lib/ProTable/hooks/useAntdTable.js +9 -2
- package/lib/ProTabs/index.js +2 -1
- package/lib/ProTree/components/ProTree.js +2 -1
- package/lib/ProTree/components/ProTreeSelect/index.js +2 -1
- package/lib/ProTreeModal/index.js +2 -1
- package/package.json +1 -1
@@ -3,10 +3,12 @@ import _Badge from "antd/es/badge";
|
|
3
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
4
4
|
import "antd/es/table/style";
|
5
5
|
import _Table from "antd/es/table";
|
6
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
6
7
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
7
8
|
var _excluded = ["tableProps"];
|
8
9
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
9
10
|
import { memo } from 'react';
|
11
|
+
import useEditTableError from '../../utils/useEditTableError';
|
10
12
|
var BaseTable = function BaseTable(_ref) {
|
11
13
|
var _value$;
|
12
14
|
var tableProps = _ref.tableProps,
|
@@ -29,8 +31,14 @@ var BaseTable = function BaseTable(_ref) {
|
|
29
31
|
page = tableProps.page,
|
30
32
|
formatMessage = tableProps.formatMessage,
|
31
33
|
locale = tableProps.locale,
|
32
|
-
handlePageChange = tableProps.handlePageChange
|
33
|
-
|
34
|
+
handlePageChange = tableProps.handlePageChange;
|
35
|
+
var _useEditTableError = useEditTableError({
|
36
|
+
containerNode: tableRef.current,
|
37
|
+
className: 'ant-form-item-explain-error',
|
38
|
+
isEnabled: pagination // 分页时启用
|
39
|
+
}),
|
40
|
+
_useEditTableError2 = _slicedToArray(_useEditTableError, 1),
|
41
|
+
errorLength = _useEditTableError2[0];
|
34
42
|
return _jsxs(_Fragment, {
|
35
43
|
children: [headerRender ? _jsx("div", {
|
36
44
|
className: "pro-edit-table-header",
|
@@ -51,10 +59,9 @@ var BaseTable = function BaseTable(_ref) {
|
|
51
59
|
};
|
52
60
|
}
|
53
61
|
}, resetProps), {}, {
|
54
|
-
pagination: pagination ? _objectSpread({
|
55
|
-
|
56
|
-
|
57
|
-
showSizeChanger: false,
|
62
|
+
pagination: pagination ? _objectSpread(_objectSpread({
|
63
|
+
showSizeChanger: true,
|
64
|
+
pageSizeOptions: [5, 10, 20, 50],
|
58
65
|
showQuickJumper: true,
|
59
66
|
total: value === null || value === void 0 ? void 0 : value.length,
|
60
67
|
showTotal: function showTotal(total) {
|
@@ -65,15 +72,18 @@ var BaseTable = function BaseTable(_ref) {
|
|
65
72
|
});
|
66
73
|
},
|
67
74
|
itemRender: function itemRender(index, type, originalElement) {
|
68
|
-
return type === 'page' && page.pageNum === index &&
|
75
|
+
return type === 'page' && page.pageNum === index && errorLength ? _jsxs("div", {
|
69
76
|
className: "pro-edit-table-pagination-item-badge",
|
70
77
|
children: [_jsx(_Badge, {
|
71
|
-
count:
|
78
|
+
count: errorLength
|
72
79
|
}), originalElement]
|
73
80
|
}) : originalElement;
|
74
81
|
},
|
75
82
|
onChange: handlePageChange
|
76
|
-
}, pagination)
|
83
|
+
}, pagination), {}, {
|
84
|
+
current: page.pageNum,
|
85
|
+
pageSize: page.pageSize
|
86
|
+
}) : false,
|
77
87
|
rowKey: "rowKey",
|
78
88
|
scroll: {
|
79
89
|
x: scroll === null || scroll === void 0 ? void 0 : scroll.x,
|
package/es/ProEditTable/index.js
CHANGED
@@ -99,8 +99,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
99
99
|
page: {
|
100
100
|
pageNum: 1,
|
101
101
|
pageSize: (pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) || 10
|
102
|
-
}
|
103
|
-
pageErrorNum: 0
|
102
|
+
}
|
104
103
|
}),
|
105
104
|
_useSetState2 = _slicedToArray(_useSetState, 2),
|
106
105
|
state = _useSetState2[0],
|
@@ -111,8 +110,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
111
110
|
virtualKey = state.virtualKey,
|
112
111
|
selectedRowKeys = state.selectedRowKeys,
|
113
112
|
selectedRows = state.selectedRows,
|
114
|
-
page = state.page
|
115
|
-
pageErrorNum = state.pageErrorNum;
|
113
|
+
page = state.page;
|
116
114
|
var virtualRowName = getNamePath(isArray(name) ? name : [name], virtualKey);
|
117
115
|
// 样式处理
|
118
116
|
var _className = classnames({
|
@@ -171,32 +169,44 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
171
169
|
case 0:
|
172
170
|
_context.prev = 0;
|
173
171
|
if (!pagination) {
|
172
|
+
_context.next = 8;
|
173
|
+
break;
|
174
|
+
}
|
175
|
+
if (!(pageSize !== page.pageSize)) {
|
174
176
|
_context.next = 5;
|
175
177
|
break;
|
176
178
|
}
|
177
|
-
|
179
|
+
setState({
|
180
|
+
page: {
|
181
|
+
pageNum: current,
|
182
|
+
pageSize: pageSize
|
183
|
+
}
|
184
|
+
});
|
185
|
+
return _context.abrupt("return");
|
186
|
+
case 5:
|
187
|
+
_context.next = 7;
|
178
188
|
return form.validateFields([name], {
|
179
189
|
recursive: true
|
180
190
|
});
|
181
|
-
case
|
191
|
+
case 7:
|
182
192
|
setState({
|
183
193
|
page: {
|
184
194
|
pageNum: current,
|
185
195
|
pageSize: pageSize !== null && pageSize !== void 0 ? pageSize : page.pageSize
|
186
196
|
}
|
187
197
|
});
|
188
|
-
case
|
189
|
-
_context.next =
|
198
|
+
case 8:
|
199
|
+
_context.next = 13;
|
190
200
|
break;
|
191
|
-
case
|
192
|
-
_context.prev =
|
201
|
+
case 10:
|
202
|
+
_context.prev = 10;
|
193
203
|
_context.t0 = _context["catch"](0);
|
194
204
|
handleScrollToError();
|
195
|
-
case
|
205
|
+
case 13:
|
196
206
|
case "end":
|
197
207
|
return _context.stop();
|
198
208
|
}
|
199
|
-
}, _callee, null, [[0,
|
209
|
+
}, _callee, null, [[0, 10]]);
|
200
210
|
}));
|
201
211
|
return function (_x, _x2) {
|
202
212
|
return _ref4.apply(this, arguments);
|
@@ -413,7 +423,6 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
413
423
|
page: page,
|
414
424
|
formatMessage: formatMessage,
|
415
425
|
locale: locale,
|
416
|
-
pageErrorNum: pageErrorNum,
|
417
426
|
handlePageChange: handlePageChange
|
418
427
|
}
|
419
428
|
})), !isView && (value === null || value === void 0 ? void 0 : value.length) ? toolbarSticky ? _jsx(_Affix, _objectSpread(_objectSpread({
|
@@ -439,9 +448,9 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
439
448
|
columns: columns,
|
440
449
|
page: page,
|
441
450
|
pagination: pagination,
|
442
|
-
setState: setState,
|
443
451
|
isView: isView,
|
444
|
-
disabled: disabled
|
452
|
+
disabled: disabled,
|
453
|
+
setState: setState
|
445
454
|
});
|
446
455
|
}
|
447
456
|
}) : null]
|
@@ -38,14 +38,14 @@ export declare function cloneDeepFilterNode(value: any): any;
|
|
38
38
|
/**
|
39
39
|
* 分页校验
|
40
40
|
*/
|
41
|
-
export declare const onPageCheck: ({ form, name, value, columns, page, pagination,
|
41
|
+
export declare const onPageCheck: ({ form, name, value, columns, setState, page, pagination, isView, disabled }: {
|
42
42
|
form: any;
|
43
43
|
name: any;
|
44
44
|
value: any;
|
45
45
|
columns: any;
|
46
|
+
setState: any;
|
46
47
|
page: any;
|
47
48
|
pagination: any;
|
48
|
-
setState: any;
|
49
49
|
isView: any;
|
50
50
|
disabled: any;
|
51
51
|
}) => Promise<void>;
|
@@ -339,13 +339,13 @@ var handleCheckCellValue = /*#__PURE__*/function () {
|
|
339
339
|
*/
|
340
340
|
export var onPageCheck = /*#__PURE__*/function () {
|
341
341
|
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref7) {
|
342
|
-
var form, name, value, columns, page, pagination,
|
342
|
+
var form, name, value, columns, setState, page, pagination, isView, disabled, pageNum, pageSize, pageArr, flag, errorNum, errorPageNum, _i, _pageArr, item, start, end, nextValues, _iterator2, _step2, record, _iterator3, _step3, column, result, nextState;
|
343
343
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
344
344
|
while (1) switch (_context2.prev = _context2.next) {
|
345
345
|
case 0:
|
346
|
-
form = _ref7.form, name = _ref7.name, value = _ref7.value, columns = _ref7.columns,
|
346
|
+
form = _ref7.form, name = _ref7.name, value = _ref7.value, columns = _ref7.columns, setState = _ref7.setState, page = _ref7.page, pagination = _ref7.pagination, isView = _ref7.isView, disabled = _ref7.disabled;
|
347
347
|
if (!(pagination && !isView && !disabled)) {
|
348
|
-
_context2.next =
|
348
|
+
_context2.next = 72;
|
349
349
|
break;
|
350
350
|
}
|
351
351
|
pageNum = page.pageNum, pageSize = page.pageSize;
|
@@ -447,7 +447,7 @@ export var onPageCheck = /*#__PURE__*/function () {
|
|
447
447
|
break;
|
448
448
|
case 60:
|
449
449
|
if (!(flag && errorNum > 0)) {
|
450
|
-
_context2.next =
|
450
|
+
_context2.next = 72;
|
451
451
|
break;
|
452
452
|
}
|
453
453
|
nextState = {
|
@@ -473,13 +473,6 @@ export var onPageCheck = /*#__PURE__*/function () {
|
|
473
473
|
_context2.t3 = _context2["catch"](64);
|
474
474
|
handleScrollToError();
|
475
475
|
case 72:
|
476
|
-
_context2.next = 75;
|
477
|
-
break;
|
478
|
-
case 74:
|
479
|
-
setState({
|
480
|
-
pageErrorNum: 0
|
481
|
-
});
|
482
|
-
case 75:
|
483
476
|
case "end":
|
484
477
|
return _context2.stop();
|
485
478
|
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
interface UseEditTableErrorProps {
|
2
|
+
containerNode: HTMLElement | null;
|
3
|
+
className: string;
|
4
|
+
isEnabled: boolean;
|
5
|
+
}
|
6
|
+
declare const useEditTableError: ({ containerNode, className, isEnabled }: UseEditTableErrorProps) => [number];
|
7
|
+
export default useEditTableError;
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
2
|
+
import { useState, useEffect } from 'react';
|
3
|
+
import { debounce } from 'lodash';
|
4
|
+
var useEditTableError = function useEditTableError(_ref) {
|
5
|
+
var containerNode = _ref.containerNode,
|
6
|
+
className = _ref.className,
|
7
|
+
isEnabled = _ref.isEnabled;
|
8
|
+
var _useState = useState(0),
|
9
|
+
_useState2 = _slicedToArray(_useState, 2),
|
10
|
+
errorLength = _useState2[0],
|
11
|
+
setErrorLength = _useState2[1];
|
12
|
+
useEffect(function () {
|
13
|
+
// 如果 isEnabled 为 false 或容器节点不存在,直接跳过监听
|
14
|
+
if (!isEnabled || !containerNode) {
|
15
|
+
return; // 如果未启用监听或容器节点不存在,直接返回
|
16
|
+
}
|
17
|
+
// 防抖处理:将 setErrorLength 函数进行防抖
|
18
|
+
var debouncedSetErrorLength = debounce(function (errorCount) {
|
19
|
+
setErrorLength(errorCount); // 更新错误数量
|
20
|
+
}, 300); // 300ms 后更新状态
|
21
|
+
var observer = new MutationObserver(function (mutations) {
|
22
|
+
mutations.forEach(function (mutation) {
|
23
|
+
// 只处理节点的 class 属性变化
|
24
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
|
25
|
+
var target = mutation.target;
|
26
|
+
// 检查目标节点是否包含指定的类
|
27
|
+
if (target.classList.contains(className)) {
|
28
|
+
// 查找所有包含 className 的节点
|
29
|
+
var errorNodes = containerNode.querySelectorAll(".".concat(className));
|
30
|
+
// debugger;
|
31
|
+
// 过滤这些节点,只保留那些类名完全为 `ant-form-item-explain-error` 的节点
|
32
|
+
var validErrorNodes = Array.from(errorNodes).filter(function (node) {
|
33
|
+
return node.classList.length === 1 && node.classList.contains('ant-form-item-explain-error');
|
34
|
+
});
|
35
|
+
if (errorLength === 0) {
|
36
|
+
debouncedSetErrorLength(0);
|
37
|
+
}
|
38
|
+
if (errorLength === validErrorNodes.length) {
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
// 使用防抖后的方法更新错误数量
|
42
|
+
debouncedSetErrorLength(validErrorNodes.length);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
// 监听子节点的添加或删除
|
46
|
+
if (mutation.type === 'childList') {
|
47
|
+
// 检查删除的节点是否包含指定的类名
|
48
|
+
mutation.removedNodes.forEach(function (removedNode) {
|
49
|
+
if (removedNode instanceof HTMLElement && removedNode.classList.contains('ant-table-row')) {
|
50
|
+
// 更新错误数量
|
51
|
+
var _errorNodes = containerNode.querySelectorAll(".".concat(className));
|
52
|
+
if (errorLength === 0) {
|
53
|
+
debouncedSetErrorLength(0);
|
54
|
+
}
|
55
|
+
if (errorLength === _errorNodes.length) {
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
// 使用防抖后的方法更新错误数量
|
59
|
+
debouncedSetErrorLength(_errorNodes.length);
|
60
|
+
}
|
61
|
+
});
|
62
|
+
}
|
63
|
+
});
|
64
|
+
});
|
65
|
+
var config = {
|
66
|
+
attributes: true,
|
67
|
+
subtree: true,
|
68
|
+
attributeFilter: ['class'],
|
69
|
+
childList: true
|
70
|
+
};
|
71
|
+
// 启动 MutationObserver
|
72
|
+
observer.observe(containerNode.querySelector('tbody'), config);
|
73
|
+
// 清理 MutationObserver 和防抖定时器
|
74
|
+
return function () {
|
75
|
+
observer.disconnect();
|
76
|
+
debouncedSetErrorLength.cancel(); // 取消防抖定时器
|
77
|
+
};
|
78
|
+
}, [containerNode, className, isEnabled]); // 当 isEnabled 改变时会重新启动或取消监听
|
79
|
+
return [errorLength];
|
80
|
+
};
|
81
|
+
export default useEditTableError;
|
@@ -256,11 +256,12 @@ var useEnumRequest = function useEnumRequest(props, dispatch) {
|
|
256
256
|
if (useRequest && (useRequest === null || useRequest === void 0 ? void 0 : useRequest.service)) {
|
257
257
|
var _ref4 = (useRequest === null || useRequest === void 0 ? void 0 : useRequest.options) || {},
|
258
258
|
defaultParams = _ref4.defaultParams;
|
259
|
+
var params = Array.isArray(defaultParams) ? defaultParams === null || defaultParams === void 0 ? void 0 : defaultParams[0] : defaultParams || {};
|
259
260
|
if (requestRefresh) {
|
260
261
|
window.localStorage.removeItem(cacheKey);
|
261
262
|
window.sessionStorage.removeItem(cacheKey);
|
262
263
|
}
|
263
|
-
enumRes.run(
|
264
|
+
enumRes.run(params);
|
264
265
|
// TODO 这段代码目前看起来是没啥用的、没起到作用
|
265
266
|
mergeData();
|
266
267
|
} else if (Object.keys(dataSource)) {
|
package/es/ProEnum/index.js
CHANGED
@@ -127,8 +127,9 @@ var ProEnum = function ProEnum(props) {
|
|
127
127
|
useDeepCompareEffect(function () {
|
128
128
|
var _ref3 = (useRequest === null || useRequest === void 0 ? void 0 : useRequest.options) || {},
|
129
129
|
defaultParams = _ref3.defaultParams;
|
130
|
+
var params = Array.isArray(defaultParams) ? defaultParams === null || defaultParams === void 0 ? void 0 : defaultParams[0] : defaultParams || {};
|
130
131
|
if (useRequest === null || useRequest === void 0 ? void 0 : useRequest.service) {
|
131
|
-
run(
|
132
|
+
run(params);
|
132
133
|
}
|
133
134
|
}, [useRequest === null || useRequest === void 0 ? void 0 : useRequest.options]);
|
134
135
|
var enumLists = useMemo(function () {
|
@@ -49,6 +49,7 @@ export function useRequestList(service, options, useRequestOptions) {
|
|
49
49
|
transformResponse = _useDefaultOptions.transformResponse;
|
50
50
|
var _ref2 = useRequestOptions || {},
|
51
51
|
defaultParams = _ref2.defaultParams;
|
52
|
+
var _defaultParams = Array.isArray(defaultParams) ? defaultParams === null || defaultParams === void 0 ? void 0 : defaultParams[0] : defaultParams || {};
|
52
53
|
// 搜索表单里的值
|
53
54
|
var _useState3 = useState(),
|
54
55
|
_useState4 = _slicedToArray(_useState3, 2),
|
@@ -56,7 +57,7 @@ export function useRequestList(service, options, useRequestOptions) {
|
|
56
57
|
setSearchValues = _useState4[1];
|
57
58
|
// 当次执行service的请求,包括page参数
|
58
59
|
var params = useMemo(function () {
|
59
|
-
var _condition = _objectSpread(_objectSpread({},
|
60
|
+
var _condition = _objectSpread(_objectSpread({}, _defaultParams), searchValues);
|
60
61
|
var tempParams = withPagination ? _objectSpread(_objectSpread({}, page), {}, {
|
61
62
|
queryBean: _condition !== null && _condition !== void 0 ? _condition : {}
|
62
63
|
}) : _condition;
|
@@ -34,7 +34,7 @@ import viewSvg from '../../../../assets/view.svg';
|
|
34
34
|
import useRequestList from './hooks/useRequestList';
|
35
35
|
import locale from '../../../../locale';
|
36
36
|
var ProModalSelect = function ProModalSelect(props, ref) {
|
37
|
-
var _useRequest$
|
37
|
+
var _useRequest$options, _useRequest$options2, _useRequest$options2$, _useRequest$options3, _formColumns$;
|
38
38
|
var value = props.value,
|
39
39
|
onChange = props.onChange,
|
40
40
|
disabled = props.disabled,
|
@@ -107,6 +107,8 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
107
107
|
rowSelection = _ref4.rowSelection,
|
108
108
|
restTableProps = _objectWithoutProperties(_ref4, _excluded3);
|
109
109
|
var preValue = useRef(value);
|
110
|
+
var defaultParams = Array.isArray(useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options = useRequest.options) === null || _useRequest$options === void 0 ? void 0 : _useRequest$options.defaultParams) ? useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options2 = useRequest.options) === null || _useRequest$options2 === void 0 ? void 0 : (_useRequest$options2$ = _useRequest$options2.defaultParams) === null || _useRequest$options2$ === void 0 ? void 0 : _useRequest$options2$[0] : (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options3 = useRequest.options) === null || _useRequest$options3 === void 0 ? void 0 : _useRequest$options3.defaultParams) || {};
|
111
|
+
var defaultParamsRef = useRef(defaultParams); // 缓存 defaultParams 的引用
|
110
112
|
var _useSetState = useSetState({
|
111
113
|
_value: value,
|
112
114
|
isInit: true,
|
@@ -316,7 +318,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
316
318
|
};
|
317
319
|
}();
|
318
320
|
var handleClose = function handleClose() {
|
319
|
-
var _useRequest$
|
321
|
+
var _useRequest$options4;
|
320
322
|
form.resetFields();
|
321
323
|
setState({
|
322
324
|
onOff: false,
|
@@ -324,7 +326,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
324
326
|
isInit: false
|
325
327
|
});
|
326
328
|
// 当设置manual为true时,清空当前弹框内已搜索出来的值
|
327
|
-
if (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$
|
329
|
+
if (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options4 = useRequest.options) === null || _useRequest$options4 === void 0 ? void 0 : _useRequest$options4.manual) {
|
328
330
|
mutate(function () {
|
329
331
|
return [];
|
330
332
|
});
|
@@ -471,7 +473,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
471
473
|
// 初始化回显,当传入initParams时,前端用来回险
|
472
474
|
var getInitValues = /*#__PURE__*/function () {
|
473
475
|
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
474
|
-
var _useRequest$
|
476
|
+
var _useRequest$options5, queryBean, page, params, res, _res$data2, _list, list, _data, nextSelectRowKeys;
|
475
477
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
476
478
|
while (1) switch (_context4.prev = _context4.next) {
|
477
479
|
case 0:
|
@@ -479,11 +481,11 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
479
481
|
_context4.next = 9;
|
480
482
|
break;
|
481
483
|
}
|
482
|
-
queryBean = _objectSpread(_objectSpread({},
|
484
|
+
queryBean = _objectSpread(_objectSpread({}, defaultParams), initParams || {});
|
483
485
|
page = _objectSpread({
|
484
486
|
pageNum: 1,
|
485
487
|
pageSize: 10
|
486
|
-
}, useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$
|
488
|
+
}, useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options5 = useRequest.options) === null || _useRequest$options5 === void 0 ? void 0 : _useRequest$options5.page);
|
487
489
|
params = withPagination ? _objectSpread(_objectSpread({}, page), {}, {
|
488
490
|
queryBean: queryBean !== null && queryBean !== void 0 ? queryBean : {}
|
489
491
|
}) : queryBean;
|
@@ -532,16 +534,16 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
532
534
|
// 初始化回显,当传入initParams时,前端用来回险
|
533
535
|
var getDefaultOneValues = /*#__PURE__*/function () {
|
534
536
|
var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
535
|
-
var _useRequest$
|
537
|
+
var _useRequest$options6;
|
536
538
|
var queryBean, page, params, res, _res$data3, _list2, list, _data2, nextSelectRowKeys;
|
537
539
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
538
540
|
while (1) switch (_context5.prev = _context5.next) {
|
539
541
|
case 0:
|
540
|
-
queryBean = _objectSpread({},
|
542
|
+
queryBean = _objectSpread({}, defaultParams);
|
541
543
|
page = _objectSpread({
|
542
544
|
pageNum: 1,
|
543
545
|
pageSize: 10
|
544
|
-
}, useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$
|
546
|
+
}, useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options6 = useRequest.options) === null || _useRequest$options6 === void 0 ? void 0 : _useRequest$options6.page);
|
545
547
|
params = withPagination ? _objectSpread(_objectSpread({}, page), {}, {
|
546
548
|
queryBean: queryBean !== null && queryBean !== void 0 ? queryBean : {}
|
547
549
|
}) : queryBean;
|
@@ -616,8 +618,8 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
616
618
|
});
|
617
619
|
useEffect(function () {
|
618
620
|
if (onOff && !visible) {
|
619
|
-
var _useRequest$
|
620
|
-
if ((useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$
|
621
|
+
var _useRequest$options7;
|
622
|
+
if ((useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options7 = useRequest.options) === null || _useRequest$options7 === void 0 ? void 0 : _useRequest$options7.manual) !== true) {
|
621
623
|
onReset();
|
622
624
|
}
|
623
625
|
var nextState = {
|
@@ -668,18 +670,48 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
668
670
|
if (useRequest) {
|
669
671
|
// 加定时器 修复依赖数据同步更新未取到问题
|
670
672
|
setTimeout(function () {
|
671
|
-
var _useRequest$options7, _useRequest$options8;
|
672
673
|
var params = withPagination ? {
|
673
674
|
pageNum: 1,
|
674
675
|
pageSize: 50,
|
675
|
-
queryBean: _objectSpread(_objectSpread({},
|
676
|
-
} : _objectSpread(_objectSpread({},
|
676
|
+
queryBean: _objectSpread(_objectSpread({}, defaultParams), initParams)
|
677
|
+
} : _objectSpread(_objectSpread({}, defaultParams), initParams);
|
677
678
|
var nextParams = transformParams ? transformParams(params) : params;
|
678
679
|
run(nextParams);
|
679
680
|
}, 300);
|
680
681
|
}
|
681
682
|
}
|
682
|
-
}, [JSON.stringify(value), visible, JSON.stringify(
|
683
|
+
}, [JSON.stringify(value), visible, JSON.stringify(defaultParams), JSON.stringify(initParams), options === null || options === void 0 ? void 0 : options.length]);
|
684
|
+
var handleSelectFocus = function handleSelectFocus() {
|
685
|
+
if (useRequest) {
|
686
|
+
var queryBean = defaultParams || {};
|
687
|
+
var params = withPagination ? {
|
688
|
+
pageNum: 1,
|
689
|
+
pageSize: 50,
|
690
|
+
queryBean: queryBean
|
691
|
+
} : queryBean;
|
692
|
+
var nextParams = transformParams ? transformParams(params) : params;
|
693
|
+
// 减少请求条件一致时,且请求过时,focus的重复请求
|
694
|
+
if (!isEqual(queryBean, defaultParamsRef.current) || !(options === null || options === void 0 ? void 0 : options.length)) {
|
695
|
+
run(nextParams); // 触发 run 请求
|
696
|
+
defaultParamsRef.current = queryBean; // 更新缓存
|
697
|
+
}
|
698
|
+
setState({
|
699
|
+
isInit: false
|
700
|
+
});
|
701
|
+
}
|
702
|
+
};
|
703
|
+
var handleSelectSearch = debounce(function (val) {
|
704
|
+
if (useRequest) {
|
705
|
+
var queryBean = _objectSpread(_objectSpread({}, defaultParams), {}, _defineProperty({}, searchKey !== null && searchKey !== void 0 ? searchKey : labelKey, val));
|
706
|
+
var params = withPagination ? {
|
707
|
+
pageNum: 1,
|
708
|
+
pageSize: 50,
|
709
|
+
queryBean: queryBean
|
710
|
+
} : queryBean;
|
711
|
+
var nextParams = transformParams ? transformParams(params) : params;
|
712
|
+
run(nextParams);
|
713
|
+
}
|
714
|
+
}, 1000);
|
683
715
|
useDebounceEffect(function () {
|
684
716
|
if (!value) {
|
685
717
|
if (defaultOne) {
|
@@ -729,35 +761,8 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
729
761
|
notFoundContent: selectLoading ? _jsx(_Spin, {
|
730
762
|
size: "small"
|
731
763
|
}) : null,
|
732
|
-
onFocus:
|
733
|
-
|
734
|
-
var _useRequest$options10;
|
735
|
-
var queryBean = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options10 = useRequest.options) === null || _useRequest$options10 === void 0 ? void 0 : _useRequest$options10.defaultParams) || {};
|
736
|
-
var params = withPagination ? {
|
737
|
-
pageNum: 1,
|
738
|
-
pageSize: 50,
|
739
|
-
queryBean: queryBean
|
740
|
-
} : queryBean;
|
741
|
-
var nextParams = transformParams ? transformParams(params) : params;
|
742
|
-
run(nextParams);
|
743
|
-
setState({
|
744
|
-
isInit: false
|
745
|
-
});
|
746
|
-
}
|
747
|
-
},
|
748
|
-
onSearch: debounce(function (val) {
|
749
|
-
if (useRequest) {
|
750
|
-
var _useRequest$options11;
|
751
|
-
var queryBean = _objectSpread(_objectSpread({}, useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options11 = useRequest.options) === null || _useRequest$options11 === void 0 ? void 0 : _useRequest$options11.defaultParams), {}, _defineProperty({}, searchKey !== null && searchKey !== void 0 ? searchKey : labelKey, val));
|
752
|
-
var params = withPagination ? {
|
753
|
-
pageNum: 1,
|
754
|
-
pageSize: 50,
|
755
|
-
queryBean: queryBean
|
756
|
-
} : queryBean;
|
757
|
-
var nextParams = transformParams ? transformParams(params) : params;
|
758
|
-
run(nextParams);
|
759
|
-
}
|
760
|
-
}, 2000),
|
764
|
+
onFocus: handleSelectFocus,
|
765
|
+
onSearch: handleSelectSearch,
|
761
766
|
style: {
|
762
767
|
width: isView || disabled ? '100%' : 'calc(100% - 30px)'
|
763
768
|
}
|
@@ -13,6 +13,10 @@ export type Props = Omit<RangePickerProps, 'value' | 'onChange' | 'format' | 'se
|
|
13
13
|
isView?: boolean;
|
14
14
|
showTime?: any;
|
15
15
|
valueType?: any;
|
16
|
+
/**
|
17
|
+
* 是否限制时间范围
|
18
|
+
*/
|
19
|
+
limit?: boolean;
|
16
20
|
};
|
17
21
|
type Value = [Moment?, Moment?, boolean?] | null;
|
18
22
|
type ValueStr = [string?, string?, string?] | null;
|
@@ -8,7 +8,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
8
8
|
import "antd/es/date-picker/style";
|
9
9
|
import _DatePicker from "antd/es/date-picker";
|
10
10
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
11
|
-
var _excluded = ["disabled", "foreverText", "foreverDate", "format", "otherProps", "separator"];
|
11
|
+
var _excluded = ["disabled", "foreverText", "foreverDate", "format", "otherProps", "separator", "limit"];
|
12
12
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
13
13
|
import { useMemo, useState } from 'react';
|
14
14
|
import { omit, isFunction, uniq, isObject } from 'lodash';
|
@@ -57,6 +57,8 @@ var ProRangeLimit = function ProRangeLimit(props) {
|
|
57
57
|
otherProps = props.otherProps,
|
58
58
|
_props$separator = props.separator,
|
59
59
|
separator = _props$separator === void 0 ? '~' : _props$separator,
|
60
|
+
_props$limit = props.limit,
|
61
|
+
limit = _props$limit === void 0 ? true : _props$limit,
|
60
62
|
rest = _objectWithoutProperties(props, _excluded);
|
61
63
|
var _ref = ProForm.useFieldProps() || {},
|
62
64
|
isViewCon = _ref.isView,
|
@@ -174,7 +176,7 @@ var ProRangeLimit = function ProRangeLimit(props) {
|
|
174
176
|
format: _format,
|
175
177
|
value: value,
|
176
178
|
onChange: handleRangeChange
|
177
|
-
})), _jsx("div", {
|
179
|
+
})), limit && _jsx("div", {
|
178
180
|
className: className,
|
179
181
|
children: _jsx(_Checkbox, {
|
180
182
|
checked: _isForever,
|
@@ -18,6 +18,10 @@ export type ProTimeLimitProps = DistributiveOmit<DatePickerProps, 'value' | 'onC
|
|
18
18
|
otherProps?: ProFormOtherProps;
|
19
19
|
mode?: 'DatePicker';
|
20
20
|
isView?: boolean;
|
21
|
+
/**
|
22
|
+
* 是否限制时间范围
|
23
|
+
*/
|
24
|
+
limit?: boolean;
|
21
25
|
} & TimePickerProps & {
|
22
26
|
showTime?: PickerPanelDateProps<Moment>['showTime'];
|
23
27
|
showNow?: boolean;
|
@@ -8,7 +8,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
8
8
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
9
9
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
10
10
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
11
|
-
var _excluded = ["format", "disabled", "foreverDate", "foreverText", "valueType", "otherProps"],
|
11
|
+
var _excluded = ["format", "disabled", "foreverDate", "foreverText", "valueType", "otherProps", "limit"],
|
12
12
|
_excluded2 = ["mode"];
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
14
14
|
import classNames from 'classnames';
|
@@ -33,6 +33,8 @@ export var ProTimeLimit = function ProTimeLimit(props) {
|
|
33
33
|
_props$valueType = props.valueType,
|
34
34
|
valueType = _props$valueType === void 0 ? 'format' : _props$valueType,
|
35
35
|
otherProps = props.otherProps,
|
36
|
+
_props$limit = props.limit,
|
37
|
+
limit = _props$limit === void 0 ? true : _props$limit,
|
36
38
|
rest = _objectWithoutProperties(props, _excluded);
|
37
39
|
var _ref = ProForm.useFieldProps() || {},
|
38
40
|
isViewCon = _ref.isView,
|
@@ -129,7 +131,7 @@ export var ProTimeLimit = function ProTimeLimit(props) {
|
|
129
131
|
format: _format,
|
130
132
|
value: value,
|
131
133
|
onChange: onChange
|
132
|
-
})), _jsx("div", {
|
134
|
+
})), limit && _jsx("div", {
|
133
135
|
className: className,
|
134
136
|
children: _jsx(_Checkbox, {
|
135
137
|
checked: isForever,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
3
|
-
var _excluded = ["show", "type", "viewRender", "viewType", "valueType", "formItemProps", "colProps", "formItemChildProps", "fieldProps", "onDiff", "clearNotShow", "required", "confirm", "desensitization"];
|
3
|
+
var _excluded = ["show", "type", "viewRender", "viewType", "valueType", "formItemProps", "colProps", "formItemChildProps", "fieldProps", "onDiff", "clearNotShow", "required", "confirm", "desensitization", "span"];
|
4
4
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
5
5
|
import React from 'react';
|
6
6
|
import { isBoolean, isFunction, union, isString } from 'lodash';
|
@@ -75,6 +75,7 @@ var RenderFields = function RenderFields(props) {
|
|
75
75
|
columnRequired = column.required,
|
76
76
|
confirm = column.confirm,
|
77
77
|
desensitization = column.desensitization,
|
78
|
+
span = column.span,
|
78
79
|
otherFormItemProps = _objectWithoutProperties(column, _excluded);
|
79
80
|
var component = column.component;
|
80
81
|
var _isView = typeof column.isView === 'boolean' ? column.isView : isView;
|
@@ -169,7 +170,9 @@ var RenderFields = function RenderFields(props) {
|
|
169
170
|
if (!TargetComponent) {
|
170
171
|
return [];
|
171
172
|
}
|
172
|
-
var _colProps =
|
173
|
+
var _colProps = span ? {
|
174
|
+
span: span
|
175
|
+
} : _objectSpread(_objectSpread({}, defaultColProps), colProps);
|
173
176
|
// 其余参数收进对象里传给子组件 componentProps只包含子组件参数
|
174
177
|
var otherProps = {
|
175
178
|
label: _formItemProps.label,
|