@zat-design/sisyphus-react 3.7.3-beta.1 → 3.7.3-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/ProEditTable/components/RenderField/{ListChanged.d.ts → ListChangedWrapper.d.ts} +2 -2
- package/es/ProEditTable/components/RenderField/{ListChanged.js → ListChangedWrapper.js} +15 -10
- package/es/ProEditTable/components/RenderField/index.js +2 -2
- package/es/ProEnum/index.js +5 -4
- package/es/ProEnum/utils/index.d.ts +1 -1
- package/es/ProEnum/utils/index.js +4 -0
- package/{lib/ProForm/components/render/Changed.d.ts → es/ProForm/components/render/ChangedWrapper.d.ts} +4 -3
- package/es/ProForm/components/render/{Changed.js → ChangedWrapper.js} +28 -14
- package/es/ProForm/components/render/Render.js +6 -8
- package/es/ProForm/components/render/RenderFields.d.ts +2 -3
- package/es/ProForm/components/render/RenderFields.js +2 -4
- package/es/ProForm/components/render/propsType.d.ts +2 -2
- package/es/ProForm/index.js +3 -6
- package/es/ProForm/propsType.d.ts +12 -2
- package/es/utils/index.d.ts +2 -0
- package/es/utils/index.js +13 -0
- package/lib/ProEditTable/components/RenderField/{ListChanged.d.ts → ListChangedWrapper.d.ts} +2 -2
- package/lib/ProEditTable/components/RenderField/{ListChanged.js → ListChangedWrapper.js} +18 -11
- package/lib/ProEditTable/components/RenderField/index.js +2 -2
- package/lib/ProEnum/index.js +5 -4
- package/lib/ProEnum/utils/index.d.ts +1 -1
- package/lib/ProEnum/utils/index.js +4 -0
- package/{es/ProForm/components/render/Changed.d.ts → lib/ProForm/components/render/ChangedWrapper.d.ts} +4 -3
- package/lib/ProForm/components/render/{Changed.js → ChangedWrapper.js} +28 -14
- package/lib/ProForm/components/render/Render.js +6 -8
- package/lib/ProForm/components/render/RenderFields.d.ts +2 -3
- package/lib/ProForm/components/render/RenderFields.js +2 -4
- package/lib/ProForm/components/render/propsType.d.ts +2 -2
- package/lib/ProForm/index.js +3 -6
- package/lib/ProForm/propsType.d.ts +12 -2
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +19 -0
- package/package.json +2 -1
- /package/es/ProForm/utils/{useChanged.d.ts → _useChanged.d.ts} +0 -0
- /package/es/ProForm/utils/{useChanged.js → _useChanged.js} +0 -0
- /package/es/ProForm/utils/{useListChanged.d.ts → _useListChanged.d.ts} +0 -0
- /package/es/ProForm/utils/{useListChanged.js → _useListChanged.js} +0 -0
- /package/lib/ProForm/utils/{useChanged.d.ts → _useChanged.d.ts} +0 -0
- /package/lib/ProForm/utils/{useChanged.js → _useChanged.js} +0 -0
- /package/lib/ProForm/utils/{useListChanged.d.ts → _useListChanged.d.ts} +0 -0
- /package/lib/ProForm/utils/{useListChanged.js → _useListChanged.js} +0 -0
|
@@ -12,5 +12,5 @@ interface Props {
|
|
|
12
12
|
equalWith?: (preValue: any, curValue: any) => boolean | undefined;
|
|
13
13
|
[name: string]: any;
|
|
14
14
|
}
|
|
15
|
-
declare const
|
|
16
|
-
export default
|
|
15
|
+
declare const ListChangedWrapper: React.FC<Props>;
|
|
16
|
+
export default ListChangedWrapper;
|
|
@@ -9,6 +9,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
9
9
|
import React, { useMemo } from 'react';
|
|
10
10
|
import { get } from 'lodash';
|
|
11
11
|
import { diffOriginal } from '../../../ProForm/utils/diffOriginal';
|
|
12
|
+
import { useProConfig } from '../../../ProConfigProvider';
|
|
13
|
+
import { isEmpty } from '../../../utils';
|
|
12
14
|
var toNamePath = function toNamePath(name) {
|
|
13
15
|
if (Array.isArray(name)) {
|
|
14
16
|
return name;
|
|
@@ -61,7 +63,7 @@ var getOriginalValue = function getOriginalValue(_ref) {
|
|
|
61
63
|
return get(originalValues, originalName);
|
|
62
64
|
}) : get(originalValues, originalName);
|
|
63
65
|
};
|
|
64
|
-
var
|
|
66
|
+
var ListChangedWrapper = function ListChangedWrapper(props) {
|
|
65
67
|
var name = props.name,
|
|
66
68
|
names = props.names,
|
|
67
69
|
namesStr = props.namesStr,
|
|
@@ -76,11 +78,13 @@ var ListChanged = function ListChanged(props) {
|
|
|
76
78
|
children = props.children,
|
|
77
79
|
type = props.type,
|
|
78
80
|
rest = _objectWithoutProperties(props, _excluded);
|
|
81
|
+
var _useProConfig = useProConfig('ProEditTable'),
|
|
82
|
+
isDiffAll = _useProConfig.isDiffAll;
|
|
79
83
|
var namePath = toNamePath(namesStr || name);
|
|
80
84
|
var originalNamePath = toNamePath(originalName);
|
|
81
85
|
var originalNamePaths = originalNames && toNamePaths(originalNames);
|
|
82
|
-
var
|
|
83
|
-
var originalValue =
|
|
86
|
+
var isWatch = originalValues && !['FormList', 'ProEditTable'].includes(type);
|
|
87
|
+
var originalValue = isWatch ? getOriginalValue({
|
|
84
88
|
namePath: namePath,
|
|
85
89
|
originalName: originalNamePath,
|
|
86
90
|
originalNames: originalNamePaths,
|
|
@@ -88,9 +92,9 @@ var ListChanged = function ListChanged(props) {
|
|
|
88
92
|
rowKeyPath: rowKeyPath,
|
|
89
93
|
form: form
|
|
90
94
|
}) : undefined;
|
|
91
|
-
var noChange = !equalWith && (!originalValues ||
|
|
92
|
-
var
|
|
93
|
-
if (
|
|
95
|
+
var noChange = !equalWith && (!originalValues || isDiffAll ? false : isEmpty(originalValue));
|
|
96
|
+
var isChanged = useMemo(function () {
|
|
97
|
+
if (!isWatch || noChange) return false;
|
|
94
98
|
return diffOriginal({
|
|
95
99
|
value: props.value,
|
|
96
100
|
originalValue: originalValue,
|
|
@@ -99,11 +103,12 @@ var ListChanged = function ListChanged(props) {
|
|
|
99
103
|
// name: isString(namesStr) ? namesStr : originalName || name,
|
|
100
104
|
});
|
|
101
105
|
}, [props.value, originalValue]);
|
|
102
|
-
if (
|
|
106
|
+
if (!isWatch || noChange) {
|
|
103
107
|
return /*#__PURE__*/React.isValidElement(children) && /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, children.props), rest));
|
|
104
108
|
}
|
|
105
109
|
return _jsx(_Tooltip, {
|
|
106
|
-
|
|
110
|
+
// 传入undefined 鼠标移入显示移出隐藏
|
|
111
|
+
open: isChanged ? undefined : false,
|
|
107
112
|
getPopupContainer: function getPopupContainer(target) {
|
|
108
113
|
return target.parentElement;
|
|
109
114
|
},
|
|
@@ -116,9 +121,9 @@ var ListChanged = function ListChanged(props) {
|
|
|
116
121
|
})) : undefined]
|
|
117
122
|
}),
|
|
118
123
|
children: _jsx("div", {
|
|
119
|
-
className:
|
|
124
|
+
className: isChanged ? 'pro-form-item-changed' : '',
|
|
120
125
|
children: /*#__PURE__*/React.isValidElement(children) ? /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, children.props), rest)) : undefined
|
|
121
126
|
})
|
|
122
127
|
});
|
|
123
128
|
};
|
|
124
|
-
export default
|
|
129
|
+
export default ListChangedWrapper;
|
|
@@ -25,7 +25,7 @@ import useRules from '../../../ProForm/utils/useRules';
|
|
|
25
25
|
import { isSelect, isTrim } from '../../../ProForm/utils';
|
|
26
26
|
import ConfirmWrapper from '../../../ProForm/components/render/ConfirmWrapper';
|
|
27
27
|
import { getDefaultProps } from '../../utils/getDefaultProps';
|
|
28
|
-
import
|
|
28
|
+
import ListChangedWrapper from './ListChangedWrapper';
|
|
29
29
|
var RenderField = function RenderField(_ref) {
|
|
30
30
|
var _type, _type$replace, _fieldProps2, _names, _TargetComponent4, _componentProps2;
|
|
31
31
|
var value = _ref.text,
|
|
@@ -547,7 +547,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
547
547
|
var FormItem = null;
|
|
548
548
|
var FieldComponent = /*#__PURE__*/React.isValidElement(TargetComponent) ? ( /*#__PURE__*/React.cloneElement(TargetComponent, componentProps)) : _jsx(TargetComponent, _objectSpread({}, componentProps));
|
|
549
549
|
if (originalValues) {
|
|
550
|
-
FieldComponent = _jsx(
|
|
550
|
+
FieldComponent = _jsx(ListChangedWrapper, {
|
|
551
551
|
name: cellName,
|
|
552
552
|
names: names,
|
|
553
553
|
namesStr: [].concat(_toConsumableArray(baseName), [index, dataIndex]),
|
package/es/ProEnum/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
11
11
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
12
12
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
13
13
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
14
|
-
var _excluded = ["code", "type", "dataSource", "useRequest", "value", "component", "onChange", "transformResponse", "otherProps"],
|
|
14
|
+
var _excluded = ["code", "type", "dataSource", "useRequest", "value", "component", "onChange", "transformResponse", "otherProps", "isView"],
|
|
15
15
|
_excluded2 = ["fieldNames", "clear", "cacheKey", "showCodeName"];
|
|
16
16
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
17
|
import { useDeepCompareEffect, useRequest as useRequestFunc } from 'ahooks';
|
|
@@ -39,10 +39,11 @@ var ProEnum = function ProEnum(props) {
|
|
|
39
39
|
onChange = props.onChange,
|
|
40
40
|
transformResponse = props.transformResponse,
|
|
41
41
|
otherProps = props.otherProps,
|
|
42
|
+
isView = props.isView,
|
|
42
43
|
enumProps = _objectWithoutProperties(props, _excluded);
|
|
43
44
|
var _ref = otherProps || {},
|
|
44
|
-
isView = _ref.isView,
|
|
45
45
|
viewEmpty = _ref.viewEmpty;
|
|
46
|
+
var _isView = isView || otherProps.isView;
|
|
46
47
|
var _ref2 = useProConfig('ProEnum') || {},
|
|
47
48
|
fieldNames = _ref2.fieldNames,
|
|
48
49
|
_ref2$clear = _ref2.clear,
|
|
@@ -226,7 +227,7 @@ var ProEnum = function ProEnum(props) {
|
|
|
226
227
|
if (!code && !dataSource && !useRequest) {
|
|
227
228
|
var _locale$ProEnum4;
|
|
228
229
|
_message.error(locale === null || locale === void 0 ? void 0 : (_locale$ProEnum4 = locale.ProEnum) === null || _locale$ProEnum4 === void 0 ? void 0 : _locale$ProEnum4.errorNoEnumType);
|
|
229
|
-
return;
|
|
230
|
+
// return;
|
|
230
231
|
}
|
|
231
232
|
var transToLabel = function transToLabel(value) {
|
|
232
233
|
var list = dataList && dataList.length ? dataList : enumLists;
|
|
@@ -271,7 +272,7 @@ var ProEnum = function ProEnum(props) {
|
|
|
271
272
|
};
|
|
272
273
|
return isFunction(props.optionRender) && record.length ? _optionRender() : labelList === null || labelList === void 0 ? void 0 : labelList.join(',');
|
|
273
274
|
};
|
|
274
|
-
if (
|
|
275
|
+
if (_isView) {
|
|
275
276
|
if (Array.isArray(value)) {
|
|
276
277
|
return _jsx(Container, {
|
|
277
278
|
tooltip: true,
|
|
@@ -5,7 +5,7 @@ interface EnumRes {
|
|
|
5
5
|
[key: string]: any;
|
|
6
6
|
}
|
|
7
7
|
export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any): EnumRes;
|
|
8
|
-
export declare function setEnumData(storage: StorageType, cacheKey: string, data:
|
|
8
|
+
export declare function setEnumData(storage: StorageType, cacheKey: string, data: any): boolean;
|
|
9
9
|
export declare function hasEnumList(storage: StorageType, cacheKey: any, code: string): DataOption[];
|
|
10
10
|
export declare function isObject(obj: any): boolean;
|
|
11
11
|
export declare function mergeCacheData(storage: string, code: string, cacheKey: string, responseData: any): void;
|
|
@@ -13,6 +13,10 @@ export function getEnumData(storage, cacheKey, baseEnumStorage) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
export function setEnumData(storage, cacheKey, data) {
|
|
16
|
+
var _Object$keys;
|
|
17
|
+
if (!((_Object$keys = Object.keys(data === null || data === void 0 ? void 0 : data.data)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
16
20
|
if (storage === 'localStorage') {
|
|
17
21
|
window.localStorage.setItem(cacheKey, JSON.stringify(data));
|
|
18
22
|
} else if (storage === 'sessionStorage') {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { FormInstance } from 'antd';
|
|
2
2
|
import { NamePath } from 'antd/lib/form/interface';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { DiffConfigProps } from '../../propsType';
|
|
4
5
|
interface Props {
|
|
5
6
|
name?: NamePath;
|
|
6
7
|
names?: NamePath[];
|
|
7
8
|
namesStr?: string;
|
|
8
|
-
|
|
9
|
+
diffConfig?: DiffConfigProps;
|
|
9
10
|
form: FormInstance;
|
|
10
11
|
equalWith?: (preValue: any, curValue: any) => boolean | undefined;
|
|
11
12
|
[name: string]: any;
|
|
12
13
|
}
|
|
13
|
-
declare const
|
|
14
|
-
export default
|
|
14
|
+
declare const ChangedWrapper: React.FC<Props>;
|
|
15
|
+
export default ChangedWrapper;
|
|
@@ -4,30 +4,36 @@ import "antd/es/tooltip/style";
|
|
|
4
4
|
import _Tooltip from "antd/es/tooltip";
|
|
5
5
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
6
6
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
7
|
-
var _excluded = ["name", "names", "namesStr", "
|
|
7
|
+
var _excluded = ["name", "names", "namesStr", "form", "equalWith", "children", "type", "diffConfig"];
|
|
8
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { get } from 'lodash';
|
|
10
10
|
import React, { useMemo } from 'react';
|
|
11
11
|
import { diffOriginal } from '../../utils/diffOriginal';
|
|
12
|
-
|
|
12
|
+
import { useProConfig } from '../../../ProConfigProvider';
|
|
13
|
+
import { isEmpty } from '../../../utils';
|
|
14
|
+
var ChangedWrapper = function ChangedWrapper(props) {
|
|
15
|
+
var _diffConfig$toolTip;
|
|
13
16
|
var name = props.name,
|
|
14
17
|
names = props.names,
|
|
15
18
|
namesStr = props.namesStr,
|
|
16
|
-
originalValues = props.originalValues,
|
|
17
19
|
form = props.form,
|
|
18
20
|
equalWith = props.equalWith,
|
|
19
21
|
children = props.children,
|
|
20
22
|
type = props.type,
|
|
21
|
-
|
|
23
|
+
diffConfig = props.diffConfig,
|
|
22
24
|
rest = _objectWithoutProperties(props, _excluded);
|
|
25
|
+
var _useProConfig = useProConfig('ProForm'),
|
|
26
|
+
isDiffAll = _useProConfig.isDiffAll;
|
|
27
|
+
var originalValues = diffConfig.originalValues;
|
|
28
|
+
var toolTip = (_diffConfig$toolTip = diffConfig.toolTip) !== null && _diffConfig$toolTip !== void 0 ? _diffConfig$toolTip : true;
|
|
23
29
|
// 不渲染tooltip
|
|
24
|
-
var
|
|
30
|
+
var isWatch = toolTip && !['FormList', 'ProEditTable'].includes(type);
|
|
25
31
|
var originalValue = (names === null || names === void 0 ? void 0 : names.length) ? names.map(function (name) {
|
|
26
32
|
return get(originalValues, name);
|
|
27
33
|
}) : get(originalValues, name);
|
|
28
|
-
var noChange = !equalWith && (!originalValues ||
|
|
29
|
-
var
|
|
30
|
-
if (
|
|
34
|
+
var noChange = !equalWith && (!originalValues || isDiffAll ? false : isEmpty(originalValue));
|
|
35
|
+
var isChanged = useMemo(function () {
|
|
36
|
+
if (!isWatch || noChange) return false;
|
|
31
37
|
return diffOriginal({
|
|
32
38
|
originalValue: originalValue,
|
|
33
39
|
value: props.value,
|
|
@@ -35,30 +41,38 @@ var Changed = function Changed(props) {
|
|
|
35
41
|
equalWith: equalWith
|
|
36
42
|
// name: namesStr || name,
|
|
37
43
|
});
|
|
38
|
-
}, [
|
|
44
|
+
}, [isWatch, noChange, props.value, originalValue]);
|
|
39
45
|
var tipContent = useMemo(function () {
|
|
40
|
-
if (
|
|
46
|
+
if (!isWatch || noChange) return undefined;
|
|
41
47
|
return /*#__PURE__*/React.isValidElement(children) ? /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, children.props), {}, {
|
|
42
48
|
isView: true,
|
|
43
49
|
value: originalValue,
|
|
44
50
|
checked: type === 'Switch' ? originalValue : undefined
|
|
45
51
|
})) : undefined;
|
|
46
52
|
}, [originalValue, children]);
|
|
47
|
-
if (
|
|
53
|
+
if (!isWatch || noChange) {
|
|
48
54
|
return /*#__PURE__*/React.isValidElement(children) && /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, children.props), rest));
|
|
49
55
|
}
|
|
56
|
+
var tipOpenCalc = function tipOpenCalc() {
|
|
57
|
+
if (!toolTip) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
// 传入undefined 鼠标移入显示移出隐藏
|
|
61
|
+
return isChanged ? undefined : false;
|
|
62
|
+
};
|
|
50
63
|
return _jsx(_Tooltip, {
|
|
51
|
-
open:
|
|
64
|
+
open: tipOpenCalc(),
|
|
52
65
|
getPopupContainer: function getPopupContainer(target) {
|
|
53
66
|
return target.parentElement;
|
|
54
67
|
},
|
|
55
68
|
title: _jsxs(_Space, {
|
|
56
69
|
children: ["\u521D\u59CB\u503C\uFF1A", tipContent]
|
|
57
70
|
}),
|
|
71
|
+
placement: "topLeft",
|
|
58
72
|
children: _jsx("div", {
|
|
59
|
-
className:
|
|
73
|
+
className: isChanged ? 'pro-form-item-changed' : '',
|
|
60
74
|
children: /*#__PURE__*/React.isValidElement(children) ? /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, children.props), rest)) : undefined
|
|
61
75
|
})
|
|
62
76
|
});
|
|
63
77
|
};
|
|
64
|
-
export default
|
|
78
|
+
export default ChangedWrapper;
|
|
@@ -28,7 +28,7 @@ import valueTypeMap from '../../utils/valueType';
|
|
|
28
28
|
import tipSvg from '../../../assets/tip.svg';
|
|
29
29
|
import useRules from '../../utils/useRules';
|
|
30
30
|
import ConfirmWrapper from './ConfirmWrapper';
|
|
31
|
-
import
|
|
31
|
+
import ChangedWrapper from './ChangedWrapper';
|
|
32
32
|
// 这个组件只管渲染, 参数的整理在外部处理
|
|
33
33
|
var Render = function Render(props) {
|
|
34
34
|
var _ref2, _ref3, _ref4, _ref5, _otherProps$names2;
|
|
@@ -46,12 +46,11 @@ var Render = function Render(props) {
|
|
|
46
46
|
formDisabled = props.formDisabled,
|
|
47
47
|
type = props.type,
|
|
48
48
|
isSelect = props.isSelect,
|
|
49
|
-
originalValues = props.originalValues,
|
|
50
49
|
equalWith = props.equalWith,
|
|
51
50
|
requiredOnView = props.requiredOnView,
|
|
52
|
-
originalDiffTip = props.originalDiffTip,
|
|
53
51
|
confirm = props.confirm,
|
|
54
|
-
globalControl = props.globalControl
|
|
52
|
+
globalControl = props.globalControl,
|
|
53
|
+
diffConfig = props.diffConfig;
|
|
55
54
|
var colProps = props.colProps;
|
|
56
55
|
// 剔除一些不是FormItem的属性, 防止控制台报warning
|
|
57
56
|
var labelWidth = formItemProps.labelWidth,
|
|
@@ -427,15 +426,14 @@ var Render = function Render(props) {
|
|
|
427
426
|
span: 24 // 默认占一行
|
|
428
427
|
});
|
|
429
428
|
}
|
|
430
|
-
if (
|
|
431
|
-
child = _jsx(
|
|
429
|
+
if (diffConfig) {
|
|
430
|
+
child = _jsx(ChangedWrapper, {
|
|
432
431
|
name: formItemProps.name,
|
|
433
432
|
names: otherProps.names,
|
|
434
433
|
namesStr: namesStr,
|
|
435
|
-
|
|
434
|
+
diffConfig: diffConfig,
|
|
436
435
|
form: form,
|
|
437
436
|
equalWith: equalWith,
|
|
438
|
-
originalDiffTip: originalDiffTip,
|
|
439
437
|
type: type,
|
|
440
438
|
onChange: handleChange,
|
|
441
439
|
children: child
|
|
@@ -2,7 +2,7 @@ import { ColProps } from 'antd';
|
|
|
2
2
|
import { FormInstance } from 'antd/es/form/Form';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { ProColumnProps } from './propsType';
|
|
5
|
-
import {
|
|
5
|
+
import { DiffConfigProps } from '../../propsType';
|
|
6
6
|
interface Props<T = any> {
|
|
7
7
|
isView?: boolean;
|
|
8
8
|
columns: ProColumnProps[];
|
|
@@ -13,11 +13,10 @@ interface Props<T = any> {
|
|
|
13
13
|
viewEmpty?: React.ReactNode;
|
|
14
14
|
openState?: boolean;
|
|
15
15
|
labelWidth?: string | number;
|
|
16
|
-
|
|
16
|
+
diffConfig?: DiffConfigProps;
|
|
17
17
|
clearNotShow?: boolean;
|
|
18
18
|
requiredOnView?: boolean;
|
|
19
19
|
required?: boolean | boolean[] | (() => boolean | boolean[]);
|
|
20
|
-
originalDiffTip?: boolean;
|
|
21
20
|
globalControl?: boolean;
|
|
22
21
|
}
|
|
23
22
|
declare const RenderFields: React.FC<Props>;
|
|
@@ -22,11 +22,10 @@ var RenderFields = function RenderFields(props) {
|
|
|
22
22
|
viewEmpty = _props$viewEmpty === void 0 ? '-' : _props$viewEmpty,
|
|
23
23
|
openState = props.openState,
|
|
24
24
|
labelWidth = props.labelWidth,
|
|
25
|
-
originalValues = props.originalValues,
|
|
26
25
|
outerClearNotShow = props.clearNotShow,
|
|
27
26
|
requiredOnView = props.requiredOnView,
|
|
28
27
|
required = props.required,
|
|
29
|
-
|
|
28
|
+
diffConfig = props.diffConfig,
|
|
30
29
|
globalControl = props.globalControl;
|
|
31
30
|
// 是否包含隐藏字段
|
|
32
31
|
var hiddenData = columns.filter(function (item) {
|
|
@@ -206,10 +205,9 @@ var RenderFields = function RenderFields(props) {
|
|
|
206
205
|
otherProps: otherProps,
|
|
207
206
|
fieldProps: isFunction(fieldProps) ? fieldProps : null,
|
|
208
207
|
isSelect: _isSelect,
|
|
209
|
-
|
|
208
|
+
diffConfig: diffConfig,
|
|
210
209
|
equalWith: equalWith,
|
|
211
210
|
requiredOnView: requiredOnView,
|
|
212
|
-
originalDiffTip: originalDiffTip,
|
|
213
211
|
globalControl: globalControl
|
|
214
212
|
})
|
|
215
213
|
}, "".concat(_formItemProps.name || _formItemProps.label).concat(index));
|
|
@@ -30,7 +30,7 @@ import { ProUploadProps } from '../../../ProUpload/propsType';
|
|
|
30
30
|
import { ProTreeProps } from '../../../ProTree/propsType';
|
|
31
31
|
import { GroupProps as GroupCopyProps } from '../combination/Group/propsType';
|
|
32
32
|
import { ProCollapseProps } from '../../../ProLayout/components/ProCollapse/PropTypes';
|
|
33
|
-
import { DistributiveOmit } from '../../propsType';
|
|
33
|
+
import { DistributiveOmit, DiffConfigProps } from '../../propsType';
|
|
34
34
|
export type ComponentMap = keyof typeof componentMap;
|
|
35
35
|
type ValidateKey = keyof typeof validate;
|
|
36
36
|
type RegExpKey = keyof typeof regExp;
|
|
@@ -267,7 +267,7 @@ export interface RenderProps<Values = any> {
|
|
|
267
267
|
form: FormInstance<Values>;
|
|
268
268
|
fieldProps?: ReactiveFunction<Values, React.ReactNode>;
|
|
269
269
|
isSelect: boolean;
|
|
270
|
-
|
|
270
|
+
diffConfig: DiffConfigProps;
|
|
271
271
|
requiredOnView?: boolean;
|
|
272
272
|
confirm?: ProFormColumnProps['confirm'];
|
|
273
273
|
globalControl?: boolean;
|
package/es/ProForm/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import _Space from "antd/es/space";
|
|
|
11
11
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
12
12
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
13
13
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
14
|
-
var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "
|
|
14
|
+
var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "diffConfig", "submitOnEnter", "clearNotShow", "initialValues", "requiredOnView", "formId", "required", "formKey", "globalControl", "scrollToError", "optimize"];
|
|
15
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
16
|
import { DoubleLeftOutlined } from '@ant-design/icons';
|
|
17
17
|
import classnames from 'classnames';
|
|
@@ -53,7 +53,7 @@ var ProForm = function ProForm(props, ref) {
|
|
|
53
53
|
labelWidth = props.labelWidth,
|
|
54
54
|
onValuesChange = props.onValuesChange,
|
|
55
55
|
onFinish = props.onFinish,
|
|
56
|
-
|
|
56
|
+
diffConfig = props.diffConfig,
|
|
57
57
|
submitOnEnter = props.submitOnEnter,
|
|
58
58
|
_props$clearNotShow = props.clearNotShow,
|
|
59
59
|
clearNotShow = _props$clearNotShow === void 0 ? true : _props$clearNotShow,
|
|
@@ -62,8 +62,6 @@ var ProForm = function ProForm(props, ref) {
|
|
|
62
62
|
requiredOnView = _props$requiredOnView === void 0 ? true : _props$requiredOnView,
|
|
63
63
|
formId = props.formId,
|
|
64
64
|
required = props.required,
|
|
65
|
-
_props$originalDiffTi = props.originalDiffTip,
|
|
66
|
-
originalDiffTip = _props$originalDiffTi === void 0 ? true : _props$originalDiffTi,
|
|
67
65
|
formKey = props.formKey,
|
|
68
66
|
globalControl = props.globalControl,
|
|
69
67
|
_props$scrollToError = props.scrollToError,
|
|
@@ -261,11 +259,10 @@ var ProForm = function ProForm(props, ref) {
|
|
|
261
259
|
colProps: colProps,
|
|
262
260
|
viewEmpty: viewEmpty,
|
|
263
261
|
labelWidth: labelWidth,
|
|
264
|
-
|
|
262
|
+
diffConfig: diffConfig,
|
|
265
263
|
clearNotShow: clearNotShow,
|
|
266
264
|
requiredOnView: requiredOnView,
|
|
267
265
|
required: required,
|
|
268
|
-
originalDiffTip: originalDiffTip,
|
|
269
266
|
globalControl: globalControl
|
|
270
267
|
}), footerRender()]
|
|
271
268
|
})), children]
|
|
@@ -45,6 +45,16 @@ export interface ProFormOtherProps {
|
|
|
45
45
|
globalControl?: boolean;
|
|
46
46
|
formDisabled?: boolean;
|
|
47
47
|
}
|
|
48
|
+
export interface DiffConfigProps<Values = any> {
|
|
49
|
+
/** 比对原始数据源 */
|
|
50
|
+
originalValues: Values;
|
|
51
|
+
/** 是否显示对比值气泡 */
|
|
52
|
+
toolTip?: boolean;
|
|
53
|
+
/** 变更提示颜色 */
|
|
54
|
+
changeTipColor?: string;
|
|
55
|
+
/** 新增提示颜色 */
|
|
56
|
+
addTipColor?: string;
|
|
57
|
+
}
|
|
48
58
|
export interface ProFormProps<Values = any> extends FormProps<Values> {
|
|
49
59
|
disabled?: boolean;
|
|
50
60
|
/** 全局控制优先 */
|
|
@@ -67,14 +77,14 @@ export interface ProFormProps<Values = any> extends FormProps<Values> {
|
|
|
67
77
|
viewEmpty?: React.ReactNode | string;
|
|
68
78
|
confirmLoading?: boolean;
|
|
69
79
|
labelWidth?: string | number;
|
|
70
|
-
originalValues?: Values;
|
|
71
80
|
/** 是否回车提交 */
|
|
72
81
|
submitOnEnter?: boolean;
|
|
73
82
|
clearNotShow?: boolean;
|
|
74
83
|
requiredOnView?: boolean;
|
|
75
84
|
formId?: string;
|
|
76
85
|
required?: boolean | boolean[];
|
|
77
|
-
|
|
86
|
+
/** 表单比对配置 */
|
|
87
|
+
diffConfig?: DiffConfigProps;
|
|
78
88
|
scrollToError?: boolean;
|
|
79
89
|
/** 性能模式,谨慎使用,默认不开启
|
|
80
90
|
* 1. 开启不过滤names的中间态值
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var EMPTY_VALUE = [undefined, null, ''];
|
|
2
|
+
/** 判断一个值是否是空值 */
|
|
3
|
+
export var isEmpty = function isEmpty(value) {
|
|
4
|
+
if (EMPTY_VALUE.includes(value)) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
if (Array.isArray(value)) {
|
|
8
|
+
return !(value === null || value === void 0 ? void 0 : value.length) || value.every(function (item) {
|
|
9
|
+
return EMPTY_VALUE.includes(item);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
};
|
package/lib/ProEditTable/components/RenderField/{ListChanged.d.ts → ListChangedWrapper.d.ts}
RENAMED
|
@@ -12,5 +12,5 @@ interface Props {
|
|
|
12
12
|
equalWith?: (preValue: any, curValue: any) => boolean | undefined;
|
|
13
13
|
[name: string]: any;
|
|
14
14
|
}
|
|
15
|
-
declare const
|
|
16
|
-
export default
|
|
15
|
+
declare const ListChangedWrapper: React.FC<Props>;
|
|
16
|
+
export default ListChangedWrapper;
|
|
@@ -13,6 +13,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
13
13
|
var _antd = require("antd");
|
|
14
14
|
var _lodash = require("lodash");
|
|
15
15
|
var _diffOriginal = require("../../../ProForm/utils/diffOriginal");
|
|
16
|
+
var _ProConfigProvider = require("../../../ProConfigProvider");
|
|
17
|
+
var _utils = require("../../../utils");
|
|
16
18
|
var _excluded = ["name", "names", "namesStr", "originalName", "originalNames", "originalValues", "form", "equalWith", "rowKeyPath", "children", "type"];
|
|
17
19
|
var toNamePath = function toNamePath(name) {
|
|
18
20
|
if (Array.isArray(name)) {
|
|
@@ -66,7 +68,7 @@ var getOriginalValue = function getOriginalValue(_ref) {
|
|
|
66
68
|
return (0, _lodash.get)(originalValues, originalName);
|
|
67
69
|
}) : (0, _lodash.get)(originalValues, originalName);
|
|
68
70
|
};
|
|
69
|
-
var
|
|
71
|
+
var ListChangedWrapper = function ListChangedWrapper(props) {
|
|
70
72
|
var name = props.name,
|
|
71
73
|
names = props.names,
|
|
72
74
|
namesStr = props.namesStr,
|
|
@@ -81,11 +83,13 @@ var ListChanged = function ListChanged(props) {
|
|
|
81
83
|
children = props.children,
|
|
82
84
|
type = props.type,
|
|
83
85
|
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
86
|
+
var _useProConfig = (0, _ProConfigProvider.useProConfig)('ProEditTable'),
|
|
87
|
+
isDiffAll = _useProConfig.isDiffAll;
|
|
84
88
|
var namePath = toNamePath(namesStr || name);
|
|
85
89
|
var originalNamePath = toNamePath(originalName);
|
|
86
90
|
var originalNamePaths = originalNames && toNamePaths(originalNames);
|
|
87
|
-
var
|
|
88
|
-
var originalValue =
|
|
91
|
+
var isWatch = originalValues && !['FormList', 'ProEditTable'].includes(type);
|
|
92
|
+
var originalValue = isWatch ? getOriginalValue({
|
|
89
93
|
namePath: namePath,
|
|
90
94
|
originalName: originalNamePath,
|
|
91
95
|
originalNames: originalNamePaths,
|
|
@@ -93,9 +97,9 @@ var ListChanged = function ListChanged(props) {
|
|
|
93
97
|
rowKeyPath: rowKeyPath,
|
|
94
98
|
form: form
|
|
95
99
|
}) : undefined;
|
|
96
|
-
var noChange = !equalWith && (!originalValues ||
|
|
97
|
-
var
|
|
98
|
-
if (
|
|
100
|
+
var noChange = !equalWith && (!originalValues || isDiffAll ? false : (0, _utils.isEmpty)(originalValue));
|
|
101
|
+
var isChanged = (0, _react.useMemo)(function () {
|
|
102
|
+
if (!isWatch || noChange) return false;
|
|
99
103
|
return (0, _diffOriginal.diffOriginal)({
|
|
100
104
|
value: props.value,
|
|
101
105
|
originalValue: originalValue,
|
|
@@ -104,11 +108,14 @@ var ListChanged = function ListChanged(props) {
|
|
|
104
108
|
// name: isString(namesStr) ? namesStr : originalName || name,
|
|
105
109
|
});
|
|
106
110
|
}, [props.value, originalValue]);
|
|
107
|
-
if (
|
|
111
|
+
if (!isWatch || noChange) {
|
|
108
112
|
return /*#__PURE__*/_react.default.isValidElement(children) && /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, children.props), rest));
|
|
109
113
|
}
|
|
110
|
-
return (0, _jsxRuntime.jsx)(_antd.Tooltip
|
|
111
|
-
|
|
114
|
+
return (0, _jsxRuntime.jsx)(_antd.Tooltip
|
|
115
|
+
// 传入undefined 鼠标移入显示移出隐藏
|
|
116
|
+
, {
|
|
117
|
+
// 传入undefined 鼠标移入显示移出隐藏
|
|
118
|
+
open: isChanged ? undefined : false,
|
|
112
119
|
getPopupContainer: function getPopupContainer(target) {
|
|
113
120
|
return target.parentElement;
|
|
114
121
|
},
|
|
@@ -121,9 +128,9 @@ var ListChanged = function ListChanged(props) {
|
|
|
121
128
|
})) : undefined]
|
|
122
129
|
}),
|
|
123
130
|
children: (0, _jsxRuntime.jsx)("div", {
|
|
124
|
-
className:
|
|
131
|
+
className: isChanged ? 'pro-form-item-changed' : '',
|
|
125
132
|
children: /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, children.props), rest)) : undefined
|
|
126
133
|
})
|
|
127
134
|
});
|
|
128
135
|
};
|
|
129
|
-
var _default = exports.default =
|
|
136
|
+
var _default = exports.default = ListChangedWrapper;
|
|
@@ -29,7 +29,7 @@ var _useRules = _interopRequireDefault(require("../../../ProForm/utils/useRules"
|
|
|
29
29
|
var _utils = require("../../../ProForm/utils");
|
|
30
30
|
var _ConfirmWrapper = _interopRequireDefault(require("../../../ProForm/components/render/ConfirmWrapper"));
|
|
31
31
|
var _getDefaultProps = require("../../utils/getDefaultProps");
|
|
32
|
-
var
|
|
32
|
+
var _ListChangedWrapper = _interopRequireDefault(require("./ListChangedWrapper"));
|
|
33
33
|
var _excluded = ["type", "valueType", "names", "fieldProps", "labelRequired", "editRender", "component", "viewRender", "title", "originTitle", "label", "dataIndex", "formItemProps", "isEditable", "required", "rules", "equalWith", "className", "trim", "confirm"];
|
|
34
34
|
/* eslint-disable prefer-destructuring */
|
|
35
35
|
/* eslint-disable prefer-const */
|
|
@@ -554,7 +554,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
554
554
|
var FormItem = null;
|
|
555
555
|
var FieldComponent = /*#__PURE__*/_react.default.isValidElement(TargetComponent) ? ( /*#__PURE__*/_react.default.cloneElement(TargetComponent, componentProps)) : (0, _jsxRuntime.jsx)(TargetComponent, (0, _objectSpread2.default)({}, componentProps));
|
|
556
556
|
if (originalValues) {
|
|
557
|
-
FieldComponent = (0, _jsxRuntime.jsx)(
|
|
557
|
+
FieldComponent = (0, _jsxRuntime.jsx)(_ListChangedWrapper.default, {
|
|
558
558
|
name: cellName,
|
|
559
559
|
names: names,
|
|
560
560
|
namesStr: [].concat((0, _toConsumableArray2.default)(baseName), [index, dataIndex]),
|
package/lib/ProEnum/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var _getEnumLabel = _interopRequireDefault(require("./utils/getEnumLabel"));
|
|
|
26
26
|
var _useEnum = _interopRequireDefault(require("./hooks/useEnum"));
|
|
27
27
|
var _locale = _interopRequireDefault(require("../locale"));
|
|
28
28
|
require("./style/index.less");
|
|
29
|
-
var _excluded = ["code", "type", "dataSource", "useRequest", "value", "component", "onChange", "transformResponse", "otherProps"],
|
|
29
|
+
var _excluded = ["code", "type", "dataSource", "useRequest", "value", "component", "onChange", "transformResponse", "otherProps", "isView"],
|
|
30
30
|
_excluded2 = ["fieldNames", "clear", "cacheKey", "showCodeName"];
|
|
31
31
|
var ProEnum = function ProEnum(props) {
|
|
32
32
|
var _enumProps$showCodeNa;
|
|
@@ -40,10 +40,11 @@ var ProEnum = function ProEnum(props) {
|
|
|
40
40
|
onChange = props.onChange,
|
|
41
41
|
transformResponse = props.transformResponse,
|
|
42
42
|
otherProps = props.otherProps,
|
|
43
|
+
isView = props.isView,
|
|
43
44
|
enumProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
44
45
|
var _ref = otherProps || {},
|
|
45
|
-
isView = _ref.isView,
|
|
46
46
|
viewEmpty = _ref.viewEmpty;
|
|
47
|
+
var _isView = isView || otherProps.isView;
|
|
47
48
|
var _ref2 = (0, _ProConfigProvider.useProConfig)('ProEnum') || {},
|
|
48
49
|
fieldNames = _ref2.fieldNames,
|
|
49
50
|
_ref2$clear = _ref2.clear,
|
|
@@ -227,7 +228,7 @@ var ProEnum = function ProEnum(props) {
|
|
|
227
228
|
if (!code && !dataSource && !useRequest) {
|
|
228
229
|
var _locale$ProEnum4;
|
|
229
230
|
_antd.message.error(_locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProEnum4 = _locale.default.ProEnum) === null || _locale$ProEnum4 === void 0 ? void 0 : _locale$ProEnum4.errorNoEnumType);
|
|
230
|
-
return;
|
|
231
|
+
// return;
|
|
231
232
|
}
|
|
232
233
|
var transToLabel = function transToLabel(value) {
|
|
233
234
|
var list = dataList && dataList.length ? dataList : enumLists;
|
|
@@ -272,7 +273,7 @@ var ProEnum = function ProEnum(props) {
|
|
|
272
273
|
};
|
|
273
274
|
return (0, _lodash.isFunction)(props.optionRender) && record.length ? _optionRender() : labelList === null || labelList === void 0 ? void 0 : labelList.join(',');
|
|
274
275
|
};
|
|
275
|
-
if (
|
|
276
|
+
if (_isView) {
|
|
276
277
|
if (Array.isArray(value)) {
|
|
277
278
|
return (0, _jsxRuntime.jsx)(_Container.default, {
|
|
278
279
|
tooltip: true,
|
|
@@ -5,7 +5,7 @@ interface EnumRes {
|
|
|
5
5
|
[key: string]: any;
|
|
6
6
|
}
|
|
7
7
|
export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any): EnumRes;
|
|
8
|
-
export declare function setEnumData(storage: StorageType, cacheKey: string, data:
|
|
8
|
+
export declare function setEnumData(storage: StorageType, cacheKey: string, data: any): boolean;
|
|
9
9
|
export declare function hasEnumList(storage: StorageType, cacheKey: any, code: string): DataOption[];
|
|
10
10
|
export declare function isObject(obj: any): boolean;
|
|
11
11
|
export declare function mergeCacheData(storage: string, code: string, cacheKey: string, responseData: any): void;
|
|
@@ -26,6 +26,10 @@ function getEnumData(storage, cacheKey, baseEnumStorage) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
function setEnumData(storage, cacheKey, data) {
|
|
29
|
+
var _Object$keys;
|
|
30
|
+
if (!((_Object$keys = Object.keys(data === null || data === void 0 ? void 0 : data.data)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
29
33
|
if (storage === 'localStorage') {
|
|
30
34
|
window.localStorage.setItem(cacheKey, JSON.stringify(data));
|
|
31
35
|
} else if (storage === 'sessionStorage') {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { FormInstance } from 'antd';
|
|
2
2
|
import { NamePath } from 'antd/lib/form/interface';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { DiffConfigProps } from '../../propsType';
|
|
4
5
|
interface Props {
|
|
5
6
|
name?: NamePath;
|
|
6
7
|
names?: NamePath[];
|
|
7
8
|
namesStr?: string;
|
|
8
|
-
|
|
9
|
+
diffConfig?: DiffConfigProps;
|
|
9
10
|
form: FormInstance;
|
|
10
11
|
equalWith?: (preValue: any, curValue: any) => boolean | undefined;
|
|
11
12
|
[name: string]: any;
|
|
12
13
|
}
|
|
13
|
-
declare const
|
|
14
|
-
export default
|
|
14
|
+
declare const ChangedWrapper: React.FC<Props>;
|
|
15
|
+
export default ChangedWrapper;
|
|
@@ -13,26 +13,32 @@ var _antd = require("antd");
|
|
|
13
13
|
var _lodash = require("lodash");
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
15
|
var _diffOriginal = require("../../utils/diffOriginal");
|
|
16
|
-
var
|
|
17
|
-
var
|
|
16
|
+
var _ProConfigProvider = require("../../../ProConfigProvider");
|
|
17
|
+
var _utils = require("../../../utils");
|
|
18
|
+
var _excluded = ["name", "names", "namesStr", "form", "equalWith", "children", "type", "diffConfig"];
|
|
19
|
+
var ChangedWrapper = function ChangedWrapper(props) {
|
|
20
|
+
var _diffConfig$toolTip;
|
|
18
21
|
var name = props.name,
|
|
19
22
|
names = props.names,
|
|
20
23
|
namesStr = props.namesStr,
|
|
21
|
-
originalValues = props.originalValues,
|
|
22
24
|
form = props.form,
|
|
23
25
|
equalWith = props.equalWith,
|
|
24
26
|
children = props.children,
|
|
25
27
|
type = props.type,
|
|
26
|
-
|
|
28
|
+
diffConfig = props.diffConfig,
|
|
27
29
|
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
30
|
+
var _useProConfig = (0, _ProConfigProvider.useProConfig)('ProForm'),
|
|
31
|
+
isDiffAll = _useProConfig.isDiffAll;
|
|
32
|
+
var originalValues = diffConfig.originalValues;
|
|
33
|
+
var toolTip = (_diffConfig$toolTip = diffConfig.toolTip) !== null && _diffConfig$toolTip !== void 0 ? _diffConfig$toolTip : true;
|
|
28
34
|
// 不渲染tooltip
|
|
29
|
-
var
|
|
35
|
+
var isWatch = toolTip && !['FormList', 'ProEditTable'].includes(type);
|
|
30
36
|
var originalValue = (names === null || names === void 0 ? void 0 : names.length) ? names.map(function (name) {
|
|
31
37
|
return (0, _lodash.get)(originalValues, name);
|
|
32
38
|
}) : (0, _lodash.get)(originalValues, name);
|
|
33
|
-
var noChange = !equalWith && (!originalValues ||
|
|
34
|
-
var
|
|
35
|
-
if (
|
|
39
|
+
var noChange = !equalWith && (!originalValues || isDiffAll ? false : (0, _utils.isEmpty)(originalValue));
|
|
40
|
+
var isChanged = (0, _react.useMemo)(function () {
|
|
41
|
+
if (!isWatch || noChange) return false;
|
|
36
42
|
return (0, _diffOriginal.diffOriginal)({
|
|
37
43
|
originalValue: originalValue,
|
|
38
44
|
value: props.value,
|
|
@@ -40,30 +46,38 @@ var Changed = function Changed(props) {
|
|
|
40
46
|
equalWith: equalWith
|
|
41
47
|
// name: namesStr || name,
|
|
42
48
|
});
|
|
43
|
-
}, [
|
|
49
|
+
}, [isWatch, noChange, props.value, originalValue]);
|
|
44
50
|
var tipContent = (0, _react.useMemo)(function () {
|
|
45
|
-
if (
|
|
51
|
+
if (!isWatch || noChange) return undefined;
|
|
46
52
|
return /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, children.props), {}, {
|
|
47
53
|
isView: true,
|
|
48
54
|
value: originalValue,
|
|
49
55
|
checked: type === 'Switch' ? originalValue : undefined
|
|
50
56
|
})) : undefined;
|
|
51
57
|
}, [originalValue, children]);
|
|
52
|
-
if (
|
|
58
|
+
if (!isWatch || noChange) {
|
|
53
59
|
return /*#__PURE__*/_react.default.isValidElement(children) && /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, children.props), rest));
|
|
54
60
|
}
|
|
61
|
+
var tipOpenCalc = function tipOpenCalc() {
|
|
62
|
+
if (!toolTip) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
// 传入undefined 鼠标移入显示移出隐藏
|
|
66
|
+
return isChanged ? undefined : false;
|
|
67
|
+
};
|
|
55
68
|
return (0, _jsxRuntime.jsx)(_antd.Tooltip, {
|
|
56
|
-
open:
|
|
69
|
+
open: tipOpenCalc(),
|
|
57
70
|
getPopupContainer: function getPopupContainer(target) {
|
|
58
71
|
return target.parentElement;
|
|
59
72
|
},
|
|
60
73
|
title: (0, _jsxRuntime.jsxs)(_antd.Space, {
|
|
61
74
|
children: ["\u521D\u59CB\u503C\uFF1A", tipContent]
|
|
62
75
|
}),
|
|
76
|
+
placement: "topLeft",
|
|
63
77
|
children: (0, _jsxRuntime.jsx)("div", {
|
|
64
|
-
className:
|
|
78
|
+
className: isChanged ? 'pro-form-item-changed' : '',
|
|
65
79
|
children: /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, children.props), rest)) : undefined
|
|
66
80
|
})
|
|
67
81
|
});
|
|
68
82
|
};
|
|
69
|
-
var _default = exports.default =
|
|
83
|
+
var _default = exports.default = ChangedWrapper;
|
|
@@ -26,7 +26,7 @@ var _valueType = _interopRequireDefault(require("../../utils/valueType"));
|
|
|
26
26
|
var _tip = _interopRequireDefault(require("../../../assets/tip.svg"));
|
|
27
27
|
var _useRules = _interopRequireDefault(require("../../utils/useRules"));
|
|
28
28
|
var _ConfirmWrapper = _interopRequireDefault(require("./ConfirmWrapper"));
|
|
29
|
-
var
|
|
29
|
+
var _ChangedWrapper = _interopRequireDefault(require("./ChangedWrapper"));
|
|
30
30
|
var _excluded = ["labelWidth", "hiddenNames", "trim", "upperCase", "className", "rules", "required", "labelRequired", "tooltip"];
|
|
31
31
|
/* eslint-disable prefer-destructuring */
|
|
32
32
|
// 这个组件只管渲染, 参数的整理在外部处理
|
|
@@ -46,12 +46,11 @@ var Render = function Render(props) {
|
|
|
46
46
|
formDisabled = props.formDisabled,
|
|
47
47
|
type = props.type,
|
|
48
48
|
isSelect = props.isSelect,
|
|
49
|
-
originalValues = props.originalValues,
|
|
50
49
|
equalWith = props.equalWith,
|
|
51
50
|
requiredOnView = props.requiredOnView,
|
|
52
|
-
originalDiffTip = props.originalDiffTip,
|
|
53
51
|
confirm = props.confirm,
|
|
54
|
-
globalControl = props.globalControl
|
|
52
|
+
globalControl = props.globalControl,
|
|
53
|
+
diffConfig = props.diffConfig;
|
|
55
54
|
var colProps = props.colProps;
|
|
56
55
|
// 剔除一些不是FormItem的属性, 防止控制台报warning
|
|
57
56
|
var labelWidth = formItemProps.labelWidth,
|
|
@@ -427,15 +426,14 @@ var Render = function Render(props) {
|
|
|
427
426
|
span: 24 // 默认占一行
|
|
428
427
|
});
|
|
429
428
|
}
|
|
430
|
-
if (
|
|
431
|
-
child = (0, _jsxRuntime.jsx)(
|
|
429
|
+
if (diffConfig) {
|
|
430
|
+
child = (0, _jsxRuntime.jsx)(_ChangedWrapper.default, {
|
|
432
431
|
name: formItemProps.name,
|
|
433
432
|
names: otherProps.names,
|
|
434
433
|
namesStr: namesStr,
|
|
435
|
-
|
|
434
|
+
diffConfig: diffConfig,
|
|
436
435
|
form: form,
|
|
437
436
|
equalWith: equalWith,
|
|
438
|
-
originalDiffTip: originalDiffTip,
|
|
439
437
|
type: type,
|
|
440
438
|
onChange: handleChange,
|
|
441
439
|
children: child
|
|
@@ -2,7 +2,7 @@ import { ColProps } from 'antd';
|
|
|
2
2
|
import { FormInstance } from 'antd/es/form/Form';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { ProColumnProps } from './propsType';
|
|
5
|
-
import {
|
|
5
|
+
import { DiffConfigProps } from '../../propsType';
|
|
6
6
|
interface Props<T = any> {
|
|
7
7
|
isView?: boolean;
|
|
8
8
|
columns: ProColumnProps[];
|
|
@@ -13,11 +13,10 @@ interface Props<T = any> {
|
|
|
13
13
|
viewEmpty?: React.ReactNode;
|
|
14
14
|
openState?: boolean;
|
|
15
15
|
labelWidth?: string | number;
|
|
16
|
-
|
|
16
|
+
diffConfig?: DiffConfigProps;
|
|
17
17
|
clearNotShow?: boolean;
|
|
18
18
|
requiredOnView?: boolean;
|
|
19
19
|
required?: boolean | boolean[] | (() => boolean | boolean[]);
|
|
20
|
-
originalDiffTip?: boolean;
|
|
21
20
|
globalControl?: boolean;
|
|
22
21
|
}
|
|
23
22
|
declare const RenderFields: React.FC<Props>;
|
|
@@ -30,11 +30,10 @@ var RenderFields = function RenderFields(props) {
|
|
|
30
30
|
viewEmpty = _props$viewEmpty === void 0 ? '-' : _props$viewEmpty,
|
|
31
31
|
openState = props.openState,
|
|
32
32
|
labelWidth = props.labelWidth,
|
|
33
|
-
originalValues = props.originalValues,
|
|
34
33
|
outerClearNotShow = props.clearNotShow,
|
|
35
34
|
requiredOnView = props.requiredOnView,
|
|
36
35
|
required = props.required,
|
|
37
|
-
|
|
36
|
+
diffConfig = props.diffConfig,
|
|
38
37
|
globalControl = props.globalControl;
|
|
39
38
|
// 是否包含隐藏字段
|
|
40
39
|
var hiddenData = columns.filter(function (item) {
|
|
@@ -214,10 +213,9 @@ var RenderFields = function RenderFields(props) {
|
|
|
214
213
|
otherProps: otherProps,
|
|
215
214
|
fieldProps: (0, _lodash.isFunction)(fieldProps) ? fieldProps : null,
|
|
216
215
|
isSelect: _isSelect,
|
|
217
|
-
|
|
216
|
+
diffConfig: diffConfig,
|
|
218
217
|
equalWith: equalWith,
|
|
219
218
|
requiredOnView: requiredOnView,
|
|
220
|
-
originalDiffTip: originalDiffTip,
|
|
221
219
|
globalControl: globalControl
|
|
222
220
|
})
|
|
223
221
|
}, "".concat(_formItemProps.name || _formItemProps.label).concat(index));
|
|
@@ -30,7 +30,7 @@ import { ProUploadProps } from '../../../ProUpload/propsType';
|
|
|
30
30
|
import { ProTreeProps } from '../../../ProTree/propsType';
|
|
31
31
|
import { GroupProps as GroupCopyProps } from '../combination/Group/propsType';
|
|
32
32
|
import { ProCollapseProps } from '../../../ProLayout/components/ProCollapse/PropTypes';
|
|
33
|
-
import { DistributiveOmit } from '../../propsType';
|
|
33
|
+
import { DistributiveOmit, DiffConfigProps } from '../../propsType';
|
|
34
34
|
export type ComponentMap = keyof typeof componentMap;
|
|
35
35
|
type ValidateKey = keyof typeof validate;
|
|
36
36
|
type RegExpKey = keyof typeof regExp;
|
|
@@ -267,7 +267,7 @@ export interface RenderProps<Values = any> {
|
|
|
267
267
|
form: FormInstance<Values>;
|
|
268
268
|
fieldProps?: ReactiveFunction<Values, React.ReactNode>;
|
|
269
269
|
isSelect: boolean;
|
|
270
|
-
|
|
270
|
+
diffConfig: DiffConfigProps;
|
|
271
271
|
requiredOnView?: boolean;
|
|
272
272
|
confirm?: ProFormColumnProps['confirm'];
|
|
273
273
|
globalControl?: boolean;
|
package/lib/ProForm/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var _useForm3 = require("./utils/useForm");
|
|
|
25
25
|
var _useFieldProps = require("./utils/useFieldProps");
|
|
26
26
|
var _locale = _interopRequireDefault(require("../locale"));
|
|
27
27
|
var _useWatch = _interopRequireDefault(require("./utils/useWatch"));
|
|
28
|
-
var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "
|
|
28
|
+
var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "diffConfig", "submitOnEnter", "clearNotShow", "initialValues", "requiredOnView", "formId", "required", "formKey", "globalControl", "scrollToError", "optimize"];
|
|
29
29
|
var ProForm = function ProForm(props, ref) {
|
|
30
30
|
var _forms$formKey, _localStorage, _ref;
|
|
31
31
|
var _props$mode = props.mode,
|
|
@@ -54,7 +54,7 @@ var ProForm = function ProForm(props, ref) {
|
|
|
54
54
|
labelWidth = props.labelWidth,
|
|
55
55
|
onValuesChange = props.onValuesChange,
|
|
56
56
|
onFinish = props.onFinish,
|
|
57
|
-
|
|
57
|
+
diffConfig = props.diffConfig,
|
|
58
58
|
submitOnEnter = props.submitOnEnter,
|
|
59
59
|
_props$clearNotShow = props.clearNotShow,
|
|
60
60
|
clearNotShow = _props$clearNotShow === void 0 ? true : _props$clearNotShow,
|
|
@@ -63,8 +63,6 @@ var ProForm = function ProForm(props, ref) {
|
|
|
63
63
|
requiredOnView = _props$requiredOnView === void 0 ? true : _props$requiredOnView,
|
|
64
64
|
formId = props.formId,
|
|
65
65
|
required = props.required,
|
|
66
|
-
_props$originalDiffTi = props.originalDiffTip,
|
|
67
|
-
originalDiffTip = _props$originalDiffTi === void 0 ? true : _props$originalDiffTi,
|
|
68
66
|
formKey = props.formKey,
|
|
69
67
|
globalControl = props.globalControl,
|
|
70
68
|
_props$scrollToError = props.scrollToError,
|
|
@@ -262,11 +260,10 @@ var ProForm = function ProForm(props, ref) {
|
|
|
262
260
|
colProps: colProps,
|
|
263
261
|
viewEmpty: viewEmpty,
|
|
264
262
|
labelWidth: labelWidth,
|
|
265
|
-
|
|
263
|
+
diffConfig: diffConfig,
|
|
266
264
|
clearNotShow: clearNotShow,
|
|
267
265
|
requiredOnView: requiredOnView,
|
|
268
266
|
required: required,
|
|
269
|
-
originalDiffTip: originalDiffTip,
|
|
270
267
|
globalControl: globalControl
|
|
271
268
|
}), footerRender()]
|
|
272
269
|
})), children]
|
|
@@ -45,6 +45,16 @@ export interface ProFormOtherProps {
|
|
|
45
45
|
globalControl?: boolean;
|
|
46
46
|
formDisabled?: boolean;
|
|
47
47
|
}
|
|
48
|
+
export interface DiffConfigProps<Values = any> {
|
|
49
|
+
/** 比对原始数据源 */
|
|
50
|
+
originalValues: Values;
|
|
51
|
+
/** 是否显示对比值气泡 */
|
|
52
|
+
toolTip?: boolean;
|
|
53
|
+
/** 变更提示颜色 */
|
|
54
|
+
changeTipColor?: string;
|
|
55
|
+
/** 新增提示颜色 */
|
|
56
|
+
addTipColor?: string;
|
|
57
|
+
}
|
|
48
58
|
export interface ProFormProps<Values = any> extends FormProps<Values> {
|
|
49
59
|
disabled?: boolean;
|
|
50
60
|
/** 全局控制优先 */
|
|
@@ -67,14 +77,14 @@ export interface ProFormProps<Values = any> extends FormProps<Values> {
|
|
|
67
77
|
viewEmpty?: React.ReactNode | string;
|
|
68
78
|
confirmLoading?: boolean;
|
|
69
79
|
labelWidth?: string | number;
|
|
70
|
-
originalValues?: Values;
|
|
71
80
|
/** 是否回车提交 */
|
|
72
81
|
submitOnEnter?: boolean;
|
|
73
82
|
clearNotShow?: boolean;
|
|
74
83
|
requiredOnView?: boolean;
|
|
75
84
|
formId?: string;
|
|
76
85
|
required?: boolean | boolean[];
|
|
77
|
-
|
|
86
|
+
/** 表单比对配置 */
|
|
87
|
+
diffConfig?: DiffConfigProps;
|
|
78
88
|
scrollToError?: boolean;
|
|
79
89
|
/** 性能模式,谨慎使用,默认不开启
|
|
80
90
|
* 1. 开启不过滤names的中间态值
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isEmpty = void 0;
|
|
7
|
+
var EMPTY_VALUE = [undefined, null, ''];
|
|
8
|
+
/** 判断一个值是否是空值 */
|
|
9
|
+
var isEmpty = exports.isEmpty = function isEmpty(value) {
|
|
10
|
+
if (EMPTY_VALUE.includes(value)) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
return !(value === null || value === void 0 ? void 0 : value.length) || value.every(function (item) {
|
|
15
|
+
return EMPTY_VALUE.includes(item);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zat-design/sisyphus-react",
|
|
3
|
-
"version": "3.7.3-beta.
|
|
3
|
+
"version": "3.7.3-beta.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -102,6 +102,7 @@
|
|
|
102
102
|
"eslint": "7.10.0",
|
|
103
103
|
"eslint-config-za": "2.1.0",
|
|
104
104
|
"eslint-plugin-babel": "5.3.0",
|
|
105
|
+
"eslint-plugin-complexity": "^1.0.2",
|
|
105
106
|
"eslint-plugin-import": "^2.22.1",
|
|
106
107
|
"eslint-plugin-jsx-a11y": "6.2.3",
|
|
107
108
|
"eslint-plugin-react": "7.16.0",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|