@zat-design/sisyphus-react 3.9.4 → 3.9.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/extensions.json +5 -0
- package/dist/index.esm.css +42 -1
- package/dist/less.esm.css +38 -0
- package/es/ProEditTable/components/RenderField/ListChangedWrapper.d.ts +1 -1
- package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +13 -10
- package/es/ProEditTable/components/RenderField/index.js +42 -32
- package/es/ProEditTable/propsType.d.ts +1 -0
- package/es/ProEditTable/style/index.less +41 -0
- package/es/ProEditTable/utils/diffOriginal.d.ts +21 -0
- package/es/ProEditTable/utils/diffOriginal.js +65 -0
- package/es/ProEnum/index.js +1 -1
- package/es/ProForm/components/combination/Group/component/ComRender.js +9 -1
- package/es/ProForm/components/combination/Group/index.js +1 -1
- package/es/ProForm/components/combination/Group/utils.js +1 -1
- package/es/ProForm/style/index.less +8 -0
- package/es/ProForm/utils/diffOriginal.js +11 -8
- package/es/ProTable/components/FormatColumn/index.js +1 -1
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +36 -32
- package/es/ProTable/index.js +22 -15
- package/es/ProTable/propsType.d.ts +3 -2
- package/es/style/theme/antd.less +4 -1
- package/lib/ProEditTable/components/RenderField/ListChangedWrapper.d.ts +1 -1
- package/lib/ProEditTable/components/RenderField/ListChangedWrapper.js +13 -10
- package/lib/ProEditTable/components/RenderField/index.js +42 -32
- package/lib/ProEditTable/propsType.d.ts +1 -0
- package/lib/ProEditTable/style/index.less +41 -0
- package/lib/ProEditTable/utils/diffOriginal.d.ts +21 -0
- package/lib/ProEditTable/utils/diffOriginal.js +71 -0
- package/lib/ProEnum/index.js +1 -1
- package/lib/ProForm/components/combination/Group/component/ComRender.js +8 -0
- package/lib/ProForm/components/combination/Group/index.js +1 -1
- package/lib/ProForm/components/combination/Group/utils.js +1 -1
- package/lib/ProForm/style/index.less +8 -0
- package/lib/ProForm/utils/diffOriginal.js +11 -8
- package/lib/ProTable/components/FormatColumn/index.js +1 -1
- package/lib/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +36 -32
- package/lib/ProTable/index.js +22 -15
- package/lib/ProTable/propsType.d.ts +3 -2
- package/lib/style/theme/antd.less +4 -1
- package/package.json +1 -1
package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js
CHANGED
@@ -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 =
|
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 =
|
127
|
+
_context2.next = 20;
|
128
128
|
break;
|
129
129
|
}
|
130
130
|
activeLevel = activeObject.level, activeParentId = activeObject.parentId;
|
131
|
-
overLevel = overObject.level, overParentId = overObject.parentId;
|
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 =
|
157
|
+
_context2.next = 19;
|
134
158
|
break;
|
135
159
|
}
|
136
|
-
_context2.next =
|
160
|
+
_context2.next = 18;
|
137
161
|
return onDragEndGuard({
|
138
162
|
activeObject: activeObject,
|
139
163
|
overObject: overObject,
|
140
|
-
|
164
|
+
originDataSource: value,
|
165
|
+
currentDataSource: nextDataSource
|
141
166
|
});
|
142
|
-
case
|
167
|
+
case 18:
|
143
168
|
nextDataSource = _context2.sent;
|
144
|
-
|
145
|
-
|
146
|
-
case
|
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
|
}
|
package/es/ProTable/index.js
CHANGED
@@ -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
|
-
|
212
|
-
|
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
|
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/es/style/theme/antd.less
CHANGED
@@ -753,6 +753,9 @@
|
|
753
753
|
}
|
754
754
|
|
755
755
|
.@{ant-prefix}-picker.@{ant-prefix}-picker-disabled {
|
756
|
-
background: var(--zaui-disabled-bg);
|
756
|
+
background: var(--zaui-disabled-bg) !important;
|
757
757
|
}
|
758
758
|
|
759
|
+
.@{ant-prefix}-input-affix-wrapper-disabled {
|
760
|
+
background: var(--zaui-disabled-bg) !important;
|
761
|
+
}
|
@@ -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 '
|
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("
|
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
|
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
|
-
|
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)(
|
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)(
|
65
|
+
originalValue = (0, _lodash.get)(originRecord, originalName.slice(rowKeyPath.length - 1));
|
66
66
|
}
|
67
67
|
return {
|
68
68
|
originalValue: originalValue,
|
69
|
-
|
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
|
-
|
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
|
-
|
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.
|
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", "
|
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,11 +59,11 @@ 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,
|
66
65
|
confirm = column.confirm,
|
66
|
+
dependencies = column.dependencies,
|
67
67
|
resetProps = (0, _objectWithoutProperties2.default)(column, _excluded);
|
68
68
|
// editRender弃用使用component同ProForm
|
69
69
|
var _editRender = component || editRender;
|
@@ -319,6 +319,8 @@ var RenderField = function RenderField(_ref) {
|
|
319
319
|
_key2,
|
320
320
|
_args,
|
321
321
|
rowPath,
|
322
|
+
_dependencies$map,
|
323
|
+
validateFieldKeys,
|
322
324
|
row,
|
323
325
|
orgRow,
|
324
326
|
_TargetComponent,
|
@@ -330,77 +332,85 @@ var RenderField = function RenderField(_ref) {
|
|
330
332
|
_Object$keys,
|
331
333
|
_Object$keys$map,
|
332
334
|
diff,
|
333
|
-
|
335
|
+
_validateFieldKeys,
|
334
336
|
_args2 = arguments;
|
335
337
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
336
338
|
while (1) switch (_context.prev = _context.next) {
|
337
339
|
case 0:
|
338
|
-
if (!(!onFieldChange && !onChange)) {
|
339
|
-
_context.next = 2;
|
340
|
-
break;
|
341
|
-
}
|
342
|
-
return _context.abrupt("return", null);
|
343
|
-
case 2:
|
344
340
|
for (_len2 = _args2.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
345
341
|
args[_key2] = _args2[_key2];
|
346
342
|
}
|
347
343
|
_args = [].concat(args);
|
348
344
|
rowPath = [].concat((0, _toConsumableArray2.default)(namePath), [index]);
|
349
|
-
|
345
|
+
if (!(!onFieldChange && !onChange)) {
|
346
|
+
_context.next = 6;
|
347
|
+
break;
|
348
|
+
}
|
349
|
+
if (dependencies === null || dependencies === void 0 ? void 0 : dependencies.length) {
|
350
|
+
validateFieldKeys = dependencies === null || dependencies === void 0 ? void 0 : (_dependencies$map = dependencies.map) === null || _dependencies$map === void 0 ? void 0 : _dependencies$map.call(dependencies, function (key) {
|
351
|
+
return [].concat((0, _toConsumableArray2.default)(rowPath), [key]);
|
352
|
+
});
|
353
|
+
setTimeout(function () {
|
354
|
+
form.validateFields(validateFieldKeys);
|
355
|
+
}, 100);
|
356
|
+
}
|
357
|
+
return _context.abrupt("return", null);
|
358
|
+
case 6:
|
359
|
+
row = form.getFieldValue(rowPath, true);
|
350
360
|
orgRow = (0, _lodash.cloneDeep)(row);
|
351
361
|
if (!onFieldChange) {
|
352
|
-
_context.next =
|
362
|
+
_context.next = 21;
|
353
363
|
break;
|
354
364
|
}
|
355
365
|
_args = formatArgs(args);
|
356
366
|
_args[1] = row;
|
357
367
|
_context.t0 = (_TargetComponent = TargetComponent) === null || _TargetComponent === void 0 ? void 0 : (_TargetComponent$prop = _TargetComponent.props) === null || _TargetComponent$prop === void 0 ? void 0 : _TargetComponent$prop.onFieldChange;
|
358
368
|
if (!_context.t0) {
|
359
|
-
_context.next =
|
369
|
+
_context.next = 15;
|
360
370
|
break;
|
361
371
|
}
|
362
|
-
_context.next =
|
372
|
+
_context.next = 15;
|
363
373
|
return (_TargetComponent$prop2 = TargetComponent.props).onFieldChange.apply(_TargetComponent$prop2, (0, _toConsumableArray2.default)(_args));
|
364
|
-
case
|
374
|
+
case 15:
|
365
375
|
_context.t1 = onFieldChange;
|
366
376
|
if (!_context.t1) {
|
367
|
-
_context.next =
|
377
|
+
_context.next = 19;
|
368
378
|
break;
|
369
379
|
}
|
370
|
-
_context.next =
|
380
|
+
_context.next = 19;
|
371
381
|
return onFieldChange.apply(void 0, (0, _toConsumableArray2.default)(_args));
|
372
|
-
case
|
373
|
-
_context.next =
|
382
|
+
case 19:
|
383
|
+
_context.next = 30;
|
374
384
|
break;
|
375
|
-
case
|
385
|
+
case 21:
|
376
386
|
_args = _args.concat([row, index, form]);
|
377
387
|
_context.t2 = (_TargetComponent2 = TargetComponent) === null || _TargetComponent2 === void 0 ? void 0 : (_TargetComponent2$pro = _TargetComponent2.props) === null || _TargetComponent2$pro === void 0 ? void 0 : _TargetComponent2$pro.onChange;
|
378
388
|
if (!_context.t2) {
|
379
|
-
_context.next =
|
389
|
+
_context.next = 26;
|
380
390
|
break;
|
381
391
|
}
|
382
|
-
_context.next =
|
392
|
+
_context.next = 26;
|
383
393
|
return (_TargetComponent$prop3 = TargetComponent.props).onChange.apply(_TargetComponent$prop3, (0, _toConsumableArray2.default)(_args));
|
384
|
-
case
|
394
|
+
case 26:
|
385
395
|
_context.t3 = onChange;
|
386
396
|
if (!_context.t3) {
|
387
|
-
_context.next =
|
397
|
+
_context.next = 30;
|
388
398
|
break;
|
389
399
|
}
|
390
|
-
_context.next =
|
400
|
+
_context.next = 30;
|
391
401
|
return onChange.apply(void 0, (0, _toConsumableArray2.default)(_args));
|
392
|
-
case
|
402
|
+
case 30:
|
393
403
|
// 判断属性是否变动
|
394
404
|
form.setFieldValue(rowPath, row);
|
395
405
|
if (validateTrigger && validateTrigger.includes('onChange')) {
|
396
406
|
if (!(0, _lodash.isEqual)(orgRow, row)) {
|
397
407
|
diff = (0, _tools.difference)(row, orgRow) || {};
|
398
|
-
|
408
|
+
_validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
|
399
409
|
return [].concat((0, _toConsumableArray2.default)(rowPath), [key]);
|
400
|
-
});
|
401
|
-
if (
|
410
|
+
}).concat(dependencies || []);
|
411
|
+
if (_validateFieldKeys === null || _validateFieldKeys === void 0 ? void 0 : _validateFieldKeys.length) {
|
402
412
|
setTimeout(function () {
|
403
|
-
form.validateFields(
|
413
|
+
form.validateFields(_validateFieldKeys);
|
404
414
|
}, 100);
|
405
415
|
}
|
406
416
|
}
|
@@ -410,7 +420,7 @@ var RenderField = function RenderField(_ref) {
|
|
410
420
|
d: Date.now()
|
411
421
|
}
|
412
422
|
});
|
413
|
-
case
|
423
|
+
case 33:
|
414
424
|
case "end":
|
415
425
|
return _context.stop();
|
416
426
|
}
|
@@ -471,7 +481,7 @@ var RenderField = function RenderField(_ref) {
|
|
471
481
|
diff = (0, _tools.difference)(row, orgRow) || {};
|
472
482
|
validateFieldKeys = (_Object$keys2 = Object.keys(diff)) === null || _Object$keys2 === void 0 ? void 0 : (_Object$keys2$map = _Object$keys2.map) === null || _Object$keys2$map === void 0 ? void 0 : _Object$keys2$map.call(_Object$keys2, function (key) {
|
473
483
|
return [].concat((0, _toConsumableArray2.default)(rowPath), [key]);
|
474
|
-
});
|
484
|
+
}).concat(dependencies || []);
|
475
485
|
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
476
486
|
debounceValidate(validateFieldKeys);
|
477
487
|
}
|
@@ -564,7 +574,7 @@ var RenderField = function RenderField(_ref) {
|
|
564
574
|
originalNames: originalNames,
|
565
575
|
originalValues: originalValues,
|
566
576
|
form: form,
|
567
|
-
equalWith: onDiff
|
577
|
+
equalWith: onDiff,
|
568
578
|
type: type,
|
569
579
|
onChange: _onChange,
|
570
580
|
valuePropName: _formItemProps.valuePropName,
|
@@ -106,6 +106,7 @@ export interface ProColumnsProps<Values = any, T = any> extends Omit<FormItemPro
|
|
106
106
|
hiddenNames?: NamePath[] | NamePath[][];
|
107
107
|
rules?: ProRule[] | RulesFn<T>;
|
108
108
|
confirm?: boolean | ModalFuncProps | FunctionArgs<Values, boolean | ModalFuncProps | void>;
|
109
|
+
dependencies?: NamePath[];
|
109
110
|
onDiff?: DiffOriginalParams['equalWith'];
|
110
111
|
[key: string]: any;
|
111
112
|
}
|
@@ -305,6 +305,47 @@
|
|
305
305
|
background-color: var(--zaui-contract-bg-add, #d2fff4) !important;
|
306
306
|
}
|
307
307
|
}
|
308
|
+
|
309
|
+
* {
|
310
|
+
// ie浏览器
|
311
|
+
scrollbar-face-color: #d2d3d7;
|
312
|
+
scrollbar-highlight-color: #979797;
|
313
|
+
scrollbar-3dlight-color: #979797;
|
314
|
+
|
315
|
+
// 悬浮轨道
|
316
|
+
::-webkit-scrollbar-thumb {
|
317
|
+
background-color: #979797;
|
318
|
+
background-clip: padding-box;
|
319
|
+
border-color: transparent;
|
320
|
+
border-style: dashed;
|
321
|
+
border-width: 4px;
|
322
|
+
border-radius: 10px;
|
323
|
+
-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0);
|
324
|
+
}
|
325
|
+
|
326
|
+
::-webkit-scrollbar-track {
|
327
|
+
background: transparent;
|
328
|
+
}
|
329
|
+
|
330
|
+
::-webkit-scrollbar-thumb {
|
331
|
+
background-color: #d2d3d7;
|
332
|
+
background-clip: padding-box;
|
333
|
+
border-color: transparent;
|
334
|
+
border-style: dashed;
|
335
|
+
border-width: 4px;
|
336
|
+
border-radius: 10px;
|
337
|
+
-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0);
|
338
|
+
}
|
339
|
+
|
340
|
+
::-webkit-scrollbar-thumb {
|
341
|
+
background-color: #979797;
|
342
|
+
}
|
343
|
+
|
344
|
+
::-webkit-scrollbar-track {
|
345
|
+
background: transparent;
|
346
|
+
}
|
347
|
+
}
|
348
|
+
|
308
349
|
}
|
309
350
|
|
310
351
|
.pro-edit-table-footer{
|
@@ -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,71 @@
|
|
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
|
+
if ((_originalValue === null || _originalValue === void 0 ? void 0 : _originalValue.length) === (_value === null || _value === void 0 ? void 0 : _value.length)) {
|
56
|
+
var isSame = _originalValue.every(function (valueItem, index) {
|
57
|
+
// 如果两个值有一个不是空值, 则进行深比较
|
58
|
+
if (!isEmpty(value === null || value === void 0 ? void 0 : value[index]) || !isEmpty(valueItem)) {
|
59
|
+
return (0, _lodash.isEqual)(value === null || value === void 0 ? void 0 : value[index], valueItem);
|
60
|
+
}
|
61
|
+
return true;
|
62
|
+
});
|
63
|
+
return isSame ? 'same' : 'changed';
|
64
|
+
}
|
65
|
+
return 'changed';
|
66
|
+
}
|
67
|
+
if (!isEmpty(_originalValue) || !isEmpty(_value)) {
|
68
|
+
return (0, _lodash.isEqual)(_value, _originalValue) ? 'same' : 'changed';
|
69
|
+
}
|
70
|
+
return 'same';
|
71
|
+
};
|
package/lib/ProEnum/index.js
CHANGED
@@ -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,13 @@ 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
|
+
var _props$component2, _props$component2$pro;
|
65
|
+
return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
66
|
+
children: [" ", props === null || props === void 0 ? void 0 : (_props$component2 = props.component) === null || _props$component2 === void 0 ? void 0 : (_props$component2$pro = _props$component2.props) === null || _props$component2$pro === void 0 ? void 0 : _props$component2$pro.children, " "]
|
67
|
+
});
|
68
|
+
}
|
61
69
|
if (viewRender && isView) {
|
62
70
|
return (0, _jsxRuntime.jsx)(_useFieldProps.FieldProvider, {
|
63
71
|
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]
|