@zat-design/sisyphus-react 3.9.4-beta.1 → 3.9.4-beta.10
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/ProEnum/index.js +1 -1
- package/es/ProForm/components/combination/Group/utils.js +1 -1
- package/es/ProTable/components/FormatColumn/index.js +16 -5
- 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/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/ProEnum/index.js +1 -1
- package/lib/ProForm/components/combination/Group/utils.js +1 -1
- package/lib/ProTable/components/FormatColumn/index.js +16 -5
- 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/package.json +1 -1
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;
|
@@ -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,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/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;
|
@@ -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]
|
@@ -129,11 +129,13 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref2) {
|
|
129
129
|
var _value = isFn ? originalRender === null || originalRender === void 0 ? void 0 : originalRender(value, record !== null && record !== void 0 ? record : {}, index) : null;
|
130
130
|
var originalResult = (0, _utils2.getOriginalValue)(value, record !== null && record !== void 0 ? record : {}, originalObj, rowKey, dataIndex);
|
131
131
|
var originalValue = originalResult.originalValue;
|
132
|
+
var _originalValue = originalValue;
|
132
133
|
var isChanged = originalResult.isChanged,
|
133
134
|
isAddCell = originalResult.isAddCell;
|
134
135
|
var isInNewRowFlag = isInNewRow(record);
|
135
136
|
var _isAddCell = isAddCell;
|
136
137
|
otherProps.isChanged = isChanged;
|
138
|
+
var nextValue = value;
|
137
139
|
// 存在比对
|
138
140
|
if ((0, _lodash.isFunction)(otherProps === null || otherProps === void 0 ? void 0 : otherProps.viewRender) && (diffConfig === null || diffConfig === void 0 ? void 0 : diffConfig.originalDataSource)) {
|
139
141
|
var _originalObj$record$r;
|
@@ -145,25 +147,34 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref2) {
|
|
145
147
|
index: index
|
146
148
|
});
|
147
149
|
// viewRender 返回值为 false 时,不显示对比
|
148
|
-
if ((0, _lodash.isBoolean)(diffResult)) {
|
150
|
+
if ((0, _lodash.isBoolean)(diffResult) && !diffResult) {
|
149
151
|
otherProps.isChanged = false;
|
150
152
|
}
|
151
|
-
|
153
|
+
_originalValue = diffResult;
|
154
|
+
nextValue = otherProps.viewRender({
|
155
|
+
originalValue: value,
|
156
|
+
originalRecord: record !== null && record !== void 0 ? record : {},
|
157
|
+
value: value,
|
158
|
+
record: record,
|
159
|
+
index: index
|
160
|
+
});
|
152
161
|
}
|
153
162
|
// 存在自定义onDiff比对
|
154
163
|
if ((0, _lodash.isFunction)(onDiff)) {
|
155
164
|
var _originalObj$record$r2;
|
156
165
|
var _diffResult = onDiff({
|
157
|
-
originalValue:
|
166
|
+
originalValue: _originalValue,
|
158
167
|
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:
|
168
|
+
value: nextValue,
|
160
169
|
record: record,
|
161
170
|
index: index
|
162
171
|
});
|
163
172
|
if (_diffResult === 'changed') {
|
173
|
+
_isAddCell = false;
|
164
174
|
otherProps.isChanged = true;
|
165
175
|
}
|
166
176
|
if (_diffResult === 'same') {
|
177
|
+
_isAddCell = false;
|
167
178
|
otherProps.isChanged = false;
|
168
179
|
}
|
169
180
|
if (_diffResult === 'add') {
|
@@ -173,7 +184,7 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref2) {
|
|
173
184
|
}
|
174
185
|
return (0, _jsxRuntime.jsx)(_RenderColumn.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, otherProps), {}, {
|
175
186
|
valueType: valueType,
|
176
|
-
originalValue: (0, _utils3.isEmpty)(
|
187
|
+
originalValue: (0, _utils3.isEmpty)(_originalValue) ? null : _originalValue,
|
177
188
|
ellipsis: ellipsis,
|
178
189
|
width: width,
|
179
190
|
value: _value,
|
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
|
}
|
package/lib/ProTable/index.js
CHANGED
@@ -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
|
-
|
219
|
-
|
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
|
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;
|