@zat-design/sisyphus-react 3.13.4-beta.5 → 3.13.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/es/ProEditTable/components/RcTable/DraggableTable.js +11 -8
- package/es/ProEditTable/index.js +3 -1
- package/es/ProEditTable/propsType.d.ts +11 -1
- package/es/ProEnum/hooks/useEnum.js +12 -20
- package/es/ProEnum/utils/index.d.ts +26 -1
- package/es/ProEnum/utils/index.js +27 -2
- package/es/ProForm/components/combination/Group/hooks/index.d.ts +20 -0
- package/es/ProForm/components/combination/Group/hooks/index.js +161 -0
- package/es/ProForm/components/combination/Group/index.js +2 -1
- package/es/ProForm/components/combination/Group/utils.d.ts +3 -16
- package/es/ProForm/components/combination/Group/utils.js +2 -160
- package/es/ProUpload/components/ButtonRender.js +3 -0
- package/lib/ProEditTable/components/RcTable/DraggableTable.js +11 -8
- package/lib/ProEditTable/index.js +3 -1
- package/lib/ProEditTable/propsType.d.ts +11 -1
- package/lib/ProEnum/hooks/useEnum.js +12 -21
- package/lib/ProEnum/utils/index.d.ts +26 -1
- package/lib/ProEnum/utils/index.js +27 -2
- package/lib/ProForm/components/combination/Group/hooks/index.d.ts +20 -0
- package/lib/ProForm/components/combination/Group/hooks/index.js +169 -0
- package/lib/ProForm/components/combination/Group/index.js +2 -1
- package/lib/ProForm/components/combination/Group/utils.d.ts +3 -16
- package/lib/ProForm/components/combination/Group/utils.js +2 -161
- package/lib/ProUpload/components/ButtonRender.js +3 -0
- package/package.json +1 -1
@@ -79,17 +79,13 @@ var DndWrapper = function DndWrapper(_ref2) {
|
|
79
79
|
value = _ref2.value,
|
80
80
|
onChange = _ref2.onChange,
|
81
81
|
onDrag = _ref2.onDrag,
|
82
|
+
onDragEnd = _ref2.onDragEnd,
|
82
83
|
disabled = _ref2.disabled,
|
83
84
|
children = _ref2.children;
|
84
|
-
var
|
85
|
+
var onDragEndtInside = function onDragEndtInside(event) {
|
85
86
|
var active = event.active,
|
86
87
|
over = event.over;
|
87
88
|
if (active.id !== (over === null || over === void 0 ? void 0 : over.id)) {
|
88
|
-
if (onDrag) {
|
89
|
-
var nextList = onDrag(event, value);
|
90
|
-
onChange(nextList);
|
91
|
-
return;
|
92
|
-
}
|
93
89
|
var activeIndex = value.findIndex(function (i) {
|
94
90
|
return i.rowKey === active.id;
|
95
91
|
});
|
@@ -97,11 +93,16 @@ var DndWrapper = function DndWrapper(_ref2) {
|
|
97
93
|
return i.rowKey === (over === null || over === void 0 ? void 0 : over.id);
|
98
94
|
});
|
99
95
|
var nextValue = (0, _sortable.arrayMove)(value, activeIndex, overIndex);
|
96
|
+
if (onDrag || onDragEnd) {
|
97
|
+
var nextList = onDragEnd ? onDragEnd(event, value, nextValue) : onDrag(event, value, nextValue);
|
98
|
+
onChange(nextList);
|
99
|
+
return;
|
100
|
+
}
|
100
101
|
onChange(nextValue);
|
101
102
|
}
|
102
103
|
};
|
103
104
|
return draggable && !disabled ? (0, _jsxRuntime.jsx)(_core.DndContext, {
|
104
|
-
onDragEnd:
|
105
|
+
onDragEnd: onDragEndtInside,
|
105
106
|
children: (0, _jsxRuntime.jsx)(_sortable.SortableContext, {
|
106
107
|
items: (value === null || value === void 0 ? void 0 : (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.rowKey) ? value.map(function (i) {
|
107
108
|
return i.rowKey;
|
@@ -137,11 +138,13 @@ var DraggableTable = function DraggableTable(_ref3) {
|
|
137
138
|
handlePageChange = tableProps.handlePageChange;
|
138
139
|
var onChange = draggableProps.onChange,
|
139
140
|
onDrag = draggableProps.onDrag,
|
140
|
-
draggable = draggableProps.draggable
|
141
|
+
draggable = draggableProps.draggable,
|
142
|
+
onDragEnd = draggableProps.onDragEnd;
|
141
143
|
return (0, _jsxRuntime.jsxs)(DndWrapper, {
|
142
144
|
value: value,
|
143
145
|
onChange: onChange,
|
144
146
|
onDrag: onDrag,
|
147
|
+
onDragEnd: onDragEnd,
|
145
148
|
disabled: disabled,
|
146
149
|
draggable: draggable,
|
147
150
|
children: [headerRender ? (0, _jsxRuntime.jsx)("div", {
|
@@ -26,12 +26,13 @@ var _ProForm = _interopRequireDefault(require("../ProForm"));
|
|
26
26
|
var _empty = _interopRequireDefault(require("../assets/empty.png"));
|
27
27
|
var _locale = _interopRequireWildcard(require("../locale"));
|
28
28
|
var _RcTable = require("./components/RcTable");
|
29
|
-
var _excluded = ["value", "onChange", "onDrag", "className", "columns", "type", "mode", "stripe", "draggable", "virtual", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "toolbarSticky", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "rowKey", "rowDisabled", "rowDraggable", "footerRender", "scroll", "actionDirection", "diffConfig"];
|
29
|
+
var _excluded = ["value", "onChange", "onDrag", "onDragEnd", "className", "columns", "type", "mode", "stripe", "draggable", "virtual", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "toolbarSticky", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "rowKey", "rowDisabled", "rowDraggable", "footerRender", "scroll", "actionDirection", "diffConfig"];
|
30
30
|
var ProEditTable = function ProEditTable(_ref, ref) {
|
31
31
|
var _resetProps$id, _resetProps$id$split, _themeConfig$data2, _resetProps$otherProp;
|
32
32
|
var value = _ref.value,
|
33
33
|
onChange = _ref.onChange,
|
34
34
|
onDrag = _ref.onDrag,
|
35
|
+
onDragEnd = _ref.onDragEnd,
|
35
36
|
className = _ref.className,
|
36
37
|
columns = _ref.columns,
|
37
38
|
type = _ref.type,
|
@@ -408,6 +409,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
408
409
|
draggableProps: {
|
409
410
|
onChange: onChange,
|
410
411
|
onDrag: onDrag,
|
412
|
+
onDragEnd: onDragEnd,
|
411
413
|
draggable: draggable
|
412
414
|
},
|
413
415
|
tableProps: {
|
@@ -377,8 +377,18 @@ export interface ProEditTableProps<T = any> extends Omit<TableProps<T>, 'onChang
|
|
377
377
|
rowDraggable?: (record?: T) => string | boolean;
|
378
378
|
/**
|
379
379
|
* 拖拽事件处理
|
380
|
+
* @param event 拖拽事件
|
381
|
+
* @param dataSource 当前数据源
|
382
|
+
* @param nextDataSource 拖拽后的数据源
|
380
383
|
*/
|
381
|
-
onDrag?: (event: DragEndEvent, dataSource: T[]) => T[];
|
384
|
+
onDrag?: (event: DragEndEvent, dataSource: T[], nextDataSource: T[]) => T[];
|
385
|
+
/**
|
386
|
+
* 拖拽结束事件处理
|
387
|
+
* @param event 拖拽事件
|
388
|
+
* @param dataSource 当前数据源
|
389
|
+
* @param nextDataSource 拖拽后的数据源
|
390
|
+
*/
|
391
|
+
onDragEnd?: (event: DragEndEvent, dataSource: T[], nextDataSource: T[]) => T[];
|
382
392
|
/**
|
383
393
|
* 引用对象
|
384
394
|
*/
|
@@ -6,18 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.default = void 0;
|
7
7
|
var _ProConfigProvider = require("../../ProConfigProvider");
|
8
8
|
var _utils = require("../utils");
|
9
|
+
var _ref;
|
9
10
|
/* eslint-disable no-redeclare */
|
10
|
-
|
11
|
-
var baseEnumStorage = null;
|
12
|
-
try {
|
13
|
-
var storedData = window.localStorage.getItem('zat-design-pro-component-cacheKey');
|
14
|
-
if (storedData) {
|
15
|
-
baseEnumStorage = JSON.parse(storedData);
|
16
|
-
}
|
17
|
-
} catch (error) {
|
18
|
-
console.error('解析枚举缓存数据失败', error);
|
19
|
-
baseEnumStorage = null;
|
20
|
-
}
|
11
|
+
var baseEnumStorage = (_ref = window.localStorage.getItem('zat-design-pro-component-cacheKey') && JSON.parse(window.localStorage.getItem('zat-design-pro-component-cacheKey'))) !== null && _ref !== void 0 ? _ref : null;
|
21
12
|
/**
|
22
13
|
* 根据 code 从枚举缓存取出对应的 options 、以及回显
|
23
14
|
* @param codes
|
@@ -26,16 +17,16 @@ try {
|
|
26
17
|
* @returns
|
27
18
|
*/
|
28
19
|
function useEnum(codes, value, compose) {
|
29
|
-
var
|
30
|
-
|
31
|
-
storage =
|
32
|
-
var
|
33
|
-
|
34
|
-
cacheKey =
|
35
|
-
|
36
|
-
fieldNames =
|
37
|
-
|
38
|
-
clear =
|
20
|
+
var _ref2 = (0, _ProConfigProvider.useProConfig)('globalConfig') || {},
|
21
|
+
_ref2$storage = _ref2.storage,
|
22
|
+
storage = _ref2$storage === void 0 ? 'localStorage' : _ref2$storage;
|
23
|
+
var _ref3 = (0, _ProConfigProvider.useProConfig)('ProEnum') || {},
|
24
|
+
_ref3$cacheKey = _ref3.cacheKey,
|
25
|
+
cacheKey = _ref3$cacheKey === void 0 ? 'zat-design-pro-component-cacheKey' : _ref3$cacheKey,
|
26
|
+
_ref3$fieldNames = _ref3.fieldNames,
|
27
|
+
fieldNames = _ref3$fieldNames === void 0 ? {} : _ref3$fieldNames,
|
28
|
+
_ref3$clear = _ref3.clear,
|
29
|
+
clear = _ref3$clear === void 0 ? true : _ref3$clear;
|
39
30
|
var catchData = (0, _utils.getEnumData)(storage, cacheKey, baseEnumStorage);
|
40
31
|
// 默认枚举缓存数据
|
41
32
|
baseEnumStorage = catchData;
|
@@ -11,10 +11,35 @@ interface EnumRes {
|
|
11
11
|
* @param baseEnumStorage
|
12
12
|
* @returns
|
13
13
|
*/
|
14
|
-
export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any
|
14
|
+
export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any): EnumRes;
|
15
|
+
/**
|
16
|
+
* 设置枚举数据
|
17
|
+
* @param storage
|
18
|
+
* @param cacheKey
|
19
|
+
* @param data
|
20
|
+
*/
|
15
21
|
export declare function setEnumData(storage: StorageType, cacheKey: string, data: any): boolean;
|
22
|
+
/**
|
23
|
+
* 判断枚举列表是否存在
|
24
|
+
* @param storage
|
25
|
+
* @param cacheKey
|
26
|
+
* @param code
|
27
|
+
* @returns
|
28
|
+
*/
|
16
29
|
export declare function hasEnumList(storage: StorageType, cacheKey: any, code: string): import("../propsType").DataOptionType[];
|
30
|
+
/**
|
31
|
+
* 判断是否是对象
|
32
|
+
* @param obj
|
33
|
+
* @returns
|
34
|
+
*/
|
17
35
|
export declare function isObject(obj: any): boolean;
|
36
|
+
/**
|
37
|
+
* 合并枚举数据
|
38
|
+
* @param storage
|
39
|
+
* @param code
|
40
|
+
* @param cacheKey
|
41
|
+
* @param responseData
|
42
|
+
*/
|
18
43
|
export declare function mergeCacheData(storage: string, code: string, cacheKey: string, responseData: any): void;
|
19
44
|
/**
|
20
45
|
* diff code 差异
|
@@ -21,8 +21,8 @@ var _excluded = ["children"];
|
|
21
21
|
* @param baseEnumStorage
|
22
22
|
* @returns
|
23
23
|
*/
|
24
|
-
function getEnumData(storage, cacheKey, baseEnumStorage
|
25
|
-
if (baseEnumStorage
|
24
|
+
function getEnumData(storage, cacheKey, baseEnumStorage) {
|
25
|
+
if (baseEnumStorage) {
|
26
26
|
return baseEnumStorage;
|
27
27
|
}
|
28
28
|
if (storage === 'localStorage') {
|
@@ -32,6 +32,12 @@ function getEnumData(storage, cacheKey, baseEnumStorage, dataSource) {
|
|
32
32
|
return JSON.parse(window.sessionStorage.getItem(cacheKey) || '{}');
|
33
33
|
}
|
34
34
|
}
|
35
|
+
/**
|
36
|
+
* 设置枚举数据
|
37
|
+
* @param storage
|
38
|
+
* @param cacheKey
|
39
|
+
* @param data
|
40
|
+
*/
|
35
41
|
function setEnumData(storage, cacheKey, data) {
|
36
42
|
var _Object$keys;
|
37
43
|
if (!((_Object$keys = Object.keys(data === null || data === void 0 ? void 0 : data.data)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length)) {
|
@@ -43,14 +49,33 @@ function setEnumData(storage, cacheKey, data) {
|
|
43
49
|
window.sessionStorage.setItem(cacheKey, JSON.stringify(data));
|
44
50
|
}
|
45
51
|
}
|
52
|
+
/**
|
53
|
+
* 判断枚举列表是否存在
|
54
|
+
* @param storage
|
55
|
+
* @param cacheKey
|
56
|
+
* @param code
|
57
|
+
* @returns
|
58
|
+
*/
|
46
59
|
function hasEnumList(storage, cacheKey, code) {
|
47
60
|
var res = getEnumData(storage, cacheKey);
|
48
61
|
var enumList = (res === null || res === void 0 ? void 0 : res.data) || {};
|
49
62
|
return enumList === null || enumList === void 0 ? void 0 : enumList[code];
|
50
63
|
}
|
64
|
+
/**
|
65
|
+
* 判断是否是对象
|
66
|
+
* @param obj
|
67
|
+
* @returns
|
68
|
+
*/
|
51
69
|
function isObject(obj) {
|
52
70
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
53
71
|
}
|
72
|
+
/**
|
73
|
+
* 合并枚举数据
|
74
|
+
* @param storage
|
75
|
+
* @param code
|
76
|
+
* @param cacheKey
|
77
|
+
* @param responseData
|
78
|
+
*/
|
54
79
|
function mergeCacheData(storage, code, cacheKey, responseData) {
|
55
80
|
var _window, _window2;
|
56
81
|
var cacheStorage = storage === 'localStorage' ? 'localStorage' : 'sessionStorage';
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
|
2
|
+
import { FormInstance } from 'antd';
|
3
|
+
import type { GroupColumnType, GroupType } from '../propsType';
|
4
|
+
export type EventArgs = any[];
|
5
|
+
interface ColumnsTransformerParams {
|
6
|
+
columns: GroupColumnType[];
|
7
|
+
name?: NamePath;
|
8
|
+
names?: NamePath[];
|
9
|
+
value?: any[];
|
10
|
+
onChange: any;
|
11
|
+
namePath?: InternalNamePath;
|
12
|
+
form: FormInstance;
|
13
|
+
index?: number;
|
14
|
+
formDisabled?: boolean;
|
15
|
+
desensitizationKey?: string;
|
16
|
+
groupProps: GroupType;
|
17
|
+
}
|
18
|
+
/** 转换columns */
|
19
|
+
export declare const useTransformColumns: (params: ColumnsTransformerParams) => any[];
|
20
|
+
export {};
|
@@ -0,0 +1,169 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports.useTransformColumns = void 0;
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
10
|
+
var _react = require("react");
|
11
|
+
var _lodash = require("lodash");
|
12
|
+
var _useDeepCompareMemo = require("../../../../utils/useDeepCompareMemo");
|
13
|
+
var _tools = require("../../../../../ProEditTable/utils/tools");
|
14
|
+
var _utils = require("../utils");
|
15
|
+
/* eslint-disable no-lonely-if */
|
16
|
+
|
17
|
+
/** 转换columns */
|
18
|
+
var useTransformColumns = exports.useTransformColumns = function useTransformColumns(params) {
|
19
|
+
var form = params.form,
|
20
|
+
columns = params.columns,
|
21
|
+
name = params.name,
|
22
|
+
names = params.names,
|
23
|
+
outerIndex = params.index,
|
24
|
+
namePath = params.namePath,
|
25
|
+
value = params.value,
|
26
|
+
internalChange = params.onChange,
|
27
|
+
groupProps = params.groupProps,
|
28
|
+
formDisabled = params.formDisabled,
|
29
|
+
desensitizationKey = params.desensitizationKey;
|
30
|
+
var timerRef = (0, _react.useRef)([]);
|
31
|
+
return columns === null || columns === void 0 ? void 0 : columns.flatMap(function (column, index) {
|
32
|
+
var type = column.type,
|
33
|
+
valueType = column.valueType,
|
34
|
+
switchValue = column.switchValue,
|
35
|
+
toISOString = column.toISOString,
|
36
|
+
toCSTString = column.toCSTString,
|
37
|
+
fieldProps = column.fieldProps,
|
38
|
+
normalize = column.normalize,
|
39
|
+
disabled = column.disabled,
|
40
|
+
show = column.show,
|
41
|
+
component = column.component,
|
42
|
+
clearNotShow = column.clearNotShow,
|
43
|
+
desensitization = column.desensitization;
|
44
|
+
var _ref = fieldProps || {},
|
45
|
+
mode = _ref.mode,
|
46
|
+
onChange = _ref.onChange,
|
47
|
+
onFieldChange = _ref.onFieldChange,
|
48
|
+
comDisabled = _ref.disabled,
|
49
|
+
onBlur = _ref.onBlur;
|
50
|
+
var _disabled = disabled || comDisabled;
|
51
|
+
var columnName = names ? names[index] : [].concat(name, index);
|
52
|
+
// 响应式字段改变后的回调
|
53
|
+
var changedCallback = function changedCallback(lastDependency, current) {
|
54
|
+
// 清值防抖 多次刷新时以最后一次为准
|
55
|
+
if (clearNotShow !== false && names) {
|
56
|
+
if ((current === null || current === void 0 ? void 0 : current.show) === false) {
|
57
|
+
clearInterval(timerRef.current[index]);
|
58
|
+
timerRef.current[index] = setTimeout(function () {
|
59
|
+
if (names) {
|
60
|
+
form.resetFields([columnName]);
|
61
|
+
}
|
62
|
+
if (!names && (value === null || value === void 0 ? void 0 : value.length)) {
|
63
|
+
value[index] = null;
|
64
|
+
form.setFieldValue(columnName, (0, _toConsumableArray2.default)(value));
|
65
|
+
}
|
66
|
+
}, 200);
|
67
|
+
} else {
|
68
|
+
clearInterval(timerRef.current[index]);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
};
|
72
|
+
// 响应式字段
|
73
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
74
|
+
var reactiveProps = (0, _useDeepCompareMemo.useDeepCompareMemo)(function () {
|
75
|
+
return (0, _utils.getReactiveProps)({
|
76
|
+
form: form,
|
77
|
+
index: index,
|
78
|
+
type: type,
|
79
|
+
namePath: namePath,
|
80
|
+
disabled: _disabled,
|
81
|
+
show: show,
|
82
|
+
component: component,
|
83
|
+
fieldProps: fieldProps,
|
84
|
+
name: columnName,
|
85
|
+
desensitization: desensitization
|
86
|
+
});
|
87
|
+
}, changedCallback, [value, show, fieldProps, _disabled, columnName, type]);
|
88
|
+
if (reactiveProps.show === false) {
|
89
|
+
return [];
|
90
|
+
}
|
91
|
+
var transform = (0, _utils.getValueTypeTrans)({
|
92
|
+
type: type,
|
93
|
+
valueType: valueType,
|
94
|
+
switchValue: switchValue,
|
95
|
+
toISOString: toISOString,
|
96
|
+
toCSTString: toCSTString,
|
97
|
+
mode: mode
|
98
|
+
});
|
99
|
+
var newValue;
|
100
|
+
var handleChange = function handleChange() {
|
101
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
102
|
+
args[_key] = arguments[_key];
|
103
|
+
}
|
104
|
+
newValue = (0, _utils.valueFromEventWrapper)(column, args);
|
105
|
+
if (transform === null || transform === void 0 ? void 0 : transform.normalize) {
|
106
|
+
var _transform$normalize;
|
107
|
+
newValue = transform === null || transform === void 0 ? void 0 : (_transform$normalize = transform.normalize) === null || _transform$normalize === void 0 ? void 0 : _transform$normalize.call(transform, newValue);
|
108
|
+
} else if (normalize) {
|
109
|
+
// @ts-ignore
|
110
|
+
newValue = normalize === null || normalize === void 0 ? void 0 : normalize(newValue);
|
111
|
+
}
|
112
|
+
internalChange === null || internalChange === void 0 ? void 0 : internalChange(newValue, args[1], index);
|
113
|
+
var values = form.getFieldValue(namePath);
|
114
|
+
var originRow = (namePath === null || namePath === void 0 ? void 0 : namePath.length) ? (0, _lodash.cloneDeep)(values) : undefined;
|
115
|
+
onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, args);
|
116
|
+
onFieldChange === null || onFieldChange === void 0 ? void 0 : onFieldChange(newValue, values, {
|
117
|
+
index: outerIndex,
|
118
|
+
namePath: namePath,
|
119
|
+
form: form,
|
120
|
+
option: args === null || args === void 0 ? void 0 : args[1]
|
121
|
+
});
|
122
|
+
// 如果是在可编辑表格或formList内部, 储存当前行的值, 并在变更后更新到表单里
|
123
|
+
if ((namePath === null || namePath === void 0 ? void 0 : namePath.length) && !(0, _lodash.isEqual)(originRow, values)) {
|
124
|
+
var _Object$keys, _Object$keys$map;
|
125
|
+
form.setFieldValue(namePath, values);
|
126
|
+
var diff = (0, _tools.difference)(originRow, values) || {};
|
127
|
+
var 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) {
|
128
|
+
return [].concat((0, _toConsumableArray2.default)(namePath), [key]);
|
129
|
+
});
|
130
|
+
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
131
|
+
setTimeout(function () {
|
132
|
+
form.validateFields([name].concat((0, _toConsumableArray2.default)(validateFieldKeys)));
|
133
|
+
}, 100);
|
134
|
+
}
|
135
|
+
}
|
136
|
+
};
|
137
|
+
var handleBlur = function handleBlur() {
|
138
|
+
if (!onBlur) return;
|
139
|
+
var values = form.getFieldValue(namePath);
|
140
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
141
|
+
args[_key2] = arguments[_key2];
|
142
|
+
}
|
143
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(args[0], values, {
|
144
|
+
index: outerIndex,
|
145
|
+
namePath: namePath,
|
146
|
+
form: form,
|
147
|
+
option: args === null || args === void 0 ? void 0 : args[1]
|
148
|
+
});
|
149
|
+
};
|
150
|
+
// 内外一个为true则为true
|
151
|
+
var getLastDisabled = function getLastDisabled() {
|
152
|
+
if (Array.isArray(groupProps.disabled)) {
|
153
|
+
return reactiveProps.disabled || groupProps.disabled[index];
|
154
|
+
}
|
155
|
+
return reactiveProps.disabled || groupProps.disabled;
|
156
|
+
};
|
157
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, column), {}, {
|
158
|
+
name: columnName
|
159
|
+
}, reactiveProps), {}, {
|
160
|
+
disabled: getLastDisabled(),
|
161
|
+
getValueProps: transform === null || transform === void 0 ? void 0 : transform.getValueProps,
|
162
|
+
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), {}, {
|
163
|
+
onChange: handleChange,
|
164
|
+
onBlur: handleBlur,
|
165
|
+
value: value === null || value === void 0 ? void 0 : value[index]
|
166
|
+
})
|
167
|
+
});
|
168
|
+
});
|
169
|
+
};
|
@@ -14,6 +14,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
14
14
|
var _lodash = require("lodash");
|
15
15
|
var _classnames2 = _interopRequireDefault(require("classnames"));
|
16
16
|
var _utils = require("./utils");
|
17
|
+
var _hooks = require("./hooks");
|
17
18
|
var _ProForm = _interopRequireDefault(require("../../../../ProForm"));
|
18
19
|
var _ComRender = _interopRequireDefault(require("./component/ComRender"));
|
19
20
|
/**
|
@@ -52,7 +53,7 @@ var Group = function Group(props) {
|
|
52
53
|
_option.current[index] = option;
|
53
54
|
onChange(_value, _option.current);
|
54
55
|
};
|
55
|
-
var columnsProps = (0,
|
56
|
+
var columnsProps = (0, _hooks.useTransformColumns)({
|
56
57
|
columns: children,
|
57
58
|
name: name,
|
58
59
|
names: names,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
|
3
3
|
import { FormInstance } from 'antd';
|
4
|
-
import type { GroupColumnType,
|
4
|
+
import type { GroupColumnType, SpaceType } from './propsType';
|
5
5
|
import type { ProFormColumnType, ReactiveFunction } from '../../render/propsType';
|
6
6
|
export type EventArgs = any[];
|
7
7
|
/**
|
@@ -50,19 +50,6 @@ type ValueTypeGetterParams = Pick<ProFormColumnType, 'valueType' | 'switchValue'
|
|
50
50
|
export declare const getValueTypeTrans: (params: ValueTypeGetterParams) => any;
|
51
51
|
/** 执行所有中间件 返回处理后的值 */
|
52
52
|
export declare const getValueMiddleware: (value: any, callbacks?: any[]) => any;
|
53
|
-
|
54
|
-
|
55
|
-
name?: NamePath;
|
56
|
-
names?: NamePath[];
|
57
|
-
value?: any[];
|
58
|
-
onChange: any;
|
59
|
-
namePath?: InternalNamePath;
|
60
|
-
form: FormInstance;
|
61
|
-
index?: number;
|
62
|
-
formDisabled?: boolean;
|
63
|
-
desensitizationKey?: string;
|
64
|
-
groupProps: GroupType;
|
65
|
-
}
|
66
|
-
/** 转换columns */
|
67
|
-
export declare const useTransformColumns: (params: ColumnsTransformerParams) => any[];
|
53
|
+
/** 获取中间件处理后的value */
|
54
|
+
export declare const valueFromEventWrapper: (column: any, args: any) => any;
|
68
55
|
export {};
|
@@ -5,20 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
6
6
|
});
|
7
7
|
exports.defaultGetValueFromEvent = defaultGetValueFromEvent;
|
8
|
-
exports.
|
9
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
8
|
+
exports.valueFromEventWrapper = exports.transformNamesString = exports.isUpperCase = exports.insertSeparator = exports.getValueTypeTrans = exports.getValueMiddleware = exports.getReactiveProps = void 0;
|
10
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
11
10
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
12
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
13
|
-
var _react = require("react");
|
14
12
|
var _lodash = require("lodash");
|
15
13
|
var _utils = require("@zat-design/utils");
|
16
14
|
var _antd = require("antd");
|
17
15
|
var _valueType = _interopRequireDefault(require("../../../utils/valueType"));
|
18
|
-
var _useDeepCompareMemo = require("../../../utils/useDeepCompareMemo");
|
19
|
-
var _tools = require("../../../../ProEditTable/utils/tools");
|
20
|
-
/* eslint-disable no-lonely-if */
|
21
|
-
|
22
16
|
/**
|
23
17
|
* 插入间隔符
|
24
18
|
* @param columns 表单配置数组
|
@@ -185,7 +179,7 @@ var getValueMiddleware = exports.getValueMiddleware = function getValueMiddlewar
|
|
185
179
|
}, value);
|
186
180
|
};
|
187
181
|
/** 获取中间件处理后的value */
|
188
|
-
var valueFromEventWrapper = function valueFromEventWrapper(column, args) {
|
182
|
+
var valueFromEventWrapper = exports.valueFromEventWrapper = function valueFromEventWrapper(column, args) {
|
189
183
|
var getValueFromEvent = column.getValueFromEvent,
|
190
184
|
_column$valuePropName = column.valuePropName,
|
191
185
|
valuePropName = _column$valuePropName === void 0 ? 'value' : _column$valuePropName,
|
@@ -201,157 +195,4 @@ var valueFromEventWrapper = function valueFromEventWrapper(column, args) {
|
|
201
195
|
if (trim) list.push(getTrim);
|
202
196
|
if (upperCase) list.push(getUpperCase);
|
203
197
|
return getValueMiddleware(newValue, list);
|
204
|
-
};
|
205
|
-
/** 转换columns */
|
206
|
-
var useTransformColumns = exports.useTransformColumns = function useTransformColumns(params) {
|
207
|
-
var form = params.form,
|
208
|
-
columns = params.columns,
|
209
|
-
name = params.name,
|
210
|
-
names = params.names,
|
211
|
-
outerIndex = params.index,
|
212
|
-
namePath = params.namePath,
|
213
|
-
value = params.value,
|
214
|
-
internalChange = params.onChange,
|
215
|
-
groupProps = params.groupProps,
|
216
|
-
formDisabled = params.formDisabled,
|
217
|
-
desensitizationKey = params.desensitizationKey;
|
218
|
-
var timerRef = (0, _react.useRef)([]);
|
219
|
-
return columns === null || columns === void 0 ? void 0 : columns.flatMap(function (column, index) {
|
220
|
-
var type = column.type,
|
221
|
-
valueType = column.valueType,
|
222
|
-
switchValue = column.switchValue,
|
223
|
-
toISOString = column.toISOString,
|
224
|
-
toCSTString = column.toCSTString,
|
225
|
-
fieldProps = column.fieldProps,
|
226
|
-
normalize = column.normalize,
|
227
|
-
disabled = column.disabled,
|
228
|
-
show = column.show,
|
229
|
-
component = column.component,
|
230
|
-
clearNotShow = column.clearNotShow,
|
231
|
-
desensitization = column.desensitization;
|
232
|
-
var _ref = fieldProps || {},
|
233
|
-
mode = _ref.mode,
|
234
|
-
onChange = _ref.onChange,
|
235
|
-
onFieldChange = _ref.onFieldChange,
|
236
|
-
comDisabled = _ref.disabled,
|
237
|
-
onBlur = _ref.onBlur;
|
238
|
-
var _disabled = disabled || comDisabled;
|
239
|
-
var columnName = names ? names[index] : [].concat(name, index);
|
240
|
-
// 响应式字段改变后的回调
|
241
|
-
var changedCallback = function changedCallback(lastDependency, current) {
|
242
|
-
// 清值防抖 多次刷新时以最后一次为准
|
243
|
-
if (clearNotShow !== false && names) {
|
244
|
-
if ((current === null || current === void 0 ? void 0 : current.show) === false) {
|
245
|
-
clearInterval(timerRef.current[index]);
|
246
|
-
timerRef.current[index] = setTimeout(function () {
|
247
|
-
if (names) {
|
248
|
-
form.resetFields([columnName]);
|
249
|
-
}
|
250
|
-
if (!names && (value === null || value === void 0 ? void 0 : value.length)) {
|
251
|
-
value[index] = null;
|
252
|
-
form.setFieldValue(columnName, (0, _toConsumableArray2.default)(value));
|
253
|
-
}
|
254
|
-
}, 200);
|
255
|
-
} else {
|
256
|
-
clearInterval(timerRef.current[index]);
|
257
|
-
}
|
258
|
-
}
|
259
|
-
};
|
260
|
-
// 响应式字段
|
261
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
262
|
-
var reactiveProps = (0, _useDeepCompareMemo.useDeepCompareMemo)(function () {
|
263
|
-
return getReactiveProps({
|
264
|
-
form: form,
|
265
|
-
index: index,
|
266
|
-
type: type,
|
267
|
-
namePath: namePath,
|
268
|
-
disabled: _disabled,
|
269
|
-
show: show,
|
270
|
-
component: component,
|
271
|
-
fieldProps: fieldProps,
|
272
|
-
name: columnName,
|
273
|
-
desensitization: desensitization
|
274
|
-
});
|
275
|
-
}, changedCallback, [value, show, fieldProps, _disabled, columnName, type]);
|
276
|
-
if (reactiveProps.show === false) {
|
277
|
-
return [];
|
278
|
-
}
|
279
|
-
var transform = getValueTypeTrans({
|
280
|
-
type: type,
|
281
|
-
valueType: valueType,
|
282
|
-
switchValue: switchValue,
|
283
|
-
toISOString: toISOString,
|
284
|
-
toCSTString: toCSTString,
|
285
|
-
mode: mode
|
286
|
-
});
|
287
|
-
var newValue;
|
288
|
-
var handleChange = function handleChange() {
|
289
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
290
|
-
args[_key] = arguments[_key];
|
291
|
-
}
|
292
|
-
newValue = valueFromEventWrapper(column, args);
|
293
|
-
if (transform === null || transform === void 0 ? void 0 : transform.normalize) {
|
294
|
-
var _transform$normalize;
|
295
|
-
newValue = transform === null || transform === void 0 ? void 0 : (_transform$normalize = transform.normalize) === null || _transform$normalize === void 0 ? void 0 : _transform$normalize.call(transform, newValue);
|
296
|
-
} else if (normalize) {
|
297
|
-
// @ts-ignore
|
298
|
-
newValue = normalize === null || normalize === void 0 ? void 0 : normalize(newValue);
|
299
|
-
}
|
300
|
-
internalChange === null || internalChange === void 0 ? void 0 : internalChange(newValue, args[1], index);
|
301
|
-
var values = form.getFieldValue(namePath);
|
302
|
-
var originRow = (namePath === null || namePath === void 0 ? void 0 : namePath.length) ? (0, _lodash.cloneDeep)(values) : undefined;
|
303
|
-
onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, args);
|
304
|
-
onFieldChange === null || onFieldChange === void 0 ? void 0 : onFieldChange(newValue, values, {
|
305
|
-
index: outerIndex,
|
306
|
-
namePath: namePath,
|
307
|
-
form: form,
|
308
|
-
option: args === null || args === void 0 ? void 0 : args[1]
|
309
|
-
});
|
310
|
-
// 如果是在可编辑表格或formList内部, 储存当前行的值, 并在变更后更新到表单里
|
311
|
-
if ((namePath === null || namePath === void 0 ? void 0 : namePath.length) && !(0, _lodash.isEqual)(originRow, values)) {
|
312
|
-
var _Object$keys, _Object$keys$map;
|
313
|
-
form.setFieldValue(namePath, values);
|
314
|
-
var diff = (0, _tools.difference)(originRow, values) || {};
|
315
|
-
var 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) {
|
316
|
-
return [].concat((0, _toConsumableArray2.default)(namePath), [key]);
|
317
|
-
});
|
318
|
-
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
319
|
-
setTimeout(function () {
|
320
|
-
form.validateFields([name].concat((0, _toConsumableArray2.default)(validateFieldKeys)));
|
321
|
-
}, 100);
|
322
|
-
}
|
323
|
-
}
|
324
|
-
};
|
325
|
-
var handleBlur = function handleBlur() {
|
326
|
-
if (!onBlur) return;
|
327
|
-
var values = form.getFieldValue(namePath);
|
328
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
329
|
-
args[_key2] = arguments[_key2];
|
330
|
-
}
|
331
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur(args[0], values, {
|
332
|
-
index: outerIndex,
|
333
|
-
namePath: namePath,
|
334
|
-
form: form,
|
335
|
-
option: args === null || args === void 0 ? void 0 : args[1]
|
336
|
-
});
|
337
|
-
};
|
338
|
-
// 内外一个为true则为true
|
339
|
-
var getLastDisabled = function getLastDisabled() {
|
340
|
-
if (Array.isArray(groupProps.disabled)) {
|
341
|
-
return reactiveProps.disabled || groupProps.disabled[index];
|
342
|
-
}
|
343
|
-
return reactiveProps.disabled || groupProps.disabled;
|
344
|
-
};
|
345
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, column), {}, {
|
346
|
-
name: columnName
|
347
|
-
}, reactiveProps), {}, {
|
348
|
-
disabled: getLastDisabled(),
|
349
|
-
getValueProps: transform === null || transform === void 0 ? void 0 : transform.getValueProps,
|
350
|
-
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), {}, {
|
351
|
-
onChange: handleChange,
|
352
|
-
onBlur: handleBlur,
|
353
|
-
value: value === null || value === void 0 ? void 0 : value[index]
|
354
|
-
})
|
355
|
-
});
|
356
|
-
});
|
357
198
|
};
|