@zat-design/sisyphus-react 3.8.2 → 3.8.3-beta.2
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 +16 -8
- package/dist/less.esm.css +16 -8
- package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +7 -6
- package/es/ProEditTable/components/RenderField/index.js +1 -0
- package/es/ProEnum/hooks/useEnumRequest.js +1 -1
- package/es/ProEnum/index.js +2 -2
- package/es/ProForm/components/base/InputNumber/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 +4 -2
- package/es/ProForm/components/combination/Group/index.js +6 -3
- package/es/ProForm/components/render/ChangedWrapper.js +8 -2
- package/es/ProForm/components/render/Render.js +3 -2
- package/es/ProForm/components/render/propsType.d.ts +4 -0
- package/es/ProForm/style/index.less +15 -2
- package/es/ProForm/utils/useShouldUpdate.js +20 -13
- package/es/ProTable/components/FormatColumn/index.d.ts +3 -1
- package/es/ProTable/components/FormatColumn/index.js +134 -24
- package/es/ProTable/components/RenderColumn/index.d.ts +1 -0
- package/es/ProTable/components/RenderColumn/index.js +22 -7
- package/es/ProTable/index.js +20 -5
- package/es/ProTable/style/index.less +8 -6
- package/lib/ProEditTable/components/RenderField/ListChangedWrapper.js +10 -9
- package/lib/ProEditTable/components/RenderField/index.js +1 -0
- package/lib/ProEnum/hooks/useEnumRequest.js +1 -1
- package/lib/ProEnum/index.js +2 -2
- package/lib/ProForm/components/base/InputNumber/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 +4 -2
- package/lib/ProForm/components/combination/Group/index.js +6 -3
- package/lib/ProForm/components/render/ChangedWrapper.js +8 -2
- package/lib/ProForm/components/render/Render.js +3 -2
- package/lib/ProForm/components/render/propsType.d.ts +4 -0
- package/lib/ProForm/style/index.less +15 -2
- package/lib/ProForm/utils/useShouldUpdate.js +18 -11
- package/lib/ProTable/components/FormatColumn/index.d.ts +3 -1
- package/lib/ProTable/components/FormatColumn/index.js +133 -23
- package/lib/ProTable/components/RenderColumn/index.d.ts +1 -0
- package/lib/ProTable/components/RenderColumn/index.js +22 -7
- package/lib/ProTable/index.js +20 -5
- package/lib/ProTable/style/index.less +8 -6
- package/package.json +4 -3
|
@@ -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"];
|
|
20
|
+
var _excluded = ["name", "names", "namesStr", "form", "equalWith", "children", "type", "diffConfig", "valuePropName", "normalize", "getValueProps"];
|
|
21
21
|
var ChangedWrapper = function ChangedWrapper(props) {
|
|
22
22
|
var _diffConfig$toolTip, _children$props, _children$props2, _children$props3;
|
|
23
23
|
var name = props.name,
|
|
@@ -31,6 +31,7 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
31
31
|
_props$valuePropName = props.valuePropName,
|
|
32
32
|
valuePropName = _props$valuePropName === void 0 ? 'value' : _props$valuePropName,
|
|
33
33
|
normalize = props.normalize,
|
|
34
|
+
getValueProps = props.getValueProps,
|
|
34
35
|
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
35
36
|
var _useProConfig = (0, _ProConfigProvider.useProConfig)('ProForm'),
|
|
36
37
|
isDiffAll = _useProConfig.isDiffAll;
|
|
@@ -58,9 +59,10 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
58
59
|
var isChanged = diffType === 'changed';
|
|
59
60
|
var tipContent = (0, _react.useMemo)(function () {
|
|
60
61
|
if (!isWatch || noChange) return undefined;
|
|
62
|
+
var valueProps = getValueProps ? getValueProps(originalValue) : originalValue;
|
|
61
63
|
return /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)({}, children.props), {}, (0, _defineProperty2.default)({
|
|
62
64
|
isView: true
|
|
63
|
-
}, valuePropName,
|
|
65
|
+
}, valuePropName, valueProps === null || valueProps === void 0 ? void 0 : valueProps.value))) : undefined;
|
|
64
66
|
}, [originalValue, children]);
|
|
65
67
|
if (!isWatch || noChange) {
|
|
66
68
|
// 嵌套子组件
|
|
@@ -92,9 +94,13 @@ var ChangedWrapper = function ChangedWrapper(props) {
|
|
|
92
94
|
},
|
|
93
95
|
title: (0, _jsxRuntime.jsxs)(_antd.Space, {
|
|
94
96
|
direction: "vertical",
|
|
97
|
+
className: "changed-tooltip",
|
|
95
98
|
children: [(0, _jsxRuntime.jsxs)(_antd.Space, {
|
|
99
|
+
align: "start",
|
|
100
|
+
className: "original-value-container",
|
|
96
101
|
children: ["\u521D\u59CB\u503C\uFF1A", tipContent]
|
|
97
102
|
}), _showEllipse && (0, _jsxRuntime.jsxs)(_antd.Space, {
|
|
103
|
+
className: "current-value-container",
|
|
98
104
|
children: ["\u5F53\u524D\u503C\uFF1A", /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)((0, _objectSpread3.default)({}, children.props), rest), {}, {
|
|
99
105
|
isView: true
|
|
100
106
|
})) : undefined]
|
|
@@ -155,7 +155,7 @@ var Render = function Render(props) {
|
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
157
|
/** 移除多余参数,防止透传给formItem报错 */
|
|
158
|
-
var _otherFormItemProps = (0, _lodash.omit)(otherFormItemProps, ['component', 'names', 'format', 'toISOString', 'toCSTString', 'switchValue', 'precision', 'clearNotShow']);
|
|
158
|
+
var _otherFormItemProps = (0, _lodash.omit)(otherFormItemProps, ['component', 'names', 'format', 'toISOString', 'toCSTString', 'switchValue', 'precision', 'clearNotShow', 'dependNames']);
|
|
159
159
|
/**
|
|
160
160
|
* globalControl 全局控制优先
|
|
161
161
|
* globalControl true时,优先级 全局【formDisabled】> formitem上【column.disabled】 > 组件上【fieldProps.disabled】
|
|
@@ -426,7 +426,7 @@ var Render = function Render(props) {
|
|
|
426
426
|
span: 24 // 默认占一行
|
|
427
427
|
});
|
|
428
428
|
}
|
|
429
|
-
if (diffConfig) {
|
|
429
|
+
if (diffConfig === null || diffConfig === void 0 ? void 0 : diffConfig.originalValues) {
|
|
430
430
|
child = (0, _jsxRuntime.jsx)(_ChangedWrapper.default, {
|
|
431
431
|
name: formItemProps.name,
|
|
432
432
|
names: otherProps.names,
|
|
@@ -438,6 +438,7 @@ var Render = function Render(props) {
|
|
|
438
438
|
onChange: handleChange,
|
|
439
439
|
valuePropName: _otherFormItemProps.valuePropName,
|
|
440
440
|
normalize: _otherFormItemProps.normalize,
|
|
441
|
+
getValueProps: _otherFormItemProps.getValueProps,
|
|
441
442
|
children: child
|
|
442
443
|
});
|
|
443
444
|
}
|
|
@@ -182,6 +182,8 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
|
|
|
182
182
|
}) => React.ReactElement<any, any> | string | undefined | null;
|
|
183
183
|
viewType?: ViewType;
|
|
184
184
|
colProps?: ColProps;
|
|
185
|
+
/** 依赖刷新字段列表 */
|
|
186
|
+
dependNames?: NamePath[];
|
|
185
187
|
/**
|
|
186
188
|
* @description 表单item的props属性
|
|
187
189
|
* @deprecated 将于下个版本 4.0.0 被弃用
|
|
@@ -190,6 +192,8 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
|
|
|
190
192
|
formItemProps?: FormItemProps<Values> & {
|
|
191
193
|
index?: number;
|
|
192
194
|
namePath?: NamePath;
|
|
195
|
+
/** 依赖刷新字段列表 */
|
|
196
|
+
dependNames?: NamePath[];
|
|
193
197
|
};
|
|
194
198
|
/**
|
|
195
199
|
* @description 表单props属性
|
|
@@ -387,7 +387,7 @@
|
|
|
387
387
|
|
|
388
388
|
// textArea
|
|
389
389
|
.@{ant-prefix}-input-textarea > textarea {
|
|
390
|
-
background: @zaui-contract-bg;
|
|
390
|
+
background: @zaui-contract-bg !important;
|
|
391
391
|
}
|
|
392
392
|
|
|
393
393
|
.pro-form-view-container {
|
|
@@ -461,7 +461,7 @@
|
|
|
461
461
|
|
|
462
462
|
// textArea
|
|
463
463
|
.@{ant-prefix}-input-textarea > textarea {
|
|
464
|
-
background: @zaui-contract-bg-add;
|
|
464
|
+
background: @zaui-contract-bg-add !important;
|
|
465
465
|
}
|
|
466
466
|
|
|
467
467
|
|
|
@@ -472,3 +472,16 @@
|
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
474
|
}
|
|
475
|
+
|
|
476
|
+
.changed-tooltip {
|
|
477
|
+
.original-value-container {
|
|
478
|
+
.ant-space-item:nth-child(1) {
|
|
479
|
+
white-space: nowrap;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
.current-value-container {
|
|
483
|
+
.ant-space-item:nth-child(1) {
|
|
484
|
+
white-space: nowrap;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
@@ -27,7 +27,7 @@ var useShouldUpdate = function useShouldUpdate(props) {
|
|
|
27
27
|
index = formItemProps.index,
|
|
28
28
|
namePath = formItemProps.namePath,
|
|
29
29
|
names = formItemProps.names,
|
|
30
|
-
|
|
30
|
+
dependNames = formItemProps.dependNames;
|
|
31
31
|
var timerRef = (0, _react.useRef)();
|
|
32
32
|
var needClear = (0, _react.useRef)(); // 是否需要执行清值操作
|
|
33
33
|
var showRef = (0, _react.useRef)();
|
|
@@ -36,13 +36,14 @@ var useShouldUpdate = function useShouldUpdate(props) {
|
|
|
36
36
|
var rulesRef = (0, _react.useRef)();
|
|
37
37
|
var fieldPropsRef = (0, _react.useRef)();
|
|
38
38
|
var originComponentRef = (0, _react.useRef)();
|
|
39
|
+
var dependNamesRef = (0, _react.useRef)();
|
|
39
40
|
var newComponent = originComponent || component; // 解决component默认赋值污染问题,需要使用originComponent
|
|
40
41
|
var _useState = (0, _react.useState)({}),
|
|
41
42
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
42
43
|
reRender = _useState2[1];
|
|
43
44
|
var values = {};
|
|
44
45
|
// 不是动态函数直接返回
|
|
45
|
-
if (!(0, _lodash.isFunction)(show) && !(0, _lodash.isFunction)(disabled) && !(0, _lodash.isFunction)(required) && !(0, _lodash.isFunction)(rules) && !(0, _lodash.isFunction)(fieldProps) && !(0, _lodash.isFunction)(originComponent)) {
|
|
46
|
+
if (!(dependNames === null || dependNames === void 0 ? void 0 : dependNames.length) && !(0, _lodash.isFunction)(show) && !(0, _lodash.isFunction)(disabled) && !(0, _lodash.isFunction)(required) && !(0, _lodash.isFunction)(rules) && !(0, _lodash.isFunction)(fieldProps) && !(0, _lodash.isFunction)(originComponent)) {
|
|
46
47
|
return {
|
|
47
48
|
shouldUpdate: _shouldUpdate,
|
|
48
49
|
show: show,
|
|
@@ -126,9 +127,22 @@ var useShouldUpdate = function useShouldUpdate(props) {
|
|
|
126
127
|
} else {
|
|
127
128
|
fieldPropsRef.current = fieldProps;
|
|
128
129
|
}
|
|
130
|
+
if (dependNames === null || dependNames === void 0 ? void 0 : dependNames.length) {
|
|
131
|
+
dependNamesRef.current = dependNames.map(function (name) {
|
|
132
|
+
return (0, _lodash.get)(values, name);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
129
135
|
return {
|
|
130
136
|
shouldUpdate: function shouldUpdate(prevValues, currentValues) {
|
|
131
137
|
// @ts-ignore formList场景取当前行数据,不取shouldUpdate变更后值
|
|
138
|
+
if (dependNames === null || dependNames === void 0 ? void 0 : dependNames.length) {
|
|
139
|
+
var curDependNamesValue = dependNames.map(function (name) {
|
|
140
|
+
return (0, _lodash.get)(currentValues, name);
|
|
141
|
+
});
|
|
142
|
+
var dependNamesChanged = !(0, _lodash.isEqualWith)(dependNamesRef.current, curDependNamesValue, _index.customEqualForFun);
|
|
143
|
+
dependNamesRef.current = curDependNamesValue;
|
|
144
|
+
if (!dependNamesChanged) return false;
|
|
145
|
+
}
|
|
132
146
|
var _currentValues;
|
|
133
147
|
if (namePath) {
|
|
134
148
|
// formList场景values取当前行数据
|
|
@@ -156,9 +170,6 @@ var useShouldUpdate = function useShouldUpdate(props) {
|
|
|
156
170
|
index: index,
|
|
157
171
|
namePath: namePath
|
|
158
172
|
}) : rules;
|
|
159
|
-
// const _component = isFunction(originComponent)
|
|
160
|
-
// ? originComponent(_currentValues, { form, index, namePath })
|
|
161
|
-
// : newComponent;
|
|
162
173
|
var _fieldProps = (0, _lodash.isFunction)(fieldProps) ? fieldProps(_currentValues, {
|
|
163
174
|
form: form,
|
|
164
175
|
index: index,
|
|
@@ -189,16 +200,12 @@ var useShouldUpdate = function useShouldUpdate(props) {
|
|
|
189
200
|
}
|
|
190
201
|
var equalRes = (0, _lodash.isEqualWith)(rulesRef.current, _rules, _index.customEqualForFun);
|
|
191
202
|
var proEqualRes = (0, _lodash.isEqualWith)(fieldPropsRef.current, _fieldProps, _index.customEqualForFun);
|
|
192
|
-
if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !equalRes || !proEqualRes ||
|
|
193
|
-
|
|
194
|
-
// (isEqualWith(fieldPropsRef.current, _fieldProps, customEqualForFun) && !isEqual(prevValues, currentValues)) ||
|
|
195
|
-
// !isEqualWith(originComponentRef.current, _component, customEqualForFun) ||
|
|
196
|
-
(0, _index.equalDependencies)(dependencies, prevValues, _currentValues)) {
|
|
203
|
+
if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !equalRes || !proEqualRes || (_fieldProps === null || _fieldProps === void 0 ? void 0 : _fieldProps.transformResponse) // 防止fieldProps变更时,transformResponse根据fieldProps新值无法触发更新
|
|
204
|
+
) {
|
|
197
205
|
showRef.current = _show;
|
|
198
206
|
disabledRef.current = _disabled;
|
|
199
207
|
requiredRef.current = _required;
|
|
200
208
|
rulesRef.current = _rules;
|
|
201
|
-
// originComponentRef.current = _component;
|
|
202
209
|
fieldPropsRef.current = _fieldProps;
|
|
203
210
|
reRender({});
|
|
204
211
|
return false;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ProTableColumn } from '../../propsType';
|
|
3
|
-
export declare const formatColumn: ({ column, originalObj, dataSourceObj, rowKey, diffToolTip, wrapToolTipProps, }: {
|
|
3
|
+
export declare const formatColumn: ({ column, originalObj, dataSourceObj, rowKey, diffToolTip, wrapToolTipProps, scroll, onUpdateMinWidth, }: {
|
|
4
4
|
column: ProTableColumn;
|
|
5
5
|
originalObj: any;
|
|
6
6
|
dataSourceObj: any;
|
|
7
7
|
rowKey: any;
|
|
8
8
|
diffToolTip?: boolean;
|
|
9
9
|
wrapToolTipProps?: any;
|
|
10
|
+
scroll?: any;
|
|
11
|
+
onUpdateMinWidth?: any;
|
|
10
12
|
}) => void;
|
|
11
13
|
/**
|
|
12
14
|
* 查找最近的父级className
|
|
@@ -10,6 +10,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
var _moment15 = _interopRequireDefault(require("moment"));
|
|
12
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
13
14
|
var _antd = require("antd");
|
|
14
15
|
var _lodash = require("lodash");
|
|
15
16
|
var _utils = require("@zat-design/utils");
|
|
@@ -18,13 +19,45 @@ var _RenderColumn = _interopRequireDefault(require("../RenderColumn"));
|
|
|
18
19
|
var _utils2 = require("../../utils");
|
|
19
20
|
var _getEnumLabel = _interopRequireDefault(require("../../../ProEnum/utils/getEnumLabel"));
|
|
20
21
|
var _ProForm = _interopRequireDefault(require("../../../ProForm"));
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
var isReactElement = function isReactElement(element) {
|
|
23
|
+
return /*#__PURE__*/(0, _react.isValidElement)(element);
|
|
24
|
+
};
|
|
25
|
+
var calcMinWidth = function calcMinWidth(_ref) {
|
|
26
|
+
var minWidth = _ref.minWidth,
|
|
27
|
+
width = _ref.width,
|
|
28
|
+
title = _ref.title,
|
|
29
|
+
isMaxContentOverFlow = _ref.isMaxContentOverFlow,
|
|
30
|
+
callback = _ref.callback;
|
|
31
|
+
if (!minWidth && !width && isMaxContentOverFlow) {
|
|
32
|
+
var tempEl = document.createElement('div');
|
|
33
|
+
tempEl.style.display = 'inline-block';
|
|
34
|
+
document.body.appendChild(tempEl);
|
|
35
|
+
if ((0, _lodash.isFunction)(title)) {
|
|
36
|
+
var component = title();
|
|
37
|
+
_reactDom.default.render(component, tempEl);
|
|
38
|
+
} else if (isReactElement(title)) {
|
|
39
|
+
_reactDom.default.render(title, tempEl);
|
|
40
|
+
} else {
|
|
41
|
+
tempEl.innerHTML = title;
|
|
42
|
+
}
|
|
43
|
+
// 使用 requestAnimationFrame 确保在下一个浏览器重绘周期中获取宽度
|
|
44
|
+
requestAnimationFrame(function () {
|
|
45
|
+
var _width = tempEl.offsetWidth;
|
|
46
|
+
_reactDom.default.unmountComponentAtNode(tempEl);
|
|
47
|
+
tempEl.remove();
|
|
48
|
+
callback(_width);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var formatColumn = exports.formatColumn = function formatColumn(_ref2) {
|
|
53
|
+
var column = _ref2.column,
|
|
54
|
+
originalObj = _ref2.originalObj,
|
|
55
|
+
dataSourceObj = _ref2.dataSourceObj,
|
|
56
|
+
rowKey = _ref2.rowKey,
|
|
57
|
+
diffToolTip = _ref2.diffToolTip,
|
|
58
|
+
wrapToolTipProps = _ref2.wrapToolTipProps,
|
|
59
|
+
scroll = _ref2.scroll,
|
|
60
|
+
onUpdateMinWidth = _ref2.onUpdateMinWidth;
|
|
28
61
|
var title = column.title,
|
|
29
62
|
valueType = column.valueType,
|
|
30
63
|
_column$format = column.format,
|
|
@@ -43,7 +76,17 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
43
76
|
_column$originalDiffT = column.originalDiffTip,
|
|
44
77
|
originalDiffTip = _column$originalDiffT === void 0 ? true : _column$originalDiffT,
|
|
45
78
|
_column$toolTipProps = column.toolTipProps,
|
|
46
|
-
toolTipProps = _column$toolTipProps === void 0 ? {} : _column$toolTipProps
|
|
79
|
+
toolTipProps = _column$toolTipProps === void 0 ? {} : _column$toolTipProps,
|
|
80
|
+
minWidth = column.minWidth;
|
|
81
|
+
// 仅在 {x: 'max-content', y: 300 } 且 column无指定 width minWidth 情况下 才开启 minWidth的自动计算
|
|
82
|
+
var isMaxContentOverFlow = (0, _lodash.isObject)(scroll) ? (scroll === null || scroll === void 0 ? void 0 : scroll.x) === 'max-content' && Reflect.ownKeys(scroll).includes('y') : false;
|
|
83
|
+
calcMinWidth({
|
|
84
|
+
minWidth: minWidth,
|
|
85
|
+
width: width,
|
|
86
|
+
title: title,
|
|
87
|
+
isMaxContentOverFlow: isMaxContentOverFlow,
|
|
88
|
+
callback: onUpdateMinWidth
|
|
89
|
+
});
|
|
47
90
|
var _toolTipProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, toolTipProps), wrapToolTipProps);
|
|
48
91
|
var _originalDiffTip = diffToolTip !== null && diffToolTip !== void 0 ? diffToolTip : originalDiffTip;
|
|
49
92
|
// 前缀处理
|
|
@@ -71,6 +114,30 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
71
114
|
}
|
|
72
115
|
};
|
|
73
116
|
if (column === null || column === void 0 ? void 0 : column.render) {
|
|
117
|
+
if (!originalObj && Object.keys(originalObj !== null && originalObj !== void 0 ? originalObj : {}).length === 0) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
var originalRender = column.render; // 保存原始的 render 方法
|
|
121
|
+
// 自定义render 手动重载下
|
|
122
|
+
column.render = function (value, record, index) {
|
|
123
|
+
var _originalObj$record$r;
|
|
124
|
+
var isFn = (0, _lodash.isFunction)(originalRender);
|
|
125
|
+
var _value = isFn ? originalRender === null || originalRender === void 0 ? void 0 : originalRender(value, record !== null && record !== void 0 ? record : {}, index) : undefined;
|
|
126
|
+
var originalValue = (0, _utils2.getOriginalValue)(value, record !== null && record !== void 0 ? record : {}, originalObj, rowKey, dataIndex);
|
|
127
|
+
var originalRenderValue = isFn ? originalRender === null || originalRender === void 0 ? void 0 : originalRender(originalValue, (_originalObj$record$r = originalObj === null || originalObj === void 0 ? void 0 : originalObj[record === null || record === void 0 ? void 0 : record[rowKey]]) !== null && _originalObj$record$r !== void 0 ? _originalObj$record$r : {}, index) : undefined;
|
|
128
|
+
return (0, _jsxRuntime.jsx)(_RenderColumn.default, {
|
|
129
|
+
valueType: valueType,
|
|
130
|
+
originalValue: originalValue === undefined ? undefined : originalRenderValue,
|
|
131
|
+
ellipsis: ellipsis,
|
|
132
|
+
width: width,
|
|
133
|
+
value: _value,
|
|
134
|
+
node: _value,
|
|
135
|
+
currentValue: _value,
|
|
136
|
+
originalDiffTip: _originalDiffTip,
|
|
137
|
+
toolTipProps: _toolTipProps,
|
|
138
|
+
minWidth: minWidth
|
|
139
|
+
});
|
|
140
|
+
};
|
|
74
141
|
return;
|
|
75
142
|
}
|
|
76
143
|
if (tooltip) {
|
|
@@ -99,7 +166,12 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
99
166
|
originalRenderValue = '-';
|
|
100
167
|
}
|
|
101
168
|
if (!value && value !== 0 && renderValue === originalRenderValue) {
|
|
102
|
-
return
|
|
169
|
+
return (0, _jsxRuntime.jsx)("div", {
|
|
170
|
+
style: {
|
|
171
|
+
minWidth: minWidth
|
|
172
|
+
},
|
|
173
|
+
children: "-"
|
|
174
|
+
});
|
|
103
175
|
}
|
|
104
176
|
var node = (0, _jsxRuntime.jsxs)(_antd.Space, {
|
|
105
177
|
size: 8,
|
|
@@ -114,7 +186,8 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
114
186
|
value: value,
|
|
115
187
|
currentValue: renderValue,
|
|
116
188
|
originalDiffTip: _originalDiffTip,
|
|
117
|
-
toolTipProps: _toolTipProps
|
|
189
|
+
toolTipProps: _toolTipProps,
|
|
190
|
+
minWidth: minWidth
|
|
118
191
|
});
|
|
119
192
|
};
|
|
120
193
|
// 千分位, 千分位带CNY前缀
|
|
@@ -133,7 +206,12 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
133
206
|
children: [prefixNode(value, record, index), renderValue, suffixNode(value, record, index)]
|
|
134
207
|
});
|
|
135
208
|
if (!value && value !== 0 && renderValue === originalRenderValue) {
|
|
136
|
-
|
|
209
|
+
(0, _jsxRuntime.jsx)("div", {
|
|
210
|
+
style: {
|
|
211
|
+
minWidth: minWidth
|
|
212
|
+
},
|
|
213
|
+
children: "-"
|
|
214
|
+
});
|
|
137
215
|
}
|
|
138
216
|
return (0, _jsxRuntime.jsx)(_RenderColumn.default, {
|
|
139
217
|
valueType: valueType,
|
|
@@ -144,7 +222,8 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
144
222
|
value: value,
|
|
145
223
|
currentValue: renderValue,
|
|
146
224
|
originalDiffTip: _originalDiffTip,
|
|
147
|
-
toolTipProps: _toolTipProps
|
|
225
|
+
toolTipProps: _toolTipProps,
|
|
226
|
+
minWidth: minWidth
|
|
148
227
|
});
|
|
149
228
|
};
|
|
150
229
|
} else if (['datePicker', 'date', 'dateTime', 'dateStartTime', 'dateEndTime', 'dateStartEndTime'].includes(valueType)) {
|
|
@@ -186,7 +265,12 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
186
265
|
children: [prefixNode(value, record, index), renderValue, suffixNode(value, record, index)]
|
|
187
266
|
});
|
|
188
267
|
if (!value && renderValue === originalRenderValue) {
|
|
189
|
-
|
|
268
|
+
(0, _jsxRuntime.jsx)("div", {
|
|
269
|
+
style: {
|
|
270
|
+
minWidth: minWidth
|
|
271
|
+
},
|
|
272
|
+
children: "-"
|
|
273
|
+
});
|
|
190
274
|
}
|
|
191
275
|
return (0, _jsxRuntime.jsx)(_RenderColumn.default, {
|
|
192
276
|
valueType: valueType,
|
|
@@ -197,7 +281,8 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
197
281
|
value: value,
|
|
198
282
|
currentValue: renderValue,
|
|
199
283
|
originalDiffTip: _originalDiffTip,
|
|
200
|
-
toolTipProps: _toolTipProps
|
|
284
|
+
toolTipProps: _toolTipProps,
|
|
285
|
+
minWidth: minWidth
|
|
201
286
|
});
|
|
202
287
|
};
|
|
203
288
|
} else if (['enumName', 'enumCodeName'].includes(valueType)) {
|
|
@@ -235,7 +320,8 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
235
320
|
value: value,
|
|
236
321
|
currentValue: renderValue,
|
|
237
322
|
originalDiffTip: _originalDiffTip,
|
|
238
|
-
toolTipProps: _toolTipProps
|
|
323
|
+
toolTipProps: _toolTipProps,
|
|
324
|
+
minWidth: minWidth
|
|
239
325
|
});
|
|
240
326
|
};
|
|
241
327
|
} else if (precision || prefix || suffix) {
|
|
@@ -251,7 +337,12 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
251
337
|
originalRenderValue = '-';
|
|
252
338
|
}
|
|
253
339
|
if (!value && value !== 0 && renderValue === originalRenderValue) {
|
|
254
|
-
|
|
340
|
+
(0, _jsxRuntime.jsx)("div", {
|
|
341
|
+
style: {
|
|
342
|
+
minWidth: minWidth
|
|
343
|
+
},
|
|
344
|
+
children: "-"
|
|
345
|
+
});
|
|
255
346
|
}
|
|
256
347
|
return (0, _jsxRuntime.jsx)(_RenderColumn.default, {
|
|
257
348
|
valueType: valueType,
|
|
@@ -262,7 +353,8 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
262
353
|
value: value,
|
|
263
354
|
currentValue: renderValue,
|
|
264
355
|
originalDiffTip: _originalDiffTip,
|
|
265
|
-
toolTipProps: _toolTipProps
|
|
356
|
+
toolTipProps: _toolTipProps,
|
|
357
|
+
minWidth: minWidth
|
|
266
358
|
});
|
|
267
359
|
};
|
|
268
360
|
} else if (valueType === 'address') {
|
|
@@ -275,7 +367,12 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
275
367
|
return !!item;
|
|
276
368
|
})) === null || _realValue$filter === void 0 ? void 0 : _realValue$filter.length) === 0;
|
|
277
369
|
if ((0, _lodash.isEqual)(value, originalValue) && isEmpty) {
|
|
278
|
-
|
|
370
|
+
(0, _jsxRuntime.jsx)("div", {
|
|
371
|
+
style: {
|
|
372
|
+
minWidth: minWidth
|
|
373
|
+
},
|
|
374
|
+
children: "-"
|
|
375
|
+
});
|
|
279
376
|
}
|
|
280
377
|
var className = (0, _classnames.default)({
|
|
281
378
|
'varied-cell': originalValue !== undefined,
|
|
@@ -318,7 +415,8 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
318
415
|
node: value,
|
|
319
416
|
value: value,
|
|
320
417
|
currentValue: value,
|
|
321
|
-
toolTipProps: _toolTipProps
|
|
418
|
+
toolTipProps: _toolTipProps,
|
|
419
|
+
minWidth: minWidth
|
|
322
420
|
}), suffixNode(value, record, index)]
|
|
323
421
|
});
|
|
324
422
|
};
|
|
@@ -326,7 +424,12 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
326
424
|
column.render = function (value, record, index) {
|
|
327
425
|
var originalValue = (0, _utils2.getOriginalValue)(value, record, originalObj, rowKey, dataIndex);
|
|
328
426
|
if (!value && value !== 0 && value === originalValue) {
|
|
329
|
-
|
|
427
|
+
(0, _jsxRuntime.jsx)("div", {
|
|
428
|
+
style: {
|
|
429
|
+
minWidth: minWidth
|
|
430
|
+
},
|
|
431
|
+
children: "-"
|
|
432
|
+
});
|
|
330
433
|
}
|
|
331
434
|
return (0, _jsxRuntime.jsxs)(_antd.Space, {
|
|
332
435
|
size: 8,
|
|
@@ -339,7 +442,8 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
339
442
|
value: value,
|
|
340
443
|
currentValue: value || '-',
|
|
341
444
|
originalDiffTip: _originalDiffTip,
|
|
342
|
-
toolTipProps: _toolTipProps
|
|
445
|
+
toolTipProps: _toolTipProps,
|
|
446
|
+
minWidth: minWidth
|
|
343
447
|
}), suffixNode(value, record, index)]
|
|
344
448
|
});
|
|
345
449
|
};
|
|
@@ -351,7 +455,12 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
351
455
|
children: [prefixNode(value, record, index), value, suffixNode(value, record, index)]
|
|
352
456
|
});
|
|
353
457
|
if (!value && value !== 0 && value === originalValue) {
|
|
354
|
-
|
|
458
|
+
(0, _jsxRuntime.jsx)("div", {
|
|
459
|
+
style: {
|
|
460
|
+
minWidth: minWidth
|
|
461
|
+
},
|
|
462
|
+
children: "-"
|
|
463
|
+
});
|
|
355
464
|
}
|
|
356
465
|
return (0, _jsxRuntime.jsx)(_RenderColumn.default, {
|
|
357
466
|
valueType: valueType,
|
|
@@ -362,7 +471,8 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
362
471
|
value: value,
|
|
363
472
|
currentValue: value || '-',
|
|
364
473
|
originalDiffTip: _originalDiffTip,
|
|
365
|
-
toolTipProps: _toolTipProps
|
|
474
|
+
toolTipProps: _toolTipProps,
|
|
475
|
+
minWidth: minWidth
|
|
366
476
|
});
|
|
367
477
|
};
|
|
368
478
|
}
|
|
@@ -27,7 +27,8 @@ var RenderColumn = function RenderColumn(props) {
|
|
|
27
27
|
originalValue = props.originalValue,
|
|
28
28
|
originalDiffTip = props.originalDiffTip,
|
|
29
29
|
_props$toolTipProps = props.toolTipProps,
|
|
30
|
-
toolTipProps = _props$toolTipProps === void 0 ? {} : _props$toolTipProps
|
|
30
|
+
toolTipProps = _props$toolTipProps === void 0 ? {} : _props$toolTipProps,
|
|
31
|
+
minWidth = props.minWidth;
|
|
31
32
|
var _useSetState = (0, _ahooks.useSetState)({
|
|
32
33
|
tooltip: false
|
|
33
34
|
}),
|
|
@@ -40,7 +41,8 @@ var RenderColumn = function RenderColumn(props) {
|
|
|
40
41
|
if (ellipsis) {
|
|
41
42
|
renderNode = (0, _jsxRuntime.jsx)(Text, {
|
|
42
43
|
style: {
|
|
43
|
-
width: currentValue === '-' ? 32.5 : width
|
|
44
|
+
width: currentValue === '-' ? 32.5 : width,
|
|
45
|
+
minWidth: minWidth
|
|
44
46
|
},
|
|
45
47
|
ellipsis: {
|
|
46
48
|
tooltip: false
|
|
@@ -51,7 +53,8 @@ var RenderColumn = function RenderColumn(props) {
|
|
|
51
53
|
return (0, _jsxRuntime.jsx)(_antd.Tooltip, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
52
54
|
className: "varied-cell",
|
|
53
55
|
style: {
|
|
54
|
-
width: width
|
|
56
|
+
width: width,
|
|
57
|
+
minWidth: minWidth
|
|
55
58
|
},
|
|
56
59
|
title: originalDiffTip ? (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
57
60
|
children: ["\u521D\u59CB\u503C\uFF1A", originalValue, (0, _jsxRuntime.jsx)("br", {}), ellipsis ? "\u5F53\u524D\u503C\uFF1A".concat(currentValue) : undefined]
|
|
@@ -66,7 +69,8 @@ var RenderColumn = function RenderColumn(props) {
|
|
|
66
69
|
return (0, _jsxRuntime.jsx)("span", {
|
|
67
70
|
className: "varied-cell",
|
|
68
71
|
style: {
|
|
69
|
-
width: width
|
|
72
|
+
width: width,
|
|
73
|
+
minWidth: minWidth
|
|
70
74
|
},
|
|
71
75
|
children: renderNode
|
|
72
76
|
});
|
|
@@ -137,7 +141,12 @@ var RenderColumn = function RenderColumn(props) {
|
|
|
137
141
|
}
|
|
138
142
|
}, toolTipProps);
|
|
139
143
|
if (!value) {
|
|
140
|
-
return
|
|
144
|
+
return (0, _jsxRuntime.jsx)("div", {
|
|
145
|
+
style: {
|
|
146
|
+
minWidth: minWidth
|
|
147
|
+
},
|
|
148
|
+
children: "-"
|
|
149
|
+
});
|
|
141
150
|
}
|
|
142
151
|
return (0, _jsxRuntime.jsx)(_antd.Tooltip, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
143
152
|
title: value,
|
|
@@ -150,7 +159,8 @@ var RenderColumn = function RenderColumn(props) {
|
|
|
150
159
|
}, tooltipProps), {}, {
|
|
151
160
|
children: (0, _jsxRuntime.jsx)(Text, {
|
|
152
161
|
style: {
|
|
153
|
-
width: width
|
|
162
|
+
width: width,
|
|
163
|
+
minWidth: minWidth
|
|
154
164
|
},
|
|
155
165
|
ellipsis: true,
|
|
156
166
|
onMouseOver: handleMouseOver,
|
|
@@ -159,6 +169,11 @@ var RenderColumn = function RenderColumn(props) {
|
|
|
159
169
|
})
|
|
160
170
|
}));
|
|
161
171
|
}
|
|
162
|
-
return
|
|
172
|
+
return (0, _jsxRuntime.jsx)("div", {
|
|
173
|
+
style: {
|
|
174
|
+
minWidth: minWidth
|
|
175
|
+
},
|
|
176
|
+
children: value || value === 0 ? node : '-'
|
|
177
|
+
});
|
|
163
178
|
};
|
|
164
179
|
var _default = exports.default = RenderColumn;
|
package/lib/ProTable/index.js
CHANGED
|
@@ -37,7 +37,7 @@ var defaultPage = exports.defaultPage = {
|
|
|
37
37
|
pageSize: 10
|
|
38
38
|
};
|
|
39
39
|
function ProTable(props) {
|
|
40
|
-
var _locale$ProTable, _curTableConfig$pathK;
|
|
40
|
+
var _locale$ProTable, _props$scroll, _curTableConfig$pathK;
|
|
41
41
|
var _ref = (0, _index.useProConfig)('globalConfig') || {},
|
|
42
42
|
configStorage = _ref.storage; // 获取全局缓存位置配置
|
|
43
43
|
var _ref2 = (0, _index.useProConfig)('ProTable') || {},
|
|
@@ -65,6 +65,9 @@ function ProTable(props) {
|
|
|
65
65
|
restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
66
66
|
var _props$scrollFollowPa = props.scrollFollowParent,
|
|
67
67
|
scrollFollowParent = _props$scrollFollowPa === void 0 ? true : _props$scrollFollowPa;
|
|
68
|
+
var _scroll = (_props$scroll = props === null || props === void 0 ? void 0 : props.scroll) !== null && _props$scroll !== void 0 ? _props$scroll : {
|
|
69
|
+
x: 'max-content'
|
|
70
|
+
};
|
|
68
71
|
var wrapToolTipProps = {
|
|
69
72
|
getPopupContainer: scrollFollowParent ? function (triggerNode) {
|
|
70
73
|
return triggerNode.parentNode;
|
|
@@ -208,18 +211,22 @@ function ProTable(props) {
|
|
|
208
211
|
}).filter(function (item) {
|
|
209
212
|
return !(item === null || item === void 0 ? void 0 : item.delete);
|
|
210
213
|
});
|
|
211
|
-
newColumns === null || newColumns === void 0 ? void 0 : newColumns.forEach(function (item) {
|
|
214
|
+
newColumns === null || newColumns === void 0 ? void 0 : newColumns.forEach(function (item, index) {
|
|
212
215
|
(0, _FormatColumn.formatColumn)({
|
|
213
216
|
column: item,
|
|
214
217
|
originalObj: originalObj,
|
|
215
218
|
dataSourceObj: dataSourceObj,
|
|
216
219
|
rowKey: 'rowKey',
|
|
217
220
|
diffToolTip: toolTip,
|
|
218
|
-
wrapToolTipProps: wrapToolTipProps
|
|
221
|
+
wrapToolTipProps: wrapToolTipProps,
|
|
222
|
+
scroll: _scroll,
|
|
223
|
+
onUpdateMinWidth: function onUpdateMinWidth(w) {
|
|
224
|
+
curColumns[index].minWidth = w;
|
|
225
|
+
}
|
|
219
226
|
});
|
|
220
227
|
});
|
|
221
228
|
return newColumns;
|
|
222
|
-
}, [curColumns, handleResize]);
|
|
229
|
+
}, [curColumns, handleResize, _scroll]);
|
|
223
230
|
var _columns = (0, _react.useMemo)(function () {
|
|
224
231
|
return columns === null || columns === void 0 ? void 0 : columns.filter(function (item, index) {
|
|
225
232
|
var show = item.show;
|
|
@@ -232,6 +239,13 @@ function ProTable(props) {
|
|
|
232
239
|
return true;
|
|
233
240
|
});
|
|
234
241
|
}, [columns]);
|
|
242
|
+
var isExistPercentWidth = !!(_columns === null || _columns === void 0 ? void 0 : _columns.find(function (item) {
|
|
243
|
+
var _item$width;
|
|
244
|
+
return (item === null || item === void 0 ? void 0 : item.width) && typeof (item === null || item === void 0 ? void 0 : item.width) === 'string' && (item === null || item === void 0 ? void 0 : (_item$width = item.width) === null || _item$width === void 0 ? void 0 : _item$width.endsWith('%'));
|
|
245
|
+
}));
|
|
246
|
+
if (isExistPercentWidth) {
|
|
247
|
+
_scroll = props === null || props === void 0 ? void 0 : props.scroll;
|
|
248
|
+
}
|
|
235
249
|
var handleColumnConfig = /*#__PURE__*/function () {
|
|
236
250
|
var _ref6 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(checkList) {
|
|
237
251
|
var newColumns, _columnConfig$onColum, catchColumns;
|
|
@@ -422,7 +436,8 @@ function ProTable(props) {
|
|
|
422
436
|
summary: summary,
|
|
423
437
|
dataSource: _dataSource
|
|
424
438
|
},
|
|
425
|
-
dataSource: _dataSource
|
|
439
|
+
dataSource: _dataSource,
|
|
440
|
+
scroll: _scroll
|
|
426
441
|
})), (0, _jsxRuntime.jsx)("span", {
|
|
427
442
|
className: "pro-table-resizable-line",
|
|
428
443
|
style: {
|
|
@@ -257,12 +257,14 @@
|
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
.@{ant-prefix}-table-
|
|
261
|
-
.@{ant-prefix}-table-
|
|
262
|
-
background: #d2fff4 !important;
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
260
|
+
tbody.@{ant-prefix}-table-tbody {
|
|
261
|
+
tr.@{ant-prefix}-table-row.new-cell {
|
|
262
|
+
background: var(--zaui-contract-bg-add; #d2fff4) !important;
|
|
263
|
+
background-color: var(--zaui-contract-bg-add; #d2fff4) !important;
|
|
264
|
+
|
|
265
|
+
td.@{ant-prefix}-table-cell {
|
|
266
|
+
background: var(--zaui-contract-bg-add; #d2fff4) !important;
|
|
267
|
+
background-color: var(--zaui-contract-bg-add; #d2fff4) !important;
|
|
266
268
|
border-bottom: 1px solid var(--zaui-form-control-line, #dcdcdc);
|
|
267
269
|
}
|
|
268
270
|
}
|