@zat-design/sisyphus-react 3.9.4-beta.1 → 3.9.4-beta.11

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 (28) hide show
  1. package/.vscode/extensions.json +5 -0
  2. package/es/ProEditTable/components/RenderField/ListChangedWrapper.d.ts +1 -1
  3. package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +13 -10
  4. package/es/ProEditTable/components/RenderField/index.js +2 -3
  5. package/es/ProEditTable/utils/diffOriginal.d.ts +21 -0
  6. package/es/ProEditTable/utils/diffOriginal.js +62 -0
  7. package/es/ProEnum/index.js +1 -1
  8. package/es/ProForm/components/combination/Group/component/ComRender.js +8 -1
  9. package/es/ProForm/components/combination/Group/index.js +1 -1
  10. package/es/ProForm/components/combination/Group/utils.js +1 -1
  11. package/es/ProTable/components/FormatColumn/index.js +12 -2
  12. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +36 -32
  13. package/es/ProTable/index.js +22 -15
  14. package/es/ProTable/propsType.d.ts +3 -2
  15. package/lib/ProEditTable/components/RenderField/ListChangedWrapper.d.ts +1 -1
  16. package/lib/ProEditTable/components/RenderField/ListChangedWrapper.js +13 -10
  17. package/lib/ProEditTable/components/RenderField/index.js +2 -3
  18. package/lib/ProEditTable/utils/diffOriginal.d.ts +21 -0
  19. package/lib/ProEditTable/utils/diffOriginal.js +68 -0
  20. package/lib/ProEnum/index.js +1 -1
  21. package/lib/ProForm/components/combination/Group/component/ComRender.js +7 -0
  22. package/lib/ProForm/components/combination/Group/index.js +1 -1
  23. package/lib/ProForm/components/combination/Group/utils.js +1 -1
  24. package/lib/ProTable/components/FormatColumn/index.js +12 -2
  25. package/lib/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +36 -32
  26. package/lib/ProTable/index.js +22 -15
  27. package/lib/ProTable/propsType.d.ts +3 -2
  28. package/package.json +1 -1
@@ -0,0 +1,5 @@
1
+ {
2
+ "recommendations": [
3
+ "kisstkondoros.vscode-codemetrics"
4
+ ]
5
+ }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { FormInstance } from 'antd';
3
3
  import { NamePath } from 'antd/lib/form/interface';
4
- import { DiffOriginalParams } from '../../../ProForm/utils/diffOriginal';
4
+ import { DiffOriginalParams } from '../../utils/diffOriginal';
5
5
  interface Props {
6
6
  name?: NamePath;
7
7
  names?: NamePath[];
@@ -10,7 +10,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
10
  import React, { useMemo, useRef } from 'react';
11
11
  import classnames from 'classnames';
12
12
  import { get } from 'lodash';
13
- import { diffOriginal } from '../../../ProForm/utils/diffOriginal';
13
+ import { diffOriginal } from '../../utils/diffOriginal';
14
14
  import { useProConfig } from '../../../ProConfigProvider';
15
15
  import { isEmpty } from '../../../utils';
16
16
  var toNamePath = function toNamePath(name) {
@@ -34,7 +34,7 @@ var getOriginalValue = function getOriginalValue(_ref) {
34
34
  if (!originalValues) {
35
35
  return undefined;
36
36
  }
37
- var originalValueRow;
37
+ var originRecord;
38
38
  if (rowKeyPath) {
39
39
  var rowValueNamePath = namePath.slice(0, rowKeyPath.length - 1); // 表单中变动值所在行
40
40
  var rowKeyName = rowKeyPath[rowKeyPath.length - 1]; // rowKey在行内的name
@@ -43,13 +43,13 @@ var getOriginalValue = function getOriginalValue(_ref) {
43
43
  var keyValue = rowValue[rowKeyName]; // 获取表单中rowKey值
44
44
  if (!keyValue) return undefined;
45
45
  var originalValueList = get(originalValues, originalName.slice(0, rowKeyPath.length - 2));
46
- originalValueRow = originalValueList === null || originalValueList === void 0 ? void 0 : originalValueList.find(function (item) {
46
+ originRecord = originalValueList === null || originalValueList === void 0 ? void 0 : originalValueList.find(function (item) {
47
47
  return item[rowKeyPath[rowKeyPath.length - 1]] === keyValue;
48
48
  });
49
49
  var originalValue;
50
50
  if (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) {
51
51
  var originalNamesValue = originalNames.map(function (originalName) {
52
- return get(originalValueRow, originalName.slice(rowKeyPath.length - 1));
52
+ return get(originRecord, originalName.slice(rowKeyPath.length - 1));
53
53
  });
54
54
  // 有可能出现数组中全是undefined的情况 视为没有值
55
55
  var fillUndefined = originalNamesValue.every(function (valItem) {
@@ -57,11 +57,12 @@ var getOriginalValue = function getOriginalValue(_ref) {
57
57
  });
58
58
  originalValue = fillUndefined ? undefined : originalNamesValue;
59
59
  } else {
60
- originalValue = get(originalValueRow, originalName.slice(rowKeyPath.length - 1));
60
+ originalValue = get(originRecord, originalName.slice(rowKeyPath.length - 1));
61
61
  }
62
62
  return {
63
63
  originalValue: originalValue,
64
- originalValueRow: originalValueRow
64
+ originRecord: originRecord,
65
+ record: rowValue
65
66
  };
66
67
  }
67
68
  // 这个方法是给editTable专用的 暂时不存在不传rowKey的情况
@@ -69,7 +70,7 @@ var getOriginalValue = function getOriginalValue(_ref) {
69
70
  originalValue: (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) ? originalNames.map(function (originalName) {
70
71
  return get(originalValues, originalName);
71
72
  }) : get(originalValues, originalName),
72
- originalValueRow: originalValueRow
73
+ originRecord: originRecord
73
74
  };
74
75
  };
75
76
  var ListChangedWrapper = function ListChangedWrapper(props) {
@@ -130,8 +131,10 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
130
131
  value: _value,
131
132
  originalValue: _originalValue,
132
133
  form: form,
133
- equalWith: equalWith
134
- // name: isString(namesStr) ? namesStr : originalName || name,
134
+ equalWith: equalWith,
135
+ originRecord: originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.originRecord,
136
+ record: originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.record,
137
+ index: index
135
138
  });
136
139
  }, [props[valuePropName], originalValue]);
137
140
  var isAdd = diffType === 'add';
@@ -144,7 +147,7 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
144
147
  var _children = children;
145
148
  if (viewRender) {
146
149
  if (! /*#__PURE__*/React.isValidElement(viewRender)) {
147
- return viewRender(orgValue, (originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.originalValueRow) || {}, {
150
+ return viewRender(orgValue, (originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.originRecord) || {}, {
148
151
  form: form,
149
152
  name: name,
150
153
  index: index
@@ -6,7 +6,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
6
6
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
7
7
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
8
8
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
9
- var _excluded = ["type", "valueType", "names", "fieldProps", "labelRequired", "editRender", "component", "viewRender", "title", "originTitle", "label", "dataIndex", "formItemProps", "isEditable", "required", "rules", "equalWith", "onDiff", "className", "trim", "confirm", "dependencies"];
9
+ var _excluded = ["type", "valueType", "names", "fieldProps", "labelRequired", "editRender", "component", "viewRender", "title", "originTitle", "label", "dataIndex", "formItemProps", "isEditable", "required", "rules", "onDiff", "className", "trim", "confirm", "dependencies"];
10
10
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
11
11
  /* eslint-disable prefer-destructuring */
12
12
  /* eslint-disable prefer-const */
@@ -52,7 +52,6 @@ var RenderField = function RenderField(_ref) {
52
52
  required = _column$required === void 0 ? false : _column$required,
53
53
  _column$rules = column.rules,
54
54
  rules = _column$rules === void 0 ? [] : _column$rules,
55
- equalWith = column.equalWith,
56
55
  onDiff = column.onDiff,
57
56
  className = column.className,
58
57
  trim = column.trim,
@@ -568,7 +567,7 @@ var RenderField = function RenderField(_ref) {
568
567
  originalNames: originalNames,
569
568
  originalValues: originalValues,
570
569
  form: form,
571
- equalWith: onDiff || equalWith,
570
+ equalWith: onDiff,
572
571
  type: type,
573
572
  onChange: _onChange,
574
573
  valuePropName: _formItemProps.valuePropName,
@@ -0,0 +1,21 @@
1
+ import { FormInstance } from 'antd';
2
+ export type DiffType = 'same' | 'add' | 'changed';
3
+ export interface DiffOriginalParams {
4
+ originalValue: any;
5
+ value: any;
6
+ form: FormInstance;
7
+ equalWith?: ({ originValue, originRecord, value, record, index }: {
8
+ originValue: any;
9
+ originRecord: any;
10
+ value: any;
11
+ record: any;
12
+ index: number;
13
+ }) => DiffType | undefined;
14
+ /** 原始行数据 */
15
+ originRecord: any;
16
+ /** 当前行数据 */
17
+ record: any;
18
+ /** 当前行索引 */
19
+ index: number;
20
+ }
21
+ export declare const diffOriginal: (params: DiffOriginalParams) => DiffType;
@@ -0,0 +1,62 @@
1
+ import { isEqual, isFunction, isObject } from 'lodash';
2
+ import { validate } from '@zat-design/utils';
3
+ var isEmpty = validate.isEmpty;
4
+ // 过滤对象中undefined字段
5
+ // 防止{a: '1'} {a: '1', b: undefined | null}被认为不相等
6
+ var filterObject = function filterObject(data) {
7
+ if (!isObject(data) || Array.isArray(data) || data === null) return data;
8
+ var resData = {};
9
+ Object.keys(data).forEach(function (key) {
10
+ if (!isEmpty(data[key])) {
11
+ resData[key] = data[key];
12
+ }
13
+ });
14
+ // 空对象视为null 比较时 null undefined {} [] '' 视为相等
15
+ if (!Object.keys(resData).length) return null;
16
+ return resData;
17
+ };
18
+ export var diffOriginal = function diffOriginal(params) {
19
+ var originalValue = params.originalValue,
20
+ value = params.value,
21
+ equalWith = params.equalWith,
22
+ originRecord = params.originRecord,
23
+ record = params.record,
24
+ index = params.index;
25
+ // 支持传入自定义比较事件
26
+ if (isFunction(equalWith)) {
27
+ var diffRes = equalWith({
28
+ originValue: originalValue,
29
+ originRecord: originRecord,
30
+ value: value,
31
+ record: record,
32
+ index: index
33
+ });
34
+ // 如果返回undefined走内置比较逻辑
35
+ if (diffRes !== undefined) {
36
+ if (typeof diffRes === 'boolean') {
37
+ return diffRes ? 'same' : 'changed';
38
+ }
39
+ return diffRes;
40
+ }
41
+ }
42
+ var _value = filterObject(value);
43
+ var _originalValue = filterObject(originalValue);
44
+ // 如果原始值为空 且当前有值的话 认为变更类型是新增
45
+ if (isEmpty(_originalValue) && !isEmpty(_value)) {
46
+ return 'add';
47
+ }
48
+ if (Array.isArray(_originalValue)) {
49
+ var isSame = _originalValue.every(function (valueItem, index) {
50
+ // 如果两个值有一个不是空值, 则进行深比较
51
+ if (!isEmpty(value === null || value === void 0 ? void 0 : value[index]) || !isEmpty(valueItem)) {
52
+ return isEqual(value === null || value === void 0 ? void 0 : value[index], valueItem);
53
+ }
54
+ return true;
55
+ });
56
+ return isSame ? 'same' : 'changed';
57
+ }
58
+ if (!isEmpty(_originalValue) || !isEmpty(_value)) {
59
+ return isEqual(_value, _originalValue) ? 'same' : 'changed';
60
+ }
61
+ return 'same';
62
+ };
@@ -230,7 +230,7 @@ var ProEnum = function ProEnum(props) {
230
230
  };
231
231
  if (!code && !dataSource && !useRequest) {
232
232
  var _locale$ProEnum4;
233
- _message.error(locale === null || locale === void 0 ? void 0 : (_locale$ProEnum4 = locale.ProEnum) === null || _locale$ProEnum4 === void 0 ? void 0 : _locale$ProEnum4.errorNoEnumType);
233
+ _message.error("".concat(otherProps === null || otherProps === void 0 ? void 0 : otherProps.label, "-").concat(otherProps === null || otherProps === void 0 ? void 0 : otherProps.name, "-").concat(locale === null || locale === void 0 ? void 0 : (_locale$ProEnum4 = locale.ProEnum) === null || _locale$ProEnum4 === void 0 ? void 0 : _locale$ProEnum4.errorNoEnumType));
234
234
  }
235
235
  var transToLabel = function transToLabel(value) {
236
236
  var list = dataList && dataList.length ? dataList : enumLists;
@@ -2,7 +2,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
2
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
3
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
4
  var _excluded = ["type", "confirm", "component", "fieldProps", "contextProps", "before", "after", "getValueProps", "valuePropName", "valueType", "isView", "viewRender"];
5
- import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
6
6
  import React from 'react';
7
7
  import ConfirmWrapper from '../../../../components/render/ConfirmWrapper';
8
8
  import { FieldProvider } from '../../../../utils/useFieldProps';
@@ -30,6 +30,7 @@ var getComRender = function getComRender(component, props, componentProps) {
30
30
  };
31
31
  /** 渲染组件 */
32
32
  var ComRender = function ComRender(props) {
33
+ var _props$component, _props$component$prop;
33
34
  var type = props.type,
34
35
  confirm = props.confirm,
35
36
  component = props.component,
@@ -50,6 +51,12 @@ var ComRender = function ComRender(props) {
50
51
  };
51
52
  var _props = mergedGetValueProps(fieldProps.value);
52
53
  var componentProps = _objectSpread(_objectSpread(_objectSpread({}, fieldProps), rest), _props);
54
+ var isSeparator = (props === null || props === void 0 ? void 0 : (_props$component = props.component) === null || _props$component === void 0 ? void 0 : (_props$component$prop = _props$component.props) === null || _props$component$prop === void 0 ? void 0 : _props$component$prop.className) === 'group-separator';
55
+ if (isSeparator && isView) {
56
+ return _jsx(_Fragment, {
57
+ children: "/"
58
+ });
59
+ }
53
60
  if (viewRender && isView) {
54
61
  return _jsx(FieldProvider, {
55
62
  value: _objectSpread(_objectSpread({}, contextProps), {}, {
@@ -71,7 +71,7 @@ var Group = function Group(props) {
71
71
  children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? _jsx(_Space.Compact, {
72
72
  children: columns.map(function (column, index) {
73
73
  column.otherProps = otherProps;
74
- // 自定义间隔移除对于参数
74
+ // 自定义间隔移除对应参数
75
75
  if (column === null || column === void 0 ? void 0 : column.separator) {
76
76
  delete column.separator;
77
77
  delete column.otherProps;
@@ -329,7 +329,7 @@ export var useTransformColumns = function useTransformColumns(params) {
329
329
  }, reactiveProps), {}, {
330
330
  disabled: getLastDisabled(),
331
331
  getValueProps: transform === null || transform === void 0 ? void 0 : transform.getValueProps,
332
- fieldProps: _objectSpread(_objectSpread({}, column === null || column === void 0 ? void 0 : column.fieldProps), {}, {
332
+ fieldProps: _objectSpread(_objectSpread(_objectSpread({}, column === null || column === void 0 ? void 0 : column.fieldProps), reactiveProps === null || reactiveProps === void 0 ? void 0 : reactiveProps.fieldProps), {}, {
333
333
  onChange: handleChange,
334
334
  onBlur: handleBlur,
335
335
  value: value === null || value === void 0 ? void 0 : value[index]
@@ -128,6 +128,7 @@ export var formatColumn = function formatColumn(_ref2) {
128
128
  var isInNewRowFlag = isInNewRow(record);
129
129
  var _isAddCell = isAddCell;
130
130
  otherProps.isChanged = isChanged;
131
+ var nextValue = value;
131
132
  // 存在比对
132
133
  if (isFunction(otherProps === null || otherProps === void 0 ? void 0 : otherProps.viewRender) && (diffConfig === null || diffConfig === void 0 ? void 0 : diffConfig.originalDataSource)) {
133
134
  var _originalObj$record$r;
@@ -139,10 +140,17 @@ export var formatColumn = function formatColumn(_ref2) {
139
140
  index: index
140
141
  });
141
142
  // viewRender 返回值为 false 时,不显示对比
142
- if (isBoolean(diffResult)) {
143
+ if (isBoolean(diffResult) && !diffResult) {
143
144
  otherProps.isChanged = false;
144
145
  }
145
146
  originalValue = diffResult;
147
+ nextValue = otherProps.viewRender({
148
+ originalValue: value,
149
+ originalRecord: record !== null && record !== void 0 ? record : {},
150
+ value: value,
151
+ record: record,
152
+ index: index
153
+ });
146
154
  }
147
155
  // 存在自定义onDiff比对
148
156
  if (isFunction(onDiff)) {
@@ -150,14 +158,16 @@ export var formatColumn = function formatColumn(_ref2) {
150
158
  var _diffResult = onDiff({
151
159
  originalValue: originalValue,
152
160
  originalRecord: (_originalObj$record$r2 = originalObj === null || originalObj === void 0 ? void 0 : originalObj[record === null || record === void 0 ? void 0 : record[rowKey]]) !== null && _originalObj$record$r2 !== void 0 ? _originalObj$record$r2 : {},
153
- value: value,
161
+ value: nextValue,
154
162
  record: record,
155
163
  index: index
156
164
  });
157
165
  if (_diffResult === 'changed') {
166
+ _isAddCell = false;
158
167
  otherProps.isChanged = true;
159
168
  }
160
169
  if (_diffResult === 'same') {
170
+ _isAddCell = false;
161
171
  otherProps.isChanged = false;
162
172
  }
163
173
  if (_diffResult === 'add') {
@@ -106,7 +106,7 @@ var DndWrapper = function DndWrapper(_ref2) {
106
106
  }();
107
107
  var onDragEnd = /*#__PURE__*/function () {
108
108
  var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref5) {
109
- var active, over, transformedValue, activeObject, overObject, activeLevel, activeParentId, overLevel, overParentId, nextDataSource, _flatTree, activeIndex, overIndex, nextValue;
109
+ var active, over, transformedValue, activeObject, overObject, activeLevel, activeParentId, overLevel, overParentId, nextDataSource, _nextDataSource, _flatTree, activeIndex, overIndex, nextValue;
110
110
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
111
111
  while (1) switch (_context2.prev = _context2.next) {
112
112
  case 0:
@@ -114,7 +114,7 @@ var DndWrapper = function DndWrapper(_ref2) {
114
114
  // 为数据源划分层级及parentId
115
115
  transformedValue = addLevelAndParentId(value, rowKey); // 同一level层级的且parentId相同的,可以互相之间拖拽替换
116
116
  if (!(active.id !== (over === null || over === void 0 ? void 0 : over.id))) {
117
- _context2.next = 15;
117
+ _context2.next = 20;
118
118
  break;
119
119
  }
120
120
  activeObject = treeNodeFind(transformedValue, function (t) {
@@ -124,47 +124,51 @@ var DndWrapper = function DndWrapper(_ref2) {
124
124
  return t.rowKey === (over === null || over === void 0 ? void 0 : over.id);
125
125
  });
126
126
  if (!(activeObject && overObject)) {
127
- _context2.next = 15;
127
+ _context2.next = 20;
128
128
  break;
129
129
  }
130
130
  activeLevel = activeObject.level, activeParentId = activeObject.parentId;
131
- overLevel = overObject.level, overParentId = overObject.parentId; // 如果传了onDragEndGuard 则视为外部业务逻辑自处理
131
+ overLevel = overObject.level, overParentId = overObject.parentId;
132
+ nextDataSource = value;
133
+ if (!(activeLevel === overLevel && activeParentId === overParentId)) {
134
+ _context2.next = 20;
135
+ break;
136
+ }
137
+ // 将树平铺
138
+ _flatTree = transformTreeToArray(transformedValue).map(function (item) {
139
+ return _objectSpread(_objectSpread({}, item), {}, {
140
+ children: undefined
141
+ });
142
+ });
143
+ activeIndex = _flatTree.findIndex(function (i) {
144
+ return i.rowKey === active.id;
145
+ });
146
+ overIndex = _flatTree.findIndex(function (i) {
147
+ return i.rowKey === (over === null || over === void 0 ? void 0 : over.id);
148
+ });
149
+ nextValue = arrayMove(_flatTree, activeIndex, overIndex);
150
+ nextDataSource = createTreeFromArray(nextValue, {
151
+ itemKey: 'rowKey',
152
+ parentKey: 'parentId',
153
+ childrenKey: 'children'
154
+ });
155
+ // 如果传了onDragEndGuard 则视为外部业务逻辑自处理
132
156
  if (!(onDragEndGuard && isFunction(onDragEndGuard))) {
133
- _context2.next = 14;
157
+ _context2.next = 19;
134
158
  break;
135
159
  }
136
- _context2.next = 11;
160
+ _context2.next = 18;
137
161
  return onDragEndGuard({
138
162
  activeObject: activeObject,
139
163
  overObject: overObject,
140
- currentDataSource: value
164
+ originDataSource: value,
165
+ currentDataSource: nextDataSource
141
166
  });
142
- case 11:
167
+ case 18:
143
168
  nextDataSource = _context2.sent;
144
- onChange(nextDataSource !== null && nextDataSource !== void 0 ? nextDataSource : []);
145
- return _context2.abrupt("return");
146
- case 14:
147
- if (activeLevel === overLevel && activeParentId === overParentId) {
148
- // 将树平铺
149
- _flatTree = transformTreeToArray(transformedValue).map(function (item) {
150
- return _objectSpread(_objectSpread({}, item), {}, {
151
- children: undefined
152
- });
153
- });
154
- activeIndex = _flatTree.findIndex(function (i) {
155
- return i.rowKey === active.id;
156
- });
157
- overIndex = _flatTree.findIndex(function (i) {
158
- return i.rowKey === (over === null || over === void 0 ? void 0 : over.id);
159
- });
160
- nextValue = arrayMove(_flatTree, activeIndex, overIndex);
161
- onChange(createTreeFromArray(nextValue, {
162
- itemKey: 'rowKey',
163
- parentKey: 'parentId',
164
- childrenKey: 'children'
165
- }));
166
- }
167
- case 15:
169
+ case 19:
170
+ onChange((_nextDataSource = nextDataSource) !== null && _nextDataSource !== void 0 ? _nextDataSource : []);
171
+ case 20:
168
172
  case "end":
169
173
  return _context2.stop();
170
174
  }
@@ -187,6 +187,26 @@ var ProTable = function ProTable(props) {
187
187
  return 'new-cell';
188
188
  }
189
189
  };
190
+ var _formatColumns = function formatColumns(nextColumns) {
191
+ nextColumns === null || nextColumns === void 0 ? void 0 : nextColumns.forEach(function (item, index) {
192
+ formatColumn({
193
+ column: item,
194
+ originalObj: originalObj,
195
+ rowKey: props.rowKey,
196
+ diffConfig: diffConfig,
197
+ wrapToolTipProps: wrapToolTipProps,
198
+ scroll: _scroll,
199
+ onUpdateMinWidth: function onUpdateMinWidth(w) {
200
+ curColumns[index].minWidth = w;
201
+ },
202
+ isInNewRow: _rowClassName
203
+ });
204
+ if (item.children && Array.isArray(item.children)) {
205
+ _formatColumns(item.children);
206
+ }
207
+ });
208
+ return nextColumns;
209
+ };
190
210
  var columns = useMemo(function () {
191
211
  var newColumns = curColumns.map(function (item, index) {
192
212
  var _propsColumnObj$getCo2;
@@ -208,21 +228,8 @@ var ProTable = function ProTable(props) {
208
228
  }).filter(function (item) {
209
229
  return !(item === null || item === void 0 ? void 0 : item.delete);
210
230
  });
211
- newColumns === null || newColumns === void 0 ? void 0 : newColumns.forEach(function (item, index) {
212
- formatColumn({
213
- column: item,
214
- originalObj: originalObj,
215
- rowKey: props.rowKey,
216
- diffConfig: diffConfig,
217
- wrapToolTipProps: wrapToolTipProps,
218
- scroll: _scroll,
219
- onUpdateMinWidth: function onUpdateMinWidth(w) {
220
- curColumns[index].minWidth = w;
221
- },
222
- isInNewRow: _rowClassName
223
- });
224
- });
225
- return newColumns;
231
+ var nextColumns = _formatColumns(newColumns);
232
+ return nextColumns;
226
233
  }, [curColumns, handleResize, _scroll, originalDataSource, originalObj, _rowClassName]);
227
234
  var _columns = useMemo(function () {
228
235
  return columns === null || columns === void 0 ? void 0 : columns.filter(function (item, index) {
@@ -19,7 +19,7 @@ export interface ProTableSummaryProps {
19
19
  fixed?: boolean;
20
20
  }
21
21
  export interface ProTableColumn extends Omit<ColumnType<any>, 'dataIndex'> {
22
- dataIndex: string | string[];
22
+ dataIndex?: string | string[];
23
23
  width?: number | string;
24
24
  minWidth?: number;
25
25
  valueType?: ProTableValueType;
@@ -43,8 +43,9 @@ export interface ProTableColumn extends Omit<ColumnType<any>, 'dataIndex'> {
43
43
  /** 自定义比对函数, 触发条件必须写render */
44
44
  onDiff?: ({ value, record, index, originalValue, originalRecord }: any) => any;
45
45
  /** 自定义提示render, 触发条件必须写render */
46
- viewRender?: ({ value, record, index, originalValue, originalRecord }: any) => 'same' | 'changed' | 'add' | undefined;
46
+ viewRender?: ({ value, record, index, originalValue, originalRecord, }: any) => 'same' | 'changed' | 'add' | undefined;
47
47
  isChanged?: boolean | null;
48
+ children?: ProTableColumn[];
48
49
  }
49
50
  export interface CreateTreeFromArrayOptions {
50
51
  itemKey?: string;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { FormInstance } from 'antd';
3
3
  import { NamePath } from 'antd/lib/form/interface';
4
- import { DiffOriginalParams } from '../../../ProForm/utils/diffOriginal';
4
+ import { DiffOriginalParams } from '../../utils/diffOriginal';
5
5
  interface Props {
6
6
  name?: NamePath;
7
7
  names?: NamePath[];
@@ -14,7 +14,7 @@ var _react = _interopRequireWildcard(require("react"));
14
14
  var _antd = require("antd");
15
15
  var _classnames = _interopRequireDefault(require("classnames"));
16
16
  var _lodash = require("lodash");
17
- var _diffOriginal = require("../../../ProForm/utils/diffOriginal");
17
+ var _diffOriginal = require("../../utils/diffOriginal");
18
18
  var _ProConfigProvider = require("../../../ProConfigProvider");
19
19
  var _utils = require("../../../utils");
20
20
  var _excluded = ["name", "names", "namesStr", "originalName", "originalNames", "originalValues", "form", "equalWith", "rowKeyPath", "children", "type", "normalize", "getValueProps", "valuePropName", "viewRender", "diffConfig", "index"];
@@ -39,7 +39,7 @@ var getOriginalValue = function getOriginalValue(_ref) {
39
39
  if (!originalValues) {
40
40
  return undefined;
41
41
  }
42
- var originalValueRow;
42
+ var originRecord;
43
43
  if (rowKeyPath) {
44
44
  var rowValueNamePath = namePath.slice(0, rowKeyPath.length - 1); // 表单中变动值所在行
45
45
  var rowKeyName = rowKeyPath[rowKeyPath.length - 1]; // rowKey在行内的name
@@ -48,13 +48,13 @@ var getOriginalValue = function getOriginalValue(_ref) {
48
48
  var keyValue = rowValue[rowKeyName]; // 获取表单中rowKey值
49
49
  if (!keyValue) return undefined;
50
50
  var originalValueList = (0, _lodash.get)(originalValues, originalName.slice(0, rowKeyPath.length - 2));
51
- originalValueRow = originalValueList === null || originalValueList === void 0 ? void 0 : originalValueList.find(function (item) {
51
+ originRecord = originalValueList === null || originalValueList === void 0 ? void 0 : originalValueList.find(function (item) {
52
52
  return item[rowKeyPath[rowKeyPath.length - 1]] === keyValue;
53
53
  });
54
54
  var originalValue;
55
55
  if (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) {
56
56
  var originalNamesValue = originalNames.map(function (originalName) {
57
- return (0, _lodash.get)(originalValueRow, originalName.slice(rowKeyPath.length - 1));
57
+ return (0, _lodash.get)(originRecord, originalName.slice(rowKeyPath.length - 1));
58
58
  });
59
59
  // 有可能出现数组中全是undefined的情况 视为没有值
60
60
  var fillUndefined = originalNamesValue.every(function (valItem) {
@@ -62,11 +62,12 @@ var getOriginalValue = function getOriginalValue(_ref) {
62
62
  });
63
63
  originalValue = fillUndefined ? undefined : originalNamesValue;
64
64
  } else {
65
- originalValue = (0, _lodash.get)(originalValueRow, originalName.slice(rowKeyPath.length - 1));
65
+ originalValue = (0, _lodash.get)(originRecord, originalName.slice(rowKeyPath.length - 1));
66
66
  }
67
67
  return {
68
68
  originalValue: originalValue,
69
- originalValueRow: originalValueRow
69
+ originRecord: originRecord,
70
+ record: rowValue
70
71
  };
71
72
  }
72
73
  // 这个方法是给editTable专用的 暂时不存在不传rowKey的情况
@@ -74,7 +75,7 @@ var getOriginalValue = function getOriginalValue(_ref) {
74
75
  originalValue: (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) ? originalNames.map(function (originalName) {
75
76
  return (0, _lodash.get)(originalValues, originalName);
76
77
  }) : (0, _lodash.get)(originalValues, originalName),
77
- originalValueRow: originalValueRow
78
+ originRecord: originRecord
78
79
  };
79
80
  };
80
81
  var ListChangedWrapper = function ListChangedWrapper(props) {
@@ -135,8 +136,10 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
135
136
  value: _value,
136
137
  originalValue: _originalValue,
137
138
  form: form,
138
- equalWith: equalWith
139
- // name: isString(namesStr) ? namesStr : originalName || name,
139
+ equalWith: equalWith,
140
+ originRecord: originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.originRecord,
141
+ record: originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.record,
142
+ index: index
140
143
  });
141
144
  }, [props[valuePropName], originalValue]);
142
145
  var isAdd = diffType === 'add';
@@ -149,7 +152,7 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
149
152
  var _children = children;
150
153
  if (viewRender) {
151
154
  if (! /*#__PURE__*/_react.default.isValidElement(viewRender)) {
152
- return viewRender(orgValue, (originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.originalValueRow) || {}, {
155
+ return viewRender(orgValue, (originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.originRecord) || {}, {
153
156
  form: form,
154
157
  name: name,
155
158
  index: index
@@ -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", "equalWith", "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"];
34
34
  /* eslint-disable prefer-destructuring */
35
35
  /* eslint-disable prefer-const */
36
36
  var RenderField = function RenderField(_ref) {
@@ -59,7 +59,6 @@ var RenderField = function RenderField(_ref) {
59
59
  required = _column$required === void 0 ? false : _column$required,
60
60
  _column$rules = column.rules,
61
61
  rules = _column$rules === void 0 ? [] : _column$rules,
62
- equalWith = column.equalWith,
63
62
  onDiff = column.onDiff,
64
63
  className = column.className,
65
64
  trim = column.trim,
@@ -575,7 +574,7 @@ var RenderField = function RenderField(_ref) {
575
574
  originalNames: originalNames,
576
575
  originalValues: originalValues,
577
576
  form: form,
578
- equalWith: onDiff || equalWith,
577
+ equalWith: onDiff,
579
578
  type: type,
580
579
  onChange: _onChange,
581
580
  valuePropName: _formItemProps.valuePropName,
@@ -0,0 +1,21 @@
1
+ import { FormInstance } from 'antd';
2
+ export type DiffType = 'same' | 'add' | 'changed';
3
+ export interface DiffOriginalParams {
4
+ originalValue: any;
5
+ value: any;
6
+ form: FormInstance;
7
+ equalWith?: ({ originValue, originRecord, value, record, index }: {
8
+ originValue: any;
9
+ originRecord: any;
10
+ value: any;
11
+ record: any;
12
+ index: number;
13
+ }) => DiffType | undefined;
14
+ /** 原始行数据 */
15
+ originRecord: any;
16
+ /** 当前行数据 */
17
+ record: any;
18
+ /** 当前行索引 */
19
+ index: number;
20
+ }
21
+ export declare const diffOriginal: (params: DiffOriginalParams) => DiffType;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.diffOriginal = void 0;
7
+ var _lodash = require("lodash");
8
+ var _utils = require("@zat-design/utils");
9
+ var isEmpty = _utils.validate.isEmpty;
10
+ // 过滤对象中undefined字段
11
+ // 防止{a: '1'} {a: '1', b: undefined | null}被认为不相等
12
+ var filterObject = function filterObject(data) {
13
+ if (!(0, _lodash.isObject)(data) || Array.isArray(data) || data === null) return data;
14
+ var resData = {};
15
+ Object.keys(data).forEach(function (key) {
16
+ if (!isEmpty(data[key])) {
17
+ resData[key] = data[key];
18
+ }
19
+ });
20
+ // 空对象视为null 比较时 null undefined {} [] '' 视为相等
21
+ if (!Object.keys(resData).length) return null;
22
+ return resData;
23
+ };
24
+ var diffOriginal = exports.diffOriginal = function diffOriginal(params) {
25
+ var originalValue = params.originalValue,
26
+ value = params.value,
27
+ equalWith = params.equalWith,
28
+ originRecord = params.originRecord,
29
+ record = params.record,
30
+ index = params.index;
31
+ // 支持传入自定义比较事件
32
+ if ((0, _lodash.isFunction)(equalWith)) {
33
+ var diffRes = equalWith({
34
+ originValue: originalValue,
35
+ originRecord: originRecord,
36
+ value: value,
37
+ record: record,
38
+ index: index
39
+ });
40
+ // 如果返回undefined走内置比较逻辑
41
+ if (diffRes !== undefined) {
42
+ if (typeof diffRes === 'boolean') {
43
+ return diffRes ? 'same' : 'changed';
44
+ }
45
+ return diffRes;
46
+ }
47
+ }
48
+ var _value = filterObject(value);
49
+ var _originalValue = filterObject(originalValue);
50
+ // 如果原始值为空 且当前有值的话 认为变更类型是新增
51
+ if (isEmpty(_originalValue) && !isEmpty(_value)) {
52
+ return 'add';
53
+ }
54
+ if (Array.isArray(_originalValue)) {
55
+ var isSame = _originalValue.every(function (valueItem, index) {
56
+ // 如果两个值有一个不是空值, 则进行深比较
57
+ if (!isEmpty(value === null || value === void 0 ? void 0 : value[index]) || !isEmpty(valueItem)) {
58
+ return (0, _lodash.isEqual)(value === null || value === void 0 ? void 0 : value[index], valueItem);
59
+ }
60
+ return true;
61
+ });
62
+ return isSame ? 'same' : 'changed';
63
+ }
64
+ if (!isEmpty(_originalValue) || !isEmpty(_value)) {
65
+ return (0, _lodash.isEqual)(_value, _originalValue) ? 'same' : 'changed';
66
+ }
67
+ return 'same';
68
+ };
@@ -231,7 +231,7 @@ var ProEnum = function ProEnum(props) {
231
231
  };
232
232
  if (!code && !dataSource && !useRequest) {
233
233
  var _locale$ProEnum4;
234
- _antd.message.error(_locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProEnum4 = _locale.default.ProEnum) === null || _locale$ProEnum4 === void 0 ? void 0 : _locale$ProEnum4.errorNoEnumType);
234
+ _antd.message.error("".concat(otherProps === null || otherProps === void 0 ? void 0 : otherProps.label, "-").concat(otherProps === null || otherProps === void 0 ? void 0 : otherProps.name, "-").concat(_locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProEnum4 = _locale.default.ProEnum) === null || _locale$ProEnum4 === void 0 ? void 0 : _locale$ProEnum4.errorNoEnumType));
235
235
  }
236
236
  var transToLabel = function transToLabel(value) {
237
237
  var list = dataList && dataList.length ? dataList : enumLists;
@@ -38,6 +38,7 @@ var getComRender = function getComRender(component, props, componentProps) {
38
38
  };
39
39
  /** 渲染组件 */
40
40
  var ComRender = function ComRender(props) {
41
+ var _props$component, _props$component$prop;
41
42
  var type = props.type,
42
43
  confirm = props.confirm,
43
44
  component = props.component,
@@ -58,6 +59,12 @@ var ComRender = function ComRender(props) {
58
59
  };
59
60
  var _props = mergedGetValueProps(fieldProps.value);
60
61
  var componentProps = (0, _objectSpread3.default)((0, _objectSpread3.default)((0, _objectSpread3.default)({}, fieldProps), rest), _props);
62
+ var isSeparator = (props === null || props === void 0 ? void 0 : (_props$component = props.component) === null || _props$component === void 0 ? void 0 : (_props$component$prop = _props$component.props) === null || _props$component$prop === void 0 ? void 0 : _props$component$prop.className) === 'group-separator';
63
+ if (isSeparator && isView) {
64
+ return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
65
+ children: "/"
66
+ });
67
+ }
61
68
  if (viewRender && isView) {
62
69
  return (0, _jsxRuntime.jsx)(_useFieldProps.FieldProvider, {
63
70
  value: (0, _objectSpread3.default)((0, _objectSpread3.default)({}, contextProps), {}, {
@@ -77,7 +77,7 @@ var Group = function Group(props) {
77
77
  children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? (0, _jsxRuntime.jsx)(_antd.Space.Compact, {
78
78
  children: columns.map(function (column, index) {
79
79
  column.otherProps = otherProps;
80
- // 自定义间隔移除对于参数
80
+ // 自定义间隔移除对应参数
81
81
  if (column === null || column === void 0 ? void 0 : column.separator) {
82
82
  delete column.separator;
83
83
  delete column.otherProps;
@@ -337,7 +337,7 @@ var useTransformColumns = exports.useTransformColumns = function useTransformCol
337
337
  }, reactiveProps), {}, {
338
338
  disabled: getLastDisabled(),
339
339
  getValueProps: transform === null || transform === void 0 ? void 0 : transform.getValueProps,
340
- fieldProps: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, column === null || column === void 0 ? void 0 : column.fieldProps), {}, {
340
+ fieldProps: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, column === null || column === void 0 ? void 0 : column.fieldProps), reactiveProps === null || reactiveProps === void 0 ? void 0 : reactiveProps.fieldProps), {}, {
341
341
  onChange: handleChange,
342
342
  onBlur: handleBlur,
343
343
  value: value === null || value === void 0 ? void 0 : value[index]
@@ -134,6 +134,7 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref2) {
134
134
  var isInNewRowFlag = isInNewRow(record);
135
135
  var _isAddCell = isAddCell;
136
136
  otherProps.isChanged = isChanged;
137
+ var nextValue = value;
137
138
  // 存在比对
138
139
  if ((0, _lodash.isFunction)(otherProps === null || otherProps === void 0 ? void 0 : otherProps.viewRender) && (diffConfig === null || diffConfig === void 0 ? void 0 : diffConfig.originalDataSource)) {
139
140
  var _originalObj$record$r;
@@ -145,10 +146,17 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref2) {
145
146
  index: index
146
147
  });
147
148
  // viewRender 返回值为 false 时,不显示对比
148
- if ((0, _lodash.isBoolean)(diffResult)) {
149
+ if ((0, _lodash.isBoolean)(diffResult) && !diffResult) {
149
150
  otherProps.isChanged = false;
150
151
  }
151
152
  originalValue = diffResult;
153
+ nextValue = otherProps.viewRender({
154
+ originalValue: value,
155
+ originalRecord: record !== null && record !== void 0 ? record : {},
156
+ value: value,
157
+ record: record,
158
+ index: index
159
+ });
152
160
  }
153
161
  // 存在自定义onDiff比对
154
162
  if ((0, _lodash.isFunction)(onDiff)) {
@@ -156,14 +164,16 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref2) {
156
164
  var _diffResult = onDiff({
157
165
  originalValue: originalValue,
158
166
  originalRecord: (_originalObj$record$r2 = originalObj === null || originalObj === void 0 ? void 0 : originalObj[record === null || record === void 0 ? void 0 : record[rowKey]]) !== null && _originalObj$record$r2 !== void 0 ? _originalObj$record$r2 : {},
159
- value: value,
167
+ value: nextValue,
160
168
  record: record,
161
169
  index: index
162
170
  });
163
171
  if (_diffResult === 'changed') {
172
+ _isAddCell = false;
164
173
  otherProps.isChanged = true;
165
174
  }
166
175
  if (_diffResult === 'same') {
176
+ _isAddCell = false;
167
177
  otherProps.isChanged = false;
168
178
  }
169
179
  if (_diffResult === 'add') {
@@ -113,7 +113,7 @@ var DndWrapper = function DndWrapper(_ref2) {
113
113
  }();
114
114
  var onDragEnd = /*#__PURE__*/function () {
115
115
  var _ref6 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(_ref5) {
116
- var active, over, transformedValue, activeObject, overObject, activeLevel, activeParentId, overLevel, overParentId, nextDataSource, _flatTree, activeIndex, overIndex, nextValue;
116
+ var active, over, transformedValue, activeObject, overObject, activeLevel, activeParentId, overLevel, overParentId, nextDataSource, _nextDataSource, _flatTree, activeIndex, overIndex, nextValue;
117
117
  return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
118
118
  while (1) switch (_context2.prev = _context2.next) {
119
119
  case 0:
@@ -121,7 +121,7 @@ var DndWrapper = function DndWrapper(_ref2) {
121
121
  // 为数据源划分层级及parentId
122
122
  transformedValue = (0, _index.addLevelAndParentId)(value, rowKey); // 同一level层级的且parentId相同的,可以互相之间拖拽替换
123
123
  if (!(active.id !== (over === null || over === void 0 ? void 0 : over.id))) {
124
- _context2.next = 15;
124
+ _context2.next = 20;
125
125
  break;
126
126
  }
127
127
  activeObject = (0, _index.treeNodeFind)(transformedValue, function (t) {
@@ -131,47 +131,51 @@ var DndWrapper = function DndWrapper(_ref2) {
131
131
  return t.rowKey === (over === null || over === void 0 ? void 0 : over.id);
132
132
  });
133
133
  if (!(activeObject && overObject)) {
134
- _context2.next = 15;
134
+ _context2.next = 20;
135
135
  break;
136
136
  }
137
137
  activeLevel = activeObject.level, activeParentId = activeObject.parentId;
138
- overLevel = overObject.level, overParentId = overObject.parentId; // 如果传了onDragEndGuard 则视为外部业务逻辑自处理
138
+ overLevel = overObject.level, overParentId = overObject.parentId;
139
+ nextDataSource = value;
140
+ if (!(activeLevel === overLevel && activeParentId === overParentId)) {
141
+ _context2.next = 20;
142
+ break;
143
+ }
144
+ // 将树平铺
145
+ _flatTree = (0, _index.transformTreeToArray)(transformedValue).map(function (item) {
146
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {
147
+ children: undefined
148
+ });
149
+ });
150
+ activeIndex = _flatTree.findIndex(function (i) {
151
+ return i.rowKey === active.id;
152
+ });
153
+ overIndex = _flatTree.findIndex(function (i) {
154
+ return i.rowKey === (over === null || over === void 0 ? void 0 : over.id);
155
+ });
156
+ nextValue = (0, _sortable.arrayMove)(_flatTree, activeIndex, overIndex);
157
+ nextDataSource = (0, _index.createTreeFromArray)(nextValue, {
158
+ itemKey: 'rowKey',
159
+ parentKey: 'parentId',
160
+ childrenKey: 'children'
161
+ });
162
+ // 如果传了onDragEndGuard 则视为外部业务逻辑自处理
139
163
  if (!(onDragEndGuard && (0, _lodash.isFunction)(onDragEndGuard))) {
140
- _context2.next = 14;
164
+ _context2.next = 19;
141
165
  break;
142
166
  }
143
- _context2.next = 11;
167
+ _context2.next = 18;
144
168
  return onDragEndGuard({
145
169
  activeObject: activeObject,
146
170
  overObject: overObject,
147
- currentDataSource: value
171
+ originDataSource: value,
172
+ currentDataSource: nextDataSource
148
173
  });
149
- case 11:
174
+ case 18:
150
175
  nextDataSource = _context2.sent;
151
- onChange(nextDataSource !== null && nextDataSource !== void 0 ? nextDataSource : []);
152
- return _context2.abrupt("return");
153
- case 14:
154
- if (activeLevel === overLevel && activeParentId === overParentId) {
155
- // 将树平铺
156
- _flatTree = (0, _index.transformTreeToArray)(transformedValue).map(function (item) {
157
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {
158
- children: undefined
159
- });
160
- });
161
- activeIndex = _flatTree.findIndex(function (i) {
162
- return i.rowKey === active.id;
163
- });
164
- overIndex = _flatTree.findIndex(function (i) {
165
- return i.rowKey === (over === null || over === void 0 ? void 0 : over.id);
166
- });
167
- nextValue = (0, _sortable.arrayMove)(_flatTree, activeIndex, overIndex);
168
- onChange((0, _index.createTreeFromArray)(nextValue, {
169
- itemKey: 'rowKey',
170
- parentKey: 'parentId',
171
- childrenKey: 'children'
172
- }));
173
- }
174
- case 15:
176
+ case 19:
177
+ onChange((_nextDataSource = nextDataSource) !== null && _nextDataSource !== void 0 ? _nextDataSource : []);
178
+ case 20:
175
179
  case "end":
176
180
  return _context2.stop();
177
181
  }
@@ -194,6 +194,26 @@ var ProTable = function ProTable(props) {
194
194
  return 'new-cell';
195
195
  }
196
196
  };
197
+ var _formatColumns = function formatColumns(nextColumns) {
198
+ nextColumns === null || nextColumns === void 0 ? void 0 : nextColumns.forEach(function (item, index) {
199
+ (0, _FormatColumn.formatColumn)({
200
+ column: item,
201
+ originalObj: originalObj,
202
+ rowKey: props.rowKey,
203
+ diffConfig: diffConfig,
204
+ wrapToolTipProps: wrapToolTipProps,
205
+ scroll: _scroll,
206
+ onUpdateMinWidth: function onUpdateMinWidth(w) {
207
+ curColumns[index].minWidth = w;
208
+ },
209
+ isInNewRow: _rowClassName
210
+ });
211
+ if (item.children && Array.isArray(item.children)) {
212
+ _formatColumns(item.children);
213
+ }
214
+ });
215
+ return nextColumns;
216
+ };
197
217
  var columns = (0, _react.useMemo)(function () {
198
218
  var newColumns = curColumns.map(function (item, index) {
199
219
  var _propsColumnObj$getCo2;
@@ -215,21 +235,8 @@ var ProTable = function ProTable(props) {
215
235
  }).filter(function (item) {
216
236
  return !(item === null || item === void 0 ? void 0 : item.delete);
217
237
  });
218
- newColumns === null || newColumns === void 0 ? void 0 : newColumns.forEach(function (item, index) {
219
- (0, _FormatColumn.formatColumn)({
220
- column: item,
221
- originalObj: originalObj,
222
- rowKey: props.rowKey,
223
- diffConfig: diffConfig,
224
- wrapToolTipProps: wrapToolTipProps,
225
- scroll: _scroll,
226
- onUpdateMinWidth: function onUpdateMinWidth(w) {
227
- curColumns[index].minWidth = w;
228
- },
229
- isInNewRow: _rowClassName
230
- });
231
- });
232
- return newColumns;
238
+ var nextColumns = _formatColumns(newColumns);
239
+ return nextColumns;
233
240
  }, [curColumns, handleResize, _scroll, originalDataSource, originalObj, _rowClassName]);
234
241
  var _columns = (0, _react.useMemo)(function () {
235
242
  return columns === null || columns === void 0 ? void 0 : columns.filter(function (item, index) {
@@ -19,7 +19,7 @@ export interface ProTableSummaryProps {
19
19
  fixed?: boolean;
20
20
  }
21
21
  export interface ProTableColumn extends Omit<ColumnType<any>, 'dataIndex'> {
22
- dataIndex: string | string[];
22
+ dataIndex?: string | string[];
23
23
  width?: number | string;
24
24
  minWidth?: number;
25
25
  valueType?: ProTableValueType;
@@ -43,8 +43,9 @@ export interface ProTableColumn extends Omit<ColumnType<any>, 'dataIndex'> {
43
43
  /** 自定义比对函数, 触发条件必须写render */
44
44
  onDiff?: ({ value, record, index, originalValue, originalRecord }: any) => any;
45
45
  /** 自定义提示render, 触发条件必须写render */
46
- viewRender?: ({ value, record, index, originalValue, originalRecord }: any) => 'same' | 'changed' | 'add' | undefined;
46
+ viewRender?: ({ value, record, index, originalValue, originalRecord, }: any) => 'same' | 'changed' | 'add' | undefined;
47
47
  isChanged?: boolean | null;
48
+ children?: ProTableColumn[];
48
49
  }
49
50
  export interface CreateTreeFromArrayOptions {
50
51
  itemKey?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.9.4-beta.1",
3
+ "version": "3.9.4-beta.11",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",