ztxkui 4.2.18-9 → 4.2.18-91
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/App.js +315 -291
- package/dist/Demo.js +58 -42
- package/dist/DemoCom/BasicDemo.js +57 -56
- package/dist/DemoCom/CodeQueryDemo.js +3 -2
- package/dist/DemoCom/CollapseDemo.js +28 -27
- package/dist/DemoCom/DragSort.js +11 -10
- package/dist/DemoCom/FormDemo.js +36 -30
- package/dist/DemoCom/PrintContainerDemo.js +151 -150
- package/dist/DemoCom/PrintDemo.js +15 -14
- package/dist/DemoCom/SinaturesDemo.js +9 -8
- package/dist/DemoCom/SyhDemo.js +21 -20
- package/dist/DemoCom/TableAnalyse.js +34 -33
- package/dist/DemoCom/TableDemo.js +74 -70
- package/dist/DemoCom/TableDemo1.js +34 -33
- package/dist/DemoCom/TableDetail.d.ts +9 -0
- package/dist/DemoCom/TableDetail.js +259 -0
- package/dist/DemoCom/TestCom.js +22 -19
- package/dist/DemoCom/data.d.ts +110 -0
- package/dist/DemoCom/data.js +2308 -0
- package/dist/TableDemo/BasicTable.js +103 -29
- package/dist/TableDemo/EditableTable.js +177 -91
- package/dist/TableDemo/ModalTable.js +25 -24
- package/dist/TableDemo/ProEditableTable.d.ts +21 -0
- package/dist/TableDemo/ProEditableTable.js +483 -0
- package/dist/TableDemo/data.d.ts +15 -0
- package/dist/TableDemo/data.js +44 -11
- package/dist/TableDemo/index.js +5 -4
- package/dist/TreeDemo.js +8 -7
- package/dist/TreeSelectDemo.js +10 -7
- package/dist/UI/Form/index.d.ts +3 -0
- package/dist/UI/Form/index.js +346 -0
- package/dist/UI/index.d.ts +2 -0
- package/dist/UI/index.js +10 -0
- package/dist/UploadDemo.js +12 -17
- package/dist/components/Button/button.js +3 -2
- package/dist/components/Collapse/collapse.js +2 -1
- package/dist/components/EnhanceSelect/index.d.ts +5 -1
- package/dist/components/EnhanceSelect/index.js +179 -32
- package/dist/components/EnhanceTree/index.js +4 -3
- package/dist/components/EnhanceTreeSelect/index.js +11 -5
- package/dist/components/Export/export.js +5 -4
- package/dist/components/Input/input.d.ts +3 -0
- package/dist/components/Input/input.js +53 -3
- package/dist/components/InputNumber/input-number.js +3 -2
- package/dist/components/NumberCase/index.js +9 -7
- package/dist/components/Print/print.js +4 -3
- package/dist/components/PrintContainer/AttachPreviewModal.js +3 -2
- package/dist/components/PrintContainer/PrintModal.js +4 -3
- package/dist/components/PrintContainer/handle.d.ts +2 -4
- package/dist/components/PrintContainer/handle.js +3 -2
- package/dist/components/PrintContainer/lodop.js +2 -1
- package/dist/components/PrintContainer/print-container.js +74 -73
- package/dist/components/PrintContainer/service.js +5 -4
- package/dist/components/ProForm/hooks.d.ts +23 -0
- package/dist/components/ProForm/hooks.js +209 -0
- package/dist/components/ProForm/index.d.ts +6 -0
- package/dist/components/ProForm/index.js +101 -0
- package/dist/components/ProForm/interface.d.ts +169 -0
- package/dist/components/ProForm/interface.js +1 -0
- package/dist/components/ProForm/item.d.ts +13 -0
- package/dist/components/ProForm/item.js +221 -0
- package/dist/components/ProForm/items.d.ts +5 -0
- package/dist/components/ProForm/items.js +36 -0
- package/dist/components/ProForm/search-drawer.d.ts +12 -0
- package/dist/components/ProForm/search-drawer.js +202 -0
- package/dist/components/ProForm/setting.d.ts +5 -0
- package/dist/components/ProForm/setting.js +13 -0
- package/dist/components/ProFormList/index.d.ts +12 -0
- package/dist/components/ProFormList/index.js +34 -0
- package/dist/components/ProTable/hooks.d.ts +28 -0
- package/dist/components/ProTable/hooks.js +279 -0
- package/dist/components/ProTable/index.d.ts +8 -0
- package/dist/components/ProTable/index.js +77 -0
- package/dist/components/ProTable/interface.d.ts +51 -0
- package/dist/components/ProTable/interface.js +1 -0
- package/dist/components/RangePicker/range-picker.js +5 -2
- package/dist/components/SortableCancel/sortable-cancel.d.ts +1 -0
- package/dist/components/SortableCancel/sortable-cancel.js +2 -2
- package/dist/components/Table/components/FillDown.d.ts +8 -0
- package/dist/components/Table/components/FillDown.js +11 -0
- package/dist/components/Table/components/FilterDropdown.d.ts +15 -0
- package/dist/components/Table/components/FilterDropdown.js +93 -0
- package/dist/components/Table/constants.d.ts +2 -0
- package/dist/components/Table/constants.js +2 -0
- package/dist/components/Table/hooks/useColumns.d.ts +25 -8
- package/dist/components/Table/hooks/useColumns.js +704 -180
- package/dist/components/Table/hooks/useDropRef.js +4 -2
- package/dist/components/Table/hooks/useInnerPagination.js +1 -0
- package/dist/components/Table/hooks/useSelectSubtotal.d.ts +4 -0
- package/dist/components/Table/hooks/useSelectSubtotal.js +182 -0
- package/dist/components/Table/hooks/useVituralScrollBar.d.ts +10 -0
- package/dist/components/Table/hooks/useVituralScrollBar.js +234 -0
- package/dist/components/Table/index.d.ts +11 -0
- package/dist/components/Table/table-adddel-column.d.ts +8 -5
- package/dist/components/Table/table-adddel-column.js +16 -5
- package/dist/components/Table/table-dynamic.js +165 -18
- package/dist/components/Table/table-enhance-cell.d.ts +7 -3
- package/dist/components/Table/table-enhance-cell.js +214 -109
- package/dist/components/Table/table-enhance-row.d.ts +4 -4
- package/dist/components/Table/table-enhance-row.js +10 -11
- package/dist/components/Table/table-headTooltip.d.ts +6 -0
- package/dist/components/Table/table-headTooltip.js +13 -0
- package/dist/components/Table/table-resizable-title.d.ts +4 -5
- package/dist/components/Table/table-resizable-title.js +33 -6
- package/dist/components/Table/table-sort.d.ts +11 -0
- package/dist/components/Table/table-sort.js +66 -0
- package/dist/components/Table/table.d.ts +30 -4
- package/dist/components/Table/table.js +526 -180
- package/dist/components/Table/utils/dom.d.ts +26 -0
- package/dist/components/Table/utils/dom.js +123 -0
- package/dist/components/Table/utils/filterHandle.d.ts +1 -0
- package/dist/components/Table/utils/filterHandle.js +66 -0
- package/dist/components/Table/utils/getSummaryData.d.ts +2 -1
- package/dist/components/Table/utils/getSummaryData.js +282 -25
- package/dist/components/Table/utils/shallowEqual.d.ts +2 -0
- package/dist/components/Table/utils/shallowEqual.js +35 -0
- package/dist/components/Table/utils/validate.d.ts +1 -1
- package/dist/components/Table/utils/validate.js +30 -11
- package/dist/components/TreeSelect/index.d.ts +15 -0
- package/dist/components/TreeSelect/index.js +29 -0
- package/dist/components/Upload/upload-table.js +31 -26
- package/dist/components/Upload/upload.js +23 -18
- package/dist/components/Upload/utils.js +11 -10
- package/dist/components/UploadSingle/upload-single.js +5 -4
- package/dist/components/Watermark/index.d.ts +2 -0
- package/dist/components/Watermark/index.js +2 -0
- package/dist/components/Watermark/interface.d.ts +20 -0
- package/dist/components/Watermark/interface.js +1 -0
- package/dist/components/Watermark/utils.d.ts +1 -0
- package/dist/components/Watermark/utils.js +70 -0
- package/dist/components/Watermark/water.d.ts +50 -0
- package/dist/components/Watermark/water.js +66 -0
- package/dist/components/Watermark/watermark-div.d.ts +4 -0
- package/dist/components/Watermark/watermark-div.js +41 -0
- package/dist/components/Watermark/watermark-shadow.d.ts +6 -0
- package/dist/components/Watermark/watermark-shadow.js +116 -0
- package/dist/components/Watermark/watermark.d.ts +3 -0
- package/dist/components/Watermark/watermark.js +102 -0
- package/dist/components/WorkflowPrintContainer/component/Gragh/Gragh.d.ts +9 -0
- package/dist/components/WorkflowPrintContainer/component/Gragh/Gragh.js +63 -0
- package/dist/components/WorkflowPrintContainer/component/Header.d.ts +12 -0
- package/dist/components/WorkflowPrintContainer/component/Header.js +109 -0
- package/dist/components/WorkflowPrintContainer/component/ProcessDetail.d.ts +18 -0
- package/dist/components/WorkflowPrintContainer/component/ProcessDetail.js +243 -0
- package/dist/components/WorkflowPrintContainer/component/Upload/index.d.ts +20 -0
- package/dist/components/WorkflowPrintContainer/component/Upload/index.js +59 -0
- package/dist/components/WorkflowPrintContainer/component/association/component/TableList.d.ts +10 -0
- package/dist/components/WorkflowPrintContainer/component/association/component/TableList.js +75 -0
- package/dist/components/WorkflowPrintContainer/component/association/index.d.ts +9 -0
- package/dist/components/WorkflowPrintContainer/component/association/index.js +92 -0
- package/dist/components/WorkflowPrintContainer/component/attention/component/TableList.d.ts +9 -0
- package/dist/components/WorkflowPrintContainer/component/attention/component/TableList.js +38 -0
- package/dist/components/WorkflowPrintContainer/component/attention/index.d.ts +10 -0
- package/dist/components/WorkflowPrintContainer/component/attention/index.js +95 -0
- package/dist/components/WorkflowPrintContainer/component/audit/component/TableList.d.ts +8 -0
- package/dist/components/WorkflowPrintContainer/component/audit/component/TableList.js +53 -0
- package/dist/components/WorkflowPrintContainer/component/audit/index.d.ts +7 -0
- package/dist/components/WorkflowPrintContainer/component/audit/index.js +88 -0
- package/dist/components/WorkflowPrintContainer/component/previewTable/component/TableList.d.ts +9 -0
- package/dist/components/WorkflowPrintContainer/component/previewTable/component/TableList.js +53 -0
- package/dist/components/WorkflowPrintContainer/component/previewTable/index.d.ts +11 -0
- package/dist/components/WorkflowPrintContainer/component/previewTable/index.js +60 -0
- package/dist/components/WorkflowPrintContainer/component/send/component/TableList.d.ts +9 -0
- package/dist/components/WorkflowPrintContainer/component/send/component/TableList.js +50 -0
- package/dist/components/WorkflowPrintContainer/component/send/index.d.ts +9 -0
- package/dist/components/WorkflowPrintContainer/component/send/index.js +92 -0
- package/dist/components/WorkflowPrintContainer/component/trail/component/TableList.d.ts +12 -0
- package/dist/components/WorkflowPrintContainer/component/trail/component/TableList.js +282 -0
- package/dist/components/WorkflowPrintContainer/component/trail/index.d.ts +11 -0
- package/dist/components/WorkflowPrintContainer/component/trail/index.js +56 -0
- package/dist/components/WorkflowPrintContainer/images.d.ts +2 -0
- package/dist/components/WorkflowPrintContainer/images.js +2 -0
- package/dist/components/WorkflowPrintContainer/index.d.ts +2 -0
- package/dist/components/WorkflowPrintContainer/index.js +2 -0
- package/dist/components/WorkflowPrintContainer/service.d.ts +14 -0
- package/dist/components/WorkflowPrintContainer/service.js +101 -0
- package/dist/components/WorkflowPrintContainer/usePagination.d.ts +14 -0
- package/dist/components/WorkflowPrintContainer/usePagination.js +22 -0
- package/dist/components/WorkflowPrintContainer/workflow-print-container.d.ts +100 -0
- package/dist/components/WorkflowPrintContainer/workflow-print-container.js +236 -0
- package/dist/components/business/Analyse/index.js +12 -11
- package/dist/components/business/CodeQuery/component/SearchForm.js +3 -2
- package/dist/components/business/CodeQuery/component/TableList.js +5 -4
- package/dist/components/business/CodeQuery/hooks.js +2 -1
- package/dist/components/business/CodeQuery/index.js +2 -1
- package/dist/components/business/Common/UserForgetPassword/index.js +36 -28
- package/dist/components/business/Common/UserInfo/component/MakingForm.js +11 -10
- package/dist/components/business/Common/UserInfo/index.js +7 -4
- package/dist/components/business/Common/UserPassword/index.d.ts +1 -0
- package/dist/components/business/Common/UserPassword/index.js +39 -18
- package/dist/components/business/Common/validatePassword.d.ts +1 -1
- package/dist/components/business/Common/validatePassword.js +17 -7
- package/dist/components/business/DetailCard/index.js +7 -6
- package/dist/components/business/DetailHeader/index.js +7 -6
- package/dist/components/business/DetailList/index.js +5 -4
- package/dist/components/business/DgColumns/index.js +12 -11
- package/dist/components/business/ExportButton/index.js +6 -5
- package/dist/components/business/Footer/index.js +4 -1
- package/dist/components/business/GridList/item.d.ts +1 -1
- package/dist/components/business/List/item.d.ts +1 -1
- package/dist/components/business/NewList/item.d.ts +1 -1
- package/dist/components/business/NewList/item.js +1 -1
- package/dist/components/business/OperationBtnGroup/index.js +17 -16
- package/dist/components/business/SearchContainer/hooks/useToggle.d.ts +1 -1
- package/dist/components/business/SearchContainer/hooks/useToggle.js +5 -4
- package/dist/components/business/SearchContainer/record-common-item.d.ts +14 -0
- package/dist/components/business/SearchContainer/record-common-item.js +82 -0
- package/dist/components/business/SearchContainer/record-common-list.d.ts +3 -0
- package/dist/components/business/SearchContainer/record-common-list.js +64 -0
- package/dist/components/business/SearchContainer/search-container.d.ts +13 -0
- package/dist/components/business/SearchContainer/search-container.js +32 -3
- package/dist/components/business/SearchContainer/search-drawer.d.ts +1 -0
- package/dist/components/business/SearchContainer/search-drawer.js +139 -13
- package/dist/components/business/SearchContainer/search-item.js +33 -2
- package/dist/components/business/SearchContainer/search-left.d.ts +1 -0
- package/dist/components/business/SearchContainer/search-left.js +11 -3
- package/dist/components/business/SearchContainer/search-right.js +23 -4
- package/dist/components/business/SearchContainer/useRecordCommonInit.d.ts +15 -0
- package/dist/components/business/SearchContainer/useRecordCommonInit.js +242 -0
- package/dist/components/business/SearchContainer/useRecordCommonSearch.d.ts +7 -0
- package/dist/components/business/SearchContainer/useRecordCommonSearch.js +140 -0
- package/dist/components/business/SearchContainer/useRecordCommonSearchContext.d.ts +31 -0
- package/dist/components/business/SearchContainer/useRecordCommonSearchContext.js +8 -0
- package/dist/components/business/Signatures/components/AttachOperation.js +7 -6
- package/dist/components/business/Signatures/components/CompareResult.js +7 -6
- package/dist/components/business/Signatures/components/DetailTable.js +37 -34
- package/dist/components/business/Signatures/components/QunjSeal.js +5 -4
- package/dist/components/business/Signatures/components/SealCheckbox.js +3 -2
- package/dist/components/business/Signatures/components/TemplateAttach.js +2 -1
- package/dist/components/business/Signatures/index.js +64 -53
- package/dist/components/business/SortList/sort-drawer.js +5 -4
- package/dist/components/business/Template/index.js +11 -10
- package/dist/components/utils/MyStorage.d.ts +36 -0
- package/dist/components/utils/MyStorage.js +120 -0
- package/dist/components/utils/ZtxkContext.d.ts +34 -0
- package/dist/components/utils/ZtxkContext.js +13 -0
- package/dist/components/utils/fetch.d.ts +10 -0
- package/dist/components/utils/fetch.js +119 -0
- package/dist/components/utils/index.d.ts +1 -0
- package/dist/components/utils/index.js +20 -0
- package/dist/components/utils/processNumber.d.ts +12 -0
- package/dist/components/utils/processNumber.js +106 -0
- package/dist/components/utils/upload.js +6 -3
- package/dist/components/utils/useBaseContext.d.ts +5 -0
- package/dist/components/utils/useBaseContext.js +10 -0
- package/dist/components/utils/useLastest.d.ts +2 -0
- package/dist/components/utils/useLastest.js +6 -0
- package/dist/components/utils/useMemoizedFn.d.ts +4 -0
- package/dist/components/utils/useMemoizedFn.js +19 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/index.css +1011 -7
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +200 -84
- package/dist/locales/en-US.json +818 -0
- package/dist/locales/zh-CN.json +818 -0
- package/dist/request.js +6 -5
- package/package.json +7 -2
|
@@ -9,14 +9,21 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
13
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
14
|
+
to[j] = from[i];
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
import i18next from 'ztxkutils/dist/i18next';
|
|
18
|
+
import React, { memo, useCallback, useMemo, useState } from 'react';
|
|
13
19
|
import { SettingOutlined } from '@ant-design/icons';
|
|
14
|
-
import { Drawer, Button, Sortable, Checkbox } from '../../../index';
|
|
15
|
-
import { DndProvider } from 'react-dnd';
|
|
20
|
+
import { Drawer, Button, Sortable, SortableCancel, Checkbox, Input, message, } from '../../../index';
|
|
21
|
+
import { DndProvider, useDrop } from 'react-dnd';
|
|
16
22
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
17
23
|
import update from 'immutability-helper';
|
|
24
|
+
var typeSymbol = Symbol('search-drawer');
|
|
18
25
|
var SearchDrawer = function (_a) {
|
|
19
|
-
var visible = _a.visible, onClose = _a.onClose, onReset = _a.onReset, onSure = _a.onSure, onInsideChange = _a.onInsideChange, dynamicList = _a.dynamicList;
|
|
26
|
+
var visible = _a.visible, onClose = _a.onClose, onReset = _a.onReset, onSure = _a.onSure, onInsideChange = _a.onInsideChange, dynamicList = _a.dynamicList, disabledHideItem = _a.disabledHideItem;
|
|
20
27
|
var checkedValues = useMemo(function () {
|
|
21
28
|
var _checkedValues = [];
|
|
22
29
|
dynamicList.forEach(function (item) {
|
|
@@ -26,6 +33,30 @@ var SearchDrawer = function (_a) {
|
|
|
26
33
|
});
|
|
27
34
|
return _checkedValues;
|
|
28
35
|
}, [dynamicList]);
|
|
36
|
+
var _b = useState(null), filterDynamicColumns = _b[0], setFilterDynamicColumns = _b[1];
|
|
37
|
+
var _c = useState([]), filterCheckedValues = _c[0], setFilterCheckedValues = _c[1];
|
|
38
|
+
var onFindItemHandle = useCallback(function (id) {
|
|
39
|
+
var dragItem = dynamicList === null || dynamicList === void 0 ? void 0 : dynamicList.filter(function (c) { return "" + c.name === id; })[0];
|
|
40
|
+
return {
|
|
41
|
+
dragItem: dragItem,
|
|
42
|
+
index: dynamicList === null || dynamicList === void 0 ? void 0 : dynamicList.indexOf(dragItem),
|
|
43
|
+
};
|
|
44
|
+
}, [dynamicList]);
|
|
45
|
+
var onMoveItemHandle = useCallback(function (id, to) {
|
|
46
|
+
var _a = onFindItemHandle(id), dragItem = _a.dragItem, index = _a.index;
|
|
47
|
+
var currentList = update(dynamicList, {
|
|
48
|
+
$splice: [
|
|
49
|
+
[index, 1],
|
|
50
|
+
[to, 0, dragItem],
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
onInsideChange && onInsideChange(currentList);
|
|
54
|
+
if (filterDynamicColumns) {
|
|
55
|
+
setFilterDynamicColumns(currentList.filter(function (c) {
|
|
56
|
+
return filterDynamicColumns === null || filterDynamicColumns === void 0 ? void 0 : filterDynamicColumns.find(function (f) { return f.name === c.name; });
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
}, [onFindItemHandle, dynamicList, onInsideChange, filterDynamicColumns]);
|
|
29
60
|
/**移动事件 */
|
|
30
61
|
var onMoveItem = useCallback(function (dragIndex, hoverIndex) {
|
|
31
62
|
var dragCard = dynamicList[dragIndex];
|
|
@@ -39,12 +70,23 @@ var SearchDrawer = function (_a) {
|
|
|
39
70
|
}, [dynamicList, onInsideChange]);
|
|
40
71
|
/**确认事件 */
|
|
41
72
|
var onSureHandle = useCallback(function () {
|
|
73
|
+
var _checkedValues = [];
|
|
74
|
+
dynamicList.forEach(function (item) {
|
|
75
|
+
if (item.show) {
|
|
76
|
+
_checkedValues.push(item.name);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
if (_checkedValues.length === 0) {
|
|
80
|
+
message.info(i18next.t('请至少保留一个展示!'));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
42
83
|
onSure && onSure(dynamicList);
|
|
43
84
|
}, [onSure, dynamicList]);
|
|
44
85
|
var onCheckboxChange = function (checkedValues) {
|
|
86
|
+
var newCheckedValues = __spreadArray(__spreadArray([], filterCheckedValues), checkedValues);
|
|
45
87
|
var newDynamicList = dynamicList.map(function (item) { return (__assign({}, item)); }) || [];
|
|
46
88
|
newDynamicList.forEach(function (item) {
|
|
47
|
-
if (!
|
|
89
|
+
if (!newCheckedValues.find(function (value) { return value === item.name; })) {
|
|
48
90
|
item.show = false;
|
|
49
91
|
}
|
|
50
92
|
else {
|
|
@@ -55,16 +97,100 @@ var SearchDrawer = function (_a) {
|
|
|
55
97
|
};
|
|
56
98
|
/**底部按钮 */
|
|
57
99
|
var renderFooter = function () { return (React.createElement(React.Fragment, null,
|
|
58
|
-
React.createElement(Button, { type: "default", onClick: onClose },
|
|
59
|
-
React.createElement(Button, { type: "default", onClick: onReset },
|
|
60
|
-
React.createElement(Button, { type: "primary", onClick: onSureHandle },
|
|
100
|
+
React.createElement(Button, { type: "default", onClick: onClose }, i18next.t('取消')),
|
|
101
|
+
React.createElement(Button, { type: "default", onClick: onReset }, i18next.t('重置')),
|
|
102
|
+
React.createElement(Button, { type: "primary", onClick: onSureHandle }, i18next.t('确定')))); };
|
|
103
|
+
/**
|
|
104
|
+
* @description 表格列动态显示/隐藏 - 全选/反选按钮点击回调
|
|
105
|
+
* @author (可补充作者姓名)
|
|
106
|
+
* @param {('all' | 'inverse')} type - 操作类型:'all' 全选(仅对「过滤后可见+可动态操作」列生效),'inverse' 反选(同上)
|
|
107
|
+
* @see dynamicColumns - 原始完整表格列集合(包含所有列)
|
|
108
|
+
* @see filterDynamicColumns - 过滤后的可见列集合(仅操作此集合中的列)
|
|
109
|
+
* @see checkedValues - 已选中的列 key 集合(状态变量)
|
|
110
|
+
* @see setCheckedValues - 更新选中列的状态函数
|
|
111
|
+
* @note 核心规则(解决「过滤后操作不影响过滤前数据」的核心诉求):
|
|
112
|
+
* 1. 操作范围严格限制:仅对「过滤后可见列(filterDynamicColumns 优先,无则 dynamicColumns)+ 可动态操作(isNoDynamicHide: false)」的列生效
|
|
113
|
+
* 2. 过滤后隐藏的列(未在 targetColumns 中):无论是否可动态,均不参与全选/反选,保持其原始选中状态不变
|
|
114
|
+
* 3. 禁止动态隐藏的列(isNoDynamicHide: true):即使在过滤后可见,也不参与全选/反选,保持原始选中状态
|
|
115
|
+
* 4. 仅当操作后选中状态发生变化时才更新,避免无效渲染
|
|
116
|
+
*/
|
|
117
|
+
var onCheckBtn = function (type) {
|
|
118
|
+
// 1. 确定操作的目标列集合:仅对「过滤后可见列」操作(优先 filterDynamicColumns,无则用 dynamicColumns)
|
|
119
|
+
var targetColumns = filterDynamicColumns !== null && filterDynamicColumns !== void 0 ? filterDynamicColumns : dynamicList;
|
|
120
|
+
// 2. 拆分目标列中的两类列(仅在可见列范围内处理)
|
|
121
|
+
// 2.1 「可操作列」:过滤后可见 + 允许动态隐藏(isNoDynamicHide: false)→ 参与全选/反选
|
|
122
|
+
var operableKeys = targetColumns
|
|
123
|
+
.filter(function (column) { return !column.disabled && !column.dynamicDisabled; })
|
|
124
|
+
.map(function (column) { return column.name; });
|
|
125
|
+
var operableLen = operableKeys.length;
|
|
126
|
+
// 2.2 「不可操作列」:过滤后可见 + 禁止动态隐藏(isNoDynamicHide: true)→ 不参与操作,保留原选中状态
|
|
127
|
+
var visibleNonOperableKeys = targetColumns
|
|
128
|
+
.filter(function (column) { return column.disabled || column.dynamicDisabled; })
|
|
129
|
+
.map(function (column) { return column.name; });
|
|
130
|
+
// 3. 拆分当前已选中的 keys(确保「过滤后隐藏的列」状态不变)
|
|
131
|
+
// 3.1 已选中的「过滤后隐藏的列」:无论是否可动态,均保留原状态(不参与本次操作)
|
|
132
|
+
var hiddenCheckedKeys = checkedValues.filter(function (key) { return !targetColumns.some(function (column) { return column.name === key; }); } // 不在目标列(过滤后隐藏)的选中项
|
|
133
|
+
);
|
|
134
|
+
// 3.2 已选中的「可见不可操作列」:保留原选中状态
|
|
135
|
+
var visibleNonOperableCheckedKeys = checkedValues.filter(function (key) {
|
|
136
|
+
return visibleNonOperableKeys.includes(key);
|
|
137
|
+
});
|
|
138
|
+
// 3.3 已选中的「可见可操作列」:参与本次全选/反选
|
|
139
|
+
var operableCheckedKeys = checkedValues.filter(function (key) {
|
|
140
|
+
return operableKeys.includes(key);
|
|
141
|
+
});
|
|
142
|
+
// 4. 全选逻辑:仅选中「可见可操作列」,其他列(隐藏列、可见不可操作列)保持原状态
|
|
143
|
+
if (type === 'all') {
|
|
144
|
+
// 边界判断:仅当「已选中的可操作列数 ≠ 可操作列总数」时才更新(避免无效渲染)
|
|
145
|
+
if (operableCheckedKeys.length !== operableLen) {
|
|
146
|
+
onCheckboxChange(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], filterCheckedValues), operableKeys), visibleNonOperableCheckedKeys), hiddenCheckedKeys));
|
|
147
|
+
}
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
// 5. 反选逻辑:仅反选「可见可操作列」,其他列保持原状态
|
|
151
|
+
var inversedOperableKeys = operableKeys.filter(function (key) { return !operableCheckedKeys.includes(key); });
|
|
152
|
+
onCheckboxChange(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], filterCheckedValues), inversedOperableKeys), visibleNonOperableCheckedKeys), hiddenCheckedKeys));
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* @description 搜索过滤触发的回调
|
|
156
|
+
* @param value 搜索值
|
|
157
|
+
*/
|
|
158
|
+
var onSearchHandle = function (value) {
|
|
159
|
+
if (!value) {
|
|
160
|
+
setFilterCheckedValues([]);
|
|
161
|
+
setFilterDynamicColumns(null);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
var filterColumns = dynamicList.filter(function (column) {
|
|
165
|
+
var _a, _b, _c;
|
|
166
|
+
var title = column.label || column.hiddenLabelName || column.name;
|
|
167
|
+
return (_c = (_b = (_a = title === null || title === void 0 ? void 0 : title.toLowerCase) === null || _a === void 0 ? void 0 : _a.call(title)) === null || _b === void 0 ? void 0 : _b.includes) === null || _c === void 0 ? void 0 : _c.call(_b, value.toLowerCase());
|
|
168
|
+
});
|
|
169
|
+
// 未参与过滤的列,单独缓存起来
|
|
170
|
+
setFilterCheckedValues(checkedValues.filter(function (key) { return !filterColumns.find(function (column) { return column.name === key; }); }));
|
|
171
|
+
setFilterDynamicColumns(filterColumns);
|
|
172
|
+
};
|
|
61
173
|
return (React.createElement(Drawer, { className: "search-drawer", title: React.createElement("div", null,
|
|
62
174
|
React.createElement(SettingOutlined, { style: { fontSize: 16 } }),
|
|
63
175
|
React.createElement("span", { className: "search-drawer--title-text" },
|
|
64
|
-
|
|
65
|
-
React.createElement("span", null,
|
|
66
|
-
React.createElement(DndProvider, { backend: HTML5Backend, context: window },
|
|
67
|
-
React.createElement(
|
|
68
|
-
|
|
176
|
+
i18next.t('查询条件自定义'),
|
|
177
|
+
React.createElement("span", null, i18next.t('(拖拽排序)')))), width: 290, placement: "right", visible: visible, closable: false, maskClosable: false, footer: renderFooter() },
|
|
178
|
+
React.createElement(DndProvider, { backend: HTML5Backend, context: window }, disabledHideItem ? (React.createElement(React.Fragment, null, dynamicList.map(function (item, index) { return (React.createElement(Sortable, { key: item.name, type: "search-drawer", index: index, onMoveItem: onMoveItem },
|
|
179
|
+
React.createElement("div", null, item.label || item.hiddenLabelName || item.name))); }))) : (React.createElement("div", { className: "search-drawer--filter" },
|
|
180
|
+
React.createElement("div", { className: "search-drawer--filter-input" },
|
|
181
|
+
React.createElement(Input.Search, { placeholder: i18next.t('搜索'), onSearch: onSearchHandle }),
|
|
182
|
+
React.createElement(Button, { type: "default", className: "selector-all", loading: false, onClick: function () { return onCheckBtn('all'); } }, i18next.t('全选')),
|
|
183
|
+
React.createElement(Button, { type: "default", className: "selector-inverse", loading: false, onClick: function () { return onCheckBtn('inverse'); } }, i18next.t('反选'))),
|
|
184
|
+
React.createElement(Checkbox.Group, { value: checkedValues, onChange: onCheckboxChange },
|
|
185
|
+
React.createElement(Container, { dynamicColumns: filterDynamicColumns || dynamicList, onFindItemHandle: onFindItemHandle, onMoveItemHandle: onMoveItemHandle })))))));
|
|
69
186
|
};
|
|
187
|
+
function Container(_a) {
|
|
188
|
+
var dynamicColumns = _a.dynamicColumns, onFindItemHandle = _a.onFindItemHandle, onMoveItemHandle = _a.onMoveItemHandle;
|
|
189
|
+
var _b = useDrop(function () { return ({ accept: typeSymbol }); }), drop = _b[1];
|
|
190
|
+
return (React.createElement("div", { ref: drop }, Array.isArray(dynamicColumns) &&
|
|
191
|
+
dynamicColumns.map(function (item, index) {
|
|
192
|
+
return item.name ? (React.createElement(SortableCancel, { type: typeSymbol, key: item.name, id: item.name, onFindItem: onFindItemHandle, onMoveItem: onMoveItemHandle, tipTitle: item.label || item.hiddenLabelName || item.name },
|
|
193
|
+
React.createElement(Checkbox, { value: item.name, disabled: item.disabled || item.dynamicDisabled }, item.label || item.hiddenLabelName || item.name))) : null;
|
|
194
|
+
})));
|
|
195
|
+
}
|
|
70
196
|
export default memo(SearchDrawer);
|
|
@@ -20,9 +20,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
import React from 'react';
|
|
23
|
+
import React, { useCallback, useContext, isValidElement } from 'react';
|
|
24
24
|
import { Form } from 'antd';
|
|
25
25
|
import classNames from 'classnames';
|
|
26
|
+
import { SearchContainerContext } from './search-container';
|
|
26
27
|
var Item = Form.Item;
|
|
27
28
|
function getWidthStr(width) {
|
|
28
29
|
// switch (width) {
|
|
@@ -58,7 +59,37 @@ var SearchItem = function (_a) {
|
|
|
58
59
|
'zt-search__left__item--nolabel': noLabel,
|
|
59
60
|
'zt-search__left__item--nolabelshowbg': noLabelShowBg,
|
|
60
61
|
});
|
|
62
|
+
var _b = useContext(SearchContainerContext), onItemEnterHandleContext = _b.onItemEnterHandle, rightSearchHandleRef = _b.rightSearchHandleRef;
|
|
63
|
+
var handleKeyDown = useCallback(function (e) {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
// 检查是否按下回车键
|
|
66
|
+
if (e.key === 'Enter') {
|
|
67
|
+
e.preventDefault(); // 阻止表单提交等默认行为
|
|
68
|
+
onItemEnterHandleContext === null || onItemEnterHandleContext === void 0 ? void 0 : onItemEnterHandleContext(); // 触发回调
|
|
69
|
+
(_a = rightSearchHandleRef === null || rightSearchHandleRef === void 0 ? void 0 : rightSearchHandleRef.current) === null || _a === void 0 ? void 0 : _a.call(// 触发回调
|
|
70
|
+
rightSearchHandleRef);
|
|
71
|
+
}
|
|
72
|
+
// 调用子组件原有的 onKeyDown(如果存在)
|
|
73
|
+
if (isValidElement(children) &&
|
|
74
|
+
typeof ((_b = children === null || children === void 0 ? void 0 : children.props) === null || _b === void 0 ? void 0 : _b.onKeyDown) === 'function') {
|
|
75
|
+
children.props.onKeyDown(e);
|
|
76
|
+
}
|
|
77
|
+
}, [children, onItemEnterHandleContext, rightSearchHandleRef]);
|
|
78
|
+
var renderChildren = function () {
|
|
79
|
+
try {
|
|
80
|
+
return (onItemEnterHandleContext || (rightSearchHandleRef === null || rightSearchHandleRef === void 0 ? void 0 : rightSearchHandleRef.current)) &&
|
|
81
|
+
isValidElement(children)
|
|
82
|
+
? React.cloneElement(children, {
|
|
83
|
+
onKeyDown: handleKeyDown,
|
|
84
|
+
})
|
|
85
|
+
: children;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
console.error('Error rendering children:', error);
|
|
89
|
+
return children;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
61
92
|
return (React.createElement("div", { className: classes, style: __assign({ width: getWidthStr(width) }, style) },
|
|
62
|
-
React.createElement(Item, __assign({}, restProps),
|
|
93
|
+
React.createElement(Item, __assign({}, restProps), renderChildren())));
|
|
63
94
|
};
|
|
64
95
|
export default SearchItem;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import i18next from 'ztxkutils/dist/i18next';
|
|
1
2
|
import React, { useCallback, useEffect, useState, useRef, useImperativeHandle, } from 'react';
|
|
2
3
|
import classNames from 'classnames';
|
|
3
4
|
import SearchDrawer from './search-drawer';
|
|
4
5
|
import { SettingOutlined, DownOutlined } from '@ant-design/icons';
|
|
5
6
|
import useDynamic, { setDynamicKey, getNewChildren } from './hooks/useDynamic';
|
|
6
7
|
import useToggle from './hooks/useToggle';
|
|
8
|
+
import { useRecordCommonSearchContext } from './useRecordCommonSearchContext';
|
|
7
9
|
function useConfigChildren(children, isDynamic) {
|
|
8
10
|
var _a = useState(null), configChildren = _a[0], setConfigChildren = _a[1];
|
|
9
11
|
useEffect(function () {
|
|
@@ -19,13 +21,19 @@ function useConfigChildren(children, isDynamic) {
|
|
|
19
21
|
return { configChildren: configChildren };
|
|
20
22
|
}
|
|
21
23
|
var SearchLeft = function (_a) {
|
|
22
|
-
var children = _a.children, className = _a.className, isDynamic = _a.isDynamic, _dynamicStorageKey = _a.dynamicStorageKey, onChange = _a.onChange, _b = _a.isFlex, isFlex = _b === void 0 ? true : _b, configInfo = _a.configInfo, isToggle = _a.isToggle, handleRef = _a.handleRef;
|
|
24
|
+
var children = _a.children, className = _a.className, isDynamic = _a.isDynamic, _dynamicStorageKey = _a.dynamicStorageKey, onChange = _a.onChange, _b = _a.isFlex, isFlex = _b === void 0 ? true : _b, configInfo = _a.configInfo, isToggle = _a.isToggle, handleRef = _a.handleRef, defaultToggle = _a.defaultToggle;
|
|
25
|
+
var getRecordCommonSearchKey = useRecordCommonSearchContext().getRecordCommonSearchKey;
|
|
23
26
|
// 为了兼容之前的写法,默认取当前路由地址,但是这种情况会导致微前端下面出现一些问题
|
|
24
27
|
// 所以在使用组件的时候,如果要使用动态配置,必须传入dynamicStorageKey
|
|
25
28
|
// 如果有时间还是需要传入storageKey,之前的写法需要简化
|
|
26
29
|
var dynamicStorageKey = _dynamicStorageKey
|
|
27
30
|
? _dynamicStorageKey
|
|
28
31
|
: window.location.pathname;
|
|
32
|
+
if (getRecordCommonSearchKey) {
|
|
33
|
+
getRecordCommonSearchKey.current = function () {
|
|
34
|
+
return dynamicStorageKey;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
29
37
|
/**缓存初始化值 */
|
|
30
38
|
var _c = useDynamic(children, isDynamic, dynamicStorageKey), dynamicArr = _c.dynamicArr, initDynamicArr = _c.initDynamicArr, newChildren = _c.newChildren;
|
|
31
39
|
var configChildren = useConfigChildren(children, isDynamic).configChildren;
|
|
@@ -42,7 +50,7 @@ var SearchLeft = function (_a) {
|
|
|
42
50
|
}, [dynamicArr]);
|
|
43
51
|
/** 表单容器Ref */
|
|
44
52
|
var containerRef = useRef(null);
|
|
45
|
-
var _f = useToggle(containerRef, dynamicList, isToggle), toggle = _f.toggle, onToggleChange = _f.onToggleChange, setToggleHandle = _f.setToggleHandle;
|
|
53
|
+
var _f = useToggle(containerRef, dynamicList, isToggle, defaultToggle), toggle = _f.toggle, onToggleChange = _f.onToggleChange, setToggleHandle = _f.setToggleHandle;
|
|
46
54
|
useImperativeHandle(handleRef, function () { return ({
|
|
47
55
|
setToggleHandle: setToggleHandle,
|
|
48
56
|
}); });
|
|
@@ -112,7 +120,7 @@ var SearchLeft = function (_a) {
|
|
|
112
120
|
else {
|
|
113
121
|
newRules.unshift({
|
|
114
122
|
required: !!(config === null || config === void 0 ? void 0 : config.isRequired),
|
|
115
|
-
message: label
|
|
123
|
+
message: i18next.t('{{label}} 未填!', { label: label }),
|
|
116
124
|
});
|
|
117
125
|
}
|
|
118
126
|
// 覆盖 disabled rules里面的required属性
|
|
@@ -1,11 +1,30 @@
|
|
|
1
|
+
import i18next from 'ztxkutils/dist/i18next';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import classNames from 'classnames';
|
|
3
4
|
import { Button } from '../../../index';
|
|
5
|
+
import { SearchContainerContext } from './search-container';
|
|
6
|
+
import useRecordCommonSearch from './useRecordCommonSearch';
|
|
4
7
|
var SearchRight = function (_a) {
|
|
5
8
|
var children = _a.children, className = _a.className, onSearchHandle = _a.onSearchHandle, onResetHandle = _a.onResetHandle;
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
var rightSearchHandleRef = React.useContext(SearchContainerContext).rightSearchHandleRef;
|
|
10
|
+
var _b = useRecordCommonSearch(), onRecordSearchHandle = _b.onRecordSearchHandle, recordCommonSearch = _b.recordCommonSearch, setCurrentRecordCommonSearchKey = _b.setCurrentRecordCommonSearchKey;
|
|
11
|
+
var selfOnResetHandle = function () {
|
|
12
|
+
setCurrentRecordCommonSearchKey === null || setCurrentRecordCommonSearchKey === void 0 ? void 0 : setCurrentRecordCommonSearchKey('');
|
|
13
|
+
onResetHandle === null || onResetHandle === void 0 ? void 0 : onResetHandle();
|
|
14
|
+
};
|
|
15
|
+
var classes = classNames('zt-search__right', className, {
|
|
16
|
+
'zt-search__right--record': recordCommonSearch,
|
|
17
|
+
});
|
|
18
|
+
if (rightSearchHandleRef) {
|
|
19
|
+
rightSearchHandleRef.current = onSearchHandle;
|
|
20
|
+
}
|
|
21
|
+
return !recordCommonSearch ? (React.createElement("div", { className: classes },
|
|
22
|
+
React.createElement(Button, { type: "default", onClick: selfOnResetHandle }, i18next.t('重置')),
|
|
23
|
+
React.createElement(Button, { type: "primary", onClick: onSearchHandle, htmlType: "submit" }, i18next.t('查询')))) : (React.createElement("div", { className: classes },
|
|
24
|
+
React.createElement("div", { className: "zt-search__right--record-left" },
|
|
25
|
+
React.createElement(Button, { type: "default", onClick: selfOnResetHandle }, i18next.t('重置')),
|
|
26
|
+
React.createElement(Button, { type: "primary", onClick: onSearchHandle, htmlType: "submit" }, i18next.t('查询'))),
|
|
27
|
+
React.createElement("div", { className: "zt-search__right--record-right", style: { marginTop: 12 } },
|
|
28
|
+
React.createElement(Button, { type: "default", onClick: onRecordSearchHandle, style: { width: '100%' } }, i18next.t('保存为常用搜索')))));
|
|
10
29
|
};
|
|
11
30
|
export default SearchRight;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import MyStorage from '../../utils/MyStorage';
|
|
3
|
+
export default function useRecordCommonInit(): {
|
|
4
|
+
getRecordCommonSearchKeyRef: React.MutableRefObject<() => string>;
|
|
5
|
+
storageRef: React.MutableRefObject<MyStorage>;
|
|
6
|
+
recordCommonList: any[];
|
|
7
|
+
setRecordCommonList: React.Dispatch<React.SetStateAction<any[]>>;
|
|
8
|
+
currentRecordCommonSearchKey: string;
|
|
9
|
+
setCurrentRecordCommonSearchKey: React.Dispatch<React.SetStateAction<string>>;
|
|
10
|
+
setData: (data: any) => Promise<unknown>;
|
|
11
|
+
deleteData: (localIndex: number) => Promise<void>;
|
|
12
|
+
setReplaceData: (data: any) => Promise<any>;
|
|
13
|
+
reTransformData: (data: any, timeKeys?: any) => {};
|
|
14
|
+
updateServerData: () => Promise<unknown>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { useEffect, useState, useRef } from 'react';
|
|
49
|
+
import { COMMON_RECORD_SEARCH_KEY } from './useRecordCommonSearch';
|
|
50
|
+
import MyStorage from '../../utils/MyStorage';
|
|
51
|
+
import dayjs from 'dayjs';
|
|
52
|
+
import { catchHandle } from '../../utils/fetch';
|
|
53
|
+
export default function useRecordCommonInit() {
|
|
54
|
+
var _this = this;
|
|
55
|
+
// 当前表单用哪个key来存储数据。{ key: [{ title: xx, data: xx, key: xx }, {...}] }
|
|
56
|
+
var getRecordCommonSearchKeyRef = useRef();
|
|
57
|
+
// 常用搜索列表存储实例
|
|
58
|
+
var storageRef = useRef(new MyStorage({ tableKey: COMMON_RECORD_SEARCH_KEY }));
|
|
59
|
+
// 常用搜索列表
|
|
60
|
+
var _a = useState([]), recordCommonList = _a[0], setRecordCommonList = _a[1];
|
|
61
|
+
// 当前常用搜索key值
|
|
62
|
+
var _b = useState(''), currentRecordCommonSearchKey = _b[0], setCurrentRecordCommonSearchKey = _b[1];
|
|
63
|
+
useEffect(function () {
|
|
64
|
+
var _a;
|
|
65
|
+
var recordCommonSearchKey = ((_a = getRecordCommonSearchKeyRef.current) === null || _a === void 0 ? void 0 : _a.call(getRecordCommonSearchKeyRef)) || window.location.pathname;
|
|
66
|
+
storageRef.current
|
|
67
|
+
.getItem(recordCommonSearchKey)
|
|
68
|
+
.then(function (res) { return setRecordCommonList(res || []); });
|
|
69
|
+
}, []);
|
|
70
|
+
/**
|
|
71
|
+
* description: 数据转换。主要是将时间对象转成字符串
|
|
72
|
+
*/
|
|
73
|
+
var transformData = function (data) {
|
|
74
|
+
// 处理数据,将数据中的时间对象做一下转换
|
|
75
|
+
var dataValue = data;
|
|
76
|
+
var newDataValue = {}; // 为了不影响之前的数据
|
|
77
|
+
var timeKeys = [];
|
|
78
|
+
if (dataValue) {
|
|
79
|
+
Object.keys(dataValue).forEach(function (key) {
|
|
80
|
+
var value = dataValue[key];
|
|
81
|
+
if (Array.isArray(value)) {
|
|
82
|
+
newDataValue[key] = [];
|
|
83
|
+
value.forEach(function (item) {
|
|
84
|
+
if (dayjs.isDayjs(item)) {
|
|
85
|
+
timeKeys.push(key);
|
|
86
|
+
newDataValue[key].push(dayjs(item).format('YYYY-MM-DD HH:mm:ss'));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
newDataValue[key].push(item);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
var itemIsDayjs = dayjs.isDayjs(value);
|
|
95
|
+
if (itemIsDayjs) {
|
|
96
|
+
timeKeys.push(key);
|
|
97
|
+
}
|
|
98
|
+
newDataValue[key] = itemIsDayjs
|
|
99
|
+
? dayjs(value).format('YYYY-MM-DD HH:mm:ss')
|
|
100
|
+
: value;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
newDataValue: newDataValue,
|
|
106
|
+
timeKeys: timeKeys,
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* @description: 数据转换。主要是将时间字符串转成时间对象。
|
|
111
|
+
*/
|
|
112
|
+
var reTransformData = function (data, timeKeys) {
|
|
113
|
+
if (timeKeys === void 0) { timeKeys = []; }
|
|
114
|
+
// 处理数据,将数据中的时间对象做一下转换
|
|
115
|
+
var dataValue = data;
|
|
116
|
+
var newDataValue = {}; // 为了不影响之前的数据
|
|
117
|
+
if (dataValue) {
|
|
118
|
+
Object.keys(dataValue).forEach(function (key) {
|
|
119
|
+
var value = dataValue[key];
|
|
120
|
+
if (Array.isArray(value)) {
|
|
121
|
+
newDataValue[key] = [];
|
|
122
|
+
value.forEach(function (item) {
|
|
123
|
+
if (timeKeys.includes(key)) {
|
|
124
|
+
newDataValue[key].push(dayjs(item));
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
newDataValue[key].push(item);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
newDataValue[key] = timeKeys.includes(key) ? dayjs(value) : value;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return newDataValue;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* description: 存储数据
|
|
140
|
+
* @param {*} data 常用搜索数据
|
|
141
|
+
* @param {*} localIndex 本地存储索引 如果传了索引 就是修改
|
|
142
|
+
*/
|
|
143
|
+
var setData = function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
144
|
+
var localKey, _a, newDataValue, timeKeys, saveData;
|
|
145
|
+
var _b, _c;
|
|
146
|
+
return __generator(this, function (_d) {
|
|
147
|
+
localKey = ((_b = getRecordCommonSearchKeyRef === null || getRecordCommonSearchKeyRef === void 0 ? void 0 : getRecordCommonSearchKeyRef.current) === null || _b === void 0 ? void 0 : _b.call(getRecordCommonSearchKeyRef)) || window.location.pathname;
|
|
148
|
+
_a = transformData(data.value), newDataValue = _a.newDataValue, timeKeys = _a.timeKeys;
|
|
149
|
+
saveData = __assign(__assign({}, data), { value: newDataValue, timeKeys: timeKeys });
|
|
150
|
+
return [2 /*return*/, (_c = storageRef === null || storageRef === void 0 ? void 0 : storageRef.current) === null || _c === void 0 ? void 0 : _c.getItem(localKey).then(function (res) {
|
|
151
|
+
var _a, _b;
|
|
152
|
+
// 处理数据,将数据中的时间对象做一下转换
|
|
153
|
+
var result = res;
|
|
154
|
+
if (!result) {
|
|
155
|
+
result = [saveData];
|
|
156
|
+
}
|
|
157
|
+
else if (Array.isArray(result)) {
|
|
158
|
+
var index = result.findIndex(function (item) { return item.key === saveData.key; });
|
|
159
|
+
if (index !== -1) {
|
|
160
|
+
result[index] = saveData;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
result.unshift(saveData);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
setCurrentRecordCommonSearchKey(saveData.key);
|
|
167
|
+
if (setRecordCommonList) {
|
|
168
|
+
setRecordCommonList(result);
|
|
169
|
+
}
|
|
170
|
+
return (_b = (_a = storageRef === null || storageRef === void 0 ? void 0 : storageRef.current) === null || _a === void 0 ? void 0 : _a.setItem(localKey, result)) === null || _b === void 0 ? void 0 : _b.then(function () {
|
|
171
|
+
return updateServerData();
|
|
172
|
+
});
|
|
173
|
+
})];
|
|
174
|
+
});
|
|
175
|
+
}); };
|
|
176
|
+
/**
|
|
177
|
+
* description: 删除数据
|
|
178
|
+
* @param {*} localIndex 本地存储索引
|
|
179
|
+
*/
|
|
180
|
+
var deleteData = function (localIndex) { return __awaiter(_this, void 0, void 0, function () {
|
|
181
|
+
var localKey;
|
|
182
|
+
var _a, _b;
|
|
183
|
+
return __generator(this, function (_c) {
|
|
184
|
+
localKey = ((_a = getRecordCommonSearchKeyRef === null || getRecordCommonSearchKeyRef === void 0 ? void 0 : getRecordCommonSearchKeyRef.current) === null || _a === void 0 ? void 0 : _a.call(getRecordCommonSearchKeyRef)) || window.location.pathname;
|
|
185
|
+
return [2 /*return*/, (_b = storageRef === null || storageRef === void 0 ? void 0 : storageRef.current) === null || _b === void 0 ? void 0 : _b.getItem(localKey).then(function (res) {
|
|
186
|
+
var _a, _b;
|
|
187
|
+
if (Array.isArray(res)) {
|
|
188
|
+
res.splice(localIndex, 1);
|
|
189
|
+
(_b = (_a = storageRef === null || storageRef === void 0 ? void 0 : storageRef.current) === null || _a === void 0 ? void 0 : _a.setItem(localKey, res)) === null || _b === void 0 ? void 0 : _b.then(function () {
|
|
190
|
+
return updateServerData();
|
|
191
|
+
});
|
|
192
|
+
if (setRecordCommonList) {
|
|
193
|
+
setRecordCommonList(res);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
})];
|
|
197
|
+
});
|
|
198
|
+
}); };
|
|
199
|
+
/**
|
|
200
|
+
* description: 直接替换原有数据
|
|
201
|
+
* @param {*} data 常用搜索数据
|
|
202
|
+
*/
|
|
203
|
+
var setReplaceData = function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
204
|
+
var localKey;
|
|
205
|
+
var _a, _b;
|
|
206
|
+
return __generator(this, function (_c) {
|
|
207
|
+
localKey = ((_a = getRecordCommonSearchKeyRef === null || getRecordCommonSearchKeyRef === void 0 ? void 0 : getRecordCommonSearchKeyRef.current) === null || _a === void 0 ? void 0 : _a.call(getRecordCommonSearchKeyRef)) || window.location.pathname;
|
|
208
|
+
if (setRecordCommonList) {
|
|
209
|
+
setRecordCommonList(data);
|
|
210
|
+
}
|
|
211
|
+
return [2 /*return*/, (_b = storageRef === null || storageRef === void 0 ? void 0 : storageRef.current) === null || _b === void 0 ? void 0 : _b.setItem(localKey, data)];
|
|
212
|
+
});
|
|
213
|
+
}); };
|
|
214
|
+
/**
|
|
215
|
+
* 直接更新服务器数据
|
|
216
|
+
*/
|
|
217
|
+
var updateServerData = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
218
|
+
var _a, _b;
|
|
219
|
+
return __generator(this, function (_c) {
|
|
220
|
+
return [2 /*return*/, (_b = (_a = storageRef.current) === null || _a === void 0 ? void 0 : _a.getAllItems()) === null || _b === void 0 ? void 0 : _b.then(function (res) {
|
|
221
|
+
return catchHandle({
|
|
222
|
+
customKey: COMMON_RECORD_SEARCH_KEY,
|
|
223
|
+
customValue: JSON.stringify(res),
|
|
224
|
+
mark: '常用搜索用户配置',
|
|
225
|
+
});
|
|
226
|
+
})];
|
|
227
|
+
});
|
|
228
|
+
}); };
|
|
229
|
+
return {
|
|
230
|
+
getRecordCommonSearchKeyRef: getRecordCommonSearchKeyRef,
|
|
231
|
+
storageRef: storageRef,
|
|
232
|
+
recordCommonList: recordCommonList,
|
|
233
|
+
setRecordCommonList: setRecordCommonList,
|
|
234
|
+
currentRecordCommonSearchKey: currentRecordCommonSearchKey,
|
|
235
|
+
setCurrentRecordCommonSearchKey: setCurrentRecordCommonSearchKey,
|
|
236
|
+
setData: setData,
|
|
237
|
+
deleteData: deleteData,
|
|
238
|
+
setReplaceData: setReplaceData,
|
|
239
|
+
reTransformData: reTransformData,
|
|
240
|
+
updateServerData: updateServerData,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const COMMON_RECORD_SEARCH_KEY = "ztxk_form_common_record_search_key";
|
|
2
|
+
export default function useRecordCommonSearch(): {
|
|
3
|
+
onRecordSearchHandle: () => void;
|
|
4
|
+
recordCommonSearch: boolean;
|
|
5
|
+
currentRecordCommonSearchKey: string;
|
|
6
|
+
setCurrentRecordCommonSearchKey: (key: string) => void;
|
|
7
|
+
};
|