@zat-design/sisyphus-react 3.10.3-beta.3 → 3.10.3-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/extensions.json +5 -0
- package/es/ProEditTable/index.js +12 -7
- package/es/ProSelect/index.js +31 -6
- package/lib/ProEditTable/index.js +12 -7
- package/lib/ProSelect/index.js +30 -5
- package/package.json +1 -1
package/es/ProEditTable/index.js
CHANGED
@@ -169,28 +169,33 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
169
169
|
while (1) switch (_context.prev = _context.next) {
|
170
170
|
case 0:
|
171
171
|
_context.prev = 0;
|
172
|
-
|
172
|
+
if (!pagination) {
|
173
|
+
_context.next = 5;
|
174
|
+
break;
|
175
|
+
}
|
176
|
+
_context.next = 4;
|
173
177
|
return form.validateFields([name], {
|
174
178
|
recursive: true
|
175
179
|
});
|
176
|
-
case
|
180
|
+
case 4:
|
177
181
|
setState({
|
178
182
|
page: {
|
179
183
|
pageNum: current,
|
180
184
|
pageSize: pageSize !== null && pageSize !== void 0 ? pageSize : page.pageSize
|
181
185
|
}
|
182
186
|
});
|
183
|
-
|
187
|
+
case 5:
|
188
|
+
_context.next = 10;
|
184
189
|
break;
|
185
|
-
case
|
186
|
-
_context.prev =
|
190
|
+
case 7:
|
191
|
+
_context.prev = 7;
|
187
192
|
_context.t0 = _context["catch"](0);
|
188
193
|
handleScrollToError();
|
189
|
-
case
|
194
|
+
case 10:
|
190
195
|
case "end":
|
191
196
|
return _context.stop();
|
192
197
|
}
|
193
|
-
}, _callee, null, [[0,
|
198
|
+
}, _callee, null, [[0, 7]]);
|
194
199
|
}));
|
195
200
|
return function (_x, _x2) {
|
196
201
|
return _ref4.apply(this, arguments);
|
package/es/ProSelect/index.js
CHANGED
@@ -12,7 +12,7 @@ import _Select from "antd/es/select";
|
|
12
12
|
var _excluded = ["dataSource", "defaultDisableValue", "useRequest", "fieldNames", "tooltip", "otherProps", "labelInValue", "filterInList", "scrollFollowParent", "defaultOne", "onSearch", "optionRender", "onChange", "updateDataSource", "transformResponse", "getValueProps", "isView"];
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
14
14
|
import { useDeepCompareEffect, useRequest as useRequestFunc } from 'ahooks';
|
15
|
-
import React, { useImperativeHandle, useState, forwardRef, isValidElement } from 'react';
|
15
|
+
import React, { useImperativeHandle, useState, forwardRef, isValidElement, useCallback } from 'react';
|
16
16
|
import { isFunction, isObject, isString, omit, isNumber } from 'lodash';
|
17
17
|
import { useProConfig } from '../ProConfigProvider';
|
18
18
|
import Container from '../ProForm/components/Container';
|
@@ -23,7 +23,7 @@ import { getSelectList } from './utils';
|
|
23
23
|
import './index.less';
|
24
24
|
var Option = _Select.Option;
|
25
25
|
export var ProSelect = function ProSelect(props, ref) {
|
26
|
-
var _selectProps$showCode, _locale$ProSelect;
|
26
|
+
var _selectProps$showCode, _useRequest$options, _locale$ProSelect;
|
27
27
|
var _ref = useProConfig('ProSelect') || {},
|
28
28
|
_ref$fieldNames = _ref.fieldNames,
|
29
29
|
proSelectFieldNames = _ref$fieldNames === void 0 ? {} : _ref$fieldNames,
|
@@ -87,6 +87,21 @@ export var ProSelect = function ProSelect(props, ref) {
|
|
87
87
|
}
|
88
88
|
setSelectList(data || []);
|
89
89
|
};
|
90
|
+
var successTransformDataHandle = useCallback(function (res) {
|
91
|
+
if (transformResponse && typeof transformResponse === 'function') {
|
92
|
+
return transformResponse(res);
|
93
|
+
}
|
94
|
+
var _ref3 = res || {},
|
95
|
+
_ref3$status = _ref3.status,
|
96
|
+
status = _ref3$status === void 0 ? 200 : _ref3$status,
|
97
|
+
msg = _ref3.message,
|
98
|
+
data = _ref3.data;
|
99
|
+
if (status !== 200) {
|
100
|
+
_message.error(msg);
|
101
|
+
return;
|
102
|
+
}
|
103
|
+
return data;
|
104
|
+
}, []);
|
90
105
|
var fetchFunction = useRequestFunc(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, _objectSpread({
|
91
106
|
manual: true,
|
92
107
|
onSuccess: function onSuccess(data) {
|
@@ -100,6 +115,7 @@ export var ProSelect = function ProSelect(props, ref) {
|
|
100
115
|
},
|
101
116
|
debounceWait: 300
|
102
117
|
}, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options));
|
118
|
+
var cacheList = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options = useRequest.options) === null || _useRequest$options === void 0 ? void 0 : _useRequest$options.cacheKey) ? successTransformDataHandle(fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data) : [];
|
103
119
|
var getValueObject = function getValueObject(input) {
|
104
120
|
if (Array.isArray(input) && input.length) {
|
105
121
|
var resArr = [];
|
@@ -124,15 +140,24 @@ export var ProSelect = function ProSelect(props, ref) {
|
|
124
140
|
useDeepCompareEffect(function () {
|
125
141
|
setSelectList(dataSource);
|
126
142
|
}, [dataSource]);
|
143
|
+
useDeepCompareEffect(function () {
|
144
|
+
var _useRequest$options2;
|
145
|
+
// 设置cacheKey后使用缓存的数据
|
146
|
+
if (!(selectList === null || selectList === void 0 ? void 0 : selectList.length) && (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options2 = useRequest.options) === null || _useRequest$options2 === void 0 ? void 0 : _useRequest$options2.cacheKey)) {
|
147
|
+
if (cacheList === null || cacheList === void 0 ? void 0 : cacheList.length) {
|
148
|
+
setSelectList(cacheList);
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}, [fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data]);
|
127
152
|
useDeepCompareEffect(function () {
|
128
153
|
// 默认disable值时,不查询接口
|
129
154
|
if (defaultDisableValue || !useRequest) {
|
130
155
|
return;
|
131
156
|
}
|
132
|
-
var
|
133
|
-
defaultParams =
|
134
|
-
manual =
|
135
|
-
if (manual) {
|
157
|
+
var _ref4 = (useRequest === null || useRequest === void 0 ? void 0 : useRequest.options) || {},
|
158
|
+
defaultParams = _ref4.defaultParams,
|
159
|
+
manual = _ref4.manual;
|
160
|
+
if (manual || (cacheList === null || cacheList === void 0 ? void 0 : cacheList.length)) {
|
136
161
|
return;
|
137
162
|
}
|
138
163
|
fetchFunction.run(defaultParams);
|
@@ -172,28 +172,33 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
172
172
|
while (1) switch (_context.prev = _context.next) {
|
173
173
|
case 0:
|
174
174
|
_context.prev = 0;
|
175
|
-
|
175
|
+
if (!pagination) {
|
176
|
+
_context.next = 5;
|
177
|
+
break;
|
178
|
+
}
|
179
|
+
_context.next = 4;
|
176
180
|
return form.validateFields([name], {
|
177
181
|
recursive: true
|
178
182
|
});
|
179
|
-
case
|
183
|
+
case 4:
|
180
184
|
setState({
|
181
185
|
page: {
|
182
186
|
pageNum: current,
|
183
187
|
pageSize: pageSize !== null && pageSize !== void 0 ? pageSize : page.pageSize
|
184
188
|
}
|
185
189
|
});
|
186
|
-
|
190
|
+
case 5:
|
191
|
+
_context.next = 10;
|
187
192
|
break;
|
188
|
-
case
|
189
|
-
_context.prev =
|
193
|
+
case 7:
|
194
|
+
_context.prev = 7;
|
190
195
|
_context.t0 = _context["catch"](0);
|
191
196
|
(0, _tools.handleScrollToError)();
|
192
|
-
case
|
197
|
+
case 10:
|
193
198
|
case "end":
|
194
199
|
return _context.stop();
|
195
200
|
}
|
196
|
-
}, _callee, null, [[0,
|
201
|
+
}, _callee, null, [[0, 7]]);
|
197
202
|
}));
|
198
203
|
return function (_x, _x2) {
|
199
204
|
return _ref4.apply(this, arguments);
|
package/lib/ProSelect/index.js
CHANGED
@@ -24,7 +24,7 @@ require("./index.less");
|
|
24
24
|
var _excluded = ["dataSource", "defaultDisableValue", "useRequest", "fieldNames", "tooltip", "otherProps", "labelInValue", "filterInList", "scrollFollowParent", "defaultOne", "onSearch", "optionRender", "onChange", "updateDataSource", "transformResponse", "getValueProps", "isView"];
|
25
25
|
var Option = _antd.Select.Option;
|
26
26
|
var ProSelect = exports.ProSelect = function ProSelect(props, ref) {
|
27
|
-
var _selectProps$showCode, _locale$ProSelect;
|
27
|
+
var _selectProps$showCode, _useRequest$options, _locale$ProSelect;
|
28
28
|
var _ref = (0, _ProConfigProvider.useProConfig)('ProSelect') || {},
|
29
29
|
_ref$fieldNames = _ref.fieldNames,
|
30
30
|
proSelectFieldNames = _ref$fieldNames === void 0 ? {} : _ref$fieldNames,
|
@@ -88,6 +88,21 @@ var ProSelect = exports.ProSelect = function ProSelect(props, ref) {
|
|
88
88
|
}
|
89
89
|
setSelectList(data || []);
|
90
90
|
};
|
91
|
+
var successTransformDataHandle = (0, _react.useCallback)(function (res) {
|
92
|
+
if (transformResponse && typeof transformResponse === 'function') {
|
93
|
+
return transformResponse(res);
|
94
|
+
}
|
95
|
+
var _ref3 = res || {},
|
96
|
+
_ref3$status = _ref3.status,
|
97
|
+
status = _ref3$status === void 0 ? 200 : _ref3$status,
|
98
|
+
msg = _ref3.message,
|
99
|
+
data = _ref3.data;
|
100
|
+
if (status !== 200) {
|
101
|
+
_antd.message.error(msg);
|
102
|
+
return;
|
103
|
+
}
|
104
|
+
return data;
|
105
|
+
}, []);
|
91
106
|
var fetchFunction = (0, _ahooks.useRequest)(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, (0, _objectSpread2.default)({
|
92
107
|
manual: true,
|
93
108
|
onSuccess: function onSuccess(data) {
|
@@ -101,6 +116,7 @@ var ProSelect = exports.ProSelect = function ProSelect(props, ref) {
|
|
101
116
|
},
|
102
117
|
debounceWait: 300
|
103
118
|
}, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options));
|
119
|
+
var cacheList = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options = useRequest.options) === null || _useRequest$options === void 0 ? void 0 : _useRequest$options.cacheKey) ? successTransformDataHandle(fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data) : [];
|
104
120
|
var getValueObject = function getValueObject(input) {
|
105
121
|
if (Array.isArray(input) && input.length) {
|
106
122
|
var resArr = [];
|
@@ -125,15 +141,24 @@ var ProSelect = exports.ProSelect = function ProSelect(props, ref) {
|
|
125
141
|
(0, _ahooks.useDeepCompareEffect)(function () {
|
126
142
|
setSelectList(dataSource);
|
127
143
|
}, [dataSource]);
|
144
|
+
(0, _ahooks.useDeepCompareEffect)(function () {
|
145
|
+
var _useRequest$options2;
|
146
|
+
// 设置cacheKey后使用缓存的数据
|
147
|
+
if (!(selectList === null || selectList === void 0 ? void 0 : selectList.length) && (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options2 = useRequest.options) === null || _useRequest$options2 === void 0 ? void 0 : _useRequest$options2.cacheKey)) {
|
148
|
+
if (cacheList === null || cacheList === void 0 ? void 0 : cacheList.length) {
|
149
|
+
setSelectList(cacheList);
|
150
|
+
}
|
151
|
+
}
|
152
|
+
}, [fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data]);
|
128
153
|
(0, _ahooks.useDeepCompareEffect)(function () {
|
129
154
|
// 默认disable值时,不查询接口
|
130
155
|
if (defaultDisableValue || !useRequest) {
|
131
156
|
return;
|
132
157
|
}
|
133
|
-
var
|
134
|
-
defaultParams =
|
135
|
-
manual =
|
136
|
-
if (manual) {
|
158
|
+
var _ref4 = (useRequest === null || useRequest === void 0 ? void 0 : useRequest.options) || {},
|
159
|
+
defaultParams = _ref4.defaultParams,
|
160
|
+
manual = _ref4.manual;
|
161
|
+
if (manual || (cacheList === null || cacheList === void 0 ? void 0 : cacheList.length)) {
|
137
162
|
return;
|
138
163
|
}
|
139
164
|
fetchFunction.run(defaultParams);
|