@zat-design/sisyphus-react 3.9.0-beta.9 → 3.9.1-beta.1
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 +26 -16
- package/dist/less.esm.css +22 -14
- package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +7 -3
- package/es/ProEditTable/components/RenderField/index.js +3 -2
- package/es/ProEditTable/index.js +23 -16
- package/es/ProEditTable/style/index.less +14 -2
- package/es/ProEnum/index.js +5 -3
- package/es/ProEnum/propsType.d.ts +1 -0
- package/es/ProForm/components/base/SwitchCheckbox/index.js +9 -2
- package/es/ProForm/components/combination/FormList/index.js +1 -1
- package/es/ProForm/components/combination/Group/component/ComRender.d.ts +1 -0
- package/es/ProForm/components/combination/Group/component/ComRender.js +12 -1
- package/es/ProForm/components/combination/ProModalSelect/index.js +28 -28
- package/es/ProForm/components/render/ChangedWrapper.js +1 -1
- package/es/ProForm/components/render/RenderFields.js +3 -2
- package/es/ProForm/components/render/propsType.d.ts +1 -0
- package/es/ProForm/style/index.less +10 -6
- package/es/ProForm/utils/diffOriginal.js +18 -12
- package/es/ProTable/components/FormatColumn/index.d.ts +4 -2
- package/es/ProTable/components/FormatColumn/index.js +54 -33
- package/es/ProTable/components/RenderColumn/index.d.ts +1 -2
- package/es/ProTable/components/RenderColumn/index.js +16 -12
- package/es/ProTable/components/TableResizable/index.js +1 -5
- package/es/ProTable/index.js +0 -1
- package/es/ProTable/propsType.d.ts +1 -2
- package/es/ProTable/utils/index.d.ts +5 -2
- package/es/ProTable/utils/index.js +13 -4
- package/es/style/theme/antd.less +4 -2
- package/es/utils/index.d.ts +1 -1
- package/es/utils/index.js +4 -1
- package/lib/ProEditTable/components/RenderField/ListChangedWrapper.js +5 -1
- package/lib/ProEditTable/components/RenderField/index.js +3 -2
- package/lib/ProEditTable/index.js +23 -16
- package/lib/ProEditTable/style/index.less +14 -2
- package/lib/ProEnum/index.js +5 -3
- package/lib/ProEnum/propsType.d.ts +1 -0
- package/lib/ProForm/components/base/SwitchCheckbox/index.js +9 -2
- package/lib/ProForm/components/combination/FormList/index.js +1 -1
- package/lib/ProForm/components/combination/Group/component/ComRender.d.ts +1 -0
- package/lib/ProForm/components/combination/Group/component/ComRender.js +12 -1
- package/lib/ProForm/components/combination/ProModalSelect/index.js +27 -27
- package/lib/ProForm/components/render/ChangedWrapper.js +1 -1
- package/lib/ProForm/components/render/RenderFields.js +3 -2
- package/lib/ProForm/components/render/propsType.d.ts +1 -0
- package/lib/ProForm/style/index.less +10 -6
- package/lib/ProForm/utils/diffOriginal.js +18 -12
- package/lib/ProTable/components/FormatColumn/index.d.ts +4 -2
- package/lib/ProTable/components/FormatColumn/index.js +53 -32
- package/lib/ProTable/components/RenderColumn/index.d.ts +1 -2
- package/lib/ProTable/components/RenderColumn/index.js +16 -12
- package/lib/ProTable/components/TableResizable/index.js +0 -4
- package/lib/ProTable/index.js +0 -1
- package/lib/ProTable/propsType.d.ts +1 -2
- package/lib/ProTable/utils/index.d.ts +5 -2
- package/lib/ProTable/utils/index.js +13 -4
- package/lib/style/theme/antd.less +4 -2
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +4 -1
- package/package.json +1 -1
- package/.vscode/extensions.json +0 -5
@@ -24,7 +24,7 @@ var _excluded = ["value", "onChange", "disabled", "labelInValue", "fieldNames",
|
|
24
24
|
_excluded3 = ["rowKey", "columns", "rowSelection"];
|
25
25
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
26
26
|
import { SearchOutlined } from '@ant-design/icons';
|
27
|
-
import { useDeepCompareEffect, useMount, useSetState } from 'ahooks';
|
27
|
+
import { useDebounceEffect, useDeepCompareEffect, useMount, useSetState } from 'ahooks';
|
28
28
|
import { debounce, isArray, isEqual, isFunction, omit } from 'lodash';
|
29
29
|
import { ReactSVG } from 'react-svg';
|
30
30
|
import React, { forwardRef, useImperativeHandle, useMemo } from 'react';
|
@@ -34,7 +34,7 @@ import viewSvg from '../../../../assets/view.svg';
|
|
34
34
|
import useRequestList from './hooks/useRequestList';
|
35
35
|
import locale from '../../../../locale';
|
36
36
|
var ProModalSelect = function ProModalSelect(props, ref) {
|
37
|
-
var _formColumns$;
|
37
|
+
var _useRequest$options9, _formColumns$;
|
38
38
|
var value = props.value,
|
39
39
|
onChange = props.onChange,
|
40
40
|
disabled = props.disabled,
|
@@ -147,13 +147,21 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
147
147
|
})),
|
148
148
|
run = _useRequestList.run,
|
149
149
|
selectLoading = _useRequestList.loading;
|
150
|
+
var initParams = useMemo(function () {
|
151
|
+
var nextInitParams = useRequest === null || useRequest === void 0 ? void 0 : useRequest.initParams;
|
152
|
+
if (typeof (useRequest === null || useRequest === void 0 ? void 0 : useRequest.initParams) === 'function') {
|
153
|
+
var _contentForm$getField;
|
154
|
+
nextInitParams = useRequest === null || useRequest === void 0 ? void 0 : useRequest.initParams(value, contentForm === null || contentForm === void 0 ? void 0 : (_contentForm$getField = contentForm.getFieldsValue) === null || _contentForm$getField === void 0 ? void 0 : _contentForm$getField.call(contentForm));
|
155
|
+
}
|
156
|
+
return nextInitParams;
|
157
|
+
}, [value]);
|
150
158
|
var _useRequestList2 = useRequestList(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, {
|
151
159
|
withPagination: withPagination,
|
152
160
|
transformParams: transformParams,
|
153
161
|
transformResponse: transformResponse
|
154
162
|
}, _objectSpread({
|
155
163
|
manual: true,
|
156
|
-
ready: (
|
164
|
+
ready: (initParams || defaultOne) && !readOnly || visible
|
157
165
|
}, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options)),
|
158
166
|
data = _useRequestList2.data,
|
159
167
|
loading = _useRequestList2.loading,
|
@@ -458,18 +466,15 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
458
466
|
// 初始化回显,当传入initParams时,前端用来回险
|
459
467
|
var getInitValues = /*#__PURE__*/function () {
|
460
468
|
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
461
|
-
var
|
469
|
+
var _useRequest$options2, _useRequest$options3, queryBean, page, params, res, _res$data2, _list, list, _data, nextSelectRowKeys;
|
462
470
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
463
471
|
while (1) switch (_context4.prev = _context4.next) {
|
464
472
|
case 0:
|
465
|
-
if (
|
466
|
-
|
467
|
-
}
|
468
|
-
if (!((useRequest === null || useRequest === void 0 ? void 0 : useRequest.initParams) || defaultOne)) {
|
469
|
-
_context4.next = 10;
|
473
|
+
if (!(initParams || defaultOne)) {
|
474
|
+
_context4.next = 9;
|
470
475
|
break;
|
471
476
|
}
|
472
|
-
queryBean = _objectSpread(_objectSpread({}, useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options2 = useRequest.options) === null || _useRequest$options2 === void 0 ? void 0 : _useRequest$options2.defaultParams),
|
477
|
+
queryBean = _objectSpread(_objectSpread({}, useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options2 = useRequest.options) === null || _useRequest$options2 === void 0 ? void 0 : _useRequest$options2.defaultParams), initParams || {});
|
473
478
|
page = _objectSpread({
|
474
479
|
pageNum: 1,
|
475
480
|
pageSize: 10
|
@@ -478,9 +483,9 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
478
483
|
queryBean: queryBean !== null && queryBean !== void 0 ? queryBean : {}
|
479
484
|
}) : queryBean;
|
480
485
|
params = transformParams ? transformParams(params) : params;
|
481
|
-
_context4.next =
|
486
|
+
_context4.next = 7;
|
482
487
|
return runAsync(params);
|
483
|
-
case
|
488
|
+
case 7:
|
484
489
|
res = _context4.sent;
|
485
490
|
if (res === null || res === void 0 ? void 0 : res.data) {
|
486
491
|
list = withPagination ? res === null || res === void 0 ? void 0 : (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.list : res === null || res === void 0 ? void 0 : res.data;
|
@@ -508,7 +513,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
508
513
|
});
|
509
514
|
}
|
510
515
|
}
|
511
|
-
case
|
516
|
+
case 9:
|
512
517
|
case "end":
|
513
518
|
return _context4.stop();
|
514
519
|
}
|
@@ -599,7 +604,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
599
604
|
});
|
600
605
|
}
|
601
606
|
});
|
602
|
-
|
607
|
+
useDebounceEffect(function () {
|
603
608
|
if (onOff && !visible) {
|
604
609
|
var _useRequest$options6;
|
605
610
|
if ((useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options6 = useRequest.options) === null || _useRequest$options6 === void 0 ? void 0 : _useRequest$options6.manual) !== true) {
|
@@ -634,13 +639,13 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
634
639
|
}
|
635
640
|
setState(nextState);
|
636
641
|
}
|
637
|
-
}, [onOff, visible, value]);
|
642
|
+
}, [onOff, visible, JSON.stringify(value)]);
|
638
643
|
useDeepCompareEffect(function () {
|
639
644
|
if (value && !visible && isInit && !readOnly) {
|
640
645
|
getInitValues();
|
641
646
|
}
|
642
|
-
}, [value, visible, isInit]);
|
643
|
-
|
647
|
+
}, [JSON.stringify(value), visible, isInit]);
|
648
|
+
useDebounceEffect(function () {
|
644
649
|
if (value && !visible && readOnly) {
|
645
650
|
var _options$some;
|
646
651
|
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) {
|
@@ -652,11 +657,6 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
652
657
|
// 加定时器 修复依赖数据同步更新未取到问题
|
653
658
|
setTimeout(function () {
|
654
659
|
var _useRequest$options7, _useRequest$options8;
|
655
|
-
var initParams = useRequest === null || useRequest === void 0 ? void 0 : useRequest.initParams;
|
656
|
-
if (typeof (useRequest === null || useRequest === void 0 ? void 0 : useRequest.initParams) === 'function') {
|
657
|
-
var _contentForm$getField2;
|
658
|
-
initParams = useRequest === null || useRequest === void 0 ? void 0 : useRequest.initParams(value, contentForm === null || contentForm === void 0 ? void 0 : (_contentForm$getField2 = contentForm.getFieldsValue) === null || _contentForm$getField2 === void 0 ? void 0 : _contentForm$getField2.call(contentForm));
|
659
|
-
}
|
660
660
|
var params = withPagination ? {
|
661
661
|
pageNum: 1,
|
662
662
|
pageSize: 50,
|
@@ -666,8 +666,8 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
666
666
|
run(nextParams);
|
667
667
|
}, 300);
|
668
668
|
}
|
669
|
-
}, [value, options, visible, useRequest]);
|
670
|
-
|
669
|
+
}, [JSON.stringify(value), JSON.stringify(options), visible, JSON.stringify(useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options9 = useRequest.options) === null || _useRequest$options9 === void 0 ? void 0 : _useRequest$options9.defaultParams), JSON.stringify(initParams)]);
|
670
|
+
useDebounceEffect(function () {
|
671
671
|
if (!value) {
|
672
672
|
if (defaultOne) {
|
673
673
|
getDefaultOneValues();
|
@@ -718,8 +718,8 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
718
718
|
}) : null,
|
719
719
|
onFocus: function onFocus() {
|
720
720
|
if (useRequest) {
|
721
|
-
var _useRequest$
|
722
|
-
var queryBean = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$
|
721
|
+
var _useRequest$options10;
|
722
|
+
var queryBean = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options10 = useRequest.options) === null || _useRequest$options10 === void 0 ? void 0 : _useRequest$options10.defaultParams) || {};
|
723
723
|
var params = withPagination ? {
|
724
724
|
pageNum: 1,
|
725
725
|
pageSize: 50,
|
@@ -733,8 +733,8 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
733
733
|
}
|
734
734
|
},
|
735
735
|
onSearch: debounce(function (val) {
|
736
|
-
var _useRequest$
|
737
|
-
var queryBean = _objectSpread(_objectSpread({}, useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$
|
736
|
+
var _useRequest$options11;
|
737
|
+
var queryBean = _objectSpread(_objectSpread({}, useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options11 = useRequest.options) === null || _useRequest$options11 === void 0 ? void 0 : _useRequest$options11.defaultParams), {}, _defineProperty({}, searchKey !== null && searchKey !== void 0 ? searchKey : labelKey, val));
|
738
738
|
var params = withPagination ? {
|
739
739
|
pageNum: 1,
|
740
740
|
pageSize: 50,
|
@@ -102,7 +102,7 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
102
102
|
getPopupContainer: function getPopupContainer(trigger) {
|
103
103
|
return scrollFollowParent ? trigger.parentElement : document.body;
|
104
104
|
},
|
105
|
-
overlayClassName: "original-value-
|
105
|
+
overlayClassName: "original-value-tooltip",
|
106
106
|
placement: "topLeft",
|
107
107
|
autoAdjustOverflow: false,
|
108
108
|
title: _jsxs(_Space, {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
3
|
-
var _excluded = ["show", "type", "viewRender", "viewType", "valueType", "formItemProps", "colProps", "formItemChildProps", "fieldProps", "equalWith", "clearNotShow", "required", "confirm"];
|
3
|
+
var _excluded = ["show", "type", "viewRender", "viewType", "valueType", "formItemProps", "colProps", "formItemChildProps", "fieldProps", "equalWith", "onDiff", "clearNotShow", "required", "confirm"];
|
4
4
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
5
5
|
import React from 'react';
|
6
6
|
import { isBoolean, isFunction, union, isString } from 'lodash';
|
@@ -69,6 +69,7 @@ var RenderFields = function RenderFields(props) {
|
|
69
69
|
_column$fieldProps = column.fieldProps,
|
70
70
|
fieldProps = _column$fieldProps === void 0 ? {} : _column$fieldProps,
|
71
71
|
equalWith = column.equalWith,
|
72
|
+
onDiff = column.onDiff,
|
72
73
|
_column$clearNotShow = column.clearNotShow,
|
73
74
|
clearNotShow = _column$clearNotShow === void 0 ? outerClearNotShow : _column$clearNotShow,
|
74
75
|
columnRequired = column.required,
|
@@ -208,7 +209,7 @@ var RenderFields = function RenderFields(props) {
|
|
208
209
|
fieldProps: isFunction(fieldProps) ? fieldProps : null,
|
209
210
|
isSelect: _isSelect,
|
210
211
|
diffConfig: diffConfig,
|
211
|
-
equalWith: equalWith,
|
212
|
+
equalWith: onDiff || equalWith,
|
212
213
|
requiredOnView: requiredOnView,
|
213
214
|
globalControl: globalControl,
|
214
215
|
viewRender: viewRender
|
@@ -207,6 +207,7 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
|
|
207
207
|
hiddenNames?: string[] | any[];
|
208
208
|
rules?: ProRule[] | ReactiveFunction<Values, ProRule[]>;
|
209
209
|
equalWith?: DiffOriginalParams['equalWith'];
|
210
|
+
onDiff?: DiffOriginalParams['equalWith'];
|
210
211
|
required?: boolean | boolean[] | ReactiveFunction<Values, boolean | boolean[]>;
|
211
212
|
labelRequired?: boolean;
|
212
213
|
toISOString?: boolean;
|
@@ -385,7 +385,7 @@
|
|
385
385
|
}
|
386
386
|
|
387
387
|
// checkbox
|
388
|
-
.@{ant-prefix}-checkbox-group {
|
388
|
+
.@{ant-prefix}-checkbox-group,.pro-switch-checkbox {
|
389
389
|
padding: 5px 0
|
390
390
|
}
|
391
391
|
// switch
|
@@ -412,7 +412,7 @@
|
|
412
412
|
background: @zaui-contract-bg-add !important;
|
413
413
|
|
414
414
|
.@{ant-prefix}-input {
|
415
|
-
background: @zaui-contract-bg !important;
|
415
|
+
background: @zaui-contract-bg-add !important;
|
416
416
|
}
|
417
417
|
|
418
418
|
.@{ant-prefix}-select.@{ant-prefix}-select-disabled .@{ant-prefix}-select-selector{
|
@@ -463,7 +463,7 @@
|
|
463
463
|
}
|
464
464
|
|
465
465
|
// checkbox
|
466
|
-
.@{ant-prefix}-checkbox-group {
|
466
|
+
.@{ant-prefix}-checkbox-group,.pro-switch-checkbox {
|
467
467
|
padding: 5px 0
|
468
468
|
}
|
469
469
|
// switch
|
@@ -485,10 +485,8 @@
|
|
485
485
|
}
|
486
486
|
}
|
487
487
|
|
488
|
-
.original-value-
|
489
|
-
max-width: 100%;
|
488
|
+
.original-value-tooltip{
|
490
489
|
width: max-content;
|
491
|
-
position: fixed;
|
492
490
|
.changed-tooltip {
|
493
491
|
.original-value-container {
|
494
492
|
.ant-space-item:nth-child(1) {
|
@@ -511,3 +509,9 @@
|
|
511
509
|
}
|
512
510
|
}
|
513
511
|
|
512
|
+
.original-value-tooltip-fixed {
|
513
|
+
position: fixed;
|
514
|
+
}
|
515
|
+
|
516
|
+
|
517
|
+
|
@@ -1,15 +1,17 @@
|
|
1
1
|
import { isEqual, isFunction, isObject } from 'lodash';
|
2
2
|
import { isEmpty } from '../../utils';
|
3
3
|
// 过滤对象中undefined字段
|
4
|
-
// 防止{a: '1'} {a: '1', b: undefined}被认为不相等
|
5
|
-
var
|
4
|
+
// 防止{a: '1'} {a: '1', b: undefined | null}被认为不相等
|
5
|
+
var filterObject = function filterObject(data) {
|
6
6
|
if (!isObject(data) || Array.isArray(data) || data === null) return data;
|
7
7
|
var resData = {};
|
8
8
|
Object.keys(data).forEach(function (key) {
|
9
|
-
if (data[key]
|
9
|
+
if (!isEmpty(data[key])) {
|
10
10
|
resData[key] = data[key];
|
11
11
|
}
|
12
12
|
});
|
13
|
+
// 空对象视为null 比较时 null undefined {} [] '' 视为相等
|
14
|
+
if (!Object.keys(resData).length) return null;
|
13
15
|
return resData;
|
14
16
|
};
|
15
17
|
var nullValue = [null, undefined, '']; // 输入框空值时可能存在的三种值 视为相等
|
@@ -20,18 +22,22 @@ export var diffOriginal = function diffOriginal(params) {
|
|
20
22
|
// 支持传入自定义比较事件
|
21
23
|
if (isFunction(equalWith)) {
|
22
24
|
var diffRes = equalWith(originalValue, value);
|
23
|
-
|
24
|
-
if (
|
25
|
-
|
25
|
+
// 如果返回undefined走内置比较逻辑
|
26
|
+
if (diffRes !== undefined) {
|
27
|
+
if (typeof diffRes === 'boolean') {
|
28
|
+
return diffRes ? 'same' : 'changed';
|
29
|
+
}
|
30
|
+
return diffRes;
|
26
31
|
}
|
27
|
-
return diffRes;
|
28
32
|
}
|
33
|
+
var _value = filterObject(value);
|
34
|
+
var _originalValue = filterObject(originalValue);
|
29
35
|
// 如果原始值为空 且当前有值的话 认为变更类型是新增
|
30
|
-
if (isEmpty(
|
36
|
+
if (isEmpty(_originalValue) && !isEmpty(_value)) {
|
31
37
|
return 'add';
|
32
38
|
}
|
33
|
-
if (Array.isArray(
|
34
|
-
var isSame =
|
39
|
+
if (Array.isArray(_originalValue)) {
|
40
|
+
var isSame = _originalValue.every(function (valueItem, index) {
|
35
41
|
// 如果两个值有一个不是空值, 则进行深比较
|
36
42
|
if (!isEmpty(value === null || value === void 0 ? void 0 : value[index]) || !isEmpty(valueItem)) {
|
37
43
|
return isEqual(value === null || value === void 0 ? void 0 : value[index], valueItem);
|
@@ -40,8 +46,8 @@ export var diffOriginal = function diffOriginal(params) {
|
|
40
46
|
});
|
41
47
|
return isSame ? 'same' : 'changed';
|
42
48
|
}
|
43
|
-
if (!
|
44
|
-
return isEqual(
|
49
|
+
if (!isEmpty(_originalValue) || !isEmpty(_value)) {
|
50
|
+
return isEqual(_value, _originalValue) ? 'same' : 'changed';
|
45
51
|
}
|
46
52
|
return 'same';
|
47
53
|
};
|
@@ -1,10 +1,12 @@
|
|
1
|
+
/**
|
2
|
+
* 调整点:
|
3
|
+
*/
|
1
4
|
import React from 'react';
|
2
5
|
import { ProTableColumn } from '../../propsType';
|
3
|
-
export declare const formatColumn: ({ column, originalObj, rowKey,
|
6
|
+
export declare const formatColumn: ({ column, originalObj, rowKey, wrapToolTipProps, scroll, onUpdateMinWidth, isInNewRow, diffConfig, }: {
|
4
7
|
column: ProTableColumn;
|
5
8
|
originalObj: any;
|
6
9
|
rowKey: any;
|
7
|
-
diffToolTip?: boolean;
|
8
10
|
wrapToolTipProps?: any;
|
9
11
|
scroll?: any;
|
10
12
|
onUpdateMinWidth?: any;
|
@@ -2,13 +2,16 @@ import "antd/es/space/style";
|
|
2
2
|
import _Space from "antd/es/space";
|
3
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
5
|
-
var _excluded = ["title", "valueType", "format", "precision", "ellipsis", "code", "copyable", "width", "tooltip", "transform", "prefix", "suffix", "dataIndex", "
|
5
|
+
var _excluded = ["title", "valueType", "format", "precision", "ellipsis", "code", "copyable", "width", "tooltip", "transform", "prefix", "suffix", "dataIndex", "toolTipProps", "minWidth", "onDiff"];
|
6
6
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
7
|
+
/**
|
8
|
+
* 调整点:
|
9
|
+
*/
|
7
10
|
import { isValidElement } from 'react';
|
8
11
|
import moment from 'moment';
|
9
12
|
import classnames from 'classnames';
|
10
13
|
import ReactDOM from 'react-dom';
|
11
|
-
import { isEqual, isFunction, isString, isObject } from 'lodash';
|
14
|
+
import { isEqual, isFunction, isString, isObject, isBoolean } from 'lodash';
|
12
15
|
import { tools } from '@zat-design/utils';
|
13
16
|
import TooltipTitle from '../TooltipTitle';
|
14
17
|
import RenderColumn from '../RenderColumn';
|
@@ -50,7 +53,6 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
50
53
|
var column = _ref2.column,
|
51
54
|
originalObj = _ref2.originalObj,
|
52
55
|
rowKey = _ref2.rowKey,
|
53
|
-
diffToolTip = _ref2.diffToolTip,
|
54
56
|
wrapToolTipProps = _ref2.wrapToolTipProps,
|
55
57
|
scroll = _ref2.scroll,
|
56
58
|
onUpdateMinWidth = _ref2.onUpdateMinWidth,
|
@@ -71,7 +73,6 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
71
73
|
prefix = column.prefix,
|
72
74
|
suffix = column.suffix,
|
73
75
|
dataIndex = column.dataIndex,
|
74
|
-
originalDiffTip = column.originalDiffTip,
|
75
76
|
_column$toolTipProps = column.toolTipProps,
|
76
77
|
toolTipProps = _column$toolTipProps === void 0 ? {} : _column$toolTipProps,
|
77
78
|
minWidth = column.minWidth,
|
@@ -87,7 +88,6 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
87
88
|
callback: onUpdateMinWidth
|
88
89
|
});
|
89
90
|
var _toolTipProps = _objectSpread(_objectSpread({}, toolTipProps), wrapToolTipProps);
|
90
|
-
var _originalDiffTip = (diffConfig === null || diffConfig === void 0 ? void 0 : diffConfig.originalDataSource) || (diffConfig === null || diffConfig === void 0 ? void 0 : diffConfig.toolTip);
|
91
91
|
// 前缀处理
|
92
92
|
var prefixNode = function prefixNode(value, record, index) {
|
93
93
|
if (!prefix) {
|
@@ -121,10 +121,13 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
121
121
|
column.render = function (value, record, index) {
|
122
122
|
var isFn = isFunction(originalRender);
|
123
123
|
var _value = isFn ? originalRender === null || originalRender === void 0 ? void 0 : originalRender(value, record !== null && record !== void 0 ? record : {}, index) : null;
|
124
|
-
var
|
124
|
+
var originalResult = getOriginalValue(value, record !== null && record !== void 0 ? record : {}, originalObj, rowKey, dataIndex);
|
125
|
+
var originalValue = originalResult.originalValue;
|
126
|
+
var isChanged = originalResult.isChanged;
|
125
127
|
var isInNewRowFlag = isInNewRow(record);
|
128
|
+
otherProps.isChanged = isChanged;
|
126
129
|
// 存在比对
|
127
|
-
if (isFunction(otherProps === null || otherProps === void 0 ? void 0 : otherProps.viewRender)) {
|
130
|
+
if (isFunction(otherProps === null || otherProps === void 0 ? void 0 : otherProps.viewRender) && (diffConfig === null || diffConfig === void 0 ? void 0 : diffConfig.originalDataSource)) {
|
128
131
|
var _originalObj$record$r;
|
129
132
|
var diffResult = otherProps.viewRender({
|
130
133
|
originalValue: originalValue,
|
@@ -133,8 +136,11 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
133
136
|
record: record,
|
134
137
|
index: index
|
135
138
|
});
|
139
|
+
// viewRender 返回值为 false 时,不显示对比
|
140
|
+
if (isBoolean(diffResult)) {
|
141
|
+
otherProps.isChanged = false;
|
142
|
+
}
|
136
143
|
originalValue = diffResult;
|
137
|
-
otherProps.diffChange = diffResult;
|
138
144
|
}
|
139
145
|
return _jsx(RenderColumn, _objectSpread(_objectSpread({}, otherProps), {}, {
|
140
146
|
valueType: valueType,
|
@@ -144,7 +150,6 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
144
150
|
value: _value,
|
145
151
|
node: _value,
|
146
152
|
currentValue: _value,
|
147
|
-
originalDiffTip: _originalDiffTip,
|
148
153
|
toolTipProps: _toolTipProps,
|
149
154
|
minWidth: minWidth,
|
150
155
|
isInNewRowFlag: isInNewRowFlag
|
@@ -171,7 +176,10 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
171
176
|
var multiple = valueType === 'percentage' ? 100 : 1000;
|
172
177
|
var realValue = tools.calc(Number(value !== null && value !== void 0 ? value : 0), '*', multiple);
|
173
178
|
var renderValue = getDecimalDigits(value) > valueTypePrecision ? realValue : realValue.toFixed(valueTypePrecision);
|
174
|
-
var
|
179
|
+
var originalResult = getOriginalValue(value, record, originalObj, rowKey, dataIndex);
|
180
|
+
var originalValue = originalResult.originalValue;
|
181
|
+
var isChanged = originalResult.isChanged;
|
182
|
+
otherProps.isChanged = isChanged;
|
175
183
|
var originalRealValue = tools.calc(Number(originalValue || null), '*', multiple);
|
176
184
|
var originalRenderValue = getDecimalDigits(originalValue) > valueTypePrecision ? originalRealValue : originalRealValue.toFixed(valueTypePrecision);
|
177
185
|
if (isEmpty(originalValue)) {
|
@@ -192,13 +200,12 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
192
200
|
var isInNewRowFlag = isInNewRow(record);
|
193
201
|
return _jsx(RenderColumn, _objectSpread(_objectSpread({}, otherProps), {}, {
|
194
202
|
valueType: valueType,
|
195
|
-
originalValue: originalValue ===
|
203
|
+
originalValue: originalValue === null ? null : originalRenderValue,
|
196
204
|
ellipsis: ellipsis,
|
197
205
|
width: width,
|
198
206
|
node: node,
|
199
207
|
value: value,
|
200
208
|
currentValue: renderValue,
|
201
|
-
originalDiffTip: _originalDiffTip,
|
202
209
|
toolTipProps: _toolTipProps,
|
203
210
|
minWidth: minWidth,
|
204
211
|
isInNewRowFlag: isInNewRowFlag
|
@@ -209,7 +216,10 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
209
216
|
column.render = function (value, record, index) {
|
210
217
|
var valueStr = valueTypePrecision ? "".concat(Number(value).toFixed(valueTypePrecision)) : "".concat(value);
|
211
218
|
var renderValue = valueStr.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
212
|
-
var
|
219
|
+
var originalResult = getOriginalValue(value, record, originalObj, rowKey, dataIndex);
|
220
|
+
var originalValue = originalResult.originalValue;
|
221
|
+
var isChanged = originalResult.isChanged;
|
222
|
+
otherProps.isChanged = isChanged;
|
213
223
|
var originalRealValue = valueTypePrecision ? "".concat(Number(originalValue).toFixed(valueTypePrecision)) : "".concat(originalValue);
|
214
224
|
var originalRenderValue = originalRealValue.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
215
225
|
if (isEmpty(originalValue)) {
|
@@ -230,13 +240,12 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
230
240
|
var isInNewRowFlag = isInNewRow(record);
|
231
241
|
return _jsx(RenderColumn, _objectSpread(_objectSpread({}, otherProps), {}, {
|
232
242
|
valueType: valueType,
|
233
|
-
originalValue: originalValue ===
|
243
|
+
originalValue: originalValue === null ? null : originalRenderValue,
|
234
244
|
ellipsis: ellipsis,
|
235
245
|
width: width,
|
236
246
|
node: node,
|
237
247
|
value: value,
|
238
248
|
currentValue: renderValue,
|
239
|
-
originalDiffTip: _originalDiffTip,
|
240
249
|
toolTipProps: _toolTipProps,
|
241
250
|
minWidth: minWidth,
|
242
251
|
isInNewRowFlag: isInNewRowFlag
|
@@ -246,7 +255,10 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
246
255
|
column.render = function (value, record, index) {
|
247
256
|
var _moment, _moment2, _moment3, _moment4, _moment5, _moment6, _moment7, _moment8, _moment9, _moment10, _moment11, _moment12, _moment13, _moment14;
|
248
257
|
var renderValue = (_moment = moment(value)) === null || _moment === void 0 ? void 0 : _moment.format(format);
|
249
|
-
var
|
258
|
+
var originalResult = getOriginalValue(value, record, originalObj, rowKey, dataIndex);
|
259
|
+
var originalValue = originalResult.originalValue;
|
260
|
+
var isChanged = originalResult.isChanged;
|
261
|
+
otherProps.isChanged = isChanged;
|
250
262
|
var originalRenderValue = (_moment2 = moment(originalValue)) === null || _moment2 === void 0 ? void 0 : _moment2.format(format);
|
251
263
|
switch (valueType) {
|
252
264
|
case 'date':
|
@@ -291,13 +303,12 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
291
303
|
var isInNewRowFlag = isInNewRow(record);
|
292
304
|
return _jsx(RenderColumn, _objectSpread(_objectSpread({}, otherProps), {}, {
|
293
305
|
valueType: valueType,
|
294
|
-
originalValue: originalValue ===
|
306
|
+
originalValue: originalValue === null ? null : originalRenderValue,
|
295
307
|
ellipsis: ellipsis,
|
296
308
|
width: width,
|
297
309
|
node: node,
|
298
310
|
value: value,
|
299
311
|
currentValue: renderValue,
|
300
|
-
originalDiffTip: _originalDiffTip,
|
301
312
|
toolTipProps: _toolTipProps,
|
302
313
|
minWidth: minWidth,
|
303
314
|
isInNewRowFlag: isInNewRowFlag
|
@@ -307,7 +318,10 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
307
318
|
column.render = function (value, record, index) {
|
308
319
|
var realCode = typeof code === 'function' ? code(value, record) : code;
|
309
320
|
var renderValue = getEnumLabel(realCode, value, valueType === 'enumCodeName');
|
310
|
-
var
|
321
|
+
var originalResult = getOriginalValue(value, record, originalObj, rowKey, dataIndex);
|
322
|
+
var originalValue = originalResult.originalValue;
|
323
|
+
var isChanged = originalResult.isChanged;
|
324
|
+
otherProps.isChanged = isChanged;
|
311
325
|
var originalRenderValue = getEnumLabel(realCode, originalValue, valueType === 'enumCodeName');
|
312
326
|
if (Array.isArray(column === null || column === void 0 ? void 0 : column.codeValues) && !realCode) {
|
313
327
|
var _column$codeValues$fi;
|
@@ -332,13 +346,12 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
332
346
|
var isInNewRowFlag = isInNewRow(record);
|
333
347
|
return _jsx(RenderColumn, _objectSpread(_objectSpread({}, otherProps), {}, {
|
334
348
|
valueType: valueType,
|
335
|
-
originalValue: originalValue ===
|
349
|
+
originalValue: originalValue === null ? null : originalRenderValue,
|
336
350
|
ellipsis: ellipsis,
|
337
351
|
width: width,
|
338
352
|
node: node,
|
339
353
|
value: value,
|
340
354
|
currentValue: renderValue,
|
341
|
-
originalDiffTip: _originalDiffTip,
|
342
355
|
toolTipProps: _toolTipProps,
|
343
356
|
minWidth: minWidth,
|
344
357
|
isInNewRowFlag: isInNewRowFlag
|
@@ -347,7 +360,10 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
347
360
|
} else if (precision || prefix || suffix) {
|
348
361
|
column.render = function (value, record, index) {
|
349
362
|
var renderValue = value === 'number' ? value.toFixed(precision) : value;
|
350
|
-
var
|
363
|
+
var originalResult = getOriginalValue(value, record, originalObj, rowKey, dataIndex);
|
364
|
+
var originalValue = originalResult.originalValue;
|
365
|
+
var isChanged = originalResult.isChanged;
|
366
|
+
otherProps.isChanged = isChanged;
|
351
367
|
var originalRenderValue = originalValue === 'number' ? originalValue.toFixed(precision) : originalValue;
|
352
368
|
var node = _jsxs(_Space, {
|
353
369
|
size: 8,
|
@@ -367,13 +383,12 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
367
383
|
var isInNewRowFlag = isInNewRow(record);
|
368
384
|
return _jsx(RenderColumn, _objectSpread(_objectSpread({}, otherProps), {}, {
|
369
385
|
valueType: valueType,
|
370
|
-
originalValue: originalValue ===
|
386
|
+
originalValue: originalValue === null ? null : originalRenderValue,
|
371
387
|
ellipsis: ellipsis,
|
372
388
|
width: width,
|
373
389
|
node: node,
|
374
390
|
value: value,
|
375
391
|
currentValue: renderValue,
|
376
|
-
originalDiffTip: _originalDiffTip,
|
377
392
|
toolTipProps: _toolTipProps,
|
378
393
|
minWidth: minWidth,
|
379
394
|
isInNewRowFlag: isInNewRowFlag
|
@@ -383,7 +398,10 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
383
398
|
column.render = function (value, record, index) {
|
384
399
|
var _realValue$filter;
|
385
400
|
var realValue = transform ? transform(value, record) : value;
|
386
|
-
var
|
401
|
+
var originalResult = getOriginalValue(value, record, originalObj, rowKey, dataIndex);
|
402
|
+
var originalValue = originalResult.originalValue;
|
403
|
+
var isChanged = originalResult.isChanged;
|
404
|
+
otherProps.isChanged = isChanged;
|
387
405
|
var originalRealValue = transform ? transform(originalValue, record) : originalValue;
|
388
406
|
var isEmpty = !realValue || Array.isArray(realValue) && (realValue === null || realValue === void 0 ? void 0 : (_realValue$filter = realValue.filter(function (item) {
|
389
407
|
return !!item;
|
@@ -422,13 +440,12 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
422
440
|
var isInNewRowFlag = isInNewRow(record);
|
423
441
|
return _jsx(RenderColumn, _objectSpread(_objectSpread({}, otherProps), {}, {
|
424
442
|
valueType: valueType,
|
425
|
-
originalValue: originalValue ===
|
443
|
+
originalValue: originalValue === null ? null : originalRenderValue,
|
426
444
|
ellipsis: ellipsis,
|
427
445
|
width: width,
|
428
446
|
node: renderNode,
|
429
447
|
value: renderValue,
|
430
448
|
currentValue: renderValue,
|
431
|
-
originalDiffTip: _originalDiffTip,
|
432
449
|
toolTipProps: _toolTipProps,
|
433
450
|
minWidth: minWidth,
|
434
451
|
isInNewRowFlag: isInNewRowFlag
|
@@ -455,7 +472,10 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
455
472
|
};
|
456
473
|
} else if (ellipsis) {
|
457
474
|
column.render = function (value, record, index) {
|
458
|
-
var
|
475
|
+
var originalResult = getOriginalValue(value, record, originalObj, rowKey, dataIndex);
|
476
|
+
var originalValue = originalResult.originalValue;
|
477
|
+
var isChanged = originalResult.isChanged;
|
478
|
+
otherProps.isChanged = isChanged;
|
459
479
|
if (!value && value !== 0 && value === originalValue) {
|
460
480
|
_jsx("div", {
|
461
481
|
style: {
|
@@ -469,13 +489,12 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
469
489
|
size: 8,
|
470
490
|
children: [prefixNode(value, record, index), _jsx(RenderColumn, _objectSpread(_objectSpread({}, otherProps), {}, {
|
471
491
|
valueType: valueType,
|
472
|
-
originalValue: originalValue ===
|
492
|
+
originalValue: originalValue === null ? null : originalValue || '-',
|
473
493
|
ellipsis: ellipsis,
|
474
494
|
width: width,
|
475
495
|
node: value,
|
476
496
|
value: value,
|
477
497
|
currentValue: value || '-',
|
478
|
-
originalDiffTip: _originalDiffTip,
|
479
498
|
toolTipProps: _toolTipProps,
|
480
499
|
minWidth: minWidth,
|
481
500
|
isInNewRowFlag: isInNewRowFlag
|
@@ -484,7 +503,10 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
484
503
|
};
|
485
504
|
} else {
|
486
505
|
column.render = function (value, record, index) {
|
487
|
-
var
|
506
|
+
var originalResult = getOriginalValue(value, record, originalObj, rowKey, dataIndex);
|
507
|
+
var originalValue = originalResult.originalValue;
|
508
|
+
var isChanged = originalResult.isChanged;
|
509
|
+
otherProps.isChanged = isChanged;
|
488
510
|
var node = _jsxs(_Space, {
|
489
511
|
size: 8,
|
490
512
|
children: [prefixNode(value, record, index), value, suffixNode(value, record, index)]
|
@@ -500,13 +522,12 @@ export var formatColumn = function formatColumn(_ref2) {
|
|
500
522
|
var isInNewRowFlag = isInNewRow(record);
|
501
523
|
return _jsx(RenderColumn, _objectSpread(_objectSpread({}, otherProps), {}, {
|
502
524
|
valueType: valueType,
|
503
|
-
originalValue: originalValue ===
|
525
|
+
originalValue: originalValue === null ? null : originalValue || '-',
|
504
526
|
ellipsis: ellipsis,
|
505
527
|
width: width,
|
506
528
|
node: node,
|
507
529
|
value: value,
|
508
530
|
currentValue: value || '-',
|
509
|
-
originalDiffTip: _originalDiffTip,
|
510
531
|
toolTipProps: _toolTipProps,
|
511
532
|
minWidth: minWidth,
|
512
533
|
isInNewRowFlag: isInNewRowFlag
|
@@ -6,14 +6,13 @@ interface Props {
|
|
6
6
|
value?: any;
|
7
7
|
currentValue?: any;
|
8
8
|
copyable?: boolean;
|
9
|
-
originalDiffTip?: boolean;
|
10
9
|
ellipsis?: any;
|
11
10
|
width?: number | string;
|
12
11
|
originalValue?: any;
|
13
12
|
toolTipProps?: TooltipProps & React.RefAttributes<unknown>;
|
14
13
|
minWidth?: number;
|
15
14
|
isInNewRowFlag?: boolean;
|
16
|
-
|
15
|
+
isChanged?: boolean;
|
17
16
|
}
|
18
17
|
declare const RenderColumn: FC<Props>;
|
19
18
|
export default RenderColumn;
|