@zat-design/sisyphus-react 3.7.3-beta.16 → 3.7.3-beta.19
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/RenderField/index.js +1 -1
- package/es/ProForm/components/combination/ProModalSelect/index.js +23 -23
- package/es/ProForm/components/render/ChangedWrapper.js +12 -5
- package/es/ProForm/propsType.d.ts +1 -0
- package/es/ProSelect/index.js +3 -3
- package/es/ProTree/components/ProTreeSelect/index.js +8 -8
- package/es/ProTree/components/SearchTitle.d.ts +2 -1
- package/es/ProTree/components/SearchTitle.js +12 -2
- package/es/ProTreeModal/components/Tree.js +15 -17
- package/es/ProTreeModal/index.js +62 -7
- package/es/ProTreeModal/utils.d.ts +1 -0
- package/es/ProTreeModal/utils.js +21 -1
- package/lib/ProEditTable/components/RenderField/index.js +1 -1
- package/lib/ProForm/components/combination/ProModalSelect/index.js +22 -22
- package/lib/ProForm/components/render/ChangedWrapper.js +12 -5
- package/lib/ProForm/propsType.d.ts +1 -0
- package/lib/ProSelect/index.js +3 -3
- package/lib/ProTree/components/ProTreeSelect/index.js +8 -8
- package/lib/ProTree/components/SearchTitle.d.ts +2 -1
- package/lib/ProTree/components/SearchTitle.js +13 -2
- package/lib/ProTreeModal/components/Tree.js +15 -17
- package/lib/ProTreeModal/index.js +61 -6
- package/lib/ProTreeModal/utils.d.ts +1 -0
- package/lib/ProTreeModal/utils.js +20 -0
- package/package.json +1 -1
|
@@ -510,7 +510,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
510
510
|
form: form,
|
|
511
511
|
names: names,
|
|
512
512
|
namePath: [].concat(_toConsumableArray(namePath), [index]),
|
|
513
|
-
name:
|
|
513
|
+
name: originalName,
|
|
514
514
|
listName: cellName,
|
|
515
515
|
viewEmpty: viewEmpty,
|
|
516
516
|
valueType: _valueType,
|
|
@@ -27,7 +27,7 @@ import { SearchOutlined } from '@ant-design/icons';
|
|
|
27
27
|
import { useDeepCompareEffect, useMount, useSetState } from 'ahooks';
|
|
28
28
|
import { debounce, isArray, isEqual, isFunction, omit } from 'lodash';
|
|
29
29
|
import { ReactSVG } from 'react-svg';
|
|
30
|
-
import React, { forwardRef,
|
|
30
|
+
import React, { forwardRef, useImperativeHandle, useMemo } from 'react';
|
|
31
31
|
import { ProForm, ProDrawerForm, ProTable, useProConfig, ProSelect } from '../../../../index';
|
|
32
32
|
import Container from '../../Container';
|
|
33
33
|
import viewSvg from '../../../../assets/view.svg';
|
|
@@ -137,10 +137,10 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
137
137
|
}, _objectSpread(_objectSpread({}, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options), {}, {
|
|
138
138
|
manual: true,
|
|
139
139
|
onSuccess: function onSuccess(res) {
|
|
140
|
-
var _res$data;
|
|
140
|
+
var _res$data, _ref5;
|
|
141
141
|
var list = withPagination ? res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.list : res === null || res === void 0 ? void 0 : res.data;
|
|
142
142
|
setState({
|
|
143
|
-
options: transformResponse ? transformResponse(res === null || res === void 0 ? void 0 : res.data) : list
|
|
143
|
+
options: (_ref5 = transformResponse ? transformResponse(res === null || res === void 0 ? void 0 : res.data) : list) !== null && _ref5 !== void 0 ? _ref5 : []
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
})),
|
|
@@ -166,9 +166,9 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
166
166
|
};
|
|
167
167
|
var handleFormat = onFormat || defaultOptionRender;
|
|
168
168
|
if (showCodeName) {
|
|
169
|
-
handleFormat = function handleFormat(
|
|
170
|
-
var value =
|
|
171
|
-
label =
|
|
169
|
+
handleFormat = function handleFormat(_ref6) {
|
|
170
|
+
var value = _ref6.value,
|
|
171
|
+
label = _ref6.label;
|
|
172
172
|
return "".concat(value, "-").concat(label);
|
|
173
173
|
};
|
|
174
174
|
}
|
|
@@ -237,7 +237,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
237
237
|
onChange(val, option);
|
|
238
238
|
};
|
|
239
239
|
var handleClick = /*#__PURE__*/function () {
|
|
240
|
-
var
|
|
240
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
241
241
|
var _yield$beforeOpen, res;
|
|
242
242
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
243
243
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -280,7 +280,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
280
280
|
}, _callee);
|
|
281
281
|
}));
|
|
282
282
|
return function handleClick() {
|
|
283
|
-
return
|
|
283
|
+
return _ref7.apply(this, arguments);
|
|
284
284
|
};
|
|
285
285
|
}();
|
|
286
286
|
var handleClose = function handleClose() {
|
|
@@ -299,7 +299,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
299
299
|
}
|
|
300
300
|
};
|
|
301
301
|
var handleFinish = /*#__PURE__*/function () {
|
|
302
|
-
var
|
|
302
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
303
303
|
var _nextSelectedRows, _nextSelectedRows2, nextSelectedRows, record, flag, res;
|
|
304
304
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
305
305
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -360,11 +360,11 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
360
360
|
}, _callee2, null, [[0, 18]]);
|
|
361
361
|
}));
|
|
362
362
|
return function handleFinish() {
|
|
363
|
-
return
|
|
363
|
+
return _ref8.apply(this, arguments);
|
|
364
364
|
};
|
|
365
365
|
}();
|
|
366
366
|
var handleSearch = /*#__PURE__*/function () {
|
|
367
|
-
var
|
|
367
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
368
368
|
var values;
|
|
369
369
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
370
370
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -383,7 +383,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
383
383
|
}, _callee3);
|
|
384
384
|
}));
|
|
385
385
|
return function handleSearch() {
|
|
386
|
-
return
|
|
386
|
+
return _ref9.apply(this, arguments);
|
|
387
387
|
};
|
|
388
388
|
}();
|
|
389
389
|
var _rowSelection = _objectSpread({
|
|
@@ -437,7 +437,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
437
437
|
};
|
|
438
438
|
// 初始化回显,当传入initParams时,前端用来回险
|
|
439
439
|
var getInitValues = /*#__PURE__*/function () {
|
|
440
|
-
var
|
|
440
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
441
441
|
var _contentForm$getField, _useRequest$options2, _useRequest$options3, queryBean, page, params, res, _res$data2, _list, list, _data, nextSelectRowKeys;
|
|
442
442
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
443
443
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -495,12 +495,12 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
495
495
|
}, _callee4);
|
|
496
496
|
}));
|
|
497
497
|
return function getInitValues() {
|
|
498
|
-
return
|
|
498
|
+
return _ref10.apply(this, arguments);
|
|
499
499
|
};
|
|
500
500
|
}();
|
|
501
501
|
// 初始化回显,当传入initParams时,前端用来回险
|
|
502
502
|
var getDefaultOneValues = /*#__PURE__*/function () {
|
|
503
|
-
var
|
|
503
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
504
504
|
var _useRequest$options4, _useRequest$options5;
|
|
505
505
|
var queryBean, page, params, res, _res$data3, _list2, list, _data2, nextSelectRowKeys;
|
|
506
506
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
@@ -548,7 +548,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
548
548
|
}, _callee5);
|
|
549
549
|
}));
|
|
550
550
|
return function getDefaultOneValues() {
|
|
551
|
-
return
|
|
551
|
+
return _ref11.apply(this, arguments);
|
|
552
552
|
};
|
|
553
553
|
}();
|
|
554
554
|
useImperativeHandle(ref, function () {
|
|
@@ -579,7 +579,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
579
579
|
});
|
|
580
580
|
}
|
|
581
581
|
});
|
|
582
|
-
|
|
582
|
+
useDeepCompareEffect(function () {
|
|
583
583
|
if (onOff && !visible) {
|
|
584
584
|
var _useRequest$options6;
|
|
585
585
|
if ((useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options6 = useRequest.options) === null || _useRequest$options6 === void 0 ? void 0 : _useRequest$options6.manual) !== true) {
|
|
@@ -615,12 +615,12 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
615
615
|
setState(nextState);
|
|
616
616
|
}
|
|
617
617
|
}, [onOff, visible, value]);
|
|
618
|
-
|
|
618
|
+
useDeepCompareEffect(function () {
|
|
619
619
|
if (value && !visible && isInit && !readOnly) {
|
|
620
620
|
getInitValues();
|
|
621
621
|
}
|
|
622
|
-
}, [value, visible, isInit
|
|
623
|
-
|
|
622
|
+
}, [value, visible, isInit]);
|
|
623
|
+
useDeepCompareEffect(function () {
|
|
624
624
|
if (value && !visible && readOnly) {
|
|
625
625
|
var _options$some;
|
|
626
626
|
var isHasValue = options === null || options === void 0 ? void 0 : (_options$some = options.some) === null || _options$some === void 0 ? void 0 : _options$some.call(options, function (item) {
|
|
@@ -647,7 +647,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
647
647
|
}, 300);
|
|
648
648
|
}
|
|
649
649
|
}, [value, options, visible, useRequest]);
|
|
650
|
-
|
|
650
|
+
useDeepCompareEffect(function () {
|
|
651
651
|
if (!value) {
|
|
652
652
|
if (defaultOne) {
|
|
653
653
|
getDefaultOneValues();
|
|
@@ -747,7 +747,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
747
747
|
children: customRender
|
|
748
748
|
});
|
|
749
749
|
}
|
|
750
|
-
|
|
750
|
+
useDeepCompareEffect(function () {
|
|
751
751
|
if (isTooltip && value) {
|
|
752
752
|
var dom = document.getElementById(uuid);
|
|
753
753
|
dom.addEventListener('mouseover', function (e) {
|
|
@@ -784,7 +784,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
784
784
|
}, [value, isTooltip]);
|
|
785
785
|
useDeepCompareEffect(function () {
|
|
786
786
|
setState({
|
|
787
|
-
options: tableProps === null || tableProps === void 0 ? void 0 : tableProps.dataSource
|
|
787
|
+
options: (tableProps === null || tableProps === void 0 ? void 0 : tableProps.dataSource) || []
|
|
788
788
|
});
|
|
789
789
|
}, [tableProps === null || tableProps === void 0 ? void 0 : tableProps.dataSource]);
|
|
790
790
|
// 当搜索条件只有一个时,且为输入框,默认设置suffix
|
|
@@ -14,7 +14,7 @@ import { diffOriginal } from '../../utils/diffOriginal';
|
|
|
14
14
|
import { useProConfig } from '../../../ProConfigProvider';
|
|
15
15
|
import { isEmpty } from '../../../utils';
|
|
16
16
|
var ChangedWrapper = function ChangedWrapper(props) {
|
|
17
|
-
var _diffConfig$toolTip, _children$props;
|
|
17
|
+
var _diffConfig$toolTip, _children$props, _children$props2, _children$props3;
|
|
18
18
|
var name = props.name,
|
|
19
19
|
names = props.names,
|
|
20
20
|
namesStr = props.namesStr,
|
|
@@ -32,7 +32,6 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
32
32
|
changeTipColor = diffConfig.changeTipColor,
|
|
33
33
|
addTipColor = diffConfig.addTipColor;
|
|
34
34
|
var toolTip = (_diffConfig$toolTip = diffConfig.toolTip) !== null && _diffConfig$toolTip !== void 0 ? _diffConfig$toolTip : true;
|
|
35
|
-
// 不渲染tooltip
|
|
36
35
|
var isWatch = toolTip && !['FormList', 'ProEditTable'].includes(type);
|
|
37
36
|
var originalValue = (names === null || names === void 0 ? void 0 : names.length) ? names.map(function (name) {
|
|
38
37
|
return get(originalValues, name);
|
|
@@ -57,7 +56,11 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
57
56
|
}, valuePropName, originalValue))) : undefined;
|
|
58
57
|
}, [originalValue, children]);
|
|
59
58
|
if (!isWatch || noChange) {
|
|
60
|
-
|
|
59
|
+
// 嵌套子组件
|
|
60
|
+
var isNestedField = ['ProEditTable'].includes(type);
|
|
61
|
+
return /*#__PURE__*/React.isValidElement(children) && /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({
|
|
62
|
+
originalValues: isNestedField ? originalValues : undefined
|
|
63
|
+
}, children.props), rest));
|
|
61
64
|
}
|
|
62
65
|
var tipOpenCalc = function tipOpenCalc() {
|
|
63
66
|
if (!toolTip) return false;
|
|
@@ -72,6 +75,8 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
72
75
|
'pro-form-item-changed': isChanged,
|
|
73
76
|
'pro-form-item-add': isAdd
|
|
74
77
|
});
|
|
78
|
+
// @ts-ignore
|
|
79
|
+
var _showEllipse = ((_children$props = children.props) === null || _children$props === void 0 ? void 0 : _children$props.showEllipse) || ((_children$props2 = children.props) === null || _children$props2 === void 0 ? void 0 : _children$props2.tooltip);
|
|
75
80
|
return _jsx(_Tooltip, {
|
|
76
81
|
open: tipOpenCalc(),
|
|
77
82
|
mouseEnterDelay: 1,
|
|
@@ -82,7 +87,7 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
82
87
|
direction: "vertical",
|
|
83
88
|
children: [_jsxs(_Space, {
|
|
84
89
|
children: ["\u521D\u59CB\u503C\uFF1A", tipContent]
|
|
85
|
-
}),
|
|
90
|
+
}), _showEllipse && _jsxs(_Space, {
|
|
86
91
|
children: ["\u5F53\u524D\u503C\uFF1A", /*#__PURE__*/React.isValidElement(children) ? /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread(_objectSpread({}, children.props), rest), {}, {
|
|
87
92
|
isView: true
|
|
88
93
|
})) : undefined]
|
|
@@ -93,7 +98,9 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
93
98
|
className: diffClassName,
|
|
94
99
|
style: style,
|
|
95
100
|
children: /*#__PURE__*/React.isValidElement(children) ? /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread(_objectSpread({}, children.props), rest), {}, {
|
|
96
|
-
|
|
101
|
+
otherProps: _objectSpread(_objectSpread({}, (_children$props3 = children.props) === null || _children$props3 === void 0 ? void 0 : _children$props3.otherProps), {}, {
|
|
102
|
+
isDiffChange: isChanged
|
|
103
|
+
})
|
|
97
104
|
})) : undefined
|
|
98
105
|
})
|
|
99
106
|
});
|
package/es/ProSelect/index.js
CHANGED
|
@@ -296,7 +296,8 @@ export var ProSelect = function ProSelect(props, ref) {
|
|
|
296
296
|
showArrow: true,
|
|
297
297
|
loading: fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.loading,
|
|
298
298
|
onChange: handleChange,
|
|
299
|
-
optionLabelProp
|
|
299
|
+
// optionLabelProp={otherProps?.isDiffChange ? "label" : 'children'} // 解决warning报错,添加默认值
|
|
300
|
+
optionLabelProp: "label" // 解决warning报错,添加默认值
|
|
300
301
|
,
|
|
301
302
|
showSearch: true,
|
|
302
303
|
filterOption: isFunction(_onSearch) ? false : function (input, option) {
|
|
@@ -314,16 +315,15 @@ export var ProSelect = function ProSelect(props, ref) {
|
|
|
314
315
|
value: transformValue(),
|
|
315
316
|
children: Array.isArray(newSelectList) && newSelectList.map(function (item) {
|
|
316
317
|
return _jsx(Option, {
|
|
318
|
+
label: item[label],
|
|
317
319
|
value: item[code],
|
|
318
320
|
record: item,
|
|
319
321
|
disabled: !!item.disabled,
|
|
320
322
|
children: _jsx(TooltipOption, {
|
|
321
323
|
title: OptionRender ? OptionRender(item) : selectProps.showCodeName ? "".concat(item[code], "-").concat(item[label]) : item[label],
|
|
322
324
|
children: OptionRender ? _jsx("span", {
|
|
323
|
-
title: OptionRender(item),
|
|
324
325
|
children: OptionRender(item)
|
|
325
326
|
}) : _jsx("span", {
|
|
326
|
-
title: selectProps.showCodeName ? "".concat(item[code], "-").concat(item[label]) : item[label],
|
|
327
327
|
children: selectProps.showCodeName ? "".concat(item[code], "-").concat(item[label]) : item[label]
|
|
328
328
|
})
|
|
329
329
|
}, item[code])
|
|
@@ -76,13 +76,13 @@ export var ProTreeSelect = function ProTreeSelect(props, ref) {
|
|
|
76
76
|
var _props$value = props.value,
|
|
77
77
|
value = _props$value === void 0 ? undefined : _props$value;
|
|
78
78
|
var _props$showEllipse = props.showEllipse,
|
|
79
|
-
showEllipse = _props$showEllipse === void 0 ? true : _props$showEllipse
|
|
80
|
-
|
|
81
|
-
isDiffChange =
|
|
79
|
+
showEllipse = _props$showEllipse === void 0 ? true : _props$showEllipse;
|
|
80
|
+
var _ref2 = otherProps !== null && otherProps !== void 0 ? otherProps : {},
|
|
81
|
+
isDiffChange = _ref2.isDiffChange;
|
|
82
82
|
var _showEllipse = showEllipse && !isDiffChange;
|
|
83
|
-
var
|
|
84
|
-
isView =
|
|
85
|
-
viewEmpty =
|
|
83
|
+
var _ref3 = otherProps || {},
|
|
84
|
+
isView = _ref3.isView,
|
|
85
|
+
viewEmpty = _ref3.viewEmpty;
|
|
86
86
|
if (fieldNames && Object.keys(fieldNames).length) {
|
|
87
87
|
code = fieldNames.value || 'value';
|
|
88
88
|
label = fieldNames.label || 'label';
|
|
@@ -215,8 +215,8 @@ export var ProTreeSelect = function ProTreeSelect(props, ref) {
|
|
|
215
215
|
return undefined;
|
|
216
216
|
}
|
|
217
217
|
// 如果配置手动加载,不执行请求
|
|
218
|
-
var
|
|
219
|
-
defaultParams =
|
|
218
|
+
var _ref4 = (useRequest === null || useRequest === void 0 ? void 0 : useRequest.options) || {},
|
|
219
|
+
defaultParams = _ref4.defaultParams;
|
|
220
220
|
// 执行用户配置的枚举服务,拉取枚举数据进行更新
|
|
221
221
|
fetchFunction.run(defaultParams);
|
|
222
222
|
}, [useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, defaultDisableValue]);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { ProFormOtherProps } from '../../ProForm/propsType';
|
|
2
3
|
declare function SearchTitle(props: {
|
|
3
4
|
searchStr?: string;
|
|
4
5
|
label?: string;
|
|
5
6
|
showEllipse?: boolean;
|
|
6
7
|
ellipseWidth?: string;
|
|
7
|
-
|
|
8
|
+
otherProps?: ProFormOtherProps;
|
|
8
9
|
}): import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
declare const _default: import("react").MemoExoticComponent<typeof SearchTitle>;
|
|
10
11
|
export default _default;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* @Author: za-xuwenli xuwenli@zhongan.io
|
|
4
|
+
* @Date: 2024-09-26 14:37:00
|
|
5
|
+
* @LastEditors: za-xuwenli xuwenli@zhongan.io
|
|
6
|
+
* @LastEditTime: 2024-09-26 17:50:59
|
|
7
|
+
* @FilePath: /za-material-warehouse/src/ProTree/components/SearchTitle.tsx
|
|
8
|
+
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
9
|
+
*/
|
|
2
10
|
import { memo } from 'react';
|
|
3
11
|
import AdaptiveTooltip from './AdaptiveTooltip';
|
|
4
12
|
function SearchTitle(props) {
|
|
@@ -7,8 +15,10 @@ function SearchTitle(props) {
|
|
|
7
15
|
searchStr = _props$searchStr === void 0 ? '' : _props$searchStr,
|
|
8
16
|
showEllipse = props.showEllipse,
|
|
9
17
|
ellipseWidth = props.ellipseWidth,
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
otherProps = props.otherProps;
|
|
19
|
+
var _ref = otherProps !== null && otherProps !== void 0 ? otherProps : {},
|
|
20
|
+
_ref$isDiffChange = _ref.isDiffChange,
|
|
21
|
+
isDiffChange = _ref$isDiffChange === void 0 ? false : _ref$isDiffChange;
|
|
12
22
|
var strTitle = label;
|
|
13
23
|
var index = strTitle === null || strTitle === void 0 ? void 0 : strTitle.indexOf(searchStr);
|
|
14
24
|
var beforeStr = strTitle === null || strTitle === void 0 ? void 0 : strTitle.substring(0, index);
|
|
@@ -177,23 +177,21 @@ function List(props, ref) {
|
|
|
177
177
|
setAutoExpandParent(false);
|
|
178
178
|
};
|
|
179
179
|
if (mode === 'render') {
|
|
180
|
-
return _jsx(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
height: 432
|
|
196
|
-
})
|
|
180
|
+
return _jsx(_Tree, {
|
|
181
|
+
disabled: disabled,
|
|
182
|
+
style: {
|
|
183
|
+
width: '100%'
|
|
184
|
+
},
|
|
185
|
+
checkable: true,
|
|
186
|
+
treeData: _treeData,
|
|
187
|
+
onExpand: onExpand,
|
|
188
|
+
expandedKeys: expandedKeys,
|
|
189
|
+
autoExpandParent: autoExpandParent,
|
|
190
|
+
selectable: false,
|
|
191
|
+
onCheck: onCheck,
|
|
192
|
+
checkedKeys: checkedValues,
|
|
193
|
+
checkStrictly: searchStr ? true : checkStrictly,
|
|
194
|
+
height: 432
|
|
197
195
|
});
|
|
198
196
|
}
|
|
199
197
|
return _jsx(_Fragment, {
|
package/es/ProTreeModal/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
15
15
|
* @Author: za-xuwenli xuwenli@zhongan.io
|
|
16
16
|
* @Date: 2024-06-04 10:01:18
|
|
17
17
|
* @LastEditors: za-xuwenli xuwenli@zhongan.io
|
|
18
|
-
* @LastEditTime: 2024-
|
|
18
|
+
* @LastEditTime: 2024-09-27 11:49:28
|
|
19
19
|
* @FilePath: /za-material-warehouse/src/ProTreeModal/index.tsx
|
|
20
20
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
21
21
|
*/
|
|
@@ -26,7 +26,8 @@ import { ReactSVG } from 'react-svg';
|
|
|
26
26
|
import classNames from 'classnames';
|
|
27
27
|
import { ProDrawerForm, useProConfig } from '../index';
|
|
28
28
|
import { Trigger, ListView, TreeView, Cascader } from './components';
|
|
29
|
-
import { getFlatTreeData, filterCheckedNodes, getChildrenKeys, findTreeNodeByKey, getAllKeys, transformMessage } from './utils';
|
|
29
|
+
import { getFlatTreeData, filterCheckedNodes, getChildrenKeys, findTreeNodeByKey, getAllKeys, transformMessage, addLevelAndParentId } from './utils';
|
|
30
|
+
import { transformTreeToArray, treeNodeFind } from '../ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/index';
|
|
30
31
|
import searchSVG from '../assets/input-search.svg';
|
|
31
32
|
import locale, { formatMessage } from '../locale';
|
|
32
33
|
import './style/index.less';
|
|
@@ -98,7 +99,8 @@ var ProTreeModal = function ProTreeModal(props) {
|
|
|
98
99
|
flatTreeData: [],
|
|
99
100
|
searchStr: '',
|
|
100
101
|
checkAll: false,
|
|
101
|
-
allKeys: []
|
|
102
|
+
allKeys: [],
|
|
103
|
+
transformedTree: []
|
|
102
104
|
}),
|
|
103
105
|
_useSetState2 = _slicedToArray(_useSetState, 2),
|
|
104
106
|
state = _useSetState2[0],
|
|
@@ -220,6 +222,12 @@ var ProTreeModal = function ProTreeModal(props) {
|
|
|
220
222
|
});
|
|
221
223
|
}
|
|
222
224
|
}, [value, state.allKeys, state.open]);
|
|
225
|
+
useDeepCompareEffect(function () {
|
|
226
|
+
var transformedTree = addLevelAndParentId(state.treeData, fieldNames);
|
|
227
|
+
setState({
|
|
228
|
+
transformedTree: transformedTree
|
|
229
|
+
});
|
|
230
|
+
}, [state.treeData]);
|
|
223
231
|
var handleClick = function handleClick() {
|
|
224
232
|
setState({
|
|
225
233
|
open: true
|
|
@@ -360,8 +368,55 @@ var ProTreeModal = function ProTreeModal(props) {
|
|
|
360
368
|
var onCheck = function onCheck(checkedKeys, info) {
|
|
361
369
|
var checkedValues = _toConsumableArray(state.checkedValues);
|
|
362
370
|
var originalTreeData = state.originalTreeData;
|
|
371
|
+
// 如果有检索则自管理
|
|
372
|
+
if (state.searchStr) {
|
|
373
|
+
var _transformTreeToArray;
|
|
374
|
+
var node = info.node;
|
|
375
|
+
// 从完整树中找到当前节点
|
|
376
|
+
var activeNode = treeNodeFind(state.transformedTree, function (t) {
|
|
377
|
+
return t[fieldNameValue] === node[fieldNameValue];
|
|
378
|
+
}, {
|
|
379
|
+
childrenKey: fieldNames.children
|
|
380
|
+
});
|
|
381
|
+
var allChildren = (_transformTreeToArray = transformTreeToArray([activeNode], {
|
|
382
|
+
childrenKey: fieldNames.children
|
|
383
|
+
})) === null || _transformTreeToArray === void 0 ? void 0 : _transformTreeToArray.map(function (item) {
|
|
384
|
+
return item[fieldNameValue];
|
|
385
|
+
});
|
|
386
|
+
// 子项合并勾选
|
|
387
|
+
checkedValues = checkedValues.concat(allChildren);
|
|
388
|
+
// 从完整树中拿到父节点 只要存在父节点,那么就判断当前children是否全被勾选 若全被勾选就合并当前key到勾选队列
|
|
389
|
+
var _recourse2 = function _recourse(findNode) {
|
|
390
|
+
if (findNode.parentId) {
|
|
391
|
+
var _transformTreeToArray2;
|
|
392
|
+
var parentNode = treeNodeFind(state.transformedTree, function (t) {
|
|
393
|
+
return t[fieldNameValue] === findNode.parentId;
|
|
394
|
+
}, {
|
|
395
|
+
childrenKey: fieldNames.children
|
|
396
|
+
});
|
|
397
|
+
var parentChildrenKeys = (_transformTreeToArray2 = transformTreeToArray([parentNode], {
|
|
398
|
+
childrenKey: fieldNames.children
|
|
399
|
+
})) === null || _transformTreeToArray2 === void 0 ? void 0 : _transformTreeToArray2.map(function (item) {
|
|
400
|
+
return item[fieldNameValue];
|
|
401
|
+
});
|
|
402
|
+
var parentChildrenAllChecked = parentChildrenKeys.every(function (key) {
|
|
403
|
+
return checkedValues.includes(key);
|
|
404
|
+
});
|
|
405
|
+
if (parentChildrenAllChecked) {
|
|
406
|
+
// 把当前父节点追加进来
|
|
407
|
+
checkedValues = checkedValues.concat([parentNode[fieldNameValue]]);
|
|
408
|
+
// 继续向上查找
|
|
409
|
+
if (parentNode.parentId) {
|
|
410
|
+
_recourse2(parentNode);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
_recourse2(activeNode);
|
|
416
|
+
}
|
|
417
|
+
var _checkStrictly = state.searchStr ? true : checkStrictly;
|
|
363
418
|
// 此时应该取消掉自身并包含它所有的子集
|
|
364
|
-
if (!info.checked && !
|
|
419
|
+
if (!info.checked && !_checkStrictly) {
|
|
365
420
|
// 1. 取消自身
|
|
366
421
|
// 2. 把所有的子节点也要取消
|
|
367
422
|
var childrenkeys = [];
|
|
@@ -378,8 +433,8 @@ var ProTreeModal = function ProTreeModal(props) {
|
|
|
378
433
|
return !parentKeys.includes(key);
|
|
379
434
|
});
|
|
380
435
|
} else {
|
|
381
|
-
//
|
|
382
|
-
if (
|
|
436
|
+
// _checkStrictly 模式下取 checkedKeys.checked 或者自身的 key
|
|
437
|
+
if (_checkStrictly) {
|
|
383
438
|
if (!info.checked) {
|
|
384
439
|
checkedValues = checkedValues.filter(function (key) {
|
|
385
440
|
return key !== info.node.key;
|
|
@@ -618,7 +673,7 @@ var ProTreeModal = function ProTreeModal(props) {
|
|
|
618
673
|
});
|
|
619
674
|
case TREE:
|
|
620
675
|
return _jsx(TreeView, {
|
|
621
|
-
treeData: state.
|
|
676
|
+
treeData: state.transformedTree,
|
|
622
677
|
originalTreeData: state.originalTreeData,
|
|
623
678
|
flatTreeData: state.flatTreeData,
|
|
624
679
|
checkedValues: state.checkedValues,
|
|
@@ -36,3 +36,4 @@ export declare function filterCheckedNodes(data: any, checkedKeys: any, searchSt
|
|
|
36
36
|
*/
|
|
37
37
|
export declare function getChildrenKeys(node: TreeDataProps, childrenKeys: string[], fieldNames: FieldNamesType, type: 'treeClose' | 'treeCheck'): void;
|
|
38
38
|
export declare const transformMessage: (obj: any, message: string) => string;
|
|
39
|
+
export declare const addLevelAndParentId: (tree: any[], fieldNames: any, currentLevel?: number, currentParentId?: any) => any[];
|
package/es/ProTreeModal/utils.js
CHANGED
|
@@ -197,4 +197,24 @@ export var transformMessage = function transformMessage(obj, message) {
|
|
|
197
197
|
_message = message.replaceAll("{".concat(key, "}"), obj[key]);
|
|
198
198
|
});
|
|
199
199
|
return _message;
|
|
200
|
-
};
|
|
200
|
+
};
|
|
201
|
+
var _addLevelAndParentId = function addLevelAndParentId() {
|
|
202
|
+
var tree = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
203
|
+
var fieldNames = arguments.length > 1 ? arguments[1] : undefined;
|
|
204
|
+
var currentLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
205
|
+
var currentParentId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
206
|
+
var _fieldNames$children = fieldNames.children,
|
|
207
|
+
children = _fieldNames$children === void 0 ? 'children' : _fieldNames$children,
|
|
208
|
+
_fieldNames$value = fieldNames.value,
|
|
209
|
+
value = _fieldNames$value === void 0 ? 'value' : _fieldNames$value;
|
|
210
|
+
return tree.map(function (node) {
|
|
211
|
+
var newNode = _objectSpread({}, node);
|
|
212
|
+
newNode.level = currentLevel;
|
|
213
|
+
newNode.parentId = currentParentId;
|
|
214
|
+
if (node[children]) {
|
|
215
|
+
newNode[children] = _addLevelAndParentId(node[children], fieldNames, currentLevel + 1, newNode[value]);
|
|
216
|
+
}
|
|
217
|
+
return newNode;
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
export { _addLevelAndParentId as addLevelAndParentId };
|
|
@@ -517,7 +517,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
517
517
|
form: form,
|
|
518
518
|
names: names,
|
|
519
519
|
namePath: [].concat((0, _toConsumableArray2.default)(namePath), [index]),
|
|
520
|
-
name:
|
|
520
|
+
name: originalName,
|
|
521
521
|
listName: cellName,
|
|
522
522
|
viewEmpty: viewEmpty,
|
|
523
523
|
valueType: _valueType,
|
|
@@ -132,10 +132,10 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
132
132
|
}, (0, _objectSpread3.default)((0, _objectSpread3.default)({}, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options), {}, {
|
|
133
133
|
manual: true,
|
|
134
134
|
onSuccess: function onSuccess(res) {
|
|
135
|
-
var _res$data;
|
|
135
|
+
var _res$data, _ref5;
|
|
136
136
|
var list = withPagination ? res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.list : res === null || res === void 0 ? void 0 : res.data;
|
|
137
137
|
setState({
|
|
138
|
-
options: transformResponse ? transformResponse(res === null || res === void 0 ? void 0 : res.data) : list
|
|
138
|
+
options: (_ref5 = transformResponse ? transformResponse(res === null || res === void 0 ? void 0 : res.data) : list) !== null && _ref5 !== void 0 ? _ref5 : []
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
})),
|
|
@@ -161,9 +161,9 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
161
161
|
};
|
|
162
162
|
var handleFormat = onFormat || defaultOptionRender;
|
|
163
163
|
if (showCodeName) {
|
|
164
|
-
handleFormat = function handleFormat(
|
|
165
|
-
var value =
|
|
166
|
-
label =
|
|
164
|
+
handleFormat = function handleFormat(_ref6) {
|
|
165
|
+
var value = _ref6.value,
|
|
166
|
+
label = _ref6.label;
|
|
167
167
|
return "".concat(value, "-").concat(label);
|
|
168
168
|
};
|
|
169
169
|
}
|
|
@@ -232,7 +232,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
232
232
|
onChange(val, option);
|
|
233
233
|
};
|
|
234
234
|
var handleClick = /*#__PURE__*/function () {
|
|
235
|
-
var
|
|
235
|
+
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
|
|
236
236
|
var _yield$beforeOpen, res;
|
|
237
237
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
|
238
238
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -275,7 +275,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
275
275
|
}, _callee);
|
|
276
276
|
}));
|
|
277
277
|
return function handleClick() {
|
|
278
|
-
return
|
|
278
|
+
return _ref7.apply(this, arguments);
|
|
279
279
|
};
|
|
280
280
|
}();
|
|
281
281
|
var handleClose = function handleClose() {
|
|
@@ -294,7 +294,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
294
294
|
}
|
|
295
295
|
};
|
|
296
296
|
var handleFinish = /*#__PURE__*/function () {
|
|
297
|
-
var
|
|
297
|
+
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2() {
|
|
298
298
|
var _nextSelectedRows, _nextSelectedRows2, nextSelectedRows, record, flag, res;
|
|
299
299
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
|
|
300
300
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -355,11 +355,11 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
355
355
|
}, _callee2, null, [[0, 18]]);
|
|
356
356
|
}));
|
|
357
357
|
return function handleFinish() {
|
|
358
|
-
return
|
|
358
|
+
return _ref8.apply(this, arguments);
|
|
359
359
|
};
|
|
360
360
|
}();
|
|
361
361
|
var handleSearch = /*#__PURE__*/function () {
|
|
362
|
-
var
|
|
362
|
+
var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee3() {
|
|
363
363
|
var values;
|
|
364
364
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee3$(_context3) {
|
|
365
365
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -378,7 +378,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
378
378
|
}, _callee3);
|
|
379
379
|
}));
|
|
380
380
|
return function handleSearch() {
|
|
381
|
-
return
|
|
381
|
+
return _ref9.apply(this, arguments);
|
|
382
382
|
};
|
|
383
383
|
}();
|
|
384
384
|
var _rowSelection = (0, _objectSpread3.default)({
|
|
@@ -432,7 +432,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
432
432
|
};
|
|
433
433
|
// 初始化回显,当传入initParams时,前端用来回险
|
|
434
434
|
var getInitValues = /*#__PURE__*/function () {
|
|
435
|
-
var
|
|
435
|
+
var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee4() {
|
|
436
436
|
var _contentForm$getField, _useRequest$options2, _useRequest$options3, queryBean, page, params, res, _res$data2, _list, list, _data, nextSelectRowKeys;
|
|
437
437
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee4$(_context4) {
|
|
438
438
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -490,12 +490,12 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
490
490
|
}, _callee4);
|
|
491
491
|
}));
|
|
492
492
|
return function getInitValues() {
|
|
493
|
-
return
|
|
493
|
+
return _ref10.apply(this, arguments);
|
|
494
494
|
};
|
|
495
495
|
}();
|
|
496
496
|
// 初始化回显,当传入initParams时,前端用来回险
|
|
497
497
|
var getDefaultOneValues = /*#__PURE__*/function () {
|
|
498
|
-
var
|
|
498
|
+
var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee5() {
|
|
499
499
|
var _useRequest$options4, _useRequest$options5;
|
|
500
500
|
var queryBean, page, params, res, _res$data3, _list2, list, _data2, nextSelectRowKeys;
|
|
501
501
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee5$(_context5) {
|
|
@@ -543,7 +543,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
543
543
|
}, _callee5);
|
|
544
544
|
}));
|
|
545
545
|
return function getDefaultOneValues() {
|
|
546
|
-
return
|
|
546
|
+
return _ref11.apply(this, arguments);
|
|
547
547
|
};
|
|
548
548
|
}();
|
|
549
549
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
@@ -574,7 +574,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
574
574
|
});
|
|
575
575
|
}
|
|
576
576
|
});
|
|
577
|
-
(0,
|
|
577
|
+
(0, _ahooks.useDeepCompareEffect)(function () {
|
|
578
578
|
if (onOff && !visible) {
|
|
579
579
|
var _useRequest$options6;
|
|
580
580
|
if ((useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options6 = useRequest.options) === null || _useRequest$options6 === void 0 ? void 0 : _useRequest$options6.manual) !== true) {
|
|
@@ -610,12 +610,12 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
610
610
|
setState(nextState);
|
|
611
611
|
}
|
|
612
612
|
}, [onOff, visible, value]);
|
|
613
|
-
(0,
|
|
613
|
+
(0, _ahooks.useDeepCompareEffect)(function () {
|
|
614
614
|
if (value && !visible && isInit && !readOnly) {
|
|
615
615
|
getInitValues();
|
|
616
616
|
}
|
|
617
|
-
}, [value, visible, isInit
|
|
618
|
-
(0,
|
|
617
|
+
}, [value, visible, isInit]);
|
|
618
|
+
(0, _ahooks.useDeepCompareEffect)(function () {
|
|
619
619
|
if (value && !visible && readOnly) {
|
|
620
620
|
var _options$some;
|
|
621
621
|
var isHasValue = options === null || options === void 0 ? void 0 : (_options$some = options.some) === null || _options$some === void 0 ? void 0 : _options$some.call(options, function (item) {
|
|
@@ -642,7 +642,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
642
642
|
}, 300);
|
|
643
643
|
}
|
|
644
644
|
}, [value, options, visible, useRequest]);
|
|
645
|
-
(0,
|
|
645
|
+
(0, _ahooks.useDeepCompareEffect)(function () {
|
|
646
646
|
if (!value) {
|
|
647
647
|
if (defaultOne) {
|
|
648
648
|
getDefaultOneValues();
|
|
@@ -742,7 +742,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
742
742
|
children: customRender
|
|
743
743
|
});
|
|
744
744
|
}
|
|
745
|
-
(0,
|
|
745
|
+
(0, _ahooks.useDeepCompareEffect)(function () {
|
|
746
746
|
if (isTooltip && value) {
|
|
747
747
|
var dom = document.getElementById(uuid);
|
|
748
748
|
dom.addEventListener('mouseover', function (e) {
|
|
@@ -779,7 +779,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
779
779
|
}, [value, isTooltip]);
|
|
780
780
|
(0, _ahooks.useDeepCompareEffect)(function () {
|
|
781
781
|
setState({
|
|
782
|
-
options: tableProps === null || tableProps === void 0 ? void 0 : tableProps.dataSource
|
|
782
|
+
options: (tableProps === null || tableProps === void 0 ? void 0 : tableProps.dataSource) || []
|
|
783
783
|
});
|
|
784
784
|
}, [tableProps === null || tableProps === void 0 ? void 0 : tableProps.dataSource]);
|
|
785
785
|
// 当搜索条件只有一个时,且为输入框,默认设置suffix
|
|
@@ -19,7 +19,7 @@ var _ProConfigProvider = require("../../../ProConfigProvider");
|
|
|
19
19
|
var _utils = require("../../../utils");
|
|
20
20
|
var _excluded = ["name", "names", "namesStr", "form", "equalWith", "children", "type", "diffConfig", "valuePropName"];
|
|
21
21
|
var ChangedWrapper = function ChangedWrapper(props) {
|
|
22
|
-
var _diffConfig$toolTip, _children$props;
|
|
22
|
+
var _diffConfig$toolTip, _children$props, _children$props2, _children$props3;
|
|
23
23
|
var name = props.name,
|
|
24
24
|
names = props.names,
|
|
25
25
|
namesStr = props.namesStr,
|
|
@@ -37,7 +37,6 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
37
37
|
changeTipColor = diffConfig.changeTipColor,
|
|
38
38
|
addTipColor = diffConfig.addTipColor;
|
|
39
39
|
var toolTip = (_diffConfig$toolTip = diffConfig.toolTip) !== null && _diffConfig$toolTip !== void 0 ? _diffConfig$toolTip : true;
|
|
40
|
-
// 不渲染tooltip
|
|
41
40
|
var isWatch = toolTip && !['FormList', 'ProEditTable'].includes(type);
|
|
42
41
|
var originalValue = (names === null || names === void 0 ? void 0 : names.length) ? names.map(function (name) {
|
|
43
42
|
return (0, _lodash.get)(originalValues, name);
|
|
@@ -62,7 +61,11 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
62
61
|
}, valuePropName, originalValue))) : undefined;
|
|
63
62
|
}, [originalValue, children]);
|
|
64
63
|
if (!isWatch || noChange) {
|
|
65
|
-
|
|
64
|
+
// 嵌套子组件
|
|
65
|
+
var isNestedField = ['ProEditTable'].includes(type);
|
|
66
|
+
return /*#__PURE__*/_react.default.isValidElement(children) && /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)({
|
|
67
|
+
originalValues: isNestedField ? originalValues : undefined
|
|
68
|
+
}, children.props), rest));
|
|
66
69
|
}
|
|
67
70
|
var tipOpenCalc = function tipOpenCalc() {
|
|
68
71
|
if (!toolTip) return false;
|
|
@@ -77,6 +80,8 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
77
80
|
'pro-form-item-changed': isChanged,
|
|
78
81
|
'pro-form-item-add': isAdd
|
|
79
82
|
});
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
var _showEllipse = ((_children$props = children.props) === null || _children$props === void 0 ? void 0 : _children$props.showEllipse) || ((_children$props2 = children.props) === null || _children$props2 === void 0 ? void 0 : _children$props2.tooltip);
|
|
80
85
|
return (0, _jsxRuntime.jsx)(_antd.Tooltip, {
|
|
81
86
|
open: tipOpenCalc(),
|
|
82
87
|
mouseEnterDelay: 1,
|
|
@@ -87,7 +92,7 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
87
92
|
direction: "vertical",
|
|
88
93
|
children: [(0, _jsxRuntime.jsxs)(_antd.Space, {
|
|
89
94
|
children: ["\u521D\u59CB\u503C\uFF1A", tipContent]
|
|
90
|
-
}),
|
|
95
|
+
}), _showEllipse && (0, _jsxRuntime.jsxs)(_antd.Space, {
|
|
91
96
|
children: ["\u5F53\u524D\u503C\uFF1A", /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)((0, _objectSpread3.default)({}, children.props), rest), {}, {
|
|
92
97
|
isView: true
|
|
93
98
|
})) : undefined]
|
|
@@ -98,7 +103,9 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
98
103
|
className: diffClassName,
|
|
99
104
|
style: style,
|
|
100
105
|
children: /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)((0, _objectSpread3.default)({}, children.props), rest), {}, {
|
|
101
|
-
|
|
106
|
+
otherProps: (0, _objectSpread3.default)((0, _objectSpread3.default)({}, (_children$props3 = children.props) === null || _children$props3 === void 0 ? void 0 : _children$props3.otherProps), {}, {
|
|
107
|
+
isDiffChange: isChanged
|
|
108
|
+
})
|
|
102
109
|
})) : undefined
|
|
103
110
|
})
|
|
104
111
|
});
|
package/lib/ProSelect/index.js
CHANGED
|
@@ -297,7 +297,8 @@ var ProSelect = exports.ProSelect = function ProSelect(props, ref) {
|
|
|
297
297
|
showArrow: true,
|
|
298
298
|
loading: fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.loading,
|
|
299
299
|
onChange: handleChange,
|
|
300
|
-
optionLabelProp
|
|
300
|
+
// optionLabelProp={otherProps?.isDiffChange ? "label" : 'children'} // 解决warning报错,添加默认值
|
|
301
|
+
optionLabelProp: "label" // 解决warning报错,添加默认值
|
|
301
302
|
,
|
|
302
303
|
showSearch: true,
|
|
303
304
|
filterOption: (0, _lodash.isFunction)(_onSearch) ? false : function (input, option) {
|
|
@@ -315,16 +316,15 @@ var ProSelect = exports.ProSelect = function ProSelect(props, ref) {
|
|
|
315
316
|
value: transformValue(),
|
|
316
317
|
children: Array.isArray(newSelectList) && newSelectList.map(function (item) {
|
|
317
318
|
return (0, _jsxRuntime.jsx)(Option, {
|
|
319
|
+
label: item[label],
|
|
318
320
|
value: item[code],
|
|
319
321
|
record: item,
|
|
320
322
|
disabled: !!item.disabled,
|
|
321
323
|
children: (0, _jsxRuntime.jsx)(TooltipOption, {
|
|
322
324
|
title: OptionRender ? OptionRender(item) : selectProps.showCodeName ? "".concat(item[code], "-").concat(item[label]) : item[label],
|
|
323
325
|
children: OptionRender ? (0, _jsxRuntime.jsx)("span", {
|
|
324
|
-
title: OptionRender(item),
|
|
325
326
|
children: OptionRender(item)
|
|
326
327
|
}) : (0, _jsxRuntime.jsx)("span", {
|
|
327
|
-
title: selectProps.showCodeName ? "".concat(item[code], "-").concat(item[label]) : item[label],
|
|
328
328
|
children: selectProps.showCodeName ? "".concat(item[code], "-").concat(item[label]) : item[label]
|
|
329
329
|
})
|
|
330
330
|
}, item[code])
|
|
@@ -76,13 +76,13 @@ var ProTreeSelect = exports.ProTreeSelect = function ProTreeSelect(props, ref) {
|
|
|
76
76
|
var _props$value = props.value,
|
|
77
77
|
value = _props$value === void 0 ? undefined : _props$value;
|
|
78
78
|
var _props$showEllipse = props.showEllipse,
|
|
79
|
-
showEllipse = _props$showEllipse === void 0 ? true : _props$showEllipse
|
|
80
|
-
|
|
81
|
-
isDiffChange =
|
|
79
|
+
showEllipse = _props$showEllipse === void 0 ? true : _props$showEllipse;
|
|
80
|
+
var _ref2 = otherProps !== null && otherProps !== void 0 ? otherProps : {},
|
|
81
|
+
isDiffChange = _ref2.isDiffChange;
|
|
82
82
|
var _showEllipse = showEllipse && !isDiffChange;
|
|
83
|
-
var
|
|
84
|
-
isView =
|
|
85
|
-
viewEmpty =
|
|
83
|
+
var _ref3 = otherProps || {},
|
|
84
|
+
isView = _ref3.isView,
|
|
85
|
+
viewEmpty = _ref3.viewEmpty;
|
|
86
86
|
if (fieldNames && Object.keys(fieldNames).length) {
|
|
87
87
|
code = fieldNames.value || 'value';
|
|
88
88
|
label = fieldNames.label || 'label';
|
|
@@ -215,8 +215,8 @@ var ProTreeSelect = exports.ProTreeSelect = function ProTreeSelect(props, ref) {
|
|
|
215
215
|
return undefined;
|
|
216
216
|
}
|
|
217
217
|
// 如果配置手动加载,不执行请求
|
|
218
|
-
var
|
|
219
|
-
defaultParams =
|
|
218
|
+
var _ref4 = (useRequest === null || useRequest === void 0 ? void 0 : useRequest.options) || {},
|
|
219
|
+
defaultParams = _ref4.defaultParams;
|
|
220
220
|
// 执行用户配置的枚举服务,拉取枚举数据进行更新
|
|
221
221
|
fetchFunction.run(defaultParams);
|
|
222
222
|
}, [useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, defaultDisableValue]);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { ProFormOtherProps } from '../../ProForm/propsType';
|
|
2
3
|
declare function SearchTitle(props: {
|
|
3
4
|
searchStr?: string;
|
|
4
5
|
label?: string;
|
|
5
6
|
showEllipse?: boolean;
|
|
6
7
|
ellipseWidth?: string;
|
|
7
|
-
|
|
8
|
+
otherProps?: ProFormOtherProps;
|
|
8
9
|
}): import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
declare const _default: import("react").MemoExoticComponent<typeof SearchTitle>;
|
|
10
11
|
export default _default;
|
|
@@ -8,14 +8,25 @@ exports.default = void 0;
|
|
|
8
8
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
var _AdaptiveTooltip = _interopRequireDefault(require("./AdaptiveTooltip"));
|
|
11
|
+
/*
|
|
12
|
+
* @Author: za-xuwenli xuwenli@zhongan.io
|
|
13
|
+
* @Date: 2024-09-26 14:37:00
|
|
14
|
+
* @LastEditors: za-xuwenli xuwenli@zhongan.io
|
|
15
|
+
* @LastEditTime: 2024-09-26 17:50:59
|
|
16
|
+
* @FilePath: /za-material-warehouse/src/ProTree/components/SearchTitle.tsx
|
|
17
|
+
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
18
|
+
*/
|
|
19
|
+
|
|
11
20
|
function SearchTitle(props) {
|
|
12
21
|
var label = props.label,
|
|
13
22
|
_props$searchStr = props.searchStr,
|
|
14
23
|
searchStr = _props$searchStr === void 0 ? '' : _props$searchStr,
|
|
15
24
|
showEllipse = props.showEllipse,
|
|
16
25
|
ellipseWidth = props.ellipseWidth,
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
otherProps = props.otherProps;
|
|
27
|
+
var _ref = otherProps !== null && otherProps !== void 0 ? otherProps : {},
|
|
28
|
+
_ref$isDiffChange = _ref.isDiffChange,
|
|
29
|
+
isDiffChange = _ref$isDiffChange === void 0 ? false : _ref$isDiffChange;
|
|
19
30
|
var strTitle = label;
|
|
20
31
|
var index = strTitle === null || strTitle === void 0 ? void 0 : strTitle.indexOf(searchStr);
|
|
21
32
|
var beforeStr = strTitle === null || strTitle === void 0 ? void 0 : strTitle.substring(0, index);
|
|
@@ -183,23 +183,21 @@ function List(props, ref) {
|
|
|
183
183
|
setAutoExpandParent(false);
|
|
184
184
|
};
|
|
185
185
|
if (mode === 'render') {
|
|
186
|
-
return (0, _jsxRuntime.jsx)(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
height: 432
|
|
202
|
-
})
|
|
186
|
+
return (0, _jsxRuntime.jsx)(_antd.Tree, {
|
|
187
|
+
disabled: disabled,
|
|
188
|
+
style: {
|
|
189
|
+
width: '100%'
|
|
190
|
+
},
|
|
191
|
+
checkable: true,
|
|
192
|
+
treeData: _treeData,
|
|
193
|
+
onExpand: onExpand,
|
|
194
|
+
expandedKeys: expandedKeys,
|
|
195
|
+
autoExpandParent: autoExpandParent,
|
|
196
|
+
selectable: false,
|
|
197
|
+
onCheck: onCheck,
|
|
198
|
+
checkedKeys: checkedValues,
|
|
199
|
+
checkStrictly: searchStr ? true : checkStrictly,
|
|
200
|
+
height: 432
|
|
203
201
|
});
|
|
204
202
|
}
|
|
205
203
|
return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
@@ -20,6 +20,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
20
20
|
var _index = require("../index");
|
|
21
21
|
var _components = require("./components");
|
|
22
22
|
var _utils = require("./utils");
|
|
23
|
+
var _index2 = require("../ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/index");
|
|
23
24
|
var _inputSearch = _interopRequireDefault(require("../assets/input-search.svg"));
|
|
24
25
|
var _locale = _interopRequireWildcard(require("../locale"));
|
|
25
26
|
require("./style/index.less");
|
|
@@ -27,7 +28,7 @@ require("./style/index.less");
|
|
|
27
28
|
* @Author: za-xuwenli xuwenli@zhongan.io
|
|
28
29
|
* @Date: 2024-06-04 10:01:18
|
|
29
30
|
* @LastEditors: za-xuwenli xuwenli@zhongan.io
|
|
30
|
-
* @LastEditTime: 2024-
|
|
31
|
+
* @LastEditTime: 2024-09-27 11:49:28
|
|
31
32
|
* @FilePath: /za-material-warehouse/src/ProTreeModal/index.tsx
|
|
32
33
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
33
34
|
*/
|
|
@@ -100,7 +101,8 @@ var ProTreeModal = function ProTreeModal(props) {
|
|
|
100
101
|
flatTreeData: [],
|
|
101
102
|
searchStr: '',
|
|
102
103
|
checkAll: false,
|
|
103
|
-
allKeys: []
|
|
104
|
+
allKeys: [],
|
|
105
|
+
transformedTree: []
|
|
104
106
|
}),
|
|
105
107
|
_useSetState2 = (0, _slicedToArray2.default)(_useSetState, 2),
|
|
106
108
|
state = _useSetState2[0],
|
|
@@ -222,6 +224,12 @@ var ProTreeModal = function ProTreeModal(props) {
|
|
|
222
224
|
});
|
|
223
225
|
}
|
|
224
226
|
}, [value, state.allKeys, state.open]);
|
|
227
|
+
(0, _ahooks.useDeepCompareEffect)(function () {
|
|
228
|
+
var transformedTree = (0, _utils.addLevelAndParentId)(state.treeData, fieldNames);
|
|
229
|
+
setState({
|
|
230
|
+
transformedTree: transformedTree
|
|
231
|
+
});
|
|
232
|
+
}, [state.treeData]);
|
|
225
233
|
var handleClick = function handleClick() {
|
|
226
234
|
setState({
|
|
227
235
|
open: true
|
|
@@ -362,8 +370,55 @@ var ProTreeModal = function ProTreeModal(props) {
|
|
|
362
370
|
var onCheck = function onCheck(checkedKeys, info) {
|
|
363
371
|
var checkedValues = (0, _toConsumableArray2.default)(state.checkedValues);
|
|
364
372
|
var originalTreeData = state.originalTreeData;
|
|
373
|
+
// 如果有检索则自管理
|
|
374
|
+
if (state.searchStr) {
|
|
375
|
+
var _transformTreeToArray;
|
|
376
|
+
var node = info.node;
|
|
377
|
+
// 从完整树中找到当前节点
|
|
378
|
+
var activeNode = (0, _index2.treeNodeFind)(state.transformedTree, function (t) {
|
|
379
|
+
return t[fieldNameValue] === node[fieldNameValue];
|
|
380
|
+
}, {
|
|
381
|
+
childrenKey: fieldNames.children
|
|
382
|
+
});
|
|
383
|
+
var allChildren = (_transformTreeToArray = (0, _index2.transformTreeToArray)([activeNode], {
|
|
384
|
+
childrenKey: fieldNames.children
|
|
385
|
+
})) === null || _transformTreeToArray === void 0 ? void 0 : _transformTreeToArray.map(function (item) {
|
|
386
|
+
return item[fieldNameValue];
|
|
387
|
+
});
|
|
388
|
+
// 子项合并勾选
|
|
389
|
+
checkedValues = checkedValues.concat(allChildren);
|
|
390
|
+
// 从完整树中拿到父节点 只要存在父节点,那么就判断当前children是否全被勾选 若全被勾选就合并当前key到勾选队列
|
|
391
|
+
var _recourse2 = function _recourse(findNode) {
|
|
392
|
+
if (findNode.parentId) {
|
|
393
|
+
var _transformTreeToArray2;
|
|
394
|
+
var parentNode = (0, _index2.treeNodeFind)(state.transformedTree, function (t) {
|
|
395
|
+
return t[fieldNameValue] === findNode.parentId;
|
|
396
|
+
}, {
|
|
397
|
+
childrenKey: fieldNames.children
|
|
398
|
+
});
|
|
399
|
+
var parentChildrenKeys = (_transformTreeToArray2 = (0, _index2.transformTreeToArray)([parentNode], {
|
|
400
|
+
childrenKey: fieldNames.children
|
|
401
|
+
})) === null || _transformTreeToArray2 === void 0 ? void 0 : _transformTreeToArray2.map(function (item) {
|
|
402
|
+
return item[fieldNameValue];
|
|
403
|
+
});
|
|
404
|
+
var parentChildrenAllChecked = parentChildrenKeys.every(function (key) {
|
|
405
|
+
return checkedValues.includes(key);
|
|
406
|
+
});
|
|
407
|
+
if (parentChildrenAllChecked) {
|
|
408
|
+
// 把当前父节点追加进来
|
|
409
|
+
checkedValues = checkedValues.concat([parentNode[fieldNameValue]]);
|
|
410
|
+
// 继续向上查找
|
|
411
|
+
if (parentNode.parentId) {
|
|
412
|
+
_recourse2(parentNode);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
_recourse2(activeNode);
|
|
418
|
+
}
|
|
419
|
+
var _checkStrictly = state.searchStr ? true : checkStrictly;
|
|
365
420
|
// 此时应该取消掉自身并包含它所有的子集
|
|
366
|
-
if (!info.checked && !
|
|
421
|
+
if (!info.checked && !_checkStrictly) {
|
|
367
422
|
// 1. 取消自身
|
|
368
423
|
// 2. 把所有的子节点也要取消
|
|
369
424
|
var childrenkeys = [];
|
|
@@ -380,8 +435,8 @@ var ProTreeModal = function ProTreeModal(props) {
|
|
|
380
435
|
return !parentKeys.includes(key);
|
|
381
436
|
});
|
|
382
437
|
} else {
|
|
383
|
-
//
|
|
384
|
-
if (
|
|
438
|
+
// _checkStrictly 模式下取 checkedKeys.checked 或者自身的 key
|
|
439
|
+
if (_checkStrictly) {
|
|
385
440
|
if (!info.checked) {
|
|
386
441
|
checkedValues = checkedValues.filter(function (key) {
|
|
387
442
|
return key !== info.node.key;
|
|
@@ -620,7 +675,7 @@ var ProTreeModal = function ProTreeModal(props) {
|
|
|
620
675
|
});
|
|
621
676
|
case TREE:
|
|
622
677
|
return (0, _jsxRuntime.jsx)(_components.TreeView, {
|
|
623
|
-
treeData: state.
|
|
678
|
+
treeData: state.transformedTree,
|
|
624
679
|
originalTreeData: state.originalTreeData,
|
|
625
680
|
flatTreeData: state.flatTreeData,
|
|
626
681
|
checkedValues: state.checkedValues,
|
|
@@ -36,3 +36,4 @@ export declare function filterCheckedNodes(data: any, checkedKeys: any, searchSt
|
|
|
36
36
|
*/
|
|
37
37
|
export declare function getChildrenKeys(node: TreeDataProps, childrenKeys: string[], fieldNames: FieldNamesType, type: 'treeClose' | 'treeCheck'): void;
|
|
38
38
|
export declare const transformMessage: (obj: any, message: string) => string;
|
|
39
|
+
export declare const addLevelAndParentId: (tree: any[], fieldNames: any, currentLevel?: number, currentParentId?: any) => any[];
|
|
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.addLevelAndParentId = void 0;
|
|
7
8
|
exports.filterCheckedNodes = filterCheckedNodes;
|
|
8
9
|
exports.findTreeNodeByKey = findTreeNodeByKey;
|
|
9
10
|
exports.getAllKeys = getAllKeys;
|
|
@@ -209,4 +210,23 @@ var transformMessage = exports.transformMessage = function transformMessage(obj,
|
|
|
209
210
|
_message = message.replaceAll("{".concat(key, "}"), obj[key]);
|
|
210
211
|
});
|
|
211
212
|
return _message;
|
|
213
|
+
};
|
|
214
|
+
var _addLevelAndParentId = exports.addLevelAndParentId = function addLevelAndParentId() {
|
|
215
|
+
var tree = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
216
|
+
var fieldNames = arguments.length > 1 ? arguments[1] : undefined;
|
|
217
|
+
var currentLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
218
|
+
var currentParentId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
219
|
+
var _fieldNames$children = fieldNames.children,
|
|
220
|
+
children = _fieldNames$children === void 0 ? 'children' : _fieldNames$children,
|
|
221
|
+
_fieldNames$value = fieldNames.value,
|
|
222
|
+
value = _fieldNames$value === void 0 ? 'value' : _fieldNames$value;
|
|
223
|
+
return tree.map(function (node) {
|
|
224
|
+
var newNode = (0, _objectSpread4.default)({}, node);
|
|
225
|
+
newNode.level = currentLevel;
|
|
226
|
+
newNode.parentId = currentParentId;
|
|
227
|
+
if (node[children]) {
|
|
228
|
+
newNode[children] = _addLevelAndParentId(node[children], fieldNames, currentLevel + 1, newNode[value]);
|
|
229
|
+
}
|
|
230
|
+
return newNode;
|
|
231
|
+
});
|
|
212
232
|
};
|