@pointcloud/pcloud-components 1.0.10 → 1.0.12
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/esm/CRUD/index.d.ts
CHANGED
|
@@ -67,18 +67,24 @@ export type CRUDProps = {
|
|
|
67
67
|
batchDeleteButtonProps?: ButtonProps;
|
|
68
68
|
/** 显示行编辑 */
|
|
69
69
|
showEdit?: boolean;
|
|
70
|
+
/** 根据行数据动态控制编辑按钮显隐 */
|
|
71
|
+
showEditPerRow?: (_record: any) => boolean;
|
|
70
72
|
/** 行编辑按钮文本 */
|
|
71
73
|
editButtonText?: string;
|
|
72
74
|
/** 编辑按钮配置 */
|
|
73
75
|
editButtonProps?: ButtonProps;
|
|
74
76
|
/** 显示行删除 */
|
|
75
77
|
showDelete?: boolean;
|
|
78
|
+
/** 根据行数据动态控制删除按钮显隐 */
|
|
79
|
+
showDeletePerRow?: (_record: any) => boolean;
|
|
76
80
|
/** 删除按钮文本 */
|
|
77
81
|
deleteButtonText?: string;
|
|
78
82
|
/** 删除按钮配置 */
|
|
79
83
|
deleteButtonProps?: ButtonProps;
|
|
80
84
|
/** 显示行查看 */
|
|
81
85
|
showView?: boolean;
|
|
86
|
+
/** 根据行数据动态控制查看按钮显隐 */
|
|
87
|
+
showViewPerRow?: (_record: any) => boolean;
|
|
82
88
|
/** 行查看按钮文本 */
|
|
83
89
|
viewButtonText?: string;
|
|
84
90
|
/** 行查看按钮配置 */
|
package/dist/esm/CRUD/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
6
6
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
8
|
var _excluded = ["immediate"],
|
|
9
|
-
_excluded2 = ["columns"
|
|
9
|
+
_excluded2 = ["columns"];
|
|
10
10
|
import React, { useMemo, useState, useContext, useCallback, useRef, forwardRef, useImperativeHandle, useEffect } from 'react';
|
|
11
11
|
import classNames from 'classnames';
|
|
12
12
|
import { Button, Popover } from 'antd';
|
|
@@ -25,7 +25,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
25
25
|
var defaultStrategies = {
|
|
26
26
|
add: {
|
|
27
27
|
keepSearchValues: true,
|
|
28
|
-
keepPage:
|
|
28
|
+
keepPage: true
|
|
29
29
|
},
|
|
30
30
|
edit: {
|
|
31
31
|
keepSearchValues: true,
|
|
@@ -54,10 +54,13 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
54
54
|
batchDeleteButtonProps = props.batchDeleteButtonProps,
|
|
55
55
|
_props$showEdit = props.showEdit,
|
|
56
56
|
showEdit = _props$showEdit === void 0 ? true : _props$showEdit,
|
|
57
|
+
showEditPerRow = props.showEditPerRow,
|
|
57
58
|
_props$showDelete = props.showDelete,
|
|
58
59
|
showDelete = _props$showDelete === void 0 ? true : _props$showDelete,
|
|
60
|
+
showDeletePerRow = props.showDeletePerRow,
|
|
59
61
|
_props$showView = props.showView,
|
|
60
62
|
showView = _props$showView === void 0 ? true : _props$showView,
|
|
63
|
+
showViewPerRow = props.showViewPerRow,
|
|
61
64
|
_props$editButtonProp = props.editButtonProps,
|
|
62
65
|
editButtonProps = _props$editButtonProp === void 0 ? {} : _props$editButtonProp,
|
|
63
66
|
_props$deleteButtonPr = props.deleteButtonProps,
|
|
@@ -365,9 +368,10 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
365
368
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
366
369
|
while (1) switch (_context6.prev = _context6.next) {
|
|
367
370
|
case 0:
|
|
368
|
-
_context6.
|
|
371
|
+
_context6.prev = 0;
|
|
372
|
+
_context6.next = 3;
|
|
369
373
|
return deleteApi(_objectSpread({}, selectedData));
|
|
370
|
-
case
|
|
374
|
+
case 3:
|
|
371
375
|
_isNeedRefreshToPage = isNeedRefreshToPage(selectedData.selectedRows.length), needRefreshToPage = _isNeedRefreshToPage.needRefreshToPage, targetPage = _isNeedRefreshToPage.targetPage;
|
|
372
376
|
handleRefresh(memoizedDeleteRefreshStrategy, {
|
|
373
377
|
needRefreshToPage: needRefreshToPage,
|
|
@@ -377,11 +381,17 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
377
381
|
selectedRowKeys: [],
|
|
378
382
|
selectedRows: []
|
|
379
383
|
});
|
|
380
|
-
|
|
384
|
+
_context6.next = 11;
|
|
385
|
+
break;
|
|
386
|
+
case 8:
|
|
387
|
+
_context6.prev = 8;
|
|
388
|
+
_context6.t0 = _context6["catch"](0);
|
|
389
|
+
return _context6.abrupt("return", Promise.reject(_context6.t0));
|
|
390
|
+
case 11:
|
|
381
391
|
case "end":
|
|
382
392
|
return _context6.stop();
|
|
383
393
|
}
|
|
384
|
-
}, _callee6);
|
|
394
|
+
}, _callee6, null, [[0, 8]]);
|
|
385
395
|
}));
|
|
386
396
|
function onOk() {
|
|
387
397
|
return _onOk.apply(this, arguments);
|
|
@@ -403,19 +413,26 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
403
413
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
404
414
|
while (1) switch (_context7.prev = _context7.next) {
|
|
405
415
|
case 0:
|
|
406
|
-
_context7.
|
|
416
|
+
_context7.prev = 0;
|
|
417
|
+
_context7.next = 3;
|
|
407
418
|
return deleteApi(record);
|
|
408
|
-
case
|
|
419
|
+
case 3:
|
|
409
420
|
_isNeedRefreshToPage2 = isNeedRefreshToPage(), needRefreshToPage = _isNeedRefreshToPage2.needRefreshToPage, targetPage = _isNeedRefreshToPage2.targetPage;
|
|
410
421
|
handleRefresh(memoizedDeleteRefreshStrategy, {
|
|
411
422
|
needRefreshToPage: needRefreshToPage,
|
|
412
423
|
targetPage: targetPage
|
|
413
424
|
});
|
|
414
|
-
|
|
425
|
+
_context7.next = 10;
|
|
426
|
+
break;
|
|
427
|
+
case 7:
|
|
428
|
+
_context7.prev = 7;
|
|
429
|
+
_context7.t0 = _context7["catch"](0);
|
|
430
|
+
return _context7.abrupt("return", Promise.reject(_context7.t0));
|
|
431
|
+
case 10:
|
|
415
432
|
case "end":
|
|
416
433
|
return _context7.stop();
|
|
417
434
|
}
|
|
418
|
-
}, _callee7);
|
|
435
|
+
}, _callee7, null, [[0, 7]]);
|
|
419
436
|
}));
|
|
420
437
|
function onOk() {
|
|
421
438
|
return _onOk2.apply(this, arguments);
|
|
@@ -533,9 +550,11 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
533
550
|
render: tableProps.moreActionColumn
|
|
534
551
|
} : tableProps.moreActionColumn : null;
|
|
535
552
|
return function (_text, record) {
|
|
553
|
+
var moreContent = moreActionConfig === null || moreActionConfig === void 0 ? void 0 : moreActionConfig.render(_text, record);
|
|
554
|
+
var showContent = !!moreContent;
|
|
536
555
|
return /*#__PURE__*/_jsxs("div", {
|
|
537
556
|
className: actionColumnClass,
|
|
538
|
-
children: [showEdit && /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({
|
|
557
|
+
children: [showEdit && (!showEditPerRow || showEditPerRow(record)) && /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({
|
|
539
558
|
type: "link",
|
|
540
559
|
icon: /*#__PURE__*/_jsx(EditOutlined, {}),
|
|
541
560
|
onClick: function onClick() {
|
|
@@ -544,7 +563,7 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
544
563
|
size: "small"
|
|
545
564
|
}, editButtonProps), {}, {
|
|
546
565
|
children: editButtonText
|
|
547
|
-
})), showDelete && /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({
|
|
566
|
+
})), showDelete && (!showDeletePerRow || showDeletePerRow(record)) && /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({
|
|
548
567
|
type: "link",
|
|
549
568
|
danger: true,
|
|
550
569
|
icon: /*#__PURE__*/_jsx(DeleteOutlined, {}),
|
|
@@ -554,7 +573,7 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
554
573
|
size: "small"
|
|
555
574
|
}, deleteButtonProps), {}, {
|
|
556
575
|
children: deleteButtonText
|
|
557
|
-
})), showView && /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({
|
|
576
|
+
})), showView && (!showViewPerRow || showViewPerRow(record)) && /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({
|
|
558
577
|
type: "link",
|
|
559
578
|
icon: /*#__PURE__*/_jsx(EyeOutlined, {}),
|
|
560
579
|
onClick: function onClick() {
|
|
@@ -563,10 +582,10 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
563
582
|
size: "small"
|
|
564
583
|
}, viewButtonProps), {}, {
|
|
565
584
|
children: viewButtonText
|
|
566
|
-
})), moreActionConfig && /*#__PURE__*/_jsx(Popover, _objectSpread(_objectSpread({
|
|
585
|
+
})), moreActionConfig && showContent && /*#__PURE__*/_jsx(Popover, _objectSpread(_objectSpread({
|
|
567
586
|
trigger: "click",
|
|
568
587
|
placement: "bottomRight",
|
|
569
|
-
content:
|
|
588
|
+
content: moreContent,
|
|
570
589
|
zIndex: 5,
|
|
571
590
|
getPopupContainer: function getPopupContainer(e) {
|
|
572
591
|
return e.parentElement || document.body;
|
|
@@ -582,17 +601,19 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
582
601
|
}))]
|
|
583
602
|
});
|
|
584
603
|
};
|
|
585
|
-
}, [handleEdit, handleDelete, handleView, showEdit, showDelete, showView, editButtonText, deleteButtonText, viewButtonText, tableProps === null || tableProps === void 0 ? void 0 : tableProps.moreActionColumn]);
|
|
604
|
+
}, [handleEdit, handleDelete, handleView, showEdit, showEditPerRow, showDelete, showDeletePerRow, showView, showViewPerRow, editButtonText, deleteButtonText, viewButtonText, tableProps === null || tableProps === void 0 ? void 0 : tableProps.moreActionColumn]);
|
|
605
|
+
// 缓存搜索参数
|
|
606
|
+
var tableExtraParams = useMemo(function () {
|
|
607
|
+
return _objectSpread(_objectSpread({}, (tableProps === null || tableProps === void 0 ? void 0 : tableProps.extraParams) || {}), searchValues);
|
|
608
|
+
}, [JSON.stringify(tableProps === null || tableProps === void 0 ? void 0 : tableProps.extraParams), JSON.stringify(searchValues)]);
|
|
586
609
|
var tablePropsWithSearch = useMemo(function () {
|
|
587
610
|
var _ref9 = tableProps || {},
|
|
588
611
|
_ref9$columns = _ref9.columns,
|
|
589
612
|
columns = _ref9$columns === void 0 ? [] : _ref9$columns,
|
|
590
|
-
tableExtraParams = _ref9.extraParams,
|
|
591
613
|
otherTableProps = _objectWithoutProperties(_ref9, _excluded2);
|
|
592
|
-
return _objectSpread({
|
|
614
|
+
return _objectSpread(_objectSpread({
|
|
593
615
|
actionColumn: actionColumn,
|
|
594
616
|
columns: tablePropsState.columns || columns,
|
|
595
|
-
extraParams: _objectSpread(_objectSpread({}, tableExtraParams || {}), searchValues),
|
|
596
617
|
rowSelection: {
|
|
597
618
|
fixed: true,
|
|
598
619
|
onChange: function onChange(selectedRowKeys, selectedRows) {
|
|
@@ -603,13 +624,23 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
603
624
|
}
|
|
604
625
|
},
|
|
605
626
|
loadMore: listApi
|
|
606
|
-
}, otherTableProps)
|
|
607
|
-
|
|
627
|
+
}, otherTableProps), {}, {
|
|
628
|
+
extraParams: tableExtraParams
|
|
629
|
+
});
|
|
630
|
+
}, [tableProps, tablePropsState.columns, tableExtraParams, actionColumn, listApi]);
|
|
608
631
|
var mergedModalFormProps = useMemo(function () {
|
|
609
|
-
var _modalFormProps$modal;
|
|
632
|
+
var _modalFormProps$modal, _modalFormProps$formP;
|
|
610
633
|
if (!(modalFormProps !== null && modalFormProps !== void 0 && modalFormProps.formProps)) return null;
|
|
611
634
|
var isViewMode = modalConfig.mode === 'view';
|
|
612
635
|
var modalTitle = (modalFormProps === null || modalFormProps === void 0 || (_modalFormProps$modal = modalFormProps.modalProps) === null || _modalFormProps$modal === void 0 ? void 0 : _modalFormProps$modal.title) || '';
|
|
636
|
+
|
|
637
|
+
// 详情模式下,显式禁用每个表单项(避免依赖 Ant Design Form 的 disabled 级联)
|
|
638
|
+
var baseItems = (_modalFormProps$formP = modalFormProps.formProps) === null || _modalFormProps$formP === void 0 ? void 0 : _modalFormProps$formP.items;
|
|
639
|
+
var items = isViewMode && baseItems !== null && baseItems !== void 0 && baseItems.length ? baseItems.map(function (item) {
|
|
640
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
641
|
+
disabled: true
|
|
642
|
+
});
|
|
643
|
+
}) : baseItems;
|
|
613
644
|
return {
|
|
614
645
|
modalProps: _objectSpread(_objectSpread({
|
|
615
646
|
open: modalConfig.visible,
|
|
@@ -618,12 +649,13 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
618
649
|
}, modalFormProps === null || modalFormProps === void 0 ? void 0 : modalFormProps.modalProps), {}, {
|
|
619
650
|
title: isViewMode ? "".concat(modalTitle, "\u8BE6\u60C5") : modalConfig.mode === 'edit' ? "\u7F16\u8F91".concat(modalTitle) : "\u65B0\u589E".concat(modalTitle)
|
|
620
651
|
}),
|
|
621
|
-
formProps: _objectSpread({
|
|
652
|
+
formProps: _objectSpread(_objectSpread({
|
|
622
653
|
values: detailData || currentRecordRef.current || {},
|
|
623
654
|
disabled: isViewMode,
|
|
624
|
-
// 详情模式下禁用表单编辑
|
|
625
655
|
className: "".concat(classname, "-modalform-").concat(modalConfig.mode)
|
|
626
|
-
}, modalFormProps === null || modalFormProps === void 0 ? void 0 : modalFormProps.formProps)
|
|
656
|
+
}, modalFormProps === null || modalFormProps === void 0 ? void 0 : modalFormProps.formProps), {}, {
|
|
657
|
+
items: items
|
|
658
|
+
})
|
|
627
659
|
};
|
|
628
660
|
}, [modalConfig, detailData, handleCancel, handleModalOk, modalFormProps, classname]);
|
|
629
661
|
var onActions = useMemo(function () {
|
|
@@ -12,8 +12,7 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
12
12
|
var DynamicFormItem = function DynamicFormItem(props) {
|
|
13
13
|
var _props$name = props.name,
|
|
14
14
|
name = _props$name === void 0 ? 'dynamicItems' : _props$name,
|
|
15
|
-
|
|
16
|
-
initialValue = _props$initialValue === void 0 ? [undefined] : _props$initialValue,
|
|
15
|
+
initialValue = props.initialValue,
|
|
17
16
|
rules = props.rules,
|
|
18
17
|
itemConfig = props.itemConfig,
|
|
19
18
|
_props$addButtonText = props.addButtonText,
|
|
@@ -26,7 +25,7 @@ var DynamicFormItem = function DynamicFormItem(props) {
|
|
|
26
25
|
_props$removeButtonPr = props.removeButtonProps,
|
|
27
26
|
removeButtonProps = _props$removeButtonPr === void 0 ? {} : _props$removeButtonPr,
|
|
28
27
|
_props$minItems = props.minItems,
|
|
29
|
-
minItems = _props$minItems === void 0 ?
|
|
28
|
+
minItems = _props$minItems === void 0 ? 1 : _props$minItems,
|
|
30
29
|
maxItems = props.maxItems,
|
|
31
30
|
_props$showAdd = props.showAdd,
|
|
32
31
|
showAdd = _props$showAdd === void 0 ? true : _props$showAdd,
|
|
@@ -34,6 +33,9 @@ var DynamicFormItem = function DynamicFormItem(props) {
|
|
|
34
33
|
showRemove = _props$showRemove === void 0 ? true : _props$showRemove,
|
|
35
34
|
_props$addPosition = props.addPosition,
|
|
36
35
|
addPosition = _props$addPosition === void 0 ? 'bottom' : _props$addPosition;
|
|
36
|
+
var _initialValue = initialValue !== null && initialValue !== void 0 ? initialValue : minItems === 0 ? [] : Array.from({
|
|
37
|
+
length: minItems
|
|
38
|
+
});
|
|
37
39
|
var renderItem = function renderItem(_ref, index, _ref2, totalFieldsCount) {
|
|
38
40
|
var key = _ref.key,
|
|
39
41
|
name = _ref.name;
|
|
@@ -86,7 +88,7 @@ var DynamicFormItem = function DynamicFormItem(props) {
|
|
|
86
88
|
};
|
|
87
89
|
return /*#__PURE__*/_jsx(Form.List, {
|
|
88
90
|
name: name,
|
|
89
|
-
initialValue:
|
|
91
|
+
initialValue: _initialValue,
|
|
90
92
|
rules: rules,
|
|
91
93
|
children: function children(fields, operation) {
|
|
92
94
|
return /*#__PURE__*/_jsxs(_Fragment, {
|