@zat-design/sisyphus-react 3.10.3 → 3.10.4-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/dist/index.esm.css +6 -0
- package/dist/less.esm.css +6 -0
- package/es/ProEditTable/components/RenderField/index.js +2 -2
- package/es/ProEditTable/index.js +44 -13
- package/es/ProEditTable/propsType.d.ts +0 -1
- package/es/ProEditTable/style/index.less +3 -1
- package/es/ProEditTable/utils/config.d.ts +1 -1
- package/es/ProEditTable/utils/config.js +11 -3
- package/es/ProEditTable/utils/index.js +0 -71
- package/es/ProForm/components/render/ConfirmWrapper.js +41 -21
- package/es/ProSelect/index.js +31 -6
- package/es/ProTable/hooks/useAntdTable.js +45 -46
- package/es/ProTable/style/index.less +3 -1
- package/es/ProTable/utils/index.d.ts +2 -0
- package/es/ProTable/utils/index.js +5 -0
- package/lib/ProEditTable/components/RenderField/index.js +2 -2
- package/lib/ProEditTable/index.js +43 -12
- package/lib/ProEditTable/propsType.d.ts +0 -1
- package/lib/ProEditTable/style/index.less +3 -1
- package/lib/ProEditTable/utils/config.d.ts +1 -1
- package/lib/ProEditTable/utils/config.js +11 -3
- package/lib/ProEditTable/utils/index.js +0 -71
- package/lib/ProForm/components/render/ConfirmWrapper.js +41 -21
- package/lib/ProSelect/index.js +30 -5
- package/lib/ProTable/hooks/useAntdTable.js +42 -43
- package/lib/ProTable/style/index.less +3 -1
- package/lib/ProTable/utils/index.d.ts +2 -0
- package/lib/ProTable/utils/index.js +6 -1
- package/package.json +3 -3
package/dist/index.esm.css
CHANGED
@@ -2242,6 +2242,9 @@
|
|
2242
2242
|
.pro-table .ant-table-summary {
|
2243
2243
|
background-color: var(--zaui-table-header-bg, #f2f3f5);
|
2244
2244
|
}
|
2245
|
+
.pro-table .ant-table-summary td {
|
2246
|
+
padding: calc(4px + var(--zaui-size)*8px);
|
2247
|
+
}
|
2245
2248
|
.pro-table .ant-table-summary .ant-table-cell {
|
2246
2249
|
font-weight: 500;
|
2247
2250
|
background-color: var(--zaui-table-header-bg, #f2f3f5);
|
@@ -4629,6 +4632,9 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
|
|
4629
4632
|
color: var(--zaui-text, #343434);
|
4630
4633
|
font-weight: 600;
|
4631
4634
|
}
|
4635
|
+
.pro-edit-table .ant-table-content > table .ant-table-summary td {
|
4636
|
+
padding: 8px 16px;
|
4637
|
+
}
|
4632
4638
|
.pro-edit-table .ant-table-content > table .ant-table-summary .ant-table-cell-fix-left,
|
4633
4639
|
.pro-edit-table .ant-table-content > table .ant-table-summary .ant-table-cell-fix-right {
|
4634
4640
|
background-color: var(--zaui-table-header-bg, #f2f3f5);
|
package/dist/less.esm.css
CHANGED
@@ -2242,6 +2242,9 @@
|
|
2242
2242
|
.pro-table .ant-table-summary {
|
2243
2243
|
background-color: var(--zaui-table-header-bg, #f2f3f5);
|
2244
2244
|
}
|
2245
|
+
.pro-table .ant-table-summary td {
|
2246
|
+
padding: calc(4px + var(--zaui-size)*8px);
|
2247
|
+
}
|
2245
2248
|
.pro-table .ant-table-summary .ant-table-cell {
|
2246
2249
|
font-weight: 500;
|
2247
2250
|
background-color: var(--zaui-table-header-bg, #f2f3f5);
|
@@ -4629,6 +4632,9 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
|
|
4629
4632
|
color: var(--zaui-text, #343434);
|
4630
4633
|
font-weight: 600;
|
4631
4634
|
}
|
4635
|
+
.pro-edit-table .ant-table-content > table .ant-table-summary td {
|
4636
|
+
padding: 8px 16px;
|
4637
|
+
}
|
4632
4638
|
.pro-edit-table .ant-table-content > table .ant-table-summary .ant-table-cell-fix-left,
|
4633
4639
|
.pro-edit-table .ant-table-content > table .ant-table-summary .ant-table-cell-fix-right {
|
4634
4640
|
background-color: var(--zaui-table-header-bg, #f2f3f5);
|
@@ -588,7 +588,7 @@ var RenderField = function RenderField(_ref) {
|
|
588
588
|
}
|
589
589
|
FormItem = TargetComponent ? _jsx(_Form.Item, _objectSpread(_objectSpread({
|
590
590
|
validateFirst: true
|
591
|
-
}, omit(_formItemProps, ['render', '
|
591
|
+
}, omit(_formItemProps, ['render', 'key', 'width', 'hiddenNames', 'name', 'onCell', _fieldProps.shouldUpdate ? 'shouldUpdate' : null])), {}, {
|
592
592
|
className: _className,
|
593
593
|
name: formNamePath ? cellName.slice((formNamePath === null || formNamePath === void 0 ? void 0 : formNamePath.length) - 1) : cellName,
|
594
594
|
children: FieldComponent
|
@@ -598,7 +598,7 @@ var RenderField = function RenderField(_ref) {
|
|
598
598
|
if (type === 'FormList') {
|
599
599
|
FormItem = _jsx(_Form.List, _objectSpread(_objectSpread({
|
600
600
|
name: formNamePath ? cellName.slice((formNamePath === null || formNamePath === void 0 ? void 0 : formNamePath.length) - 1) : cellName
|
601
|
-
}, omit(_formItemProps, ['render', '
|
601
|
+
}, omit(_formItemProps, ['render', 'key', 'width', 'hiddenNames', 'name'])), {}, {
|
602
602
|
children: function children(fields, operation, meta) {
|
603
603
|
return _jsx(TargetComponent, _objectSpread(_objectSpread({}, componentProps), {}, {
|
604
604
|
otherProps: otherProps,
|
package/es/ProEditTable/index.js
CHANGED
@@ -2,6 +2,8 @@ import "antd/es/affix/style";
|
|
2
2
|
import _Affix from "antd/es/affix";
|
3
3
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
4
4
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
5
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
6
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
5
7
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
6
8
|
import "antd/es/config-provider/style";
|
7
9
|
import _ConfigProvider from "antd/es/config-provider";
|
@@ -16,7 +18,7 @@ import { get, isArray, isBoolean, set } from 'lodash';
|
|
16
18
|
import { useDeepCompareEffect, useLocalStorageState, useSetState } from 'ahooks';
|
17
19
|
import classnames from 'classnames';
|
18
20
|
import { transformColumns } from './utils';
|
19
|
-
import { getRandom, getNamePath } from './utils/tools';
|
21
|
+
import { getRandom, getNamePath, handleScrollToError } from './utils/tools';
|
20
22
|
import { Validator, Summary, RenderToolbar } from './components';
|
21
23
|
import ProForm from '../ProForm';
|
22
24
|
import Empty from '../assets/empty.png';
|
@@ -110,7 +112,6 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
110
112
|
selectedRows = state.selectedRows,
|
111
113
|
page = state.page;
|
112
114
|
var virtualRowName = getNamePath(isArray(name) ? name : [name], virtualKey);
|
113
|
-
var cacheMap = useRef({});
|
114
115
|
// 样式处理
|
115
116
|
var _className = classnames({
|
116
117
|
'pro-edit-table': true,
|
@@ -160,13 +161,51 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
160
161
|
return getRowKey(item) === getRowKey(record);
|
161
162
|
}));
|
162
163
|
};
|
164
|
+
// 分页变更
|
165
|
+
var handlePageChange = useCallback(/*#__PURE__*/function () {
|
166
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(current, pageSize) {
|
167
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
168
|
+
while (1) switch (_context.prev = _context.next) {
|
169
|
+
case 0:
|
170
|
+
_context.prev = 0;
|
171
|
+
if (!pagination) {
|
172
|
+
_context.next = 5;
|
173
|
+
break;
|
174
|
+
}
|
175
|
+
_context.next = 4;
|
176
|
+
return form.validateFields([name], {
|
177
|
+
recursive: true
|
178
|
+
});
|
179
|
+
case 4:
|
180
|
+
setState({
|
181
|
+
page: {
|
182
|
+
pageNum: current,
|
183
|
+
pageSize: pageSize !== null && pageSize !== void 0 ? pageSize : page.pageSize
|
184
|
+
}
|
185
|
+
});
|
186
|
+
case 5:
|
187
|
+
_context.next = 10;
|
188
|
+
break;
|
189
|
+
case 7:
|
190
|
+
_context.prev = 7;
|
191
|
+
_context.t0 = _context["catch"](0);
|
192
|
+
handleScrollToError();
|
193
|
+
case 10:
|
194
|
+
case "end":
|
195
|
+
return _context.stop();
|
196
|
+
}
|
197
|
+
}, _callee, null, [[0, 7]]);
|
198
|
+
}));
|
199
|
+
return function (_x, _x2) {
|
200
|
+
return _ref4.apply(this, arguments);
|
201
|
+
};
|
202
|
+
}(), []);
|
163
203
|
var config = _objectSpread({
|
164
204
|
form: form,
|
165
205
|
mode: mode,
|
166
206
|
isView: isView,
|
167
207
|
viewEmpty: viewEmpty,
|
168
208
|
disabled: disabled,
|
169
|
-
cacheMap: cacheMap,
|
170
209
|
cellNamePath: cellNamePath,
|
171
210
|
forceUpdate: forceUpdate,
|
172
211
|
insertType: insertType,
|
@@ -194,7 +233,8 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
194
233
|
rowDisabled: rowDisabled,
|
195
234
|
actionDirection: actionDirection,
|
196
235
|
diffConfig: _objectSpread(_objectSpread({}, resetProps === null || resetProps === void 0 ? void 0 : (_resetProps$otherProp = resetProps.otherProps) === null || _resetProps$otherProp === void 0 ? void 0 : _resetProps$otherProp.diffConfig), diffConfig),
|
197
|
-
getIsNew: getIsNew
|
236
|
+
getIsNew: getIsNew,
|
237
|
+
handlePageChange: handlePageChange
|
198
238
|
}, resetProps);
|
199
239
|
// 编辑行设置下样式
|
200
240
|
var _rowClassName = function _rowClassName(record) {
|
@@ -245,15 +285,6 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
245
285
|
},
|
246
286
|
hideSelectAll: isHideCheckBox
|
247
287
|
}, rowSelection);
|
248
|
-
// 分页变更
|
249
|
-
var handlePageChange = useCallback(function (current, pageSize) {
|
250
|
-
setState({
|
251
|
-
page: {
|
252
|
-
pageNum: current,
|
253
|
-
pageSize: pageSize
|
254
|
-
}
|
255
|
-
});
|
256
|
-
}, []);
|
257
288
|
// 空列表状态
|
258
289
|
var empty = function empty() {
|
259
290
|
var _toolbarProps$filter;
|
@@ -98,7 +98,6 @@ export interface ProColumnsProps<Values = any, T = any> extends Omit<FormItemPro
|
|
98
98
|
labelRequired?: boolean;
|
99
99
|
name?: NamePath;
|
100
100
|
names?: NamePath[];
|
101
|
-
cache?: boolean;
|
102
101
|
isEditable?: boolean | RequiredFn<T>;
|
103
102
|
valueType?: ProFormValueType | ((text?: any, record?: any, options?: OptionsProps) => ProFormValueType);
|
104
103
|
tooltip?: string | ({
|
@@ -151,7 +151,9 @@
|
|
151
151
|
background-color: var(--zaui-table-header-bg, #f2f3f5);
|
152
152
|
color : var(--zaui-text, #343434);
|
153
153
|
font-weight : 600;
|
154
|
-
|
154
|
+
td{
|
155
|
+
padding: 8px 16px;
|
156
|
+
}
|
155
157
|
.@{ant-prefix}-table-cell-fix-left,
|
156
158
|
.@{ant-prefix}-table-cell-fix-right {
|
157
159
|
background-color: var(--zaui-table-header-bg, #f2f3f5);
|
@@ -20,6 +20,6 @@ export declare const actions: {
|
|
20
20
|
save: ({ record, editingKeys, setState, form, rowName, virtualRowName, result }: any) => Promise<void>;
|
21
21
|
cancel: ({ name, record, editingKeys, setState, form, virtualRowName, virtualKey }: any) => void;
|
22
22
|
delete: ({ name, record, editingKeys, setState, form, virtualKey, onlyOneLineMsg }: any) => boolean;
|
23
|
-
add: ({ result, insertType, editingKeys, setState, form, name, virtualName, virtualKey, onlyOneLineMsg, tableRef, prefixCls, }: any) => Promise<boolean>;
|
23
|
+
add: ({ result, insertType, editingKeys, setState, form, name, virtualName, virtualKey, onlyOneLineMsg, tableRef, prefixCls, page, handlePageChange, }: any) => Promise<boolean>;
|
24
24
|
mulDelete: ({ form, name, virtualKey, setState, selectedRowKeys, editingKeys }: any) => void;
|
25
25
|
};
|
@@ -7,6 +7,7 @@ import "antd/es/message/style";
|
|
7
7
|
import _message from "antd/es/message";
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
9
9
|
import { PlusOutlined } from '@ant-design/icons';
|
10
|
+
import { tools } from '@zat-design/utils';
|
10
11
|
import { set } from 'lodash';
|
11
12
|
import { onDelete, getRandom } from './tools';
|
12
13
|
import locale from '../../locale';
|
@@ -168,11 +169,11 @@ export var actions = {
|
|
168
169
|
add: function () {
|
169
170
|
var _add = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref5) {
|
170
171
|
var _tableRef$current$que, _tableRef$current$que2;
|
171
|
-
var result, insertType, editingKeys, setState, form, name, virtualName, virtualKey, onlyOneLineMsg, tableRef, _ref5$prefixCls, prefixCls, nextData, rowKey, addData, nextEditingKeys;
|
172
|
+
var result, insertType, editingKeys, setState, form, name, virtualName, virtualKey, onlyOneLineMsg, tableRef, _ref5$prefixCls, prefixCls, page, handlePageChange, nextData, rowKey, addData, nextPageNum, nextEditingKeys;
|
172
173
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
173
174
|
while (1) switch (_context2.prev = _context2.next) {
|
174
175
|
case 0:
|
175
|
-
result = _ref5.result, insertType = _ref5.insertType, editingKeys = _ref5.editingKeys, setState = _ref5.setState, form = _ref5.form, name = _ref5.name, virtualName = _ref5.virtualName, virtualKey = _ref5.virtualKey, onlyOneLineMsg = _ref5.onlyOneLineMsg, tableRef = _ref5.tableRef, _ref5$prefixCls = _ref5.prefixCls, prefixCls = _ref5$prefixCls === void 0 ? 'ant' : _ref5$prefixCls;
|
176
|
+
result = _ref5.result, insertType = _ref5.insertType, editingKeys = _ref5.editingKeys, setState = _ref5.setState, form = _ref5.form, name = _ref5.name, virtualName = _ref5.virtualName, virtualKey = _ref5.virtualKey, onlyOneLineMsg = _ref5.onlyOneLineMsg, tableRef = _ref5.tableRef, _ref5$prefixCls = _ref5.prefixCls, prefixCls = _ref5$prefixCls === void 0 ? 'ant' : _ref5$prefixCls, page = _ref5.page, handlePageChange = _ref5.handlePageChange;
|
176
177
|
nextData = _toConsumableArray(form.getFieldValue(name) || []); // 单行编辑时,需要先保存,才能进行下面的编辑
|
177
178
|
if (!(virtualKey && editingKeys.length >= 1)) {
|
178
179
|
_context2.next = 5;
|
@@ -189,7 +190,14 @@ export var actions = {
|
|
189
190
|
addData.addFlag = true;
|
190
191
|
addData.isEditing = true;
|
191
192
|
}
|
192
|
-
insertType === 'before'
|
193
|
+
if (insertType === 'before') {
|
194
|
+
nextData.unshift(addData);
|
195
|
+
handlePageChange(1);
|
196
|
+
} else {
|
197
|
+
nextData.push(addData);
|
198
|
+
nextPageNum = Math.ceil(tools.calc(nextData.length, '/', page.pageSize));
|
199
|
+
handlePageChange(nextPageNum);
|
200
|
+
}
|
193
201
|
// 当单选情况下,存储正在编辑值
|
194
202
|
if (virtualKey) {
|
195
203
|
nextEditingKeys = _toConsumableArray(editingKeys); // 开启编辑状态
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
3
2
|
import "antd/es/tooltip/style";
|
4
3
|
import _Tooltip from "antd/es/tooltip";
|
@@ -201,13 +200,10 @@ export var transformColumns = function transformColumns() {
|
|
201
200
|
virtualKey = config.virtualKey,
|
202
201
|
requiredAlign = config.requiredAlign,
|
203
202
|
isView = config.isView,
|
204
|
-
cacheMap = config.cacheMap,
|
205
203
|
setState = config.setState,
|
206
204
|
page = config.page;
|
207
205
|
var isCell = mode === 'cell';
|
208
206
|
var _columns = cloneDeepFilterNode(columns);
|
209
|
-
// 你的函数代码
|
210
|
-
var _cacheMap = _objectSpread({}, cacheMap.current);
|
211
207
|
var pageNum = tools.calc(page.pageNum, '-', 1);
|
212
208
|
var firstIndex = tools.calc(pageNum, '*', page.pageSize);
|
213
209
|
_columns.forEach(function (item, index) {
|
@@ -280,26 +276,6 @@ export var transformColumns = function transformColumns() {
|
|
280
276
|
if (item.className) {
|
281
277
|
item.className = _toConsumableArray(new Set(item.className.split(' '))).join(' ');
|
282
278
|
}
|
283
|
-
// 当列表配置cache,接口请求静态数据会做数据缓存
|
284
|
-
if (item.cache) {
|
285
|
-
var _item$fieldProps3;
|
286
|
-
// 初始化加载ProSelect,缓存当前useRequest
|
287
|
-
if (item.type === 'ProSelect') {
|
288
|
-
var _cacheMap$item$dataIn, _cacheMap$item$dataIn2;
|
289
|
-
if (!(_cacheMap === null || _cacheMap === void 0 ? void 0 : (_cacheMap$item$dataIn = _cacheMap[item.dataIndex]) === null || _cacheMap$item$dataIn === void 0 ? void 0 : (_cacheMap$item$dataIn2 = _cacheMap$item$dataIn.dataSource) === null || _cacheMap$item$dataIn2 === void 0 ? void 0 : _cacheMap$item$dataIn2.length)) {
|
290
|
-
var _item$fieldProps, _item$fieldProps2;
|
291
|
-
_cacheMap[item.dataIndex] = {
|
292
|
-
useRequest: (_item$fieldProps = item.fieldProps) === null || _item$fieldProps === void 0 ? void 0 : _item$fieldProps.useRequest,
|
293
|
-
dataSource: [],
|
294
|
-
transformResponse: (_item$fieldProps2 = item.fieldProps) === null || _item$fieldProps2 === void 0 ? void 0 : _item$fieldProps2.transformResponse
|
295
|
-
};
|
296
|
-
} else {
|
297
|
-
var _cacheMap$item$dataIn3;
|
298
|
-
item.fieldProps.dataSource = (_cacheMap$item$dataIn3 = _cacheMap[item.dataIndex]) === null || _cacheMap$item$dataIn3 === void 0 ? void 0 : _cacheMap$item$dataIn3.dataSource;
|
299
|
-
}
|
300
|
-
}
|
301
|
-
(_item$fieldProps3 = item.fieldProps) === null || _item$fieldProps3 === void 0 ? true : delete _item$fieldProps3.useRequest;
|
302
|
-
}
|
303
279
|
var _render = function _render(text, record, index) {
|
304
280
|
var isEditing = !virtualKey || editingKeys.includes(record.rowKey) || record.addFlag;
|
305
281
|
var namePath = isArray(name) ? name : [name];
|
@@ -390,53 +366,6 @@ export var transformColumns = function transformColumns() {
|
|
390
366
|
}));
|
391
367
|
actionColumn && _columns.push(actionColumn);
|
392
368
|
}
|
393
|
-
// cacheMap 用来存储缓存值,若有值后不再请求
|
394
|
-
if (JSON.stringify(cacheMap.current) === '{}') {
|
395
|
-
Promise.all(Object.entries(_cacheMap).map(/*#__PURE__*/function () {
|
396
|
-
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(item) {
|
397
|
-
var _item, key, value, _ref5, service, option;
|
398
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
399
|
-
while (1) switch (_context2.prev = _context2.next) {
|
400
|
-
case 0:
|
401
|
-
_item = _slicedToArray(item, 2), key = _item[0], value = _item[1];
|
402
|
-
_ref5 = (value === null || value === void 0 ? void 0 : value.useRequest) || {}, service = _ref5.service, option = _ref5.option;
|
403
|
-
if (!service) {
|
404
|
-
_context2.next = 8;
|
405
|
-
break;
|
406
|
-
}
|
407
|
-
_context2.t0 = key;
|
408
|
-
_context2.next = 6;
|
409
|
-
return service(_objectSpread({}, option === null || option === void 0 ? void 0 : option.defaultParams));
|
410
|
-
case 6:
|
411
|
-
_context2.t1 = _context2.sent;
|
412
|
-
return _context2.abrupt("return", [_context2.t0, _context2.t1]);
|
413
|
-
case 8:
|
414
|
-
return _context2.abrupt("return", [key, {}]);
|
415
|
-
case 9:
|
416
|
-
case "end":
|
417
|
-
return _context2.stop();
|
418
|
-
}
|
419
|
-
}, _callee2);
|
420
|
-
}));
|
421
|
-
return function (_x3) {
|
422
|
-
return _ref4.apply(this, arguments);
|
423
|
-
};
|
424
|
-
}())).then(function (res) {
|
425
|
-
res.forEach(function (item) {
|
426
|
-
var _item2 = _slicedToArray(item, 2),
|
427
|
-
key = _item2[0],
|
428
|
-
value = _item2[1];
|
429
|
-
var transformResponse = _cacheMap[key].transformResponse;
|
430
|
-
_cacheMap[key].dataSource = (transformResponse ? transformResponse(value) : value === null || value === void 0 ? void 0 : value.data) || [];
|
431
|
-
});
|
432
|
-
cacheMap.current = _cacheMap;
|
433
|
-
if (JSON.stringify(cacheMap.current) !== '{}') {
|
434
|
-
setState({
|
435
|
-
forceUpdate: {}
|
436
|
-
});
|
437
|
-
}
|
438
|
-
});
|
439
|
-
}
|
440
369
|
// 渲染操作列
|
441
370
|
return _columns;
|
442
371
|
};
|
@@ -22,25 +22,25 @@ var ConfirmWrapper = function ConfirmWrapper(props) {
|
|
22
22
|
var _ProForm$useFieldProp = ProForm.useFieldProps(),
|
23
23
|
form = _ProForm$useFieldProp.form;
|
24
24
|
var handleChange = /*#__PURE__*/function () {
|
25
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
25
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(value) {
|
26
26
|
var _len,
|
27
27
|
other,
|
28
28
|
_key,
|
29
29
|
_value,
|
30
30
|
confirmProps,
|
31
|
-
|
32
|
-
return _regeneratorRuntime().wrap(function
|
33
|
-
while (1) switch (
|
31
|
+
_args2 = arguments;
|
32
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
33
|
+
while (1) switch (_context2.prev = _context2.next) {
|
34
34
|
case 0:
|
35
|
-
for (_len =
|
36
|
-
other[_key - 1] =
|
35
|
+
for (_len = _args2.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
36
|
+
other[_key - 1] = _args2[_key];
|
37
37
|
}
|
38
38
|
_value = (value === null || value === void 0 ? void 0 : value.target) ? value.target.value : value;
|
39
39
|
if (!isFunction(confirm)) {
|
40
|
-
|
40
|
+
_context2.next = 8;
|
41
41
|
break;
|
42
42
|
}
|
43
|
-
|
43
|
+
_context2.next = 5;
|
44
44
|
return confirm(value, form.getFieldsValue(), {
|
45
45
|
option: other[0],
|
46
46
|
form: form,
|
@@ -50,13 +50,13 @@ var ConfirmWrapper = function ConfirmWrapper(props) {
|
|
50
50
|
preValue: form.getFieldValue(otherProps.listName || otherProps.name)
|
51
51
|
});
|
52
52
|
case 5:
|
53
|
-
|
54
|
-
|
53
|
+
_context2.t0 = _context2.sent;
|
54
|
+
_context2.next = 9;
|
55
55
|
break;
|
56
56
|
case 8:
|
57
|
-
|
57
|
+
_context2.t0 = confirm;
|
58
58
|
case 9:
|
59
|
-
confirmProps =
|
59
|
+
confirmProps = _context2.t0;
|
60
60
|
// 只处理 false, true 和 对象的情况
|
61
61
|
if (confirmProps === false) {
|
62
62
|
onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, [_value].concat(other));
|
@@ -70,21 +70,41 @@ var ConfirmWrapper = function ConfirmWrapper(props) {
|
|
70
70
|
}
|
71
71
|
if (isObject(confirmProps)) {
|
72
72
|
_Modal.confirm(_objectSpread(_objectSpread(_objectSpread({}, 'title' in confirmProps || 'content' in confirmProps ? {} : defaultConfirmProps), confirmProps), {}, {
|
73
|
-
onOk: function
|
74
|
-
var
|
75
|
-
|
76
|
-
|
73
|
+
onOk: function () {
|
74
|
+
var _onOk = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
75
|
+
var _confirmProps$onOk;
|
76
|
+
var _len2,
|
77
|
+
arg,
|
78
|
+
_key2,
|
79
|
+
_args = arguments;
|
80
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
81
|
+
while (1) switch (_context.prev = _context.next) {
|
82
|
+
case 0:
|
83
|
+
for (_len2 = _args.length, arg = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
84
|
+
arg[_key2] = _args[_key2];
|
85
|
+
}
|
86
|
+
_context.next = 3;
|
87
|
+
return (_confirmProps$onOk = confirmProps.onOk) === null || _confirmProps$onOk === void 0 ? void 0 : _confirmProps$onOk.call.apply(_confirmProps$onOk, [confirmProps].concat(arg));
|
88
|
+
case 3:
|
89
|
+
onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, [_value].concat(other));
|
90
|
+
case 4:
|
91
|
+
case "end":
|
92
|
+
return _context.stop();
|
93
|
+
}
|
94
|
+
}, _callee);
|
95
|
+
}));
|
96
|
+
function onOk() {
|
97
|
+
return _onOk.apply(this, arguments);
|
77
98
|
}
|
78
|
-
|
79
|
-
|
80
|
-
}
|
99
|
+
return onOk;
|
100
|
+
}()
|
81
101
|
}));
|
82
102
|
}
|
83
103
|
case 13:
|
84
104
|
case "end":
|
85
|
-
return
|
105
|
+
return _context2.stop();
|
86
106
|
}
|
87
|
-
},
|
107
|
+
}, _callee2);
|
88
108
|
}));
|
89
109
|
return function handleChange(_x) {
|
90
110
|
return _ref.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);
|