@zat-design/sisyphus-react 3.9.4-beta.1 → 3.9.4-beta.3
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/coverage/lcov-report/src/.umi/core/devScripts.ts.html +241 -0
- package/coverage/lcov-report/src/.umi/core/history.ts.html +148 -0
- package/coverage/lcov-report/src/.umi/core/index.html +206 -0
- package/coverage/lcov-report/src/.umi/core/plugin.ts.html +109 -0
- package/coverage/lcov-report/src/.umi/core/pluginRegister.ts.html +160 -0
- package/coverage/lcov-report/src/.umi/core/polyfill.ts.html +97 -0
- package/coverage/lcov-report/src/.umi/core/routes.ts.html +26050 -0
- package/coverage/lcov-report/src/.umi/core/umiExports.ts.html +112 -0
- package/coverage/lcov-report/src/.umi/dumi/demos/index.html +116 -0
- package/coverage/lcov-report/src/.umi/dumi/demos/index.ts.html +6340 -0
- package/coverage/lcov-report/src/.umi/dumi/index.html +116 -0
- package/coverage/lcov-report/src/.umi/dumi/layout.tsx.html +109 -0
- package/coverage/lcov-report/src/.umi/index.html +116 -0
- package/coverage/lcov-report/src/.umi/plugin-antd/index.html +116 -0
- package/coverage/lcov-report/src/.umi/plugin-antd/runtime.tsx.html +172 -0
- package/coverage/lcov-report/src/.umi/plugin-helmet/exports.ts.html +94 -0
- package/coverage/lcov-report/src/.umi/plugin-helmet/index.html +116 -0
- package/coverage/lcov-report/src/.umi/plugin-initial-state/Provider.tsx.html +196 -0
- package/coverage/lcov-report/src/.umi/plugin-initial-state/exports.ts.html +106 -0
- package/coverage/lcov-report/src/.umi/plugin-initial-state/index.html +146 -0
- package/coverage/lcov-report/src/.umi/plugin-initial-state/models/index.html +116 -0
- package/coverage/lcov-report/src/.umi/plugin-initial-state/models/initialState.ts.html +88 -0
- package/coverage/lcov-report/src/.umi/plugin-initial-state/runtime.tsx.html +124 -0
- package/coverage/lcov-report/src/.umi/plugin-locale/SelectLang.tsx.html +1246 -0
- package/coverage/lcov-report/src/.umi/plugin-locale/index.html +161 -0
- package/coverage/lcov-report/src/.umi/plugin-locale/locale.tsx.html +268 -0
- package/coverage/lcov-report/src/.umi/plugin-locale/localeExports.ts.html +778 -0
- package/coverage/lcov-report/src/.umi/plugin-locale/runtime.tsx.html +115 -0
- package/coverage/lcov-report/src/.umi/plugin-model/Provider.tsx.html +202 -0
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/constant.tsx.html +97 -0
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/dispatcher.tsx.html +142 -0
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/executor.tsx.html +334 -0
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/index.html +146 -0
- package/coverage/lcov-report/src/.umi/plugin-model/index.html +146 -0
- package/coverage/lcov-report/src/.umi/plugin-model/runtime.tsx.html +121 -0
- package/coverage/lcov-report/src/.umi/plugin-model/useModel.tsx.html +298 -0
- package/coverage/lcov-report/src/.umi/plugin-request/index.html +116 -0
- package/coverage/lcov-report/src/.umi/plugin-request/request.ts.html +919 -0
- package/coverage/lcov-report/src/.umi/umi.ts.html +268 -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 +2 -3
- package/es/ProEditTable/utils/diffOriginal.d.ts +21 -0
- package/es/ProEditTable/utils/diffOriginal.js +62 -0
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +36 -32
- 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 +2 -3
- package/lib/ProEditTable/utils/diffOriginal.d.ts +21 -0
- package/lib/ProEditTable/utils/diffOriginal.js +68 -0
- package/lib/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +36 -32
- package/package.json +1 -1
@@ -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,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
|
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
|
+
};
|
package/lib/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js
CHANGED
@@ -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 =
|
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 =
|
134
|
+
_context2.next = 20;
|
135
135
|
break;
|
136
136
|
}
|
137
137
|
activeLevel = activeObject.level, activeParentId = activeObject.parentId;
|
138
|
-
overLevel = overObject.level, overParentId = overObject.parentId;
|
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 =
|
164
|
+
_context2.next = 19;
|
141
165
|
break;
|
142
166
|
}
|
143
|
-
_context2.next =
|
167
|
+
_context2.next = 18;
|
144
168
|
return onDragEndGuard({
|
145
169
|
activeObject: activeObject,
|
146
170
|
overObject: overObject,
|
147
|
-
|
171
|
+
originDataSource: value,
|
172
|
+
currentDataSource: nextDataSource
|
148
173
|
});
|
149
|
-
case
|
174
|
+
case 18:
|
150
175
|
nextDataSource = _context2.sent;
|
151
|
-
|
152
|
-
|
153
|
-
case
|
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
|
}
|