@zat-design/sisyphus-react 3.9.8 → 3.10.0-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.
Files changed (63) hide show
  1. package/dist/index.esm.css +0 -5
  2. package/dist/less.esm.css +0 -5
  3. package/es/ProEditTable/components/ActionButton/index.js +57 -9
  4. package/es/ProEditTable/components/RenderField/index.js +23 -14
  5. package/es/ProEditTable/components/RenderToolbar/index.js +18 -16
  6. package/es/ProEditTable/index.js +1 -1
  7. package/es/ProEditTable/propsType.d.ts +6 -3
  8. package/es/ProEditTable/utils/diffOriginal.d.ts +1 -1
  9. package/es/ProEditTable/utils/diffOriginal.js +21 -22
  10. package/es/ProEditTable/utils/index.js +35 -30
  11. package/es/ProForm/components/combination/Group/index.js +7 -2
  12. package/es/ProForm/components/combination/Group/propsType.d.ts +1 -0
  13. package/es/ProForm/components/combination/Group/utils.d.ts +6 -1
  14. package/es/ProForm/components/combination/Group/utils.js +28 -6
  15. package/es/ProForm/components/render/Render.js +39 -22
  16. package/es/ProForm/components/render/RenderFields.d.ts +1 -0
  17. package/es/ProForm/components/render/RenderFields.js +8 -4
  18. package/es/ProForm/components/render/propsType.d.ts +3 -1
  19. package/es/ProForm/index.js +5 -2
  20. package/es/ProForm/propsType.d.ts +3 -0
  21. package/es/ProForm/utils/diffOriginal.js +9 -2
  22. package/es/ProForm/utils/useShouldUpdate.js +25 -5
  23. package/es/ProForm/utils/valueType.d.ts +8 -0
  24. package/es/ProForm/utils/valueType.js +99 -33
  25. package/es/ProLayout/components/ProHeader/style/index.less +0 -8
  26. package/es/ProTable/components/FormatColumn/index.js +2 -1
  27. package/es/ProTable/components/RenderColumn/index.d.ts +2 -0
  28. package/es/ProTable/components/RenderColumn/index.js +10 -2
  29. package/es/ProTable/hooks/useAntdTable.js +4 -3
  30. package/es/ProTable/propsType.d.ts +2 -0
  31. package/es/ProTable/utils/index.d.ts +4 -0
  32. package/es/ProTable/utils/index.js +15 -0
  33. package/lib/ProEditTable/components/ActionButton/index.js +57 -9
  34. package/lib/ProEditTable/components/RenderField/index.js +22 -13
  35. package/lib/ProEditTable/components/RenderToolbar/index.js +18 -16
  36. package/lib/ProEditTable/index.js +1 -1
  37. package/lib/ProEditTable/propsType.d.ts +6 -3
  38. package/lib/ProEditTable/utils/diffOriginal.d.ts +1 -1
  39. package/lib/ProEditTable/utils/diffOriginal.js +21 -22
  40. package/lib/ProEditTable/utils/index.js +35 -30
  41. package/lib/ProForm/components/combination/Group/index.js +7 -2
  42. package/lib/ProForm/components/combination/Group/propsType.d.ts +1 -0
  43. package/lib/ProForm/components/combination/Group/utils.d.ts +6 -1
  44. package/lib/ProForm/components/combination/Group/utils.js +28 -6
  45. package/lib/ProForm/components/render/Render.js +39 -22
  46. package/lib/ProForm/components/render/RenderFields.d.ts +1 -0
  47. package/lib/ProForm/components/render/RenderFields.js +8 -4
  48. package/lib/ProForm/components/render/propsType.d.ts +3 -1
  49. package/lib/ProForm/index.js +5 -2
  50. package/lib/ProForm/propsType.d.ts +3 -0
  51. package/lib/ProForm/utils/diffOriginal.js +9 -2
  52. package/lib/ProForm/utils/useShouldUpdate.js +25 -5
  53. package/lib/ProForm/utils/valueType.d.ts +8 -0
  54. package/lib/ProForm/utils/valueType.js +100 -34
  55. package/lib/ProLayout/components/ProHeader/style/index.less +0 -8
  56. package/lib/ProTable/components/FormatColumn/index.js +2 -1
  57. package/lib/ProTable/components/RenderColumn/index.d.ts +2 -0
  58. package/lib/ProTable/components/RenderColumn/index.js +10 -2
  59. package/lib/ProTable/hooks/useAntdTable.js +3 -2
  60. package/lib/ProTable/propsType.d.ts +2 -0
  61. package/lib/ProTable/utils/index.d.ts +4 -0
  62. package/lib/ProTable/utils/index.js +17 -1
  63. package/package.json +2 -1
@@ -1,3 +1,5 @@
1
+ import _readOnlyError from "@babel/runtime/helpers/esm/readOnlyError";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
1
3
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
4
  import Big from 'big.js';
3
5
  import { isEqual } from 'lodash';
@@ -188,13 +190,31 @@ var dateTransform = function dateTransform(_ref2) {
188
190
  }
189
191
  return result;
190
192
  };
193
+ /** 脱敏处理函数 */
194
+ export var maskStringRangeWithRegex = function maskStringRangeWithRegex(input, range) {
195
+ var _ref3 = range || [],
196
+ _ref4 = _slicedToArray(_ref3, 2),
197
+ start = _ref4[0],
198
+ end = _ref4[1];
199
+ if (start < 0) {
200
+ throw new Error('脱敏数据: start index cannot be negative');
201
+ }
202
+ var adjustedEnd = Math.min(end, input.length - 1);
203
+ if (start >= input.length) {
204
+ return '';
205
+ }
206
+ var regexPattern = "^(.{".concat(start, "})(.{").concat(adjustedEnd - start + 1, "})(.*)$");
207
+ var regex = new RegExp(regexPattern);
208
+ var maskedValue = input.replace(regex, "$1".concat('*'.repeat(adjustedEnd - start + 1), "$3"));
209
+ return maskedValue;
210
+ };
191
211
  export default {
192
212
  /** 年月日 */
193
- date: function date(_ref3) {
194
- var type = _ref3.type,
195
- toISOString = _ref3.toISOString,
196
- toCSTString = _ref3.toCSTString,
197
- mode = _ref3.mode;
213
+ date: function date(_ref5) {
214
+ var type = _ref5.type,
215
+ toISOString = _ref5.toISOString,
216
+ toCSTString = _ref5.toCSTString,
217
+ mode = _ref5.mode;
198
218
  return dateTransform({
199
219
  type: type,
200
220
  _valueType: 'date',
@@ -204,11 +224,11 @@ export default {
204
224
  });
205
225
  },
206
226
  /** 年月日 时分秒 */
207
- dateTime: function dateTime(_ref4) {
208
- var type = _ref4.type,
209
- toISOString = _ref4.toISOString,
210
- toCSTString = _ref4.toCSTString,
211
- mode = _ref4.mode;
227
+ dateTime: function dateTime(_ref6) {
228
+ var type = _ref6.type,
229
+ toISOString = _ref6.toISOString,
230
+ toCSTString = _ref6.toCSTString,
231
+ mode = _ref6.mode;
212
232
  return dateTransform({
213
233
  type: type,
214
234
  _valueType: 'dateTime',
@@ -218,11 +238,11 @@ export default {
218
238
  });
219
239
  },
220
240
  /** 年月日 00:00:00 */
221
- dateStartTime: function dateStartTime(_ref5) {
222
- var type = _ref5.type,
223
- toISOString = _ref5.toISOString,
224
- toCSTString = _ref5.toCSTString,
225
- mode = _ref5.mode;
241
+ dateStartTime: function dateStartTime(_ref7) {
242
+ var type = _ref7.type,
243
+ toISOString = _ref7.toISOString,
244
+ toCSTString = _ref7.toCSTString,
245
+ mode = _ref7.mode;
226
246
  return dateTransform({
227
247
  type: type,
228
248
  _valueType: 'dateStartTime',
@@ -232,11 +252,11 @@ export default {
232
252
  });
233
253
  },
234
254
  /** 年月日 23:59:59 */
235
- dateEndTime: function dateEndTime(_ref6) {
236
- var type = _ref6.type,
237
- toISOString = _ref6.toISOString,
238
- toCSTString = _ref6.toCSTString,
239
- mode = _ref6.mode;
255
+ dateEndTime: function dateEndTime(_ref8) {
256
+ var type = _ref8.type,
257
+ toISOString = _ref8.toISOString,
258
+ toCSTString = _ref8.toCSTString,
259
+ mode = _ref8.mode;
240
260
  return dateTransform({
241
261
  type: type,
242
262
  _valueType: 'dateEndTime',
@@ -246,11 +266,11 @@ export default {
246
266
  });
247
267
  },
248
268
  /** 年月日 00:00:00 ~ 年月日 23:59:59 */
249
- dateStartEndTime: function dateStartEndTime(_ref7) {
250
- var type = _ref7.type,
251
- toISOString = _ref7.toISOString,
252
- toCSTString = _ref7.toCSTString,
253
- mode = _ref7.mode;
269
+ dateStartEndTime: function dateStartEndTime(_ref9) {
270
+ var type = _ref9.type,
271
+ toISOString = _ref9.toISOString,
272
+ toCSTString = _ref9.toCSTString,
273
+ mode = _ref9.mode;
254
274
  return dateTransform({
255
275
  type: type,
256
276
  _valueType: 'dateStartEndTime',
@@ -260,9 +280,9 @@ export default {
260
280
  });
261
281
  },
262
282
  /** 百分比 */
263
- percentage: function percentage(_ref8) {
264
- var type = _ref8.type,
265
- valueType = _ref8.valueType;
283
+ percentage: function percentage(_ref10) {
284
+ var type = _ref10.type,
285
+ valueType = _ref10.valueType;
266
286
  return transformRatio({
267
287
  type: type,
268
288
  valueType: valueType,
@@ -270,9 +290,9 @@ export default {
270
290
  });
271
291
  },
272
292
  /** 千分比 */
273
- permillage: function permillage(_ref9) {
274
- var type = _ref9.type,
275
- valueType = _ref9.valueType;
293
+ permillage: function permillage(_ref11) {
294
+ var type = _ref11.type,
295
+ valueType = _ref11.valueType;
276
296
  return transformRatio({
277
297
  type: type,
278
298
  valueType: valueType,
@@ -280,8 +300,54 @@ export default {
280
300
  });
281
301
  },
282
302
  /** 开关 YN转换 */
283
- switch: function _switch(_ref10) {
284
- var switchValue = _ref10.switchValue;
303
+ switch: function _switch(_ref12) {
304
+ var switchValue = _ref12.switchValue;
285
305
  return switchTransform(switchValue);
306
+ },
307
+ /** 脱敏 转换 */
308
+ desensitization: function desensitization(props) {
309
+ var desensitization = props.desensitization,
310
+ type = props.type,
311
+ mode = props.mode,
312
+ names = props.names;
313
+ // 判断是否是地址控件,并带地址详情场景
314
+ if (type === 'ProCascader' && mode === 'address' && (names === null || names === void 0 ? void 0 : names.length) === 4) {
315
+ return {
316
+ getValueProps: function getValueProps(value) {
317
+ try {
318
+ if (value === null || value === void 0 ? void 0 : value.length) {
319
+ var _value = _slicedToArray(value, 4),
320
+ province = _value[0],
321
+ city = _value[1],
322
+ county = _value[2],
323
+ address = _value[3];
324
+ return {
325
+ value: [province, city, county, maskStringRangeWithRegex(address, desensitization)]
326
+ };
327
+ }
328
+ return {
329
+ value: value
330
+ };
331
+ } catch (error) {
332
+ return {
333
+ value: value
334
+ }; // 如果发生错误,返回原始值
335
+ }
336
+ }
337
+ };
338
+ }
339
+ return {
340
+ getValueProps: function getValueProps(value) {
341
+ try {
342
+ return {
343
+ value: maskStringRangeWithRegex(value, desensitization)
344
+ };
345
+ } catch (error) {
346
+ return {
347
+ value: value
348
+ }; // 如果发生错误,返回原始值
349
+ }
350
+ }
351
+ };
286
352
  }
287
353
  };
@@ -78,14 +78,6 @@
78
78
  background: #fff;
79
79
  letter-spacing: 2px;
80
80
  }
81
- &.pro-header-describe-items-more{
82
- .pro-header-tag{
83
- padding: 0;
84
- background: transparent !important;
85
- color: #333 ;
86
- }
87
-
88
- }
89
81
  }
90
82
  }
91
83
  }
@@ -78,6 +78,7 @@ export var formatColumn = function formatColumn(_ref2) {
78
78
  minWidth = column.minWidth,
79
79
  onDiff = column.onDiff,
80
80
  otherProps = _objectWithoutProperties(column, _excluded);
81
+ otherProps.scroll = scroll;
81
82
  // 仅在 {x: 'max-content', y: 300 } 且 column无指定 width minWidth 情况下 才开启 minWidth的自动计算
82
83
  var isMaxContentOverFlow = isObject(scroll) ? (scroll === null || scroll === void 0 ? void 0 : scroll.x) === 'max-content' && Reflect.ownKeys(scroll).includes('y') : false;
83
84
  calcMinWidth({
@@ -340,7 +341,7 @@ export var formatColumn = function formatColumn(_ref2) {
340
341
  if (!originalValue) {
341
342
  originalRenderValue = '-';
342
343
  }
343
- if (renderValue !== originalRenderValue) {
344
+ if (originalObj && renderValue !== originalRenderValue) {
344
345
  otherProps.isChanged = true;
345
346
  } else {
346
347
  otherProps.isChanged = false;
@@ -15,6 +15,8 @@ interface Props {
15
15
  isChanged?: boolean;
16
16
  /** 新增单元格字段 */
17
17
  isAddCell?: boolean;
18
+ /** 表格透传下来的scroll配置 */
19
+ scroll?: any;
18
20
  }
19
21
  declare const RenderColumn: FC<Props>;
20
22
  export default RenderColumn;
@@ -29,7 +29,8 @@ var RenderColumn = function RenderColumn(props) {
29
29
  _props$toolTipProps = props.toolTipProps,
30
30
  toolTipProps = _props$toolTipProps === void 0 ? {} : _props$toolTipProps,
31
31
  minWidth = props.minWidth,
32
- isInNewRowFlag = props.isInNewRowFlag;
32
+ isInNewRowFlag = props.isInNewRowFlag,
33
+ scroll = props.scroll;
33
34
  var _useSetState = useSetState({
34
35
  tooltip: false
35
36
  }),
@@ -43,8 +44,9 @@ var RenderColumn = function RenderColumn(props) {
43
44
  // 比对场景走的逻辑
44
45
  if (!isInNewRowFlag && isBoolean(props === null || props === void 0 ? void 0 : props.isChanged)) {
45
46
  var renderNode = value ? node : '-';
47
+ var isXMaxContent = (scroll === null || scroll === void 0 ? void 0 : scroll.x) === 'max-content';
46
48
  if (ellipsis || (props === null || props === void 0 ? void 0 : props.isChanged)) {
47
- renderNode = _jsx(Text, {
49
+ renderNode = !isXMaxContent ? _jsx(Text, {
48
50
  style: {
49
51
  width: currentValue === '-' ? 32.5 : width,
50
52
  minWidth: minWidth
@@ -53,6 +55,12 @@ var RenderColumn = function RenderColumn(props) {
53
55
  tooltip: false
54
56
  },
55
57
  children: ellipsis ? currentValue : renderNode
58
+ }) : _jsx("div", {
59
+ style: {
60
+ minWidth: minWidth,
61
+ width: width
62
+ },
63
+ children: ellipsis ? currentValue : renderNode
56
64
  });
57
65
  if ((props === null || props === void 0 ? void 0 : props.isChanged) === false) {
58
66
  return renderNode;
@@ -11,7 +11,7 @@ import { useCallback, useMemo, useState } from 'react';
11
11
  import { useRequest, useSetState, useDeepCompareEffect } from 'ahooks';
12
12
  import { pickBy, isObject, merge, set, isEqual } from 'lodash';
13
13
  import { defaultPage } from '../index';
14
- import { isListResult } from '../utils';
14
+ import { isListResult, removeEmptyKeys } from '../utils';
15
15
  import locale, { formatMessage } from '../../locale';
16
16
  var useDefaultOptions = function useDefaultOptions(options) {
17
17
  var _useState = useState((options === null || options === void 0 ? void 0 : options.page) || defaultPage),
@@ -219,16 +219,17 @@ function useAntdTable(service, options, useRequestOptions) {
219
219
  pageNum: 1,
220
220
  pageSize: page.pageSize
221
221
  };
222
+ var _values = removeEmptyKeys(values);
222
223
  onPageChange(newPage);
223
224
  setState({
224
- searchValues: values,
225
+ searchValues: _values,
225
226
  allSelected: false,
226
227
  selectedRecords: [],
227
228
  selectedRowKeys: []
228
229
  });
229
230
  run(getTransformParams(_objectSpread(_objectSpread({
230
231
  page: newPage
231
- }, extraFilter), values)));
232
+ }, extraFilter), _values)));
232
233
  }, [extraFilter, page.pageSize, run, getTransformParams]);
233
234
  var resetParams = useCallback(function () {
234
235
  var page = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initPage;
@@ -46,6 +46,8 @@ export interface ProTableColumn extends Omit<ColumnType<any>, 'dataIndex'> {
46
46
  viewRender?: ({ value, record, index, originalValue, originalRecord, }: any) => 'same' | 'changed' | 'add' | undefined;
47
47
  isChanged?: boolean | null;
48
48
  children?: ProTableColumn[];
49
+ /** table透传下来的scroll配置 */
50
+ scroll?: any;
49
51
  }
50
52
  export interface CreateTreeFromArrayOptions {
51
53
  itemKey?: string;
@@ -29,3 +29,7 @@ export declare const isListResult: (data: {
29
29
  [key: string]: any;
30
30
  }) => boolean;
31
31
  export declare const getRowKey: (rowKey: any, record: any) => any;
32
+ /** 移除对象中的 null , undefined, '' 的key */
33
+ export declare const removeEmptyKeys: (obj: any) => {
34
+ [k: string]: unknown;
35
+ };
@@ -1,3 +1,4 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
1
2
  import { get, isEqual } from 'lodash';
2
3
  import { validate } from '@zat-design/utils';
3
4
  var isEmpty = validate.isEmpty;
@@ -70,4 +71,18 @@ export var getRowKey = function getRowKey(rowKey, record) {
70
71
  key = (_ref = typeof rowKey === 'function' ? rowKey(record) : record[rowKey]) !== null && _ref !== void 0 ? _ref : key;
71
72
  }
72
73
  return key;
74
+ };
75
+ /** 移除对象中的 null , undefined, '' 的key */
76
+ export var removeEmptyKeys = function removeEmptyKeys(obj) {
77
+ // 使用 Object.entries() 将对象转换为键值对数组
78
+ var entries = Object.entries(obj);
79
+ // 过滤掉值为 null, undefined, 或 '' 的键值对
80
+ var filteredEntries = entries.filter(function (_ref2) {
81
+ var _ref3 = _slicedToArray(_ref2, 2),
82
+ key = _ref3[0],
83
+ value = _ref3[1];
84
+ return !isEmpty(value);
85
+ });
86
+ // 使用 Object.fromEntries() 将过滤后的键值对数组转换回对象
87
+ return Object.fromEntries(filteredEntries);
73
88
  };
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
10
  var _jsxRuntime = require("react/jsx-runtime");
10
11
  var _react = _interopRequireDefault(require("react"));
11
12
  var _antd = require("antd");
@@ -26,13 +27,20 @@ var ActionButton = function ActionButton(_ref) {
26
27
  deletePoConfirmMsg = config.deletePoConfirmMsg,
27
28
  mulDeletePoConfirmMsg = config.mulDeletePoConfirmMsg,
28
29
  max = config.max,
29
- tableLength = config.tableLength;
30
+ name = config.name,
31
+ tableLength = config.tableLength,
32
+ selectedRows = config.selectedRows;
33
+ var rowNamePath = [].concat((0, _toConsumableArray2.default)(name), [index]);
30
34
  // 操作按钮权限控制
31
35
  var getShow = function getShow(show) {
32
36
  if (typeof show === 'function') {
33
37
  return show(record, {
34
38
  index: index,
35
- form: form
39
+ form: form,
40
+ name: name,
41
+ namePath: rowNamePath,
42
+ tableLength: tableLength,
43
+ selectedRows: selectedRows
36
44
  });
37
45
  }
38
46
  return show;
@@ -42,7 +50,11 @@ var ActionButton = function ActionButton(_ref) {
42
50
  if (typeof disabled === 'function') {
43
51
  return disabled(record, {
44
52
  index: index,
45
- form: form
53
+ form: form,
54
+ name: name,
55
+ namePath: rowNamePath,
56
+ tableLength: tableLength,
57
+ selectedRows: selectedRows
46
58
  });
47
59
  }
48
60
  // 新增超过最大行,禁止操作按钮
@@ -64,14 +76,29 @@ var ActionButton = function ActionButton(_ref) {
64
76
  // 其他操作按钮Props
65
77
  var actionBtnProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, btnConfig.buttonProps), {}, {
66
78
  onClick: function onClick() {
67
- btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
79
+ btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, {
80
+ index: index,
81
+ form: form,
82
+ name: name,
83
+ namePath: rowNamePath,
84
+ tableLength: tableLength,
85
+ selectedRows: selectedRows
86
+ });
68
87
  },
69
88
  disabled: getDisabled((_btnConfig$buttonProp3 = btnConfig.buttonProps) === null || _btnConfig$buttonProp3 === void 0 ? void 0 : _btnConfig$buttonProp3.disabled)
70
89
  });
71
90
  // 当传入函数时,先转成reactNode
72
91
  if ((0, _lodash.isFunction)(btnConfig.label)) {
73
- btnConfig.label = (0, _jsxRuntime.jsx)(btnConfig.label, {
74
- form: form
92
+ var addIndex = tableLength ? tableLength - 1 : 0;
93
+ var namePath = [].concat((0, _toConsumableArray2.default)(name), [addIndex]);
94
+ var addRecord = form.getFieldValue(namePath) || {};
95
+ btnConfig.label = btnConfig.label(addRecord, {
96
+ form: form,
97
+ namePath: namePath,
98
+ name: name,
99
+ tableLength: tableLength,
100
+ selectedRows: selectedRows,
101
+ index: addIndex
75
102
  });
76
103
  }
77
104
  var isDisabled = !selectedRowKeys.length && btnConfig.type === 'mulDelete' || editingKeys.length || (delBtnProps === null || delBtnProps === void 0 ? void 0 : delBtnProps.disabled);
@@ -81,7 +108,14 @@ var ActionButton = function ActionButton(_ref) {
81
108
  placement: "topRight",
82
109
  title: deleteMsgMap[btnConfig.type],
83
110
  onConfirm: function onConfirm() {
84
- btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
111
+ btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, {
112
+ index: index,
113
+ form: form,
114
+ name: name,
115
+ namePath: rowNamePath,
116
+ tableLength: tableLength,
117
+ selectedRows: selectedRows
118
+ });
85
119
  },
86
120
  disabled: isDisabled,
87
121
  okText: _locale.default.ProEditTable.confirm,
@@ -101,13 +135,27 @@ var ActionButton = function ActionButton(_ref) {
101
135
  index: index,
102
136
  disabled: isDisabled,
103
137
  onClick: function onClick() {
104
- btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
138
+ btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, {
139
+ index: index,
140
+ form: form,
141
+ name: name,
142
+ namePath: rowNamePath,
143
+ tableLength: tableLength,
144
+ selectedRows: selectedRows
145
+ });
105
146
  }
106
147
  }))) : (0, _jsxRuntime.jsx)(_antd.Button, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(delBtnProps, ['buttonProps', 'isEditable', 'onEvent'])), {}, {
107
148
  disabled: isDisabled,
108
149
  type: "link",
109
150
  onClick: function onClick() {
110
- btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
151
+ btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, {
152
+ index: index,
153
+ form: form,
154
+ name: name,
155
+ namePath: rowNamePath,
156
+ tableLength: tableLength,
157
+ selectedRows: selectedRows
158
+ });
111
159
  },
112
160
  children: btnConfig.label
113
161
  }))
@@ -30,7 +30,7 @@ var _utils = require("../../../ProForm/utils");
30
30
  var _ConfirmWrapper = _interopRequireDefault(require("../../../ProForm/components/render/ConfirmWrapper"));
31
31
  var _getDefaultProps = require("../../utils/getDefaultProps");
32
32
  var _ListChangedWrapper = _interopRequireDefault(require("./ListChangedWrapper"));
33
- var _excluded = ["type", "valueType", "names", "fieldProps", "labelRequired", "editRender", "component", "viewRender", "title", "originTitle", "label", "dataIndex", "formItemProps", "isEditable", "required", "rules", "onDiff", "className", "trim", "confirm", "dependencies"];
33
+ var _excluded = ["type", "valueType", "names", "fieldProps", "labelRequired", "editRender", "component", "viewRender", "title", "originTitle", "label", "dataIndex", "formItemProps", "isEditable", "required", "rules", "onDiff", "className", "trim", "confirm", "dependencies", "desensitization"];
34
34
  /* eslint-disable prefer-destructuring */
35
35
  /* eslint-disable prefer-const */
36
36
  var RenderField = function RenderField(_ref) {
@@ -64,6 +64,7 @@ var RenderField = function RenderField(_ref) {
64
64
  trim = column.trim,
65
65
  confirm = column.confirm,
66
66
  dependencies = column.dependencies,
67
+ desensitization = column.desensitization,
67
68
  resetProps = (0, _objectWithoutProperties2.default)(column, _excluded);
68
69
  // editRender弃用使用component同ProForm
69
70
  var _editRender = component || editRender;
@@ -89,6 +90,7 @@ var RenderField = function RenderField(_ref) {
89
90
  var _required = required;
90
91
  var _valueType = valueType;
91
92
  var _disabled = false;
93
+ var _desensitization = desensitization || [];
92
94
  var isCell = mode === 'cell';
93
95
  if (isCell) {
94
96
  record['is-view'] = !(0, _lodash.isEqual)(cellNamePath, cellName);
@@ -125,6 +127,9 @@ var RenderField = function RenderField(_ref) {
125
127
  if ((0, _lodash.isFunction)(valueType)) {
126
128
  _valueType = valueType.apply(void 0, rowParams);
127
129
  }
130
+ if ((0, _lodash.isFunction)(desensitization)) {
131
+ _desensitization = desensitization.apply(void 0, rowParams);
132
+ }
128
133
  // 获取最终的disabled
129
134
  _disabled = (0, _tools.getDisabled)({
130
135
  globalControl: otherProps === null || otherProps === void 0 ? void 0 : otherProps.globalControl,
@@ -136,9 +141,9 @@ var RenderField = function RenderField(_ref) {
136
141
  });
137
142
  if (typeof isEditable === 'function') {
138
143
  isEditable = isEditable.apply(void 0, rowParams);
139
- setTimeout(function () {
140
- !isEditable && form.validateFields([cellName]);
141
- }, 100);
144
+ // setTimeout(() => {
145
+ // !isEditable && form.validateFields([cellName]);
146
+ // }, 100);
142
147
  }
143
148
  // 是否只读文本
144
149
  var isView = !isEditable || (record === null || record === void 0 ? void 0 : record['is-view']) || config.isView || virtualKey && !isEditing || (0, _tools.getDisabled)({
@@ -196,21 +201,23 @@ var RenderField = function RenderField(_ref) {
196
201
  * 配置valueType时,基于formItem的normalize与getValueProps进行值类型转换
197
202
  * @returns {}
198
203
  */
199
- var valueTypeTransform = (0, _react.useCallback)(function () {
200
- var _fieldProps3;
201
- // 不存在valueType返回空
202
- if (!_valueType) {
203
- return {};
204
- }
204
+ var valueTypeTransform = function valueTypeTransform() {
205
+ var _fieldProps3, _desensitization2;
205
206
  // SwitchCheckbox默认YN, 兼容已有组件
206
207
  if (type === 'SwitchCheckbox') {
207
208
  _valueType = 'switch';
208
209
  }
209
210
  var params = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, column), {}, {
210
- mode: (_fieldProps3 = _fieldProps) === null || _fieldProps3 === void 0 ? void 0 : _fieldProps3.mode
211
+ mode: (_fieldProps3 = _fieldProps) === null || _fieldProps3 === void 0 ? void 0 : _fieldProps3.mode,
212
+ desensitization: _desensitization
211
213
  });
214
+ var isDesensit = sessionStorage.getItem(otherProps === null || otherProps === void 0 ? void 0 : otherProps.desensitizationKey);
215
+ // 仅查看模式下进行数据脱敏
216
+ if (((_desensitization2 = _desensitization) === null || _desensitization2 === void 0 ? void 0 : _desensitization2.length) && _disabled && isDesensit === 'ON') {
217
+ _valueType = 'desensitization';
218
+ }
212
219
  return (0, _lodash.isFunction)(_valueType2.default[_valueType]) ? _valueType2.default[_valueType](params) : {};
213
- }, [_valueType]);
220
+ };
214
221
  if ((_names = names) === null || _names === void 0 ? void 0 : _names.length) {
215
222
  // 支持names配置,临时生成对应的formItem,用来存储单个对应的值
216
223
  names = names.map(function (key) {
@@ -524,6 +531,7 @@ var RenderField = function RenderField(_ref) {
524
531
  onBlur: _onblur,
525
532
  index: index,
526
533
  confirm: confirm,
534
+ desensitization: _desensitization,
527
535
  otherProps: {
528
536
  form: form,
529
537
  names: names,
@@ -532,7 +540,8 @@ var RenderField = function RenderField(_ref) {
532
540
  listName: cellName,
533
541
  viewEmpty: viewEmpty,
534
542
  valueType: _valueType,
535
- isView: isView
543
+ isView: isView,
544
+ desensitizationKey: otherProps === null || otherProps === void 0 ? void 0 : otherProps.desensitizationKey
536
545
  }
537
546
  });
538
547
  componentProps = (0, _lodash.omit)(componentProps, ['onFieldChange', 'namePath', 'index']);
@@ -23,12 +23,9 @@ var RenderToolbar = function RenderToolbar(config) {
23
23
  toolbarProps = config.toolbarProps,
24
24
  name = config.name,
25
25
  virtualKey = config.virtualKey,
26
- form = config.form,
27
26
  disabled = config.disabled,
28
- selectedRows = config.selectedRows,
29
27
  tableLength = config.tableLength;
30
28
  var virtualName = (0, _tools.getNamePath)(name, virtualKey);
31
- var dataSource = form.getFieldValue(name);
32
29
  // toolbarProps配置为false 默认不插入
33
30
  if (toolbarProps === false || disabled) {
34
31
  return null;
@@ -82,29 +79,34 @@ var RenderToolbar = function RenderToolbar(config) {
82
79
  toolbar.show = show !== null && show !== void 0 ? show : true;
83
80
  toolbar.needConfirm = needConfirm !== null && needConfirm !== void 0 ? needConfirm : true;
84
81
  toolbar.onEvent = /*#__PURE__*/function () {
85
- var _ref = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(record, index) {
86
- var onEvent, result;
82
+ var _ref2 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(record, _ref) {
83
+ var index, form, name, namePath, tableLength, selectedRows, onEvent, result;
87
84
  return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
88
85
  while (1) switch (_context.prev = _context.next) {
89
86
  case 0:
87
+ index = _ref.index, form = _ref.form, name = _ref.name, namePath = _ref.namePath, tableLength = _ref.tableLength, selectedRows = _ref.selectedRows;
90
88
  onEvent = onClick || onHandle;
91
89
  if (onEvent) {
92
- _context.next = 5;
90
+ _context.next = 6;
93
91
  break;
94
92
  }
95
93
  result = true;
96
- _context.next = 8;
94
+ _context.next = 9;
97
95
  break;
98
- case 5:
99
- _context.next = 7;
100
- return onEvent === null || onEvent === void 0 ? void 0 : onEvent(selectedRows, dataSource, {
96
+ case 6:
97
+ _context.next = 8;
98
+ return onEvent === null || onEvent === void 0 ? void 0 : onEvent(record, {
99
+ index: index,
101
100
  form: form,
102
- namePath: virtualName
101
+ name: name,
102
+ namePath: namePath,
103
+ tableLength: tableLength,
104
+ selectedRows: selectedRows
103
105
  });
104
- case 7:
105
- result = _context.sent;
106
106
  case 8:
107
- if (result && type !== 'custom') {
107
+ result = _context.sent;
108
+ case 9:
109
+ if (result !== false && type !== 'custom') {
108
110
  _config.actions[type]((0, _objectSpread2.default)((0, _objectSpread2.default)({}, config), {}, {
109
111
  index: index,
110
112
  record: record,
@@ -113,14 +115,14 @@ var RenderToolbar = function RenderToolbar(config) {
113
115
  virtualName: virtualName
114
116
  }));
115
117
  }
116
- case 9:
118
+ case 10:
117
119
  case "end":
118
120
  return _context.stop();
119
121
  }
120
122
  }, _callee);
121
123
  }));
122
124
  return function (_x, _x2) {
123
- return _ref.apply(this, arguments);
125
+ return _ref2.apply(this, arguments);
124
126
  };
125
127
  }();
126
128
  toolbar.buttonProps = buttonProps;
@@ -300,7 +300,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
300
300
  }, [value, config.name]);
301
301
  var _columns = (0, _react.useMemo)(function () {
302
302
  return (0, _utils.transformColumns)(columns, config);
303
- }, [valueChangeRef.current, disabled, forceUpdate, columns, page, actionProps, editingKeys, cellNamePath]);
303
+ }, [valueChangeRef.current, disabled, forceUpdate, columns, page, actionProps, editingKeys, cellNamePath, value === null || value === void 0 ? void 0 : value.length]);
304
304
  var initDataSource = function initDataSource() {
305
305
  var _value$every, _value$some;
306
306
  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) {
@@ -11,9 +11,12 @@ import { ProFormValueType, ColumnPropsMap } from '../ProForm/components/render/p
11
11
  import { DiffOriginalParams } from '../ProForm/utils/diffOriginal';
12
12
  export type ActionType = 'edit' | 'delete' | 'save' | 'cancel' | 'add' | 'mulDelete' | 'custom';
13
13
  export type ShowFunction<T> = (record?: T, options?: {
14
- index?: number;
15
- form?: FormInstance;
16
- namePath?: NamePath;
14
+ index: number;
15
+ form: FormInstance;
16
+ name: NamePath;
17
+ namePath: NamePath;
18
+ tableLength: number;
19
+ selectedRows: T[];
17
20
  }) => Promise<any> | boolean | void;
18
21
  export interface OptionsProps {
19
22
  index: number;