@zat-design/sisyphus-react 3.8.3-beta.8 → 3.8.3-beta.9
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/dist/index.esm.css +6 -0
- package/dist/less.esm.css +6 -0
- package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +21 -7
- package/es/ProEditTable/components/RenderField/index.js +8 -1
- package/es/ProForm/components/render/ChangedWrapper.js +11 -1
- package/es/ProForm/components/render/Render.js +3 -1
- package/es/ProForm/components/render/RenderFields.js +2 -1
- package/es/ProForm/style/index.less +7 -0
- package/es/ProForm/utils/diffOriginal.js +14 -2
- package/lib/ProEditTable/components/RenderField/ListChangedWrapper.js +20 -6
- package/lib/ProEditTable/components/RenderField/index.js +8 -1
- package/lib/ProForm/components/render/ChangedWrapper.js +11 -1
- package/lib/ProForm/components/render/Render.js +3 -1
- package/lib/ProForm/components/render/RenderFields.js +2 -1
- package/lib/ProForm/style/index.less +7 -0
- package/lib/ProForm/utils/diffOriginal.js +13 -1
- package/package.json +1 -1
- package/coverage/lcov-report/src/.umi/core/devScripts.ts.html +0 -241
- package/coverage/lcov-report/src/.umi/core/history.ts.html +0 -148
- package/coverage/lcov-report/src/.umi/core/index.html +0 -206
- package/coverage/lcov-report/src/.umi/core/plugin.ts.html +0 -109
- package/coverage/lcov-report/src/.umi/core/pluginRegister.ts.html +0 -160
- package/coverage/lcov-report/src/.umi/core/polyfill.ts.html +0 -97
- package/coverage/lcov-report/src/.umi/core/routes.ts.html +0 -26050
- package/coverage/lcov-report/src/.umi/core/umiExports.ts.html +0 -112
- package/coverage/lcov-report/src/.umi/dumi/demos/index.html +0 -116
- package/coverage/lcov-report/src/.umi/dumi/demos/index.ts.html +0 -6340
- package/coverage/lcov-report/src/.umi/dumi/index.html +0 -116
- package/coverage/lcov-report/src/.umi/dumi/layout.tsx.html +0 -109
- package/coverage/lcov-report/src/.umi/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-antd/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-antd/runtime.tsx.html +0 -172
- package/coverage/lcov-report/src/.umi/plugin-helmet/exports.ts.html +0 -94
- package/coverage/lcov-report/src/.umi/plugin-helmet/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-initial-state/Provider.tsx.html +0 -196
- package/coverage/lcov-report/src/.umi/plugin-initial-state/exports.ts.html +0 -106
- package/coverage/lcov-report/src/.umi/plugin-initial-state/index.html +0 -146
- package/coverage/lcov-report/src/.umi/plugin-initial-state/models/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-initial-state/models/initialState.ts.html +0 -88
- package/coverage/lcov-report/src/.umi/plugin-initial-state/runtime.tsx.html +0 -124
- package/coverage/lcov-report/src/.umi/plugin-locale/SelectLang.tsx.html +0 -1246
- package/coverage/lcov-report/src/.umi/plugin-locale/index.html +0 -161
- package/coverage/lcov-report/src/.umi/plugin-locale/locale.tsx.html +0 -268
- package/coverage/lcov-report/src/.umi/plugin-locale/localeExports.ts.html +0 -778
- package/coverage/lcov-report/src/.umi/plugin-locale/runtime.tsx.html +0 -115
- package/coverage/lcov-report/src/.umi/plugin-model/Provider.tsx.html +0 -202
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/constant.tsx.html +0 -97
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/dispatcher.tsx.html +0 -142
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/executor.tsx.html +0 -334
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/index.html +0 -146
- package/coverage/lcov-report/src/.umi/plugin-model/index.html +0 -146
- package/coverage/lcov-report/src/.umi/plugin-model/runtime.tsx.html +0 -121
- package/coverage/lcov-report/src/.umi/plugin-model/useModel.tsx.html +0 -298
- package/coverage/lcov-report/src/.umi/plugin-request/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-request/request.ts.html +0 -919
- package/coverage/lcov-report/src/.umi/umi.ts.html +0 -268
package/dist/index.esm.css
CHANGED
|
@@ -3039,6 +3039,9 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
|
|
|
3039
3039
|
border-radius: 4px;
|
|
3040
3040
|
background: var(--zaui-contract-bg, #fffaa1) !important;
|
|
3041
3041
|
}
|
|
3042
|
+
.pro-form .pro-form-item-changed .ant-input {
|
|
3043
|
+
background: var(--zaui-contract-bg, #fffaa1) !important;
|
|
3044
|
+
}
|
|
3042
3045
|
.pro-form .pro-form-item-changed .ant-select.ant-select-disabled .ant-select-selector {
|
|
3043
3046
|
background: var(--zaui-contract-bg, #fffaa1) !important;
|
|
3044
3047
|
}
|
|
@@ -3096,6 +3099,9 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
|
|
|
3096
3099
|
border-radius: 4px;
|
|
3097
3100
|
background: var(--zaui-contract-bg-add, #d2fff4) !important;
|
|
3098
3101
|
}
|
|
3102
|
+
.pro-form .pro-form-item-add .ant-input {
|
|
3103
|
+
background: var(--zaui-contract-bg, #fffaa1) !important;
|
|
3104
|
+
}
|
|
3099
3105
|
.pro-form .pro-form-item-add .ant-select.ant-select-disabled .ant-select-selector {
|
|
3100
3106
|
background: var(--zaui-contract-bg-add, #d2fff4) !important;
|
|
3101
3107
|
}
|
package/dist/less.esm.css
CHANGED
|
@@ -3039,6 +3039,9 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
|
|
|
3039
3039
|
border-radius: 4px;
|
|
3040
3040
|
background: var(--zaui-contract-bg, #fffaa1) !important;
|
|
3041
3041
|
}
|
|
3042
|
+
.pro-form .pro-form-item-changed .ant-input {
|
|
3043
|
+
background: var(--zaui-contract-bg, #fffaa1) !important;
|
|
3044
|
+
}
|
|
3042
3045
|
.pro-form .pro-form-item-changed .ant-select.ant-select-disabled .ant-select-selector {
|
|
3043
3046
|
background: var(--zaui-contract-bg, #fffaa1) !important;
|
|
3044
3047
|
}
|
|
@@ -3096,6 +3099,9 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
|
|
|
3096
3099
|
border-radius: 4px;
|
|
3097
3100
|
background: var(--zaui-contract-bg-add, #d2fff4) !important;
|
|
3098
3101
|
}
|
|
3102
|
+
.pro-form .pro-form-item-add .ant-input {
|
|
3103
|
+
background: var(--zaui-contract-bg, #fffaa1) !important;
|
|
3104
|
+
}
|
|
3099
3105
|
.pro-form .pro-form-item-add .ant-select.ant-select-disabled .ant-select-selector {
|
|
3100
3106
|
background: var(--zaui-contract-bg-add, #d2fff4) !important;
|
|
3101
3107
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import "antd/es/space/style";
|
|
3
2
|
import _Space from "antd/es/space";
|
|
4
3
|
import "antd/es/tooltip/style";
|
|
5
4
|
import _Tooltip from "antd/es/tooltip";
|
|
5
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
6
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
7
7
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
8
|
-
var _excluded = ["name", "names", "namesStr", "originalName", "originalNames", "originalValues", "form", "equalWith", "rowKeyPath", "children", "type", "normalize", "getValueProps", "valuePropName"];
|
|
8
|
+
var _excluded = ["name", "names", "namesStr", "originalName", "originalNames", "originalValues", "form", "equalWith", "rowKeyPath", "children", "type", "normalize", "getValueProps", "valuePropName", "viewRender"];
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
import React, { useMemo } from 'react';
|
|
11
11
|
import classNames from 'classnames';
|
|
@@ -66,7 +66,6 @@ var getOriginalValue = function getOriginalValue(_ref) {
|
|
|
66
66
|
}) : get(originalValues, originalName);
|
|
67
67
|
};
|
|
68
68
|
var ListChangedWrapper = function ListChangedWrapper(props) {
|
|
69
|
-
var _getValueProps;
|
|
70
69
|
var name = props.name,
|
|
71
70
|
names = props.names,
|
|
72
71
|
namesStr = props.namesStr,
|
|
@@ -84,6 +83,7 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
|
|
|
84
83
|
getValueProps = props.getValueProps,
|
|
85
84
|
_props$valuePropName = props.valuePropName,
|
|
86
85
|
valuePropName = _props$valuePropName === void 0 ? 'value' : _props$valuePropName,
|
|
86
|
+
viewRender = props.viewRender,
|
|
87
87
|
rest = _objectWithoutProperties(props, _excluded);
|
|
88
88
|
var _ref2 = useProConfig('ProEditTable') || {},
|
|
89
89
|
isDiffAll = _ref2.isDiffAll;
|
|
@@ -113,6 +113,23 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
|
|
|
113
113
|
}, [props[valuePropName], originalValue]);
|
|
114
114
|
var isAdd = diffType === 'add';
|
|
115
115
|
var isChanged = diffType === 'changed';
|
|
116
|
+
var tipContent = useMemo(function () {
|
|
117
|
+
var _getValueProps;
|
|
118
|
+
if (!isWatch || noChange) return undefined;
|
|
119
|
+
var orgValue = getValueProps ? (_getValueProps = getValueProps(originalValue)) === null || _getValueProps === void 0 ? void 0 : _getValueProps[valuePropName] : originalValue;
|
|
120
|
+
// 兼容viewRender函数和Element场景
|
|
121
|
+
var _children = children;
|
|
122
|
+
if (viewRender) {
|
|
123
|
+
if (! /*#__PURE__*/React.isValidElement(viewRender)) {
|
|
124
|
+
return viewRender(orgValue);
|
|
125
|
+
}
|
|
126
|
+
_children = viewRender;
|
|
127
|
+
}
|
|
128
|
+
return /*#__PURE__*/React.isValidElement(children) ? /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, children), {}, _defineProperty(_defineProperty({
|
|
129
|
+
// @ts-ignore
|
|
130
|
+
isView: true
|
|
131
|
+
}, valuePropName, orgValue), "checked", type === 'Switch' ? originalValue : undefined))) : undefined;
|
|
132
|
+
}, [originalValue, children]);
|
|
116
133
|
if (!isWatch || noChange) {
|
|
117
134
|
return /*#__PURE__*/React.isValidElement(children) && /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, children.props), rest));
|
|
118
135
|
}
|
|
@@ -127,10 +144,7 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
|
|
|
127
144
|
return target.parentElement;
|
|
128
145
|
},
|
|
129
146
|
title: _jsxs(_Space, {
|
|
130
|
-
children: ["\u521D\u59CB\u503C\uFF1A",
|
|
131
|
-
// @ts-ignore
|
|
132
|
-
isView: true
|
|
133
|
-
}, valuePropName, getValueProps ? (_getValueProps = getValueProps(originalValue)) === null || _getValueProps === void 0 ? void 0 : _getValueProps[valuePropName] : originalValue), "checked", type === 'Switch' ? originalValue : undefined))) : undefined]
|
|
147
|
+
children: ["\u521D\u59CB\u503C\uFF1A", tipContent]
|
|
134
148
|
}),
|
|
135
149
|
children: _jsx("div", {
|
|
136
150
|
className: diffClassName,
|
|
@@ -248,13 +248,19 @@ var RenderField = function RenderField(_ref) {
|
|
|
248
248
|
TargetComponent = _editRender;
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
+
var viewRenderFun = function viewRenderFun(value) {
|
|
252
|
+
if (/*#__PURE__*/React.isValidElement(viewRender)) {
|
|
253
|
+
return viewRender;
|
|
254
|
+
}
|
|
255
|
+
return viewRender === null || viewRender === void 0 ? void 0 : viewRender(value, record, options);
|
|
256
|
+
};
|
|
251
257
|
// 查看模式
|
|
252
258
|
if (isView) {
|
|
253
259
|
// 存在viewRender覆盖默认值
|
|
254
260
|
if (typeof viewRender === 'function') {
|
|
255
261
|
var _column$dataIndex;
|
|
256
262
|
currentValue = (column === null || column === void 0 ? void 0 : (_column$dataIndex = column.dataIndex) === null || _column$dataIndex === void 0 ? void 0 : _column$dataIndex.includes('-')) ? value : currentValue;
|
|
257
|
-
var View =
|
|
263
|
+
var View = viewRenderFun(currentValue);
|
|
258
264
|
TargetComponent = _jsx(Container, {
|
|
259
265
|
viewEmpty: viewEmpty,
|
|
260
266
|
children: View
|
|
@@ -560,6 +566,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
560
566
|
valuePropName: _formItemProps.valuePropName,
|
|
561
567
|
normalize: _formItemProps.normalize,
|
|
562
568
|
getValueProps: _formItemProps.getValueProps,
|
|
569
|
+
viewRender: viewRender && viewRenderFun,
|
|
563
570
|
children: FieldComponent
|
|
564
571
|
});
|
|
565
572
|
}
|
|
@@ -5,7 +5,7 @@ import _Tooltip from "antd/es/tooltip";
|
|
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
6
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
7
7
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
8
|
-
var _excluded = ["name", "names", "namesStr", "form", "equalWith", "children", "type", "diffConfig", "valuePropName", "normalize", "getValueProps"];
|
|
8
|
+
var _excluded = ["name", "names", "namesStr", "form", "equalWith", "children", "type", "diffConfig", "valuePropName", "normalize", "getValueProps", "viewRender"];
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
import classNames from 'classnames';
|
|
11
11
|
import { get } from 'lodash';
|
|
@@ -27,6 +27,7 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
27
27
|
valuePropName = _props$valuePropName === void 0 ? 'value' : _props$valuePropName,
|
|
28
28
|
normalize = props.normalize,
|
|
29
29
|
getValueProps = props.getValueProps,
|
|
30
|
+
viewRender = props.viewRender,
|
|
30
31
|
rest = _objectWithoutProperties(props, _excluded);
|
|
31
32
|
var _useProConfig = useProConfig('ProForm'),
|
|
32
33
|
isDiffAll = _useProConfig.isDiffAll;
|
|
@@ -52,11 +53,20 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
52
53
|
}, [isWatch, noChange, props[valuePropName], originalValue]);
|
|
53
54
|
var isAdd = diffType === 'add';
|
|
54
55
|
var isChanged = diffType === 'changed';
|
|
56
|
+
var viewRenderFun = useMemo(function () {
|
|
57
|
+
var record = form.getFieldsValue();
|
|
58
|
+
return function (orgValue) {
|
|
59
|
+
return viewRender(orgValue, record, {
|
|
60
|
+
form: form
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
}, [form]);
|
|
55
64
|
var tipContent = useMemo(function () {
|
|
56
65
|
if (!isWatch || noChange) return undefined;
|
|
57
66
|
var valueProps = getValueProps && !names ? getValueProps(originalValue) : {
|
|
58
67
|
value: originalValue
|
|
59
68
|
};
|
|
69
|
+
if (viewRender) return viewRenderFun(valueProps === null || valueProps === void 0 ? void 0 : valueProps.value);
|
|
60
70
|
return /*#__PURE__*/React.isValidElement(children) ? /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, children.props), {}, _defineProperty({
|
|
61
71
|
isView: true
|
|
62
72
|
}, valuePropName, valueProps === null || valueProps === void 0 ? void 0 : valueProps.value))) : undefined;
|
|
@@ -50,7 +50,8 @@ var Render = function Render(props) {
|
|
|
50
50
|
requiredOnView = props.requiredOnView,
|
|
51
51
|
confirm = props.confirm,
|
|
52
52
|
globalControl = props.globalControl,
|
|
53
|
-
diffConfig = props.diffConfig
|
|
53
|
+
diffConfig = props.diffConfig,
|
|
54
|
+
viewRender = props.viewRender;
|
|
54
55
|
var colProps = props.colProps;
|
|
55
56
|
// 剔除一些不是FormItem的属性, 防止控制台报warning
|
|
56
57
|
var labelWidth = formItemProps.labelWidth,
|
|
@@ -439,6 +440,7 @@ var Render = function Render(props) {
|
|
|
439
440
|
valuePropName: _otherFormItemProps.valuePropName,
|
|
440
441
|
normalize: _otherFormItemProps.normalize,
|
|
441
442
|
getValueProps: _otherFormItemProps.getValueProps,
|
|
443
|
+
viewRender: viewRender,
|
|
442
444
|
children: child
|
|
443
445
|
});
|
|
444
446
|
}
|
|
@@ -210,7 +210,8 @@ var RenderFields = function RenderFields(props) {
|
|
|
210
210
|
diffConfig: diffConfig,
|
|
211
211
|
equalWith: equalWith,
|
|
212
212
|
requiredOnView: requiredOnView,
|
|
213
|
-
globalControl: globalControl
|
|
213
|
+
globalControl: globalControl,
|
|
214
|
+
viewRender: viewRender
|
|
214
215
|
})
|
|
215
216
|
}, "".concat(_formItemProps.name || _formItemProps.label).concat(index));
|
|
216
217
|
});
|
|
@@ -329,6 +329,9 @@
|
|
|
329
329
|
border-radius: 4px;
|
|
330
330
|
background: @zaui-contract-bg !important;
|
|
331
331
|
|
|
332
|
+
.@{ant-prefix}-input {
|
|
333
|
+
background: @zaui-contract-bg !important;
|
|
334
|
+
}
|
|
332
335
|
.@{ant-prefix}-select.@{ant-prefix}-select-disabled .@{ant-prefix}-select-selector{
|
|
333
336
|
background: @zaui-contract-bg !important;
|
|
334
337
|
}
|
|
@@ -403,6 +406,10 @@
|
|
|
403
406
|
border-radius: 4px;
|
|
404
407
|
background: @zaui-contract-bg-add !important;
|
|
405
408
|
|
|
409
|
+
.@{ant-prefix}-input {
|
|
410
|
+
background: @zaui-contract-bg !important;
|
|
411
|
+
}
|
|
412
|
+
|
|
406
413
|
.@{ant-prefix}-select.@{ant-prefix}-select-disabled .@{ant-prefix}-select-selector{
|
|
407
414
|
background: @zaui-contract-bg-add !important;
|
|
408
415
|
}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import { isEqual, isFunction } from 'lodash';
|
|
1
|
+
import { isEqual, isFunction, isObject } from 'lodash';
|
|
2
2
|
import { isEmpty } from '../../utils';
|
|
3
|
+
// 过滤对象中undefined字段
|
|
4
|
+
// 防止{a: '1'} {a: '1', b: undefined}被认为不相等
|
|
5
|
+
var filterUndefined = function filterUndefined(data) {
|
|
6
|
+
if (!isObject(data) || Array.isArray(data) || data === null) return data;
|
|
7
|
+
var resData = {};
|
|
8
|
+
Object.keys(data).forEach(function (key) {
|
|
9
|
+
if (data[key] !== undefined) {
|
|
10
|
+
resData[key] = data[key];
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return resData;
|
|
14
|
+
};
|
|
3
15
|
var nullValue = [null, undefined, '']; // 输入框空值时可能存在的三种值 视为相等
|
|
4
16
|
export var diffOriginal = function diffOriginal(params) {
|
|
5
17
|
var originalValue = params.originalValue,
|
|
@@ -29,7 +41,7 @@ export var diffOriginal = function diffOriginal(params) {
|
|
|
29
41
|
return isSame ? 'same' : 'changed';
|
|
30
42
|
}
|
|
31
43
|
if (!nullValue.includes(value) || !nullValue.includes(originalValue)) {
|
|
32
|
-
return isEqual(value, originalValue) ? 'same' : 'changed';
|
|
44
|
+
return isEqual(filterUndefined(value), filterUndefined(originalValue)) ? 'same' : 'changed';
|
|
33
45
|
}
|
|
34
46
|
return 'same';
|
|
35
47
|
};
|
|
@@ -17,7 +17,7 @@ var _lodash = require("lodash");
|
|
|
17
17
|
var _diffOriginal = require("../../../ProForm/utils/diffOriginal");
|
|
18
18
|
var _ProConfigProvider = require("../../../ProConfigProvider");
|
|
19
19
|
var _utils = require("../../../utils");
|
|
20
|
-
var _excluded = ["name", "names", "namesStr", "originalName", "originalNames", "originalValues", "form", "equalWith", "rowKeyPath", "children", "type", "normalize", "getValueProps", "valuePropName"];
|
|
20
|
+
var _excluded = ["name", "names", "namesStr", "originalName", "originalNames", "originalValues", "form", "equalWith", "rowKeyPath", "children", "type", "normalize", "getValueProps", "valuePropName", "viewRender"];
|
|
21
21
|
var toNamePath = function toNamePath(name) {
|
|
22
22
|
if (Array.isArray(name)) {
|
|
23
23
|
return name;
|
|
@@ -71,7 +71,6 @@ var getOriginalValue = function getOriginalValue(_ref) {
|
|
|
71
71
|
}) : (0, _lodash.get)(originalValues, originalName);
|
|
72
72
|
};
|
|
73
73
|
var ListChangedWrapper = function ListChangedWrapper(props) {
|
|
74
|
-
var _getValueProps;
|
|
75
74
|
var name = props.name,
|
|
76
75
|
names = props.names,
|
|
77
76
|
namesStr = props.namesStr,
|
|
@@ -89,6 +88,7 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
|
|
|
89
88
|
getValueProps = props.getValueProps,
|
|
90
89
|
_props$valuePropName = props.valuePropName,
|
|
91
90
|
valuePropName = _props$valuePropName === void 0 ? 'value' : _props$valuePropName,
|
|
91
|
+
viewRender = props.viewRender,
|
|
92
92
|
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
93
93
|
var _ref2 = (0, _ProConfigProvider.useProConfig)('ProEditTable') || {},
|
|
94
94
|
isDiffAll = _ref2.isDiffAll;
|
|
@@ -118,6 +118,23 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
|
|
|
118
118
|
}, [props[valuePropName], originalValue]);
|
|
119
119
|
var isAdd = diffType === 'add';
|
|
120
120
|
var isChanged = diffType === 'changed';
|
|
121
|
+
var tipContent = (0, _react.useMemo)(function () {
|
|
122
|
+
var _getValueProps;
|
|
123
|
+
if (!isWatch || noChange) return undefined;
|
|
124
|
+
var orgValue = getValueProps ? (_getValueProps = getValueProps(originalValue)) === null || _getValueProps === void 0 ? void 0 : _getValueProps[valuePropName] : originalValue;
|
|
125
|
+
// 兼容viewRender函数和Element场景
|
|
126
|
+
var _children = children;
|
|
127
|
+
if (viewRender) {
|
|
128
|
+
if (! /*#__PURE__*/_react.default.isValidElement(viewRender)) {
|
|
129
|
+
return viewRender(orgValue);
|
|
130
|
+
}
|
|
131
|
+
_children = viewRender;
|
|
132
|
+
}
|
|
133
|
+
return /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)({}, children), {}, (0, _defineProperty2.default)((0, _defineProperty2.default)({
|
|
134
|
+
// @ts-ignore
|
|
135
|
+
isView: true
|
|
136
|
+
}, valuePropName, orgValue), "checked", type === 'Switch' ? originalValue : undefined))) : undefined;
|
|
137
|
+
}, [originalValue, children]);
|
|
121
138
|
if (!isWatch || noChange) {
|
|
122
139
|
return /*#__PURE__*/_react.default.isValidElement(children) && /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)({}, children.props), rest));
|
|
123
140
|
}
|
|
@@ -134,10 +151,7 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
|
|
|
134
151
|
return target.parentElement;
|
|
135
152
|
},
|
|
136
153
|
title: (0, _jsxRuntime.jsxs)(_antd.Space, {
|
|
137
|
-
children: ["\u521D\u59CB\u503C\uFF1A",
|
|
138
|
-
// @ts-ignore
|
|
139
|
-
isView: true
|
|
140
|
-
}, valuePropName, getValueProps ? (_getValueProps = getValueProps(originalValue)) === null || _getValueProps === void 0 ? void 0 : _getValueProps[valuePropName] : originalValue), "checked", type === 'Switch' ? originalValue : undefined))) : undefined]
|
|
154
|
+
children: ["\u521D\u59CB\u503C\uFF1A", tipContent]
|
|
141
155
|
}),
|
|
142
156
|
children: (0, _jsxRuntime.jsx)("div", {
|
|
143
157
|
className: diffClassName,
|
|
@@ -255,13 +255,19 @@ var RenderField = function RenderField(_ref) {
|
|
|
255
255
|
TargetComponent = _editRender;
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
+
var viewRenderFun = function viewRenderFun(value) {
|
|
259
|
+
if (/*#__PURE__*/_react.default.isValidElement(viewRender)) {
|
|
260
|
+
return viewRender;
|
|
261
|
+
}
|
|
262
|
+
return viewRender === null || viewRender === void 0 ? void 0 : viewRender(value, record, options);
|
|
263
|
+
};
|
|
258
264
|
// 查看模式
|
|
259
265
|
if (isView) {
|
|
260
266
|
// 存在viewRender覆盖默认值
|
|
261
267
|
if (typeof viewRender === 'function') {
|
|
262
268
|
var _column$dataIndex;
|
|
263
269
|
currentValue = (column === null || column === void 0 ? void 0 : (_column$dataIndex = column.dataIndex) === null || _column$dataIndex === void 0 ? void 0 : _column$dataIndex.includes('-')) ? value : currentValue;
|
|
264
|
-
var View =
|
|
270
|
+
var View = viewRenderFun(currentValue);
|
|
265
271
|
TargetComponent = (0, _jsxRuntime.jsx)(_Container.default, {
|
|
266
272
|
viewEmpty: viewEmpty,
|
|
267
273
|
children: View
|
|
@@ -567,6 +573,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
567
573
|
valuePropName: _formItemProps.valuePropName,
|
|
568
574
|
normalize: _formItemProps.normalize,
|
|
569
575
|
getValueProps: _formItemProps.getValueProps,
|
|
576
|
+
viewRender: viewRender && viewRenderFun,
|
|
570
577
|
children: FieldComponent
|
|
571
578
|
});
|
|
572
579
|
}
|
|
@@ -17,7 +17,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
17
17
|
var _diffOriginal = require("../../utils/diffOriginal");
|
|
18
18
|
var _ProConfigProvider = require("../../../ProConfigProvider");
|
|
19
19
|
var _utils = require("../../../utils");
|
|
20
|
-
var _excluded = ["name", "names", "namesStr", "form", "equalWith", "children", "type", "diffConfig", "valuePropName", "normalize", "getValueProps"];
|
|
20
|
+
var _excluded = ["name", "names", "namesStr", "form", "equalWith", "children", "type", "diffConfig", "valuePropName", "normalize", "getValueProps", "viewRender"];
|
|
21
21
|
var ChangedWrapper = function ChangedWrapper(props) {
|
|
22
22
|
var _diffConfig$toolTip, _children$props, _children$props2, _children$props3;
|
|
23
23
|
var name = props.name,
|
|
@@ -32,6 +32,7 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
32
32
|
valuePropName = _props$valuePropName === void 0 ? 'value' : _props$valuePropName,
|
|
33
33
|
normalize = props.normalize,
|
|
34
34
|
getValueProps = props.getValueProps,
|
|
35
|
+
viewRender = props.viewRender,
|
|
35
36
|
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
36
37
|
var _useProConfig = (0, _ProConfigProvider.useProConfig)('ProForm'),
|
|
37
38
|
isDiffAll = _useProConfig.isDiffAll;
|
|
@@ -57,11 +58,20 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
57
58
|
}, [isWatch, noChange, props[valuePropName], originalValue]);
|
|
58
59
|
var isAdd = diffType === 'add';
|
|
59
60
|
var isChanged = diffType === 'changed';
|
|
61
|
+
var viewRenderFun = (0, _react.useMemo)(function () {
|
|
62
|
+
var record = form.getFieldsValue();
|
|
63
|
+
return function (orgValue) {
|
|
64
|
+
return viewRender(orgValue, record, {
|
|
65
|
+
form: form
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
}, [form]);
|
|
60
69
|
var tipContent = (0, _react.useMemo)(function () {
|
|
61
70
|
if (!isWatch || noChange) return undefined;
|
|
62
71
|
var valueProps = getValueProps && !names ? getValueProps(originalValue) : {
|
|
63
72
|
value: originalValue
|
|
64
73
|
};
|
|
74
|
+
if (viewRender) return viewRenderFun(valueProps === null || valueProps === void 0 ? void 0 : valueProps.value);
|
|
65
75
|
return /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)({}, children.props), {}, (0, _defineProperty2.default)({
|
|
66
76
|
isView: true
|
|
67
77
|
}, valuePropName, valueProps === null || valueProps === void 0 ? void 0 : valueProps.value))) : undefined;
|
|
@@ -50,7 +50,8 @@ var Render = function Render(props) {
|
|
|
50
50
|
requiredOnView = props.requiredOnView,
|
|
51
51
|
confirm = props.confirm,
|
|
52
52
|
globalControl = props.globalControl,
|
|
53
|
-
diffConfig = props.diffConfig
|
|
53
|
+
diffConfig = props.diffConfig,
|
|
54
|
+
viewRender = props.viewRender;
|
|
54
55
|
var colProps = props.colProps;
|
|
55
56
|
// 剔除一些不是FormItem的属性, 防止控制台报warning
|
|
56
57
|
var labelWidth = formItemProps.labelWidth,
|
|
@@ -439,6 +440,7 @@ var Render = function Render(props) {
|
|
|
439
440
|
valuePropName: _otherFormItemProps.valuePropName,
|
|
440
441
|
normalize: _otherFormItemProps.normalize,
|
|
441
442
|
getValueProps: _otherFormItemProps.getValueProps,
|
|
443
|
+
viewRender: viewRender,
|
|
442
444
|
children: child
|
|
443
445
|
});
|
|
444
446
|
}
|
|
@@ -218,7 +218,8 @@ var RenderFields = function RenderFields(props) {
|
|
|
218
218
|
diffConfig: diffConfig,
|
|
219
219
|
equalWith: equalWith,
|
|
220
220
|
requiredOnView: requiredOnView,
|
|
221
|
-
globalControl: globalControl
|
|
221
|
+
globalControl: globalControl,
|
|
222
|
+
viewRender: viewRender
|
|
222
223
|
})
|
|
223
224
|
}, "".concat(_formItemProps.name || _formItemProps.label).concat(index));
|
|
224
225
|
});
|
|
@@ -329,6 +329,9 @@
|
|
|
329
329
|
border-radius: 4px;
|
|
330
330
|
background: @zaui-contract-bg !important;
|
|
331
331
|
|
|
332
|
+
.@{ant-prefix}-input {
|
|
333
|
+
background: @zaui-contract-bg !important;
|
|
334
|
+
}
|
|
332
335
|
.@{ant-prefix}-select.@{ant-prefix}-select-disabled .@{ant-prefix}-select-selector{
|
|
333
336
|
background: @zaui-contract-bg !important;
|
|
334
337
|
}
|
|
@@ -403,6 +406,10 @@
|
|
|
403
406
|
border-radius: 4px;
|
|
404
407
|
background: @zaui-contract-bg-add !important;
|
|
405
408
|
|
|
409
|
+
.@{ant-prefix}-input {
|
|
410
|
+
background: @zaui-contract-bg !important;
|
|
411
|
+
}
|
|
412
|
+
|
|
406
413
|
.@{ant-prefix}-select.@{ant-prefix}-select-disabled .@{ant-prefix}-select-selector{
|
|
407
414
|
background: @zaui-contract-bg-add !important;
|
|
408
415
|
}
|
|
@@ -6,6 +6,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.diffOriginal = void 0;
|
|
7
7
|
var _lodash = require("lodash");
|
|
8
8
|
var _utils = require("../../utils");
|
|
9
|
+
// 过滤对象中undefined字段
|
|
10
|
+
// 防止{a: '1'} {a: '1', b: undefined}被认为不相等
|
|
11
|
+
var filterUndefined = function filterUndefined(data) {
|
|
12
|
+
if (!(0, _lodash.isObject)(data) || Array.isArray(data) || data === null) return data;
|
|
13
|
+
var resData = {};
|
|
14
|
+
Object.keys(data).forEach(function (key) {
|
|
15
|
+
if (data[key] !== undefined) {
|
|
16
|
+
resData[key] = data[key];
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return resData;
|
|
20
|
+
};
|
|
9
21
|
var nullValue = [null, undefined, '']; // 输入框空值时可能存在的三种值 视为相等
|
|
10
22
|
var diffOriginal = exports.diffOriginal = function diffOriginal(params) {
|
|
11
23
|
var originalValue = params.originalValue,
|
|
@@ -35,7 +47,7 @@ var diffOriginal = exports.diffOriginal = function diffOriginal(params) {
|
|
|
35
47
|
return isSame ? 'same' : 'changed';
|
|
36
48
|
}
|
|
37
49
|
if (!nullValue.includes(value) || !nullValue.includes(originalValue)) {
|
|
38
|
-
return (0, _lodash.isEqual)(value, originalValue) ? 'same' : 'changed';
|
|
50
|
+
return (0, _lodash.isEqual)(filterUndefined(value), filterUndefined(originalValue)) ? 'same' : 'changed';
|
|
39
51
|
}
|
|
40
52
|
return 'same';
|
|
41
53
|
};
|