@zat-design/sisyphus-react 3.8.3 → 3.9.0

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.
Files changed (68) hide show
  1. package/.vscode/extensions.json +5 -0
  2. package/dist/index.esm.css +38 -3
  3. package/dist/less.esm.css +37 -2
  4. package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +83 -20
  5. package/es/ProEditTable/components/RenderField/index.js +6 -2
  6. package/es/ProEditTable/index.js +18 -9
  7. package/es/ProEditTable/propsType.d.ts +3 -6
  8. package/es/ProEditTable/style/index.less +0 -1
  9. package/es/ProEditTable/utils/index.js +10 -3
  10. package/es/ProForm/components/base/InputNumber/index.js +1 -1
  11. package/es/ProForm/components/combination/FormList/components/BlockFields.d.ts +2 -0
  12. package/es/ProForm/components/combination/FormList/components/BlockFields.js +4 -2
  13. package/es/ProForm/components/combination/FormList/components/LineFields.d.ts +2 -0
  14. package/es/ProForm/components/combination/FormList/components/LineFields.js +4 -2
  15. package/es/ProForm/components/combination/FormList/index.js +14 -3
  16. package/es/ProForm/components/combination/Group/index.js +3 -4
  17. package/es/ProForm/components/combination/ProCascader/index.js +21 -14
  18. package/es/ProForm/components/combination/ProModalSelect/index.js +17 -3
  19. package/es/ProForm/components/render/ChangedWrapper.js +29 -10
  20. package/es/ProForm/components/render/Render.js +3 -1
  21. package/es/ProForm/components/render/RenderFields.js +4 -2
  22. package/es/ProForm/propsType.d.ts +3 -0
  23. package/es/ProForm/style/index.less +35 -9
  24. package/es/ProForm/utils/diffOriginal.js +14 -2
  25. package/es/ProForm/utils/useShouldUpdate.js +1 -9
  26. package/es/ProTable/components/FormatColumn/index.d.ts +2 -1
  27. package/es/ProTable/components/FormatColumn/index.js +107 -29
  28. package/es/ProTable/components/RenderColumn/index.d.ts +1 -0
  29. package/es/ProTable/components/RenderColumn/index.js +23 -6
  30. package/es/ProTable/index.js +8 -7
  31. package/es/ProTable/propsType.d.ts +4 -0
  32. package/es/ProTable/style/index.less +14 -0
  33. package/es/style/theme/antd.less +1 -1
  34. package/es/utils/index.d.ts +1 -0
  35. package/es/utils/index.js +26 -0
  36. package/lib/ProEditTable/components/RenderField/ListChangedWrapper.js +82 -21
  37. package/lib/ProEditTable/components/RenderField/index.js +6 -2
  38. package/lib/ProEditTable/index.js +18 -9
  39. package/lib/ProEditTable/propsType.d.ts +3 -6
  40. package/lib/ProEditTable/style/index.less +0 -1
  41. package/lib/ProEditTable/utils/index.js +10 -3
  42. package/lib/ProForm/components/base/InputNumber/index.js +1 -1
  43. package/lib/ProForm/components/combination/FormList/components/BlockFields.d.ts +2 -0
  44. package/lib/ProForm/components/combination/FormList/components/BlockFields.js +4 -2
  45. package/lib/ProForm/components/combination/FormList/components/LineFields.d.ts +2 -0
  46. package/lib/ProForm/components/combination/FormList/components/LineFields.js +4 -2
  47. package/lib/ProForm/components/combination/FormList/index.js +14 -3
  48. package/lib/ProForm/components/combination/Group/index.js +3 -4
  49. package/lib/ProForm/components/combination/ProCascader/index.js +21 -14
  50. package/lib/ProForm/components/combination/ProModalSelect/index.js +17 -3
  51. package/lib/ProForm/components/render/ChangedWrapper.js +29 -10
  52. package/lib/ProForm/components/render/Render.js +3 -1
  53. package/lib/ProForm/components/render/RenderFields.js +4 -2
  54. package/lib/ProForm/propsType.d.ts +3 -0
  55. package/lib/ProForm/style/index.less +35 -9
  56. package/lib/ProForm/utils/diffOriginal.js +13 -1
  57. package/lib/ProForm/utils/useShouldUpdate.js +1 -9
  58. package/lib/ProTable/components/FormatColumn/index.d.ts +2 -1
  59. package/lib/ProTable/components/FormatColumn/index.js +107 -29
  60. package/lib/ProTable/components/RenderColumn/index.d.ts +1 -0
  61. package/lib/ProTable/components/RenderColumn/index.js +20 -5
  62. package/lib/ProTable/index.js +8 -7
  63. package/lib/ProTable/propsType.d.ts +4 -0
  64. package/lib/ProTable/style/index.less +14 -0
  65. package/lib/style/theme/antd.less +1 -1
  66. package/lib/utils/index.d.ts +1 -0
  67. package/lib/utils/index.js +28 -1
  68. package/package.json +1 -1
@@ -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", "diffConfig", "index"];
21
21
  var toNamePath = function toNamePath(name) {
22
22
  if (Array.isArray(name)) {
23
23
  return name;
@@ -39,6 +39,7 @@ var getOriginalValue = function getOriginalValue(_ref) {
39
39
  if (!originalValues) {
40
40
  return undefined;
41
41
  }
42
+ var originalValueRow;
42
43
  if (rowKeyPath) {
43
44
  var rowValueNamePath = namePath.slice(0, rowKeyPath.length - 1); // 表单中变动值所在行
44
45
  var rowKeyName = rowKeyPath[rowKeyPath.length - 1]; // rowKey在行内的name
@@ -47,7 +48,7 @@ var getOriginalValue = function getOriginalValue(_ref) {
47
48
  var keyValue = rowValue[rowKeyName]; // 获取表单中rowKey值
48
49
  if (!keyValue) return undefined;
49
50
  var originalValueList = (0, _lodash.get)(originalValues, originalName.slice(0, rowKeyPath.length - 2));
50
- var originalValueRow = originalValueList === null || originalValueList === void 0 ? void 0 : originalValueList.find(function (item) {
51
+ originalValueRow = originalValueList === null || originalValueList === void 0 ? void 0 : originalValueList.find(function (item) {
51
52
  return item[rowKeyPath[rowKeyPath.length - 1]] === keyValue;
52
53
  });
53
54
  var originalValue;
@@ -63,15 +64,21 @@ var getOriginalValue = function getOriginalValue(_ref) {
63
64
  } else {
64
65
  originalValue = (0, _lodash.get)(originalValueRow, originalName.slice(rowKeyPath.length - 1));
65
66
  }
66
- return originalValue;
67
+ return {
68
+ originalValue: originalValue,
69
+ originalValueRow: originalValueRow
70
+ };
67
71
  }
68
72
  // 这个方法是给editTable专用的 暂时不存在不传rowKey的情况
69
- return (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) ? originalNames.map(function (originalName) {
70
- return (0, _lodash.get)(originalValues, originalName);
71
- }) : (0, _lodash.get)(originalValues, originalName);
73
+ return {
74
+ originalValue: (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) ? originalNames.map(function (originalName) {
75
+ return (0, _lodash.get)(originalValues, originalName);
76
+ }) : (0, _lodash.get)(originalValues, originalName),
77
+ originalValueRow: originalValueRow
78
+ };
72
79
  };
73
80
  var ListChangedWrapper = function ListChangedWrapper(props) {
74
- var _getValueProps;
81
+ var _diffConfig$toolTip, _children$props, _children$props2, _children$props3;
75
82
  var name = props.name,
76
83
  names = props.names,
77
84
  namesStr = props.namesStr,
@@ -89,21 +96,30 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
89
96
  getValueProps = props.getValueProps,
90
97
  _props$valuePropName = props.valuePropName,
91
98
  valuePropName = _props$valuePropName === void 0 ? 'value' : _props$valuePropName,
99
+ viewRender = props.viewRender,
100
+ diffConfig = props.diffConfig,
101
+ index = props.index,
92
102
  rest = (0, _objectWithoutProperties2.default)(props, _excluded);
93
103
  var _ref2 = (0, _ProConfigProvider.useProConfig)('ProEditTable') || {},
94
104
  isDiffAll = _ref2.isDiffAll;
105
+ var _ref3 = diffConfig || {},
106
+ _ref3$scrollFollowPar = _ref3.scrollFollowParent,
107
+ scrollFollowParent = _ref3$scrollFollowPar === void 0 ? true : _ref3$scrollFollowPar;
108
+ var contentRef = (0, _react.useRef)(null);
95
109
  var namePath = toNamePath(namesStr || name);
96
110
  var originalNamePath = toNamePath(originalName);
97
111
  var originalNamePaths = originalNames && toNamePaths(originalNames);
112
+ var toolTip = (_diffConfig$toolTip = diffConfig === null || diffConfig === void 0 ? void 0 : diffConfig.toolTip) !== null && _diffConfig$toolTip !== void 0 ? _diffConfig$toolTip : true;
98
113
  var isWatch = Boolean(originalValues);
99
- var originalValue = isWatch ? getOriginalValue({
114
+ var originalDTO = getOriginalValue({
100
115
  namePath: namePath,
101
116
  originalName: originalNamePath,
102
117
  originalNames: originalNamePaths,
103
118
  originalValues: originalValues,
104
119
  rowKeyPath: rowKeyPath,
105
120
  form: form
106
- }) : undefined;
121
+ });
122
+ var originalValue = isWatch ? originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.originalValue : undefined;
107
123
  var noChange = !equalWith && (!originalValues || isDiffAll ? false : (0, _utils.isEmpty)(originalValue));
108
124
  var diffType = (0, _react.useMemo)(function () {
109
125
  if (!isWatch || noChange) return 'same';
@@ -118,30 +134,75 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
118
134
  }, [props[valuePropName], originalValue]);
119
135
  var isAdd = diffType === 'add';
120
136
  var isChanged = diffType === 'changed';
137
+ var tipContent = (0, _react.useMemo)(function () {
138
+ var _getValueProps;
139
+ if (!isWatch || noChange) return undefined;
140
+ var orgValue = getValueProps && !names ? (_getValueProps = getValueProps(originalValue)) === null || _getValueProps === void 0 ? void 0 : _getValueProps[valuePropName] : originalValue;
141
+ // 兼容viewRender函数和Element场景
142
+ var _children = children;
143
+ if (viewRender) {
144
+ if (! /*#__PURE__*/_react.default.isValidElement(viewRender)) {
145
+ return viewRender(orgValue, (originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.originalValueRow) || {}, {
146
+ form: form,
147
+ name: name,
148
+ index: index
149
+ });
150
+ }
151
+ _children = viewRender;
152
+ }
153
+ return /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)({}, children), {}, (0, _defineProperty2.default)((0, _defineProperty2.default)({
154
+ // @ts-ignore
155
+ isView: true
156
+ }, valuePropName, orgValue), "checked", type === 'Switch' ? originalValue : undefined))) : undefined;
157
+ }, [originalValue, children]);
121
158
  if (!isWatch || noChange) {
122
159
  return /*#__PURE__*/_react.default.isValidElement(children) && /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)({}, children.props), rest));
123
160
  }
161
+ // eslint-disable-next-line react-hooks/rules-of-hooks
162
+ // const isFocus = useFocus(contentRef.current);
163
+ var tipOpenCalc = function tipOpenCalc() {
164
+ if (!toolTip) return false;
165
+ // 传入undefined 鼠标移入显示移出隐藏
166
+ return isChanged ? undefined : false;
167
+ };
168
+ // @ts-ignore
169
+ var _showEllipse = ((_children$props = children.props) === null || _children$props === void 0 ? void 0 : _children$props.showEllipse) || ((_children$props2 = children.props) === null || _children$props2 === void 0 ? void 0 : _children$props2.tooltip);
124
170
  var diffClassName = (0, _classnames.default)({
125
171
  'pro-form-item-changed': isChanged,
126
172
  'pro-form-item-add': isAdd
127
173
  });
128
- return (0, _jsxRuntime.jsx)(_antd.Tooltip
129
- // 传入undefined 鼠标移入显示移出隐藏
130
- , {
131
- // 传入undefined 鼠标移入显示移出隐藏
132
- open: isChanged ? undefined : false,
133
- getPopupContainer: function getPopupContainer(target) {
134
- return target.parentElement;
174
+ var open = tipOpenCalc();
175
+ return (0, _jsxRuntime.jsx)(_antd.Tooltip, {
176
+ open: open,
177
+ getPopupContainer: function getPopupContainer(trigger) {
178
+ return scrollFollowParent ? trigger.parentElement : document.body;
135
179
  },
180
+ overlayClassName: "original-value-tootip",
181
+ placement: "topLeft",
182
+ autoAdjustOverflow: false,
136
183
  title: (0, _jsxRuntime.jsxs)(_antd.Space, {
137
- children: ["\u521D\u59CB\u503C\uFF1A", /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)({}, children), {}, (0, _defineProperty2.default)((0, _defineProperty2.default)({
138
- // @ts-ignore
139
- isView: true
140
- }, valuePropName, getValueProps ? (_getValueProps = getValueProps(originalValue)) === null || _getValueProps === void 0 ? void 0 : _getValueProps[valuePropName] : props[valuePropName]), "checked", type === 'Switch' ? originalValue : undefined))) : undefined]
184
+ direction: "vertical",
185
+ className: "changed-tooltip",
186
+ children: [(0, _jsxRuntime.jsxs)(_antd.Space, {
187
+ align: "start",
188
+ className: "original-value-container",
189
+ children: ["\u521D\u59CB\u503C\uFF1A", tipContent]
190
+ }), _showEllipse && (0, _jsxRuntime.jsxs)(_antd.Space, {
191
+ className: "current-value-container",
192
+ 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), {}, {
193
+ isView: true,
194
+ scrollFollowParent: scrollFollowParent
195
+ })) : undefined]
196
+ })]
141
197
  }),
142
198
  children: (0, _jsxRuntime.jsx)("div", {
143
199
  className: diffClassName,
144
- children: /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)({}, children.props), rest)) : undefined
200
+ children: /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)((0, _objectSpread3.default)({}, children.props), rest), {}, {
201
+ scrollFollowParent: scrollFollowParent,
202
+ otherProps: (0, _objectSpread3.default)((0, _objectSpread3.default)({}, (_children$props3 = children.props) === null || _children$props3 === void 0 ? void 0 : _children$props3.otherProps), {}, {
203
+ isDiffChange: isChanged
204
+ })
205
+ })) : undefined
145
206
  })
146
207
  });
147
208
  };
@@ -80,7 +80,8 @@ var RenderField = function RenderField(_ref) {
80
80
  rowDisabled = config.rowDisabled,
81
81
  _config$validateTrigg = config.validateTrigger,
82
82
  validateTrigger = _config$validateTrigg === void 0 ? ['onChange', 'onBlur', 'onSubmit'] : _config$validateTrigg,
83
- otherProps = config.otherProps;
83
+ otherProps = config.otherProps,
84
+ diffConfig = config.diffConfig;
84
85
  var _fieldProps = fieldProps || formItemProps || {};
85
86
  var _rules = rules || [];
86
87
  var _required = required;
@@ -261,7 +262,7 @@ var RenderField = function RenderField(_ref) {
261
262
  if (typeof viewRender === 'function') {
262
263
  var _column$dataIndex;
263
264
  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 = viewRender(currentValue, record, options);
265
+ var View = viewRender(currentValue, record || {}, options);
265
266
  TargetComponent = (0, _jsxRuntime.jsx)(_Container.default, {
266
267
  viewEmpty: viewEmpty,
267
268
  children: View
@@ -567,6 +568,9 @@ var RenderField = function RenderField(_ref) {
567
568
  valuePropName: _formItemProps.valuePropName,
568
569
  normalize: _formItemProps.normalize,
569
570
  getValueProps: _formItemProps.getValueProps,
571
+ viewRender: viewRender,
572
+ diffConfig: diffConfig,
573
+ index: index,
570
574
  children: FieldComponent
571
575
  });
572
576
  }
@@ -24,9 +24,9 @@ var _ProForm = _interopRequireDefault(require("../ProForm"));
24
24
  var _empty = _interopRequireDefault(require("../assets/empty.png"));
25
25
  var _locale = _interopRequireWildcard(require("../locale"));
26
26
  var _RcTable = require("./components/RcTable");
27
- var _excluded = ["value", "onChange", "onDrag", "className", "columns", "type", "mode", "stripe", "draggable", "virtual", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "toolbarSticky", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "originalValues", "originalDiffTip", "rowKey", "rowDisabled", "rowDraggable", "footerRender", "scroll", "actionDirection"];
27
+ var _excluded = ["value", "onChange", "onDrag", "className", "columns", "type", "mode", "stripe", "draggable", "virtual", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "toolbarSticky", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "originalValues", "rowKey", "rowDisabled", "rowDraggable", "footerRender", "scroll", "actionDirection", "diffConfig"];
28
28
  var ProEditTable = function ProEditTable(_ref, ref) {
29
- var _resetProps$id, _resetProps$id$split, _themeConfig$data2;
29
+ var _resetProps$id, _resetProps$id$split, _themeConfig$data2, _resetProps$otherProp;
30
30
  var value = _ref.value,
31
31
  onChange = _ref.onChange,
32
32
  onDrag = _ref.onDrag,
@@ -54,13 +54,13 @@ var ProEditTable = function ProEditTable(_ref, ref) {
54
54
  headerRender = _ref.headerRender,
55
55
  pagination = _ref.pagination,
56
56
  originalValues = _ref.originalValues,
57
- originalDiffTip = _ref.originalDiffTip,
58
57
  rowKey = _ref.rowKey,
59
58
  rowDisabled = _ref.rowDisabled,
60
59
  rowDraggable = _ref.rowDraggable,
61
60
  footerRender = _ref.footerRender,
62
61
  scroll = _ref.scroll,
63
62
  actionDirection = _ref.actionDirection,
63
+ diffConfig = _ref.diffConfig,
64
64
  resetProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
65
65
  // 上下文form
66
66
  var contentForm = _antd.Form.useFormInstance();
@@ -92,7 +92,6 @@ var ProEditTable = function ProEditTable(_ref, ref) {
92
92
  return (_ref2 = (_themeConfig$data$zau = themeConfig === null || themeConfig === void 0 ? void 0 : (_themeConfig$data = themeConfig.data) === null || _themeConfig$data === void 0 ? void 0 : _themeConfig$data.zauiFormAlign) !== null && _themeConfig$data$zau !== void 0 ? _themeConfig$data$zau : configRequiredAlign) !== null && _ref2 !== void 0 ? _ref2 : 'left';
93
93
  }, [themeConfig === null || themeConfig === void 0 ? void 0 : (_themeConfig$data2 = themeConfig.data) === null || _themeConfig$data2 === void 0 ? void 0 : _themeConfig$data2.zauiFormAlign]);
94
94
  var _useSetState = (0, _ahooks.useSetState)({
95
- _columns: columns,
96
95
  cellNamePath: [],
97
96
  forceUpdate: {},
98
97
  editingKeys: [],
@@ -170,10 +169,10 @@ var ProEditTable = function ProEditTable(_ref, ref) {
170
169
  tableLength: value === null || value === void 0 ? void 0 : value.length,
171
170
  page: page,
172
171
  originalValues: originalValues,
173
- originalDiffTip: originalDiffTip,
174
172
  prefixCls: prefixCls,
175
173
  rowDisabled: rowDisabled,
176
- actionDirection: actionDirection
174
+ actionDirection: actionDirection,
175
+ diffConfig: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, resetProps === null || resetProps === void 0 ? void 0 : (_resetProps$otherProp = resetProps.otherProps) === null || _resetProps$otherProp === void 0 ? void 0 : _resetProps$otherProp.diffConfig), diffConfig)
177
176
  }, resetProps);
178
177
  // 编辑行设置下样式
179
178
  var _rowClassName = function _rowClassName(record) {
@@ -278,8 +277,8 @@ var ProEditTable = function ProEditTable(_ref, ref) {
278
277
  var _columns = (0, _react.useMemo)(function () {
279
278
  return (0, _utils.transformColumns)(columns, config);
280
279
  }, [valueChangeRef.current, disabled, forceUpdate, columns, page, actionProps, editingKeys, cellNamePath]);
281
- (0, _react.useEffect)(function () {
282
- var _value$every, _originalArr$every;
280
+ var initDataSource = function initDataSource() {
281
+ var _value$every, _originalArr$every, _value$some, _originalArr$some;
283
282
  var isAllHasKey = value === null || value === void 0 ? void 0 : (_value$every = value.every) === null || _value$every === void 0 ? void 0 : _value$every.call(value, function (item) {
284
283
  return item.rowKey;
285
284
  });
@@ -288,8 +287,15 @@ var ProEditTable = function ProEditTable(_ref, ref) {
288
287
  var isOriginalAllHasKey = originalArr ? originalArr === null || originalArr === void 0 ? void 0 : (_originalArr$every = originalArr.every) === null || _originalArr$every === void 0 ? void 0 : _originalArr$every.call(originalArr, function (item) {
289
288
  return item.rowKey;
290
289
  }) : true;
290
+ // 检测当前rowkey是否与制定key的值是否一致,不一致,则执行覆盖
291
+ var isNeedCover = value === null || value === void 0 ? void 0 : (_value$some = value.some) === null || _value$some === void 0 ? void 0 : _value$some.call(value, function (item) {
292
+ return item.rowKey !== getRowKey(item);
293
+ });
294
+ var isNeedCoverOriginal = originalArr === null || originalArr === void 0 ? void 0 : (_originalArr$some = originalArr.some) === null || _originalArr$some === void 0 ? void 0 : _originalArr$some.call(originalArr, function (item) {
295
+ return item.rowKey !== getRowKey(item);
296
+ });
291
297
  // 初始化默认生成row-key
292
- if ((value === null || value === void 0 ? void 0 : value.length) && !isAllHasKey || (originalArr === null || originalArr === void 0 ? void 0 : originalArr.length) && !isOriginalAllHasKey) {
298
+ if ((value === null || value === void 0 ? void 0 : value.length) && (!isAllHasKey || isNeedCover) || (originalArr === null || originalArr === void 0 ? void 0 : originalArr.length) && (!isOriginalAllHasKey || isNeedCoverOriginal)) {
293
299
  var _originalArr$forEach;
294
300
  var nextValues = value === null || value === void 0 ? void 0 : value.map(function (item) {
295
301
  return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {
@@ -304,6 +310,9 @@ var ProEditTable = function ProEditTable(_ref, ref) {
304
310
  form.setFieldValue(virtualRowName, nextValues);
305
311
  }
306
312
  }
313
+ };
314
+ (0, _react.useEffect)(function () {
315
+ initDataSource();
307
316
  }, [value, originalValues]);
308
317
  (0, _react.useImperativeHandle)((resetProps === null || resetProps === void 0 ? void 0 : resetProps.ref) || ref, function () {
309
318
  return {
@@ -109,7 +109,6 @@ export interface ProColumnsProps<Values = any, T = any> extends Omit<FormItemPro
109
109
  }
110
110
  export type ProEditTableColumnsProps<K = any> = ProColumnsProps & ColumnPropsMap<K, 'ProEditTable'>;
111
111
  export interface State {
112
- _columns: ProEditTableColumnsProps[];
113
112
  cellNamePath: NamePath[];
114
113
  forceUpdate: {};
115
114
  editingKeys: string[];
@@ -139,11 +138,6 @@ export interface ProEditTableProps<T = any> extends Omit<TableProps<T>, 'onChang
139
138
  * @description 原始数据源,是否tooltip显示
140
139
  * @default -
141
140
  */
142
- originalDiffTip?: boolean;
143
- /**
144
- * @description 可编辑表格的类型,单行、多行、单元格编辑
145
- * @default false
146
- */
147
141
  mode?: 'single' | 'multiple' | 'cell';
148
142
  /**
149
143
  * @description 可编辑表格的类型,单行编辑或者多行编辑
@@ -276,4 +270,7 @@ export interface ProEditTableProps<T = any> extends Omit<TableProps<T>, 'onChang
276
270
  ref?: any;
277
271
  actionDirection?: 'vertical' | 'horizontal';
278
272
  validateTrigger?: string | string[];
273
+ diffConfig?: {
274
+ scrollFollowParent?: boolean;
275
+ };
279
276
  }
@@ -284,7 +284,6 @@
284
284
  .is-new-row, .is-new-row.@{ant-prefix}-table-row:hover {
285
285
  td, .@{ant-prefix}-table-cell-row-hover {
286
286
  background: var(--zaui-contract-bg-add, #d2fff4) !important;
287
-
288
287
  }
289
288
  }
290
289
  }
@@ -339,14 +339,21 @@ var transformColumns = exports.transformColumns = function transformColumns() {
339
339
  });
340
340
  }
341
341
  // 单行多行交互有较大差异
342
- return (0, _jsxRuntime.jsx)("div", {
342
+ return (0, _jsxRuntime.jsxs)("div", {
343
343
  className: cellClassName,
344
344
  onClick: function onClick() {
345
345
  isCanEdit && setState({
346
346
  cellNamePath: cellName
347
347
  });
348
348
  },
349
- children: (0, _jsxRuntime.jsx)(_components.RenderField, {
349
+ children: [index === 0 && !item.width ? (0, _jsxRuntime.jsx)("div", {
350
+ style: {
351
+ visibility: 'hidden',
352
+ height: 0,
353
+ paddingLeft: (item === null || item === void 0 ? void 0 : item.required) ? 16 : 0
354
+ },
355
+ children: columnTitle
356
+ }) : null, (0, _jsxRuntime.jsx)(_components.RenderField, {
350
357
  text: _text,
351
358
  record: record,
352
359
  index: index,
@@ -355,7 +362,7 @@ var transformColumns = exports.transformColumns = function transformColumns() {
355
362
  cellName: cellName,
356
363
  isEditing: isEditing // 是否正在编辑
357
364
  })
358
- })
365
+ })]
359
366
  });
360
367
  };
361
368
  item.render = _render;
@@ -290,7 +290,7 @@ var InputNumber = function InputNumber(props) {
290
290
  autoComplete: "off",
291
291
  placeholder: placeholder || "".concat(_locale.default.ProForm.inputPlaceholder).concat(label !== null && label !== void 0 ? label : ''),
292
292
  className: _className
293
- }, valueProps), initialConfig), rest), {}, {
293
+ }, initialConfig), valueProps), rest), {}, {
294
294
  onBlur: handleBlur,
295
295
  onFocus: handleFocus,
296
296
  min: _min,
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import { InternalNamePath } from 'antd/es/form/interface';
4
4
  import type { levelType } from '../../../../../ProLayout/components/ProCollapse/PropTypes';
5
5
  import type { FormListProps } from '../propsType';
6
+ import { DiffConfigProps } from '../../../../propsType';
6
7
  interface Props extends Omit<FormListProps, 'toolbarProps'> {
7
8
  index: number;
8
9
  namePath: InternalNamePath;
@@ -14,6 +15,7 @@ interface Props extends Omit<FormListProps, 'toolbarProps'> {
14
15
  };
15
16
  level?: levelType;
16
17
  towCollapse?: boolean;
18
+ diffConfig?: DiffConfigProps;
17
19
  }
18
20
  declare const BlockFields: React.FC<Props>;
19
21
  export default BlockFields;
@@ -36,7 +36,8 @@ var BlockFields = function BlockFields(props) {
36
36
  _props$level = props.level,
37
37
  level = _props$level === void 0 ? '2' : _props$level,
38
38
  towCollapse = props.towCollapse,
39
- id = props.id;
39
+ id = props.id,
40
+ diffConfig = props.diffConfig;
40
41
  var _title = (0, _react.useMemo)(function () {
41
42
  if ((0, _lodash.isFunction)(title)) {
42
43
  var record = form.getFieldValue(namePath);
@@ -78,7 +79,8 @@ var BlockFields = function BlockFields(props) {
78
79
  form: form,
79
80
  colProps: colProps,
80
81
  disabled: disabled,
81
- isView: isView
82
+ isView: isView,
83
+ diffConfig: diffConfig
82
84
  })
83
85
  }, field.key)
84
86
  })
@@ -2,6 +2,7 @@ import { ColProps, FormListFieldData } from 'antd';
2
2
  import React from 'react';
3
3
  import { InternalNamePath } from 'antd/es/form/interface';
4
4
  import { FormListProps } from '../propsType';
5
+ import { DiffConfigProps } from '../../../../propsType';
5
6
  interface Props extends Omit<FormListProps, 'toolbarProps'> {
6
7
  className?: string;
7
8
  index: number;
@@ -12,6 +13,7 @@ interface Props extends Omit<FormListProps, 'toolbarProps'> {
12
13
  field: Omit<FormListFieldData, 'key'> & {
13
14
  key: string;
14
15
  };
16
+ diffConfig?: DiffConfigProps;
15
17
  }
16
18
  declare const LineFields: React.FC<Props>;
17
19
  export default LineFields;
@@ -35,7 +35,8 @@ var LineFields = function LineFields(props) {
35
35
  isView = props.isView,
36
36
  draggable = props.draggable,
37
37
  className = props.className,
38
- id = props.id;
38
+ id = props.id,
39
+ diffConfig = props.diffConfig;
39
40
  var isLess = mode === 'less';
40
41
  var _useSortable = (0, _sortable.useSortable)({
41
42
  id: field.key,
@@ -76,7 +77,8 @@ var LineFields = function LineFields(props) {
76
77
  form: form,
77
78
  colProps: colProps,
78
79
  disabled: disabled,
79
- isView: isView
80
+ isView: isView,
81
+ diffConfig: diffConfig
80
82
  })
81
83
  }), actionProps !== false && (0, _jsxRuntime.jsx)(_ActionButton.default, {
82
84
  min: min,
@@ -11,6 +11,7 @@ var _jsxRuntime = require("react/jsx-runtime");
11
11
  var _react = require("react");
12
12
  var _antd = require("antd");
13
13
  var _core = require("@dnd-kit/core");
14
+ var _lodash = require("lodash");
14
15
  var _sortable = require("@dnd-kit/sortable");
15
16
  var _utils = require("../../../utils");
16
17
  var _utils2 = require("./utils");
@@ -18,6 +19,7 @@ var _ToolbarButton = _interopRequireDefault(require("./components/ToolbarButton"
18
19
  var _BlockFields = _interopRequireDefault(require("./components/BlockFields"));
19
20
  var _LineFields = _interopRequireDefault(require("./components/LineFields"));
20
21
  var _ProForm = _interopRequireDefault(require("../../../../ProForm"));
22
+ var _ProConfigProvider = require("../../../../ProConfigProvider");
21
23
  var FormList = function FormList(props, ref) {
22
24
  var columns = props.columns,
23
25
  min = props.min,
@@ -39,9 +41,16 @@ var FormList = function FormList(props, ref) {
39
41
  var _ref = _ProForm.default.useFieldProps() || {},
40
42
  form = _ref.form,
41
43
  name = _ref.name,
42
- isView = _ref.isView;
44
+ isView = _ref.isView,
45
+ diffConfig = _ref.diffConfig;
46
+ var _useProConfig = (0, _ProConfigProvider.useProConfig)('ProForm'),
47
+ isDiffAll = _useProConfig.isDiffAll;
43
48
  var errors = meta.errors;
44
49
  var _namePath = (0, _utils.toArray)(name);
50
+ var orgValues = (0, _lodash.get)(diffConfig === null || diffConfig === void 0 ? void 0 : diffConfig.originalValues, name);
51
+ var _diffConfig = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, diffConfig), {}, {
52
+ originalValues: isDiffAll ? orgValues || [] : orgValues
53
+ });
45
54
  var processColumns = (0, _react.useCallback)(function (fieldName, namePath) {
46
55
  return columns.map(function (item) {
47
56
  // names的name处理
@@ -104,7 +113,8 @@ var FormList = function FormList(props, ref) {
104
113
  colProps: {
105
114
  span: span
106
115
  },
107
- form: form
116
+ form: form,
117
+ diffConfig: _diffConfig
108
118
  }), field.key) : (0, _jsxRuntime.jsx)(_LineFields.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({
109
119
  className: _fields.length === index + 1 ? 'pro-form-list-last' : ''
110
120
  }, props), {}, {
@@ -118,7 +128,8 @@ var FormList = function FormList(props, ref) {
118
128
  colProps: {
119
129
  span: mode === 'less' ? 24 : span
120
130
  },
121
- form: form
131
+ form: form,
132
+ diffConfig: _diffConfig
122
133
  }), field.key);
123
134
  }), (0, _jsxRuntime.jsx)(_antd.Form.ErrorList, {
124
135
  errors: errors
@@ -32,15 +32,14 @@ var Group = function Group(props) {
32
32
  value = props.value,
33
33
  onChange = props.onChange,
34
34
  otherProps = props.otherProps,
35
- disabled = props.disabled,
36
- id = props.id,
37
- isView = props.isView;
35
+ id = props.id;
38
36
  var contextProps = _ProForm.default.useFieldProps() || {};
39
37
  var names = contextProps.names,
40
38
  name = contextProps.name,
41
39
  form = contextProps.form,
42
40
  namePath = contextProps.namePath,
43
- index = contextProps.index;
41
+ index = contextProps.index,
42
+ isView = contextProps.isView;
44
43
  var _option = _react.default.useRef([]);
45
44
  // 组合onChange
46
45
  var handleChange = function handleChange(value, option, index) {
@@ -50,7 +50,7 @@ var getViewLabel = function getViewLabel(_ref) {
50
50
  return viewLabel;
51
51
  };
52
52
  var ProCascader = function ProCascader(props) {
53
- var _props$otherProps, _value$slice, _ref7, _ref7$filter, _defaultLabel$filter, _locale$ProAddressBar, _locale$ProAddressBar2;
53
+ var _props$otherProps, _value$slice, _ref5, _ref5$filter, _defaultLabel$filter, _locale$ProAddressBar, _locale$ProAddressBar2;
54
54
  var _ref2 = (0, _ProConfigProvider.useProConfig)('ProAddressBar') || {},
55
55
  configDetailMaxLength = _ref2.detailMaxLength,
56
56
  configEnumCode = _ref2.enumCode,
@@ -79,7 +79,7 @@ var ProCascader = function ProCascader(props) {
79
79
  code = _props$code === void 0 ? configCode : _props$code,
80
80
  tooltip = props.tooltip,
81
81
  _props$separator = props.separator,
82
- separator = _props$separator === void 0 ? '' : _props$separator,
82
+ separator = _props$separator === void 0 ? '/' : _props$separator,
83
83
  detailPlaceholder = props.detailPlaceholder,
84
84
  otherProps = (0, _objectWithoutProperties2.default)(props, _excluded);
85
85
  var _ref3 = _.default.useFieldProps() || {},
@@ -90,16 +90,18 @@ var ProCascader = function ProCascader(props) {
90
90
  var realLevel = Math.max(2, level);
91
91
  var detail = value === null || value === void 0 ? void 0 : value[realLevel];
92
92
  var enumData = (0, _useEnum.default)(addressCode);
93
- var _ref4 = Array.isArray(enumData) ? enumData : [],
94
- _ref5 = (0, _slicedToArray2.default)(_ref4, 1),
95
- _ref5$ = _ref5[0],
96
- enumDataSource = _ref5$ === void 0 ? [] : _ref5$;
93
+ var _useProConfig = (0, _ProConfigProvider.useProConfig)('ProEnum'),
94
+ _useProConfig$dics = _useProConfig.dics,
95
+ dics = _useProConfig$dics === void 0 ? {} : _useProConfig$dics;
96
+ var enumDataSource = (0, _react.useMemo)(function () {
97
+ if (!(props === null || props === void 0 ? void 0 : props.mode)) {
98
+ return (dics === null || dics === void 0 ? void 0 : dics[addressCode]) || [];
99
+ }
100
+ return Array.isArray(enumData) ? enumData[0] : [];
101
+ }, [dics === null || dics === void 0 ? void 0 : dics[addressCode], enumData]);
97
102
  var realDataSource = (0, _react.useMemo)(function () {
98
103
  var innerDataSource = dataSource || (addressCode ? enumDataSource : []);
99
104
  var result = (0, _index.transformDataName)(isAddressMode && realLevel === 2 ? _filterDataSource(innerDataSource, level, fieldNames) : innerDataSource, fieldNames);
100
- if (transformResponse) {
101
- return transformResponse(result);
102
- }
103
105
  return result;
104
106
  }, [isAddressMode, addressCode, realLevel, dataSource, enumDataSource === null || enumDataSource === void 0 ? void 0 : enumDataSource.length]);
105
107
  var _useRequest = (0, _objectSpread3.default)({}, useRequest),
@@ -115,7 +117,7 @@ var ProCascader = function ProCascader(props) {
115
117
  defaultLabel = _useState4[0],
116
118
  setDefaultLabel = _useState4[1];
117
119
  var getFirstLevelOptions = /*#__PURE__*/function () {
118
- var _ref6 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
120
+ var _ref4 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
119
121
  var _yield$service, data, newData, transFormData, serviceData;
120
122
  return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
121
123
  while (1) switch (_context.prev = _context.next) {
@@ -143,9 +145,13 @@ var ProCascader = function ProCascader(props) {
143
145
  }, _callee);
144
146
  }));
145
147
  return function getFirstLevelOptions() {
146
- return _ref6.apply(this, arguments);
148
+ return _ref4.apply(this, arguments);
147
149
  };
148
150
  }();
151
+ // 提取出来默认每次都执行
152
+ if (transformResponse) {
153
+ realDataSource = transformResponse(realDataSource);
154
+ }
149
155
  (0, _react.useEffect)(function () {
150
156
  if (service) {
151
157
  // 传入useRequest时,初次加载级联第一级数据源
@@ -154,13 +160,14 @@ var ProCascader = function ProCascader(props) {
154
160
  }, [service]);
155
161
  (0, _react.useEffect)(function () {
156
162
  if (realIsView && value) {
163
+ var _realDataSource;
157
164
  // 传入dataSource + 查看时初始化展示
158
165
  if (service) {
159
166
  setDefaultLabel(getViewLabel({
160
167
  dataSource: serviceData,
161
168
  value: isAddressMode && hasDetail ? value === null || value === void 0 ? void 0 : value.slice(0, realLevel) : value
162
169
  }));
163
- } else if ((realDataSource === null || realDataSource === void 0 ? void 0 : realDataSource.length) > 0) {
170
+ } else if (((_realDataSource = realDataSource) === null || _realDataSource === void 0 ? void 0 : _realDataSource.length) > 0) {
164
171
  setDefaultLabel(getViewLabel({
165
172
  dataSource: realDataSource,
166
173
  value: isAddressMode && hasDetail ? value === null || value === void 0 ? void 0 : value.slice(0, realLevel) : value
@@ -194,9 +201,9 @@ var ProCascader = function ProCascader(props) {
194
201
  var addressValue = isAddressMode ? value && ((_value$slice = value.slice(0, realLevel)) === null || _value$slice === void 0 ? void 0 : _value$slice.some(function (item) {
195
202
  return !!item;
196
203
  })) ? value.slice(0, realLevel) : undefined : value;
197
- var viewValue = isAddressMode ? ((_ref7 = [].concat((0, _toConsumableArray2.default)(defaultLabel), [value === null || value === void 0 ? void 0 : value[realLevel]])) === null || _ref7 === void 0 ? void 0 : (_ref7$filter = _ref7.filter(function (item) {
204
+ var viewValue = isAddressMode ? ((_ref5 = [].concat((0, _toConsumableArray2.default)(defaultLabel), [value === null || value === void 0 ? void 0 : value[realLevel]])) === null || _ref5 === void 0 ? void 0 : (_ref5$filter = _ref5.filter(function (item) {
198
205
  return !!item;
199
- })) === null || _ref7$filter === void 0 ? void 0 : _ref7$filter.join(separator)) || '-' : (defaultLabel === null || defaultLabel === void 0 ? void 0 : (_defaultLabel$filter = defaultLabel.filter(function (item) {
206
+ })) === null || _ref5$filter === void 0 ? void 0 : _ref5$filter.join(separator)) || '-' : (defaultLabel === null || defaultLabel === void 0 ? void 0 : (_defaultLabel$filter = defaultLabel.filter(function (item) {
200
207
  return !!item;
201
208
  })) === null || _defaultLabel$filter === void 0 ? void 0 : _defaultLabel$filter.join(separator)) || '-';
202
209
  var _findSelectedOptions = function findSelectedOptions(options, value) {
@@ -190,11 +190,25 @@ var ProModalSelect = function ProModalSelect(props, ref) {
190
190
  value: item[valueKey],
191
191
  label: item[labelKey]
192
192
  }));
193
- })) === null || _data$map === void 0 ? void 0 : _data$map.join(',') : undefined;
193
+ })) === null || _data$map === void 0 ? void 0 : _data$map.join(',') : '';
194
194
  };
195
195
  var viewText = (0, _react.useMemo)(function () {
196
- return formatValue(labelInValue ? value : _value);
197
- }, [value, _value]);
196
+ var nextValue = labelInValue ? value : _value;
197
+ if (labelInValue) {
198
+ nextValue = value;
199
+ } else {
200
+ var _options$find;
201
+ var optionDTO = options === null || options === void 0 ? void 0 : (_options$find = options.find) === null || _options$find === void 0 ? void 0 : _options$find.call(options, function (item) {
202
+ return item[valueKey] === value;
203
+ });
204
+ if (optionDTO) {
205
+ nextValue = optionDTO;
206
+ } else {
207
+ nextValue = _value;
208
+ }
209
+ }
210
+ return formatValue(nextValue);
211
+ }, [value, _value, options]);
198
212
  /**
199
213
  * 获取表格的rowKey,支持函数、字符串
200
214
  * @date 2023-02-16