@zat-design/sisyphus-react 3.6.2 → 3.6.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/dist/index.esm.css +3 -3
- package/dist/less.esm.css +3 -3
- package/es/ProEditTable/components/ActionButton/index.js +4 -4
- package/es/ProEditTable/components/RenderToolbar/index.js +12 -22
- package/es/ProEditTable/utils/index.js +14 -23
- package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +2 -4
- package/es/ProForm/components/combination/FormList/index.js +5 -0
- package/es/ProForm/components/combination/ProCascader/index.js +43 -15
- package/es/ProForm/components/combination/ProCascader/style/index.less +3 -3
- package/es/ProForm/components/render/Render.js +1 -1
- package/es/ProLayout/index.js +5 -2
- package/es/ProLayout/propTypes.d.ts +4 -0
- package/es/ProLayout/utils/index.d.ts +2 -2
- package/es/ProLayout/utils/index.js +6 -4
- package/es/ProSelect/utils/index.js +3 -2
- package/es/ProStep/components/Listener/index.js +3 -8
- package/es/ProStep/index.js +48 -73
- package/lib/ProEditTable/components/ActionButton/index.js +4 -4
- package/lib/ProEditTable/components/RenderToolbar/index.js +12 -22
- package/lib/ProEditTable/utils/index.js +14 -23
- package/lib/ProForm/components/combination/FormList/components/ToolbarButton.js +2 -4
- package/lib/ProForm/components/combination/FormList/index.js +5 -0
- package/lib/ProForm/components/combination/ProCascader/index.js +42 -14
- package/lib/ProForm/components/combination/ProCascader/style/index.less +3 -3
- package/lib/ProForm/components/render/Render.js +1 -1
- package/lib/ProLayout/index.js +5 -2
- package/lib/ProLayout/propTypes.d.ts +4 -0
- package/lib/ProLayout/utils/index.d.ts +2 -2
- package/lib/ProLayout/utils/index.js +6 -4
- package/lib/ProSelect/utils/index.js +3 -2
- package/lib/ProStep/components/Listener/index.js +3 -8
- package/lib/ProStep/index.js +46 -71
- package/package.json +1 -1
- package/es/ProWaterMark/__snapshots__/index.test.tsx.snap +0 -7
- package/lib/ProWaterMark/__snapshots__/index.test.tsx.snap +0 -7
package/es/ProStep/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
3
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
6
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
7
7
|
var _excluded = ["children"];
|
|
8
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
-
import { createContext, useContext,
|
|
10
|
-
import {
|
|
9
|
+
import { createContext, useContext, useMemo, useRef, useState } from 'react';
|
|
10
|
+
import { useSetState, useLocalStorageState, useDeepCompareEffect } from 'ahooks';
|
|
11
11
|
import { handleScroll } from './utils';
|
|
12
12
|
import Step from './components/Step';
|
|
13
13
|
import Item from './components/Item';
|
|
@@ -20,21 +20,16 @@ export var useStep = function useStep() {
|
|
|
20
20
|
var ProStep = function ProStep(_ref) {
|
|
21
21
|
var children = _ref.children,
|
|
22
22
|
resetProps = _objectWithoutProperties(_ref, _excluded);
|
|
23
|
-
var
|
|
23
|
+
var _useState = useState([]),
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
ids = _useState2[0],
|
|
26
|
+
setIds = _useState2[1];
|
|
24
27
|
var _useSetState = useSetState({}),
|
|
25
28
|
_useSetState2 = _slicedToArray(_useSetState, 2),
|
|
26
29
|
errorCollection = _useSetState2[0],
|
|
27
30
|
setErrorCollection = _useSetState2[1];
|
|
28
31
|
// 注册子节点id与title映射的集合
|
|
29
32
|
var registerMap = useRef({});
|
|
30
|
-
var _useState = useState([]),
|
|
31
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
-
anchorIds = _useState2[0],
|
|
33
|
-
setAnchorIds = _useState2[1];
|
|
34
|
-
var _useState3 = useState(false),
|
|
35
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
36
|
-
loading = _useState4[0],
|
|
37
|
-
setLoading = _useState4[1];
|
|
38
33
|
var _useLocalStorageState = useLocalStorageState('cache-pro-step'),
|
|
39
34
|
_useLocalStorageState2 = _slicedToArray(_useLocalStorageState, 2),
|
|
40
35
|
setLocalData = _useLocalStorageState2[1];
|
|
@@ -43,7 +38,6 @@ var ProStep = function ProStep(_ref) {
|
|
|
43
38
|
collapse = _resetProps$collapse === void 0 ? false : _resetProps$collapse,
|
|
44
39
|
_resetProps$scrollToE = resetProps.scrollToError,
|
|
45
40
|
scrollToError = _resetProps$scrollToE === void 0 ? true : _resetProps$scrollToE;
|
|
46
|
-
var values = {};
|
|
47
41
|
var dataSource = useMemo(function () {
|
|
48
42
|
var _Object$entries, _Object$entries$map;
|
|
49
43
|
if (resetProps === null || resetProps === void 0 ? void 0 : resetProps.dataSource) {
|
|
@@ -61,14 +55,14 @@ var ProStep = function ProStep(_ref) {
|
|
|
61
55
|
order: order
|
|
62
56
|
};
|
|
63
57
|
}).filter(function (item) {
|
|
64
|
-
|
|
58
|
+
var _ids$includes;
|
|
59
|
+
return ids === null || ids === void 0 ? void 0 : (_ids$includes = ids.includes) === null || _ids$includes === void 0 ? void 0 : _ids$includes.call(ids, item.code);
|
|
65
60
|
}).sort(function (pre, next) {
|
|
66
61
|
return pre.order - next.order;
|
|
67
62
|
});
|
|
68
|
-
}, [resetProps === null || resetProps === void 0 ? void 0 : resetProps.dataSource, registerMap.current,
|
|
63
|
+
}, [resetProps === null || resetProps === void 0 ? void 0 : resetProps.dataSource, registerMap.current, ids]);
|
|
69
64
|
// 用来注册form匹配到对应的模块id
|
|
70
65
|
var register = function register(_ref4) {
|
|
71
|
-
var _registerMap$current;
|
|
72
66
|
var id = _ref4.id,
|
|
73
67
|
form = _ref4.form,
|
|
74
68
|
title = _ref4.title,
|
|
@@ -78,18 +72,23 @@ var ProStep = function ProStep(_ref) {
|
|
|
78
72
|
var record = {};
|
|
79
73
|
record.title = title;
|
|
80
74
|
record.order = order;
|
|
75
|
+
if (!ids.includes(id)) {
|
|
76
|
+
setIds(function (preState) {
|
|
77
|
+
return [].concat(_toConsumableArray(preState), [id]);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
81
80
|
if (disabled) {
|
|
82
81
|
registerMap.current[id] = record;
|
|
83
82
|
return null;
|
|
84
83
|
}
|
|
85
84
|
var subEvent = /*#__PURE__*/function () {
|
|
86
85
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
87
|
-
var
|
|
86
|
+
var value, _form$validateFields, _error$errorFields;
|
|
88
87
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
89
88
|
while (1) switch (_context.prev = _context.next) {
|
|
90
89
|
case 0:
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
_context.prev = 0;
|
|
91
|
+
value = null;
|
|
93
92
|
if (!validator) {
|
|
94
93
|
_context.next = 8;
|
|
95
94
|
break;
|
|
@@ -97,58 +96,60 @@ var ProStep = function ProStep(_ref) {
|
|
|
97
96
|
_context.next = 5;
|
|
98
97
|
return validator === null || validator === void 0 ? void 0 : validator();
|
|
99
98
|
case 5:
|
|
100
|
-
|
|
99
|
+
value = _context.sent;
|
|
101
100
|
_context.next = 11;
|
|
102
101
|
break;
|
|
103
102
|
case 8:
|
|
104
103
|
_context.next = 10;
|
|
105
104
|
return form === null || form === void 0 ? void 0 : (_form$validateFields = form.validateFields) === null || _form$validateFields === void 0 ? void 0 : _form$validateFields.call(form);
|
|
106
105
|
case 10:
|
|
107
|
-
|
|
106
|
+
value = _context.sent;
|
|
108
107
|
case 11:
|
|
109
|
-
|
|
110
|
-
_context.next = 21;
|
|
111
|
-
break;
|
|
108
|
+
return _context.abrupt("return", value);
|
|
112
109
|
case 14:
|
|
113
110
|
_context.prev = 14;
|
|
114
|
-
_context.t0 = _context["catch"](
|
|
115
|
-
|
|
116
|
-
if (num) {
|
|
117
|
-
setLocalData(false);
|
|
111
|
+
_context.t0 = _context["catch"](0);
|
|
112
|
+
if (_context.t0 === null || _context.t0 === void 0 ? void 0 : (_error$errorFields = _context.t0.errorFields) === null || _error$errorFields === void 0 ? void 0 : _error$errorFields.length) {
|
|
118
113
|
console.error(_context.t0);
|
|
114
|
+
setLocalData(false);
|
|
119
115
|
}
|
|
120
|
-
setErrorCollection(_defineProperty({}, id, num));
|
|
121
|
-
setLoading(false);
|
|
122
116
|
return _context.abrupt("return", _context.t0);
|
|
123
|
-
case
|
|
124
|
-
return _context.abrupt("return", values[id]);
|
|
125
|
-
case 22:
|
|
117
|
+
case 18:
|
|
126
118
|
case "end":
|
|
127
119
|
return _context.stop();
|
|
128
120
|
}
|
|
129
|
-
}, _callee, null, [[
|
|
121
|
+
}, _callee, null, [[0, 14]]);
|
|
130
122
|
}));
|
|
131
123
|
return function subEvent() {
|
|
132
124
|
return _ref5.apply(this, arguments);
|
|
133
125
|
};
|
|
134
126
|
}();
|
|
135
127
|
record.subEvent = subEvent;
|
|
136
|
-
|
|
137
|
-
registerMap.current[id] = record;
|
|
138
|
-
}
|
|
139
|
-
emitter.useSubscription(subEvent);
|
|
128
|
+
registerMap.current[id] = record;
|
|
140
129
|
};
|
|
141
130
|
var notify = /*#__PURE__*/function () {
|
|
142
131
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
132
|
+
var events, res, nextErrorCollection;
|
|
143
133
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
144
134
|
while (1) switch (_context2.prev = _context2.next) {
|
|
145
135
|
case 0:
|
|
146
|
-
|
|
136
|
+
events = Object.values(registerMap.current).map(function (item) {
|
|
137
|
+
var _item$subEvent;
|
|
138
|
+
return item === null || item === void 0 ? void 0 : (_item$subEvent = item.subEvent) === null || _item$subEvent === void 0 ? void 0 : _item$subEvent.call(item);
|
|
139
|
+
});
|
|
147
140
|
_context2.next = 3;
|
|
148
|
-
return
|
|
141
|
+
return Promise.all(events);
|
|
149
142
|
case 3:
|
|
150
|
-
|
|
151
|
-
|
|
143
|
+
res = _context2.sent;
|
|
144
|
+
nextErrorCollection = {};
|
|
145
|
+
Object.keys(registerMap.current).forEach(function (id, index) {
|
|
146
|
+
var _ref7 = (res === null || res === void 0 ? void 0 : res[index]) || {},
|
|
147
|
+
errorFields = _ref7.errorFields;
|
|
148
|
+
nextErrorCollection[id] = (errorFields === null || errorFields === void 0 ? void 0 : errorFields.length) || 0;
|
|
149
|
+
});
|
|
150
|
+
setErrorCollection(nextErrorCollection);
|
|
151
|
+
return _context2.abrupt("return", res);
|
|
152
|
+
case 8:
|
|
152
153
|
case "end":
|
|
153
154
|
return _context2.stop();
|
|
154
155
|
}
|
|
@@ -158,37 +159,16 @@ var ProStep = function ProStep(_ref) {
|
|
|
158
159
|
return _ref6.apply(this, arguments);
|
|
159
160
|
};
|
|
160
161
|
}();
|
|
161
|
-
var handleListenerDom = function handleListenerDom() {
|
|
162
|
-
var targetElement = document.getElementById('pro-step');
|
|
163
|
-
var observer = new MutationObserver(function (mutations) {
|
|
164
|
-
mutations.forEach(function (mutation) {
|
|
165
|
-
// 处理 DOM 树变化的逻辑
|
|
166
|
-
var Anchors = document.getElementsByClassName('pro-step-item') || [];
|
|
167
|
-
// 当前页面所存在的所有折叠项
|
|
168
|
-
var nextAnchorIds = [];
|
|
169
|
-
Array.prototype.slice.call(Anchors).forEach(function (dom) {
|
|
170
|
-
var id = dom.getAttribute('id');
|
|
171
|
-
nextAnchorIds.push(id);
|
|
172
|
-
});
|
|
173
|
-
setAnchorIds(nextAnchorIds);
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
var config = {
|
|
177
|
-
subtree: true,
|
|
178
|
-
childList: true // 是否观察子元素的添加或删除
|
|
179
|
-
};
|
|
180
|
-
observer.observe(targetElement, config);
|
|
181
|
-
};
|
|
182
162
|
var triggerTo = /*#__PURE__*/function () {
|
|
183
|
-
var
|
|
163
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(keys) {
|
|
184
164
|
var events, result, nextErrorCollection;
|
|
185
165
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
186
166
|
while (1) switch (_context3.prev = _context3.next) {
|
|
187
167
|
case 0:
|
|
188
168
|
events = [];
|
|
189
169
|
keys === null || keys === void 0 ? void 0 : keys.forEach(function (key) {
|
|
190
|
-
var _registerMap$
|
|
191
|
-
events.push(registerMap === null || registerMap === void 0 ? void 0 : (_registerMap$
|
|
170
|
+
var _registerMap$current, _registerMap$current$, _registerMap$current$2;
|
|
171
|
+
events.push(registerMap === null || registerMap === void 0 ? void 0 : (_registerMap$current = registerMap.current) === null || _registerMap$current === void 0 ? void 0 : (_registerMap$current$ = _registerMap$current[key]) === null || _registerMap$current$ === void 0 ? void 0 : (_registerMap$current$2 = _registerMap$current$.subEvent) === null || _registerMap$current$2 === void 0 ? void 0 : _registerMap$current$2.call(_registerMap$current$));
|
|
192
172
|
});
|
|
193
173
|
_context3.next = 4;
|
|
194
174
|
return Promise.all(events);
|
|
@@ -211,7 +191,7 @@ var ProStep = function ProStep(_ref) {
|
|
|
211
191
|
}, _callee3);
|
|
212
192
|
}));
|
|
213
193
|
return function triggerTo(_x) {
|
|
214
|
-
return
|
|
194
|
+
return _ref8.apply(this, arguments);
|
|
215
195
|
};
|
|
216
196
|
}();
|
|
217
197
|
useDeepCompareEffect(function () {
|
|
@@ -230,18 +210,13 @@ var ProStep = function ProStep(_ref) {
|
|
|
230
210
|
});
|
|
231
211
|
}
|
|
232
212
|
}, [errorCollection, dataSource]);
|
|
233
|
-
useEffect(function () {
|
|
234
|
-
handleListenerDom();
|
|
235
|
-
}, []);
|
|
236
213
|
return _jsx(ProStepContext.Provider, {
|
|
237
214
|
value: {
|
|
238
215
|
collapse: collapse,
|
|
239
216
|
register: register,
|
|
240
217
|
notify: notify,
|
|
241
218
|
triggerTo: triggerTo,
|
|
242
|
-
handleScroll: handleScroll
|
|
243
|
-
loading: loading,
|
|
244
|
-
setLoading: setLoading
|
|
219
|
+
handleScroll: handleScroll
|
|
245
220
|
},
|
|
246
221
|
children: _jsxs("div", {
|
|
247
222
|
className: "pro-step-wrapper",
|
|
@@ -64,7 +64,7 @@ var ActionButton = function ActionButton(_ref) {
|
|
|
64
64
|
// 其他操作按钮Props
|
|
65
65
|
var actionBtnProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, btnConfig.buttonProps), {}, {
|
|
66
66
|
onClick: function onClick() {
|
|
67
|
-
btnConfig.onEvent(record, index);
|
|
67
|
+
btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
|
|
68
68
|
},
|
|
69
69
|
disabled: getDisabled((_btnConfig$buttonProp3 = btnConfig.buttonProps) === null || _btnConfig$buttonProp3 === void 0 ? void 0 : _btnConfig$buttonProp3.disabled)
|
|
70
70
|
});
|
|
@@ -81,7 +81,7 @@ var ActionButton = function ActionButton(_ref) {
|
|
|
81
81
|
placement: "topRight",
|
|
82
82
|
title: deleteMsgMap[btnConfig.type],
|
|
83
83
|
onConfirm: function onConfirm() {
|
|
84
|
-
btnConfig.onEvent(record, index);
|
|
84
|
+
btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
|
|
85
85
|
},
|
|
86
86
|
disabled: isDisabled,
|
|
87
87
|
okText: _locale.default.ProEditTable.confirm,
|
|
@@ -101,13 +101,13 @@ var ActionButton = function ActionButton(_ref) {
|
|
|
101
101
|
index: index,
|
|
102
102
|
disabled: isDisabled,
|
|
103
103
|
onClick: function onClick() {
|
|
104
|
-
btnConfig.onEvent(record, index);
|
|
104
|
+
btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
|
|
105
105
|
}
|
|
106
106
|
}))) : (0, _jsxRuntime.jsx)(_antd.Button, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(delBtnProps, ['buttonProps', 'isEditable'])), {}, {
|
|
107
107
|
disabled: isDisabled,
|
|
108
108
|
type: "link",
|
|
109
109
|
onClick: function onClick() {
|
|
110
|
-
btnConfig.onEvent(record, index);
|
|
110
|
+
btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
|
|
111
111
|
},
|
|
112
112
|
children: btnConfig.label
|
|
113
113
|
}))
|
|
@@ -79,37 +79,27 @@ var RenderToolbar = function RenderToolbar(config) {
|
|
|
79
79
|
toolbar.needConfirm = needConfirm !== null && needConfirm !== void 0 ? needConfirm : true;
|
|
80
80
|
toolbar.onEvent = /*#__PURE__*/function () {
|
|
81
81
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(record, index) {
|
|
82
|
-
var _yield$onEvent;
|
|
83
82
|
var onEvent, result;
|
|
84
83
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
|
85
84
|
while (1) switch (_context.prev = _context.next) {
|
|
86
85
|
case 0:
|
|
87
86
|
onEvent = onClick || onHandle;
|
|
88
|
-
|
|
87
|
+
if (onEvent) {
|
|
88
|
+
_context.next = 5;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
result = true;
|
|
92
|
+
_context.next = 8;
|
|
93
|
+
break;
|
|
94
|
+
case 5:
|
|
95
|
+
_context.next = 7;
|
|
89
96
|
return onEvent === null || onEvent === void 0 ? void 0 : onEvent(selectedRows, dataSource, {
|
|
90
97
|
form: form,
|
|
91
98
|
namePath: virtualName
|
|
92
99
|
});
|
|
93
|
-
case 3:
|
|
94
|
-
_context.t1 = _yield$onEvent = _context.sent;
|
|
95
|
-
_context.t0 = _context.t1 !== null;
|
|
96
|
-
if (!_context.t0) {
|
|
97
|
-
_context.next = 7;
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
_context.t0 = _yield$onEvent !== void 0;
|
|
101
100
|
case 7:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
_context.t2 = _yield$onEvent;
|
|
107
|
-
_context.next = 12;
|
|
108
|
-
break;
|
|
109
|
-
case 11:
|
|
110
|
-
_context.t2 = true;
|
|
111
|
-
case 12:
|
|
112
|
-
result = _context.t2;
|
|
101
|
+
result = _context.sent;
|
|
102
|
+
case 8:
|
|
113
103
|
if (result && type !== 'custom') {
|
|
114
104
|
_config.actions[type]((0, _objectSpread2.default)((0, _objectSpread2.default)({}, config), {}, {
|
|
115
105
|
index: index,
|
|
@@ -119,7 +109,7 @@ var RenderToolbar = function RenderToolbar(config) {
|
|
|
119
109
|
virtualName: virtualName
|
|
120
110
|
}));
|
|
121
111
|
}
|
|
122
|
-
case
|
|
112
|
+
case 9:
|
|
123
113
|
case "end":
|
|
124
114
|
return _context.stop();
|
|
125
115
|
}
|
|
@@ -83,7 +83,7 @@ var getActionColumn = function getActionColumn(config) {
|
|
|
83
83
|
action.needConfirm = needConfirm !== null && needConfirm !== void 0 ? needConfirm : true;
|
|
84
84
|
action.onEvent = /*#__PURE__*/function () {
|
|
85
85
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(record, index) {
|
|
86
|
-
var _form$getFieldValue
|
|
86
|
+
var _form$getFieldValue;
|
|
87
87
|
var rowName, _record, onEvent, result;
|
|
88
88
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
|
89
89
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -109,31 +109,22 @@ var getActionColumn = function getActionColumn(config) {
|
|
|
109
109
|
// 编辑状态使用自定义form值,非编辑状态直接使用行数据
|
|
110
110
|
_record = (_form$getFieldValue = form.getFieldValue(rowName)) !== null && _form$getFieldValue !== void 0 ? _form$getFieldValue : record; // 新增事件可以设置初始默认值,当做函数的出参导出
|
|
111
111
|
onEvent = onClick || onHandle;
|
|
112
|
-
|
|
112
|
+
if (onEvent) {
|
|
113
|
+
_context.next = 18;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
result = true;
|
|
117
|
+
_context.next = 21;
|
|
118
|
+
break;
|
|
119
|
+
case 18:
|
|
120
|
+
_context.next = 20;
|
|
113
121
|
return onEvent === null || onEvent === void 0 ? void 0 : onEvent(_record, index, {
|
|
114
122
|
form: form,
|
|
115
123
|
namePath: virtualRowName
|
|
116
124
|
});
|
|
117
|
-
case 16:
|
|
118
|
-
_context.t2 = _yield$onEvent = _context.sent;
|
|
119
|
-
_context.t1 = _context.t2 !== null;
|
|
120
|
-
if (!_context.t1) {
|
|
121
|
-
_context.next = 20;
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
_context.t1 = _yield$onEvent !== void 0;
|
|
125
125
|
case 20:
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
_context.t3 = _yield$onEvent;
|
|
131
|
-
_context.next = 25;
|
|
132
|
-
break;
|
|
133
|
-
case 24:
|
|
134
|
-
_context.t3 = true;
|
|
135
|
-
case 25:
|
|
136
|
-
result = _context.t3;
|
|
126
|
+
result = _context.sent;
|
|
127
|
+
case 21:
|
|
137
128
|
if (result && type !== 'custom') {
|
|
138
129
|
_config.actions[type]((0, _objectSpread2.default)((0, _objectSpread2.default)({}, config), {}, {
|
|
139
130
|
rowName: [].concat((0, _toConsumableArray2.default)(name), [index]),
|
|
@@ -143,7 +134,7 @@ var getActionColumn = function getActionColumn(config) {
|
|
|
143
134
|
validateKeys: validateKeys
|
|
144
135
|
}));
|
|
145
136
|
}
|
|
146
|
-
case
|
|
137
|
+
case 22:
|
|
147
138
|
case "end":
|
|
148
139
|
return _context.stop();
|
|
149
140
|
}
|
|
@@ -208,7 +199,7 @@ var transformColumns = exports.transformColumns = function transformColumns() {
|
|
|
208
199
|
setState = config.setState,
|
|
209
200
|
page = config.page;
|
|
210
201
|
var isCell = mode === 'cell';
|
|
211
|
-
var _columns = (0,
|
|
202
|
+
var _columns = (0, _lodash.cloneDeep)(columns);
|
|
212
203
|
var _cacheMap = (0, _objectSpread2.default)({}, cacheMap.current);
|
|
213
204
|
var pageNum = _utils.tools.calc(page.pageNum, '-', 1);
|
|
214
205
|
var firstIndex = _utils.tools.calc(pageNum, '*', page.pageSize);
|
|
@@ -21,10 +21,8 @@ var _excluded = ["label", "onClick", "onHandle", "type"],
|
|
|
21
21
|
var actions = {
|
|
22
22
|
add: {
|
|
23
23
|
onClick: function onClick(value, _ref) {
|
|
24
|
-
var operation = _ref.operation
|
|
25
|
-
|
|
26
|
-
namePath = _ref.namePath;
|
|
27
|
-
operation.add();
|
|
24
|
+
var operation = _ref.operation;
|
|
25
|
+
operation.add({});
|
|
28
26
|
},
|
|
29
27
|
label: "".concat(_locale.default.ProForm.formListActions[5]),
|
|
30
28
|
icon: (0, _jsxRuntime.jsx)(_icons.PlusOutlined, {})
|
|
@@ -11,6 +11,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
11
11
|
var _react = require("react");
|
|
12
12
|
var _antd = require("antd");
|
|
13
13
|
var _core = require("@dnd-kit/core");
|
|
14
|
+
var _lodash = require("lodash");
|
|
14
15
|
var _sortable = require("@dnd-kit/sortable");
|
|
15
16
|
var _utils = require("../../../utils");
|
|
16
17
|
var _utils2 = require("./utils");
|
|
@@ -61,6 +62,10 @@ var FormList = function FormList(props, ref) {
|
|
|
61
62
|
listName: [].concat((0, _toConsumableArray2.default)(namePath), [item.name]),
|
|
62
63
|
label: mode === 'less' ? undefined : item.label
|
|
63
64
|
});
|
|
65
|
+
// 可编辑表格的columns需要消除引用关系,防止串数据
|
|
66
|
+
if (column.type === 'ProEditTable' && !(0, _lodash.isFunction)(column.fieldProps)) {
|
|
67
|
+
column.fieldProps.columns = (0, _lodash.cloneDeep)(column.fieldProps.columns);
|
|
68
|
+
}
|
|
64
69
|
return column;
|
|
65
70
|
});
|
|
66
71
|
}, [columns]);
|
|
@@ -181,20 +181,6 @@ var ProCascader = function ProCascader(props) {
|
|
|
181
181
|
return option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1;
|
|
182
182
|
});
|
|
183
183
|
};
|
|
184
|
-
var handleAddressChange = function handleAddressChange(e) {
|
|
185
|
-
var cascaderValue = value === null || value === void 0 ? void 0 : value.slice(0, realLevel);
|
|
186
|
-
if (onChange) {
|
|
187
|
-
if (!e.target.value && (cascaderValue === null || cascaderValue === void 0 ? void 0 : cascaderValue.every(function (item) {
|
|
188
|
-
return !item;
|
|
189
|
-
}))) {
|
|
190
|
-
onChange(undefined);
|
|
191
|
-
} else {
|
|
192
|
-
var realValue = value ? (0, _toConsumableArray2.default)(value) : [];
|
|
193
|
-
realValue[realLevel] = e.target.value;
|
|
194
|
-
onChange(realValue);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
184
|
var displayRender = function displayRender(label) {
|
|
199
185
|
return label === null || label === void 0 ? void 0 : label.filter(function (item) {
|
|
200
186
|
return !!item;
|
|
@@ -208,6 +194,48 @@ var ProCascader = function ProCascader(props) {
|
|
|
208
194
|
})) === null || _ref7$filter === void 0 ? void 0 : _ref7$filter.join(separator)) || '-' : (defaultLabel === null || defaultLabel === void 0 ? void 0 : (_defaultLabel$filter = defaultLabel.filter(function (item) {
|
|
209
195
|
return !!item;
|
|
210
196
|
})) === null || _defaultLabel$filter === void 0 ? void 0 : _defaultLabel$filter.join(separator)) || '-';
|
|
197
|
+
var findSelectedOptions = function findSelectedOptions(options, value) {
|
|
198
|
+
var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
199
|
+
var _value = value !== null && value !== void 0 ? value : [];
|
|
200
|
+
// 基准情况:如果 value 数组为空,且 path 不为空,说明找到了完整的路径
|
|
201
|
+
if ((_value === null || _value === void 0 ? void 0 : _value.length) === 0 && (path === null || path === void 0 ? void 0 : path.length) > 0) {
|
|
202
|
+
return path;
|
|
203
|
+
}
|
|
204
|
+
// 如果没有更多的 _value 需要匹配,或者当前选项没有 children,返回 null
|
|
205
|
+
if ((_value === null || _value === void 0 ? void 0 : _value.length) === 0 || !options || options.length === 0) {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
// 尝试在当前层级的选项中查找匹配的 _value
|
|
209
|
+
var currentValue = _value[0];
|
|
210
|
+
var foundOption = (0, _lodash.find)(options, {
|
|
211
|
+
value: currentValue
|
|
212
|
+
});
|
|
213
|
+
if (foundOption) {
|
|
214
|
+
// 如果找到了匹配的选项,并且还有更多的 value 需要匹配,递归地在子选项中查找
|
|
215
|
+
if (_value.length > 1 && foundOption.children) {
|
|
216
|
+
return findSelectedOptions(foundOption.children, _value.slice(1), [].concat((0, _toConsumableArray2.default)(path), [foundOption]));
|
|
217
|
+
}
|
|
218
|
+
// 如果没有更多的 value 需要匹配,返回当前选项(以及之前的路径)
|
|
219
|
+
return [].concat((0, _toConsumableArray2.default)(path), [foundOption]);
|
|
220
|
+
}
|
|
221
|
+
// 如果没有在当前层级的选项中找到匹配的 value,返回 null
|
|
222
|
+
return null;
|
|
223
|
+
};
|
|
224
|
+
var _selectedOptions = findSelectedOptions(service ? serviceData : realDataSource, addressValue);
|
|
225
|
+
var handleAddressChange = function handleAddressChange(e) {
|
|
226
|
+
var cascaderValue = value === null || value === void 0 ? void 0 : value.slice(0, realLevel);
|
|
227
|
+
if (onChange) {
|
|
228
|
+
if (!e.target.value && (cascaderValue === null || cascaderValue === void 0 ? void 0 : cascaderValue.every(function (item) {
|
|
229
|
+
return !item;
|
|
230
|
+
}))) {
|
|
231
|
+
onChange(undefined);
|
|
232
|
+
} else {
|
|
233
|
+
var realValue = value ? (0, _toConsumableArray2.default)(value) : [];
|
|
234
|
+
realValue[realLevel] = e.target.value;
|
|
235
|
+
onChange(realValue, _selectedOptions);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
};
|
|
211
239
|
return realIsView ? tooltip ? (0, _jsxRuntime.jsx)(_antd.Tooltip, {
|
|
212
240
|
className: className,
|
|
213
241
|
title: tooltip === true ? viewValue : tooltip,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
width: 100%;
|
|
7
7
|
|
|
8
8
|
.@{ant-prefix}-cascader {
|
|
9
|
-
width:
|
|
9
|
+
width: 45% !important;
|
|
10
10
|
|
|
11
11
|
&.no-detail {
|
|
12
12
|
width: 100% !important;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
.pro-address-detail {
|
|
17
|
-
width:
|
|
17
|
+
width: 55%;
|
|
18
18
|
margin-left: 2px;
|
|
19
19
|
|
|
20
20
|
.@{ant-prefix}-input-affix-wrapper {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
.@{ant-prefix}-input-affix-wrapper {
|
|
26
|
-
width:
|
|
26
|
+
width: 55%;
|
|
27
27
|
margin-left: 2px;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -414,7 +414,7 @@ var Render = function Render(props) {
|
|
|
414
414
|
};
|
|
415
415
|
}
|
|
416
416
|
// 需要过滤掉的form_item的key
|
|
417
|
-
var filterFormItemKey = ['onFieldChange', 'shouldUpdate', 'namePath', 'isView', 'parentNames', 'space', 'before', 'after', 'globalControl'];
|
|
417
|
+
var filterFormItemKey = ['onFieldChange', 'shouldUpdate', 'namePath', 'isView', 'parentNames', 'space', 'before', 'after', 'globalControl', 'listName'];
|
|
418
418
|
if (type === 'FormList') {
|
|
419
419
|
lastComponentProps.disabled = lastDisabled;
|
|
420
420
|
var lessMode = lastComponentProps.mode === 'less';
|
package/lib/ProLayout/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var _utils = require("./utils");
|
|
|
20
20
|
// 全局上下文
|
|
21
21
|
var LayoutContext = exports.LayoutContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
22
22
|
var ProLayout = function ProLayout(props) {
|
|
23
|
+
var _Object$keys;
|
|
23
24
|
var children = props.children,
|
|
24
25
|
_props$className = props.className,
|
|
25
26
|
className = _props$className === void 0 ? '' : _props$className,
|
|
@@ -31,6 +32,8 @@ var ProLayout = function ProLayout(props) {
|
|
|
31
32
|
headerNotice = props.headerNotice,
|
|
32
33
|
noticeIn = props.notice,
|
|
33
34
|
dataSource = props.dataSource,
|
|
35
|
+
_props$pathPrefix = props.pathPrefix,
|
|
36
|
+
pathPrefix = _props$pathPrefix === void 0 ? '' : _props$pathPrefix,
|
|
34
37
|
theme = props.theme,
|
|
35
38
|
onCollapsedChange = props.onCollapsedChange;
|
|
36
39
|
var _useSetState = (0, _ahooks.useSetState)({
|
|
@@ -57,7 +60,7 @@ var ProLayout = function ProLayout(props) {
|
|
|
57
60
|
if (Array.isArray(dataSource) && !dataSource.length) {
|
|
58
61
|
return _antd.message.warning('Warning: Missing menu data source, or menu data source is not an array');
|
|
59
62
|
}
|
|
60
|
-
var userData = (0, _utils.transformMenus)(dataSource);
|
|
63
|
+
var userData = (0, _utils.transformMenus)(dataSource, pathPrefix);
|
|
61
64
|
setState({
|
|
62
65
|
menus: userData
|
|
63
66
|
});
|
|
@@ -113,7 +116,7 @@ var ProLayout = function ProLayout(props) {
|
|
|
113
116
|
selectedPath: selectedPath,
|
|
114
117
|
onSelected: setState
|
|
115
118
|
},
|
|
116
|
-
children: !waterMarkProps ? layoutDom : (0, _jsxRuntime.jsx)(_index.ProWaterMark, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, waterMarkProps), {}, {
|
|
119
|
+
children: !((_Object$keys = Object.keys(waterMarkProps)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length) ? layoutDom : (0, _jsxRuntime.jsx)(_index.ProWaterMark, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, waterMarkProps), {}, {
|
|
117
120
|
children: layoutDom
|
|
118
121
|
}))
|
|
119
122
|
});
|
|
@@ -11,13 +11,13 @@ export declare const getIdsByPathName: (menus: any[], activeMenu?: string) => nu
|
|
|
11
11
|
* @param menuData 菜单数据源
|
|
12
12
|
* @returns []
|
|
13
13
|
*/
|
|
14
|
-
export declare const transformMenu: (menuData: any[]) => any[];
|
|
14
|
+
export declare const transformMenu: (menuData: any[], pathPrefix: string) => any[];
|
|
15
15
|
/**
|
|
16
16
|
* 转换菜单数据源评价keyUrlPath与keyIdPath
|
|
17
17
|
* @param data 菜单数据源
|
|
18
18
|
* @returns []
|
|
19
19
|
*/
|
|
20
|
-
export declare const transformMenus: (data: MenusProps) => any[] | MenusProps;
|
|
20
|
+
export declare const transformMenus: (data: MenusProps, pathPrefix: string) => any[] | MenusProps;
|
|
21
21
|
/**
|
|
22
22
|
* 获取URL中的search参数
|
|
23
23
|
* @param name 参数key
|
|
@@ -50,7 +50,7 @@ var getIdsByPathName = exports.getIdsByPathName = function getIdsByPathName(menu
|
|
|
50
50
|
* @param menuData 菜单数据源
|
|
51
51
|
* @returns []
|
|
52
52
|
*/
|
|
53
|
-
var transformMenu = exports.transformMenu = function transformMenu(menuData) {
|
|
53
|
+
var transformMenu = exports.transformMenu = function transformMenu(menuData, pathPrefix) {
|
|
54
54
|
var data = (0, _toConsumableArray2.default)(menuData);
|
|
55
55
|
var menuDeep = function menuDeep(menuDeepItem) {
|
|
56
56
|
if (!Array.isArray(menuDeepItem) || !menuDeepItem.length) {
|
|
@@ -59,6 +59,8 @@ var transformMenu = exports.transformMenu = function transformMenu(menuData) {
|
|
|
59
59
|
menuDeepItem.forEach(function (item, index) {
|
|
60
60
|
var _item$keyUrlPath, _item$keyIdPath, _item$children;
|
|
61
61
|
item.code = item.code || item.id;
|
|
62
|
+
item.url = "".concat(pathPrefix).concat(item.url);
|
|
63
|
+
item.redirectUrl = (item === null || item === void 0 ? void 0 : item.redirectUrl) ? "".concat(pathPrefix).concat(item.redirectUrl) : '';
|
|
62
64
|
// 拼接父级url与id数据
|
|
63
65
|
if (item === null || item === void 0 ? void 0 : (_item$keyUrlPath = item.keyUrlPath) === null || _item$keyUrlPath === void 0 ? void 0 : _item$keyUrlPath.length) {
|
|
64
66
|
item.keyUrlPath.push(item.redirectUrl || item.url);
|
|
@@ -95,18 +97,18 @@ var transformMenu = exports.transformMenu = function transformMenu(menuData) {
|
|
|
95
97
|
* @param data 菜单数据源
|
|
96
98
|
* @returns []
|
|
97
99
|
*/
|
|
98
|
-
var transformMenus = exports.transformMenus = function transformMenus(data) {
|
|
100
|
+
var transformMenus = exports.transformMenus = function transformMenus(data, pathPrefix) {
|
|
99
101
|
if ((0, _lodash.isPlainObject)(data)) {
|
|
100
102
|
// @ts-ignore
|
|
101
103
|
if (!Array.isArray(data === null || data === void 0 ? void 0 : data.menus)) {
|
|
102
104
|
return [];
|
|
103
105
|
}
|
|
104
106
|
// @ts-ignore
|
|
105
|
-
data.menus = transformMenu(data.menus);
|
|
107
|
+
data.menus = transformMenu(data.menus, pathPrefix);
|
|
106
108
|
return data;
|
|
107
109
|
}
|
|
108
110
|
if (Array.isArray(data)) {
|
|
109
|
-
return transformMenu(data);
|
|
111
|
+
return transformMenu(data, pathPrefix);
|
|
110
112
|
}
|
|
111
113
|
return data;
|
|
112
114
|
};
|