@zykj2024/much-library 1.1.7-beta.2 → 1.1.7-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/McCascader/city.js +909 -0
- package/dist/esm/McCascader/index.d.ts +19 -0
- package/dist/esm/McCascader/index.js +221 -0
- package/dist/esm/McCascader/index.less +72 -0
- package/dist/esm/McContainer/index.d.ts +192 -0
- package/dist/esm/McContainer/index.js +522 -0
- package/dist/esm/McContainer/index.less +132 -0
- package/dist/esm/McDateRange/index.d.ts +28 -0
- package/dist/esm/McDateRange/index.js +167 -0
- package/dist/esm/McDateRange/index.less +33 -0
- package/dist/esm/McEllipsis/index.d.ts +40 -0
- package/dist/esm/McEllipsis/index.js +115 -0
- package/dist/esm/McEllipsis/index.less +9 -0
- package/dist/esm/McEllipsisMiddle/index.d.ts +13 -0
- package/dist/esm/McEllipsisMiddle/index.js +42 -0
- package/dist/esm/McEllipsisMiddle/index.less +9 -0
- package/dist/esm/McFonts/index.d.ts +8 -0
- package/dist/esm/McFonts/index.js +7 -0
- package/dist/esm/McGroupPanel/comps/SelectedItem/index.d.ts +4 -0
- package/dist/esm/McGroupPanel/comps/SelectedItem/index.js +75 -0
- package/dist/esm/McGroupPanel/index.d.ts +30 -0
- package/dist/esm/McGroupPanel/index.js +426 -0
- package/dist/esm/McGroupPanel/index.less +161 -0
- package/dist/esm/McIconFont/iconfont.js +1 -0
- package/dist/esm/McIconFont/index.d.ts +5 -0
- package/dist/esm/McIconFont/index.js +8 -0
- package/dist/esm/McIcons/business.json +137 -0
- package/dist/esm/McIcons/index.less +22 -0
- package/dist/esm/McInput/Input.d.ts +19 -0
- package/dist/esm/McInput/Input.js +48 -0
- package/dist/esm/McInput/Search.d.ts +39 -0
- package/dist/esm/McInput/Search.js +81 -0
- package/dist/esm/McInput/TextArea.d.ts +11 -0
- package/dist/esm/McInput/TextArea.js +37 -0
- package/dist/esm/McInput/demo/Input/addonBefore.d.ts +3 -0
- package/dist/esm/McInput/demo/Input/addonBefore.js +67 -0
- package/dist/esm/McInput/demo/Input/base.d.ts +2 -0
- package/dist/esm/McInput/demo/Input/base.js +31 -0
- package/dist/esm/McInput/demo/Input/isTrim.d.ts +2 -0
- package/dist/esm/McInput/demo/Input/isTrim.js +22 -0
- package/dist/esm/McInput/demo/Input/label.d.ts +2 -0
- package/dist/esm/McInput/demo/Input/label.js +26 -0
- package/dist/esm/McInput/demo/Input/ref.d.ts +3 -0
- package/dist/esm/McInput/demo/Input/ref.js +53 -0
- package/dist/esm/McInput/demo/Input/status.d.ts +2 -0
- package/dist/esm/McInput/demo/Input/status.js +23 -0
- package/dist/esm/McInput/demo/Search/search-base.d.ts +2 -0
- package/dist/esm/McInput/demo/Search/search-base.js +38 -0
- package/dist/esm/McInput/demo/TextArea/text-area-base.d.ts +2 -0
- package/dist/esm/McInput/demo/TextArea/text-area-base.js +38 -0
- package/dist/esm/McInput/index.d.ts +13 -0
- package/dist/esm/McInput/index.js +7 -0
- package/dist/esm/McInput/index.less +62 -0
- package/dist/esm/McInputNumber/index.d.ts +16 -0
- package/dist/esm/McInputNumber/index.js +50 -0
- package/dist/esm/McInputNumber/index.less +18 -0
- package/dist/esm/McLazyLoader/index.d.ts +39 -0
- package/dist/esm/McLazyLoader/index.js +88 -0
- package/dist/esm/McListSelect/comps/ListSelect.d.ts +67 -0
- package/dist/esm/McListSelect/comps/ListSelect.js +289 -0
- package/dist/esm/McListSelect/comps/ListSelectPanel.d.ts +138 -0
- package/dist/esm/McListSelect/comps/ListSelectPanel.js +451 -0
- package/dist/esm/McListSelect/comps/SelectedItem.d.ts +17 -0
- package/dist/esm/McListSelect/comps/SelectedItem.js +76 -0
- package/dist/esm/McListSelect/index.d.ts +10 -0
- package/dist/esm/McListSelect/index.js +5 -0
- package/dist/esm/McListSelect/index.less +257 -0
- package/dist/esm/McModalProvider/index.d.ts +174 -0
- package/dist/esm/McModalProvider/index.js +498 -0
- package/dist/esm/McPeriodSelect/index.d.ts +13 -0
- package/dist/esm/McPeriodSelect/index.js +305 -0
- package/dist/esm/McPeriodSelect/index.less +187 -0
- package/dist/esm/McPopoverButton/index.d.ts +14 -0
- package/dist/esm/McPopoverButton/index.js +52 -0
- package/dist/esm/McPopoverForm/index.d.ts +14 -0
- package/dist/esm/McPopoverForm/index.js +95 -0
- package/dist/esm/McProSelect/index.d.ts +35 -0
- package/dist/esm/McProSelect/index.js +152 -0
- package/dist/esm/McResult/default.d.ts +1 -0
- package/dist/esm/McResult/default.js +98 -0
- package/dist/esm/McResult/icon.d.ts +25 -0
- package/dist/esm/McResult/icon.js +1014 -0
- package/dist/esm/McResult/index.d.ts +31 -0
- package/dist/esm/McResult/index.js +119 -0
- package/dist/esm/McResult/index.less +18 -0
- package/dist/esm/McResult/public/403.svg +164 -0
- package/dist/esm/McResult/public/404.svg +123 -0
- package/dist/esm/McResult/public/500.svg +129 -0
- package/dist/esm/McResult/public/building.svg +127 -0
- package/dist/esm/McResult/public/code403.svg +7 -0
- package/dist/esm/McResult/public/code404.svg +5 -0
- package/dist/esm/McResult/public/code500.svg +5 -0
- package/dist/esm/McResult/public/detailEmpty.svg +1 -0
- package/dist/esm/McResult/public/empty.svg +1 -0
- package/dist/esm/McResult/public/noFunction.svg +1 -0
- package/dist/esm/McResult/public/noUser.svg +90 -0
- package/dist/esm/McSelect/components/PanelSearchInput/index.d.ts +12 -0
- package/dist/esm/McSelect/components/PanelSearchInput/index.js +45 -0
- package/dist/esm/McSelect/components/PanelSearchInput/index.less +7 -0
- package/dist/esm/McSelect/index.d.ts +47 -0
- package/dist/esm/McSelect/index.js +436 -0
- package/dist/esm/McSelect/index.less +72 -0
- package/dist/esm/McTag/index.d.ts +22 -0
- package/dist/esm/McTag/index.js +59 -0
- package/dist/esm/McThemeConfig/customToken.json +39 -0
- package/dist/esm/McThemeConfig/globalStyle.d.ts +2 -0
- package/dist/esm/McThemeConfig/globalStyle.js +198 -0
- package/dist/esm/McThemeConfig/index.d.ts +9 -0
- package/dist/esm/McThemeConfig/index.js +16 -0
- package/dist/esm/McThemeConfig/layoutStyle.d.ts +2 -0
- package/dist/esm/McThemeConfig/layoutStyle.js +1 -0
- package/dist/esm/McThemeConfig/provider.d.ts +8 -0
- package/dist/esm/McThemeConfig/provider.js +20 -0
- package/dist/esm/McThemeConfig/themeToken.json +152 -0
- package/dist/esm/McTreePanel/SelectedItem.d.ts +4 -0
- package/dist/esm/McTreePanel/SelectedItem.js +75 -0
- package/dist/esm/McTreePanel/index.d.ts +27 -0
- package/dist/esm/McTreePanel/index.js +315 -0
- package/dist/esm/McTreePanel/index.less +106 -0
- package/dist/esm/McTreeSelect/index.d.ts +13 -0
- package/dist/esm/McTreeSelect/index.js +182 -0
- package/dist/esm/McTreeSelect/index.less +72 -0
- package/dist/esm/McUpload/comps/McFormUpload/comps/UploadForVal/index.d.ts +38 -0
- package/dist/esm/McUpload/comps/McFormUpload/comps/UploadForVal/index.js +209 -0
- package/dist/esm/McUpload/comps/McFormUpload/comps/UploadForVal/index.less +6 -0
- package/dist/esm/McUpload/comps/McFormUpload/index.d.ts +7 -0
- package/dist/esm/McUpload/comps/McFormUpload/index.js +29 -0
- package/dist/esm/McUpload/comps/McUploadCmp/index.d.ts +49 -0
- package/dist/esm/McUpload/comps/McUploadCmp/index.js +396 -0
- package/dist/esm/McUpload/comps/McUploadCmp/index.less +68 -0
- package/dist/esm/McUpload/comps/McUploadDragger/index.d.ts +49 -0
- package/dist/esm/McUpload/comps/McUploadDragger/index.js +264 -0
- package/dist/esm/McUpload/comps/McUploadTrigger/index.d.ts +39 -0
- package/dist/esm/McUpload/comps/McUploadTrigger/index.js +318 -0
- package/dist/esm/McUpload/comps/McUploadTrigger/index.less +204 -0
- package/dist/esm/McUpload/index.d.ts +14 -0
- package/dist/esm/McUpload/index.js +9 -0
- package/dist/esm/McUpload/tools/calculateMD5/index.d.ts +3 -0
- package/dist/esm/McUpload/tools/calculateMD5/index.js +94 -0
- package/dist/esm/McUpload/tools/calculateMD5/md5Worker.js +44 -0
- package/dist/esm/McUpload/tools/getUid.d.ts +1 -0
- package/dist/esm/McUpload/tools/getUid.js +6 -0
- package/dist/esm/McUpload/tools/materialVerification.d.ts +50 -0
- package/dist/esm/McUpload/tools/materialVerification.js +257 -0
- package/dist/esm/McUpload/tools/uploadTools.d.ts +5 -0
- package/dist/esm/McUpload/tools/uploadTools.js +56 -0
- package/dist/esm/Utils/index.d.ts +8 -0
- package/dist/esm/Utils/index.js +9 -0
- package/dist/esm/Utils/lib/Queue/PriorityQueue.d.ts +21 -0
- package/dist/esm/Utils/lib/Queue/PriorityQueue.js +197 -0
- package/dist/esm/Utils/lib/Queue/TaskQueue.d.ts +17 -0
- package/dist/esm/Utils/lib/Queue/TaskQueue.js +199 -0
- package/dist/esm/Utils/lib/Queue/tools/BinaryHeap.d.ts +25 -0
- package/dist/esm/Utils/lib/Queue/tools/BinaryHeap.js +184 -0
- package/dist/esm/Utils/lib/Queue/tools/publicDependencyMethod.d.ts +6 -0
- package/dist/esm/Utils/lib/Queue/tools/publicDependencyMethod.js +26 -0
- package/dist/esm/Utils/lib/Queue/types/baseTaskQueue.d.ts +23 -0
- package/dist/esm/Utils/lib/Queue/types/baseTaskQueue.js +10 -0
- package/dist/esm/Utils/lib/copyToClipboard.d.ts +8 -0
- package/dist/esm/Utils/lib/copyToClipboard.js +54 -0
- package/dist/esm/index.d.ts +34 -0
- package/dist/esm/index.js +33 -0
- package/dist/esm/styles/index.less +2 -0
- package/dist/esm/styles/mixins.less +52 -0
- package/dist/esm/styles/utilities.less +51 -0
- package/dist/esm/typings.d.ts +20 -0
- package/package.json +13 -9
@@ -0,0 +1,522 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
4
|
+
import { useUpdateEffect } from '@zykj2024/much-hooks';
|
5
|
+
import { Button, Spin, Table } from 'antd';
|
6
|
+
import { isNumber } from 'lodash';
|
7
|
+
import { CaretDownFilled, DoubleLeftOutlined } from 'much-icons';
|
8
|
+
import { Children, cloneElement, forwardRef, isValidElement, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
9
|
+
import "./index.less";
|
10
|
+
|
11
|
+
/** 请求参数 */
|
12
|
+
|
13
|
+
/** 批量操作配置接口 */
|
14
|
+
|
15
|
+
/** McContainer 组件 Props 类型定义 */
|
16
|
+
|
17
|
+
/** McContainer 组件 Ref 类型定义 */
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
19
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
20
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
21
|
+
/**
|
22
|
+
* McContainer 组件
|
23
|
+
* @description 一个通用的容器组件,支持查询、表格、批量操作等功能
|
24
|
+
*/
|
25
|
+
var ContainerPanel = function ContainerPanel(props, ref) {
|
26
|
+
var _tableProps$dataSourc;
|
27
|
+
var style = props.style,
|
28
|
+
className = props.className,
|
29
|
+
_props$height = props.height,
|
30
|
+
height = _props$height === void 0 ? 'calc(100vh - 88px)' : _props$height,
|
31
|
+
_props$backgroundColo = props.backgroundColor,
|
32
|
+
backgroundColor = _props$backgroundColo === void 0 ? '#ffffff' : _props$backgroundColo,
|
33
|
+
_props$showCell = props.showCell,
|
34
|
+
showCell = _props$showCell === void 0 ? true : _props$showCell,
|
35
|
+
_props$immediateQuery = props.immediateQuery,
|
36
|
+
immediateQuery = _props$immediateQuery === void 0 ? true : _props$immediateQuery,
|
37
|
+
_props$loading = props.loading,
|
38
|
+
loading = _props$loading === void 0 ? false : _props$loading,
|
39
|
+
_props$loadingText = props.loadingText,
|
40
|
+
loadingText = _props$loadingText === void 0 ? '' : _props$loadingText,
|
41
|
+
queryItems = props.queryItems,
|
42
|
+
_props$showQuery = props.showQuery,
|
43
|
+
showQuery = _props$showQuery === void 0 ? true : _props$showQuery,
|
44
|
+
_props$showReset = props.showReset,
|
45
|
+
showReset = _props$showReset === void 0 ? true : _props$showReset,
|
46
|
+
_props$showCollapse = props.showCollapse,
|
47
|
+
showCollapse = _props$showCollapse === void 0 ? false : _props$showCollapse,
|
48
|
+
_props$autoBackPagina = props.autoBackPagination,
|
49
|
+
autoBackPagination = _props$autoBackPagina === void 0 ? false : _props$autoBackPagina,
|
50
|
+
collapsibleQueryItems = props.collapsibleQueryItems,
|
51
|
+
onQuery = props.onQuery,
|
52
|
+
onReset = props.onReset,
|
53
|
+
queryRender = props.queryRender,
|
54
|
+
actionBar = props.actionBar,
|
55
|
+
_props$batchNum = props.batchNum,
|
56
|
+
batchNum = _props$batchNum === void 0 ? 0 : _props$batchNum,
|
57
|
+
batchBtns = props.batchBtns,
|
58
|
+
batch = props.batch,
|
59
|
+
actionBarRender = props.actionBarRender,
|
60
|
+
onCancel = props.onCancel,
|
61
|
+
tableProps = props.tableProps,
|
62
|
+
tableRender = props.tableRender,
|
63
|
+
onCollapse = props.onCollapse;
|
64
|
+
var _useState = useState(false),
|
65
|
+
_useState2 = _slicedToArray(_useState, 2),
|
66
|
+
collapse = _useState2[0],
|
67
|
+
setCollapse = _useState2[1];
|
68
|
+
var allNamesRef = useRef([]);
|
69
|
+
var _useState3 = useState({}),
|
70
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
71
|
+
queryParams = _useState4[0],
|
72
|
+
setQueryParams = _useState4[1];
|
73
|
+
var queryParamsRef = useRef({});
|
74
|
+
var defaultQueryParamsRef = useRef({});
|
75
|
+
var initializedRef = useRef(false);
|
76
|
+
var containerRef = useRef(null);
|
77
|
+
|
78
|
+
/* 批量操作相关 */
|
79
|
+
var _ref = batch || {},
|
80
|
+
_ref$buttonText = _ref.buttonText,
|
81
|
+
buttonText = _ref$buttonText === void 0 ? '批量操作' : _ref$buttonText,
|
82
|
+
buttonProps = _ref.buttonProps,
|
83
|
+
_ref$show = _ref.show,
|
84
|
+
batchShow = _ref$show === void 0 ? false : _ref$show,
|
85
|
+
batchOrder = _ref.order;
|
86
|
+
var _useState5 = useState(false),
|
87
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
88
|
+
showBatchBar = _useState6[0],
|
89
|
+
setShowBatchBar = _useState6[1];
|
90
|
+
|
91
|
+
/* 获取actionBar高度 */
|
92
|
+
var actionBarRef = useRef();
|
93
|
+
var _useState7 = useState(0),
|
94
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
95
|
+
actionBarHeight = _useState8[0],
|
96
|
+
setActionBarHeight = _useState8[1];
|
97
|
+
var actionBarResizeObserver = new ResizeObserver(function (entries) {
|
98
|
+
setActionBarHeight(entries[0].contentRect.height + 40);
|
99
|
+
});
|
100
|
+
useEffect(function () {
|
101
|
+
if (actionBarRef.current) {
|
102
|
+
actionBarResizeObserver.observe(actionBarRef.current);
|
103
|
+
}
|
104
|
+
return function () {
|
105
|
+
return actionBarResizeObserver.disconnect();
|
106
|
+
};
|
107
|
+
}, []);
|
108
|
+
useEffect(function () {
|
109
|
+
onCollapse === null || onCollapse === void 0 || onCollapse(collapse);
|
110
|
+
}, [collapse]);
|
111
|
+
|
112
|
+
// 为设置过name属性的查询项添加value属性和onChange事件,从而收集查询项的值(查询项自身已绑定value属性的除外,需自行编写相关业务逻辑代码进行状态管理)
|
113
|
+
var mapQuerys = function mapQuerys(items) {
|
114
|
+
var ELs = null;
|
115
|
+
if (items) {
|
116
|
+
ELs = Children.map(items.props.children ? items.props.children : items, function (item) {
|
117
|
+
if (item !== null && item !== void 0 && item.props) {
|
118
|
+
var _item$props = item.props,
|
119
|
+
_name = _item$props.name,
|
120
|
+
_onChange = _item$props.onChange;
|
121
|
+
var canCollect = _name && !item.props.hasOwnProperty('value');
|
122
|
+
if (canCollect) {
|
123
|
+
if (!allNamesRef.current.includes(_name)) {
|
124
|
+
allNamesRef.current.push(_name);
|
125
|
+
}
|
126
|
+
return /*#__PURE__*/cloneElement(item, {
|
127
|
+
value: queryParams[_name],
|
128
|
+
onChange: function onChange(v) {
|
129
|
+
var _params = _objectSpread(_objectSpread({}, queryParamsRef.current), {}, _defineProperty({}, _name, v));
|
130
|
+
queryParamsRef.current = _params;
|
131
|
+
setQueryParams(_params);
|
132
|
+
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
133
|
+
rest[_key - 1] = arguments[_key];
|
134
|
+
}
|
135
|
+
_onChange === null || _onChange === void 0 || _onChange.apply(void 0, [v].concat(rest));
|
136
|
+
}
|
137
|
+
});
|
138
|
+
}
|
139
|
+
}
|
140
|
+
return item;
|
141
|
+
});
|
142
|
+
}
|
143
|
+
return ELs;
|
144
|
+
};
|
145
|
+
|
146
|
+
// 批量操作按钮
|
147
|
+
var handelBatchClick = function handelBatchClick() {
|
148
|
+
if (showBatchBar) {
|
149
|
+
onCancel === null || onCancel === void 0 || onCancel();
|
150
|
+
}
|
151
|
+
setShowBatchBar(!showBatchBar);
|
152
|
+
};
|
153
|
+
|
154
|
+
// 批量操作按钮
|
155
|
+
var batchEl = /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({
|
156
|
+
onClick: handelBatchClick
|
157
|
+
}, buttonProps), {}, {
|
158
|
+
children: buttonText
|
159
|
+
}));
|
160
|
+
|
161
|
+
// 生成 actionBar
|
162
|
+
var mapActionBar = function mapActionBar() {
|
163
|
+
var Els;
|
164
|
+
// 是否展示批量操作按钮
|
165
|
+
if (batchShow) {
|
166
|
+
// 是否配置actionBar
|
167
|
+
if (actionBar) {
|
168
|
+
var _actionBar$props;
|
169
|
+
// 判断是否为合法的React节点
|
170
|
+
var itemsCount = /*#__PURE__*/isValidElement(actionBar) ? Children.count(actionBar === null || actionBar === void 0 || (_actionBar$props = actionBar.props) === null || _actionBar$props === void 0 ? void 0 : _actionBar$props.children) : 1;
|
171
|
+
var newEls = Children.toArray(itemsCount > 1 ? actionBar.props.children : actionBar);
|
172
|
+
var _batchOrder = isNumber(batchOrder) && batchOrder >= 0 && batchOrder <= itemsCount ? batchOrder : itemsCount;
|
173
|
+
// 插入批量操作按钮,默认放在actionBar操作项后面
|
174
|
+
newEls.splice(_batchOrder, 0, batchEl);
|
175
|
+
Els = /*#__PURE__*/cloneElement(itemsCount > 1 ? actionBar : /*#__PURE__*/_jsx(_Fragment, {}), {}, newEls);
|
176
|
+
} else {
|
177
|
+
Els = batchEl;
|
178
|
+
}
|
179
|
+
} else {
|
180
|
+
Els = actionBar;
|
181
|
+
}
|
182
|
+
return Els;
|
183
|
+
};
|
184
|
+
|
185
|
+
// 格式化查询参数(返回当前可见的查询项的参数集)
|
186
|
+
var formatQueryParams = function formatQueryParams(params) {
|
187
|
+
var _tableProps$paginatio;
|
188
|
+
var _params = tableRender || tableRender === null || (tableProps === null || tableProps === void 0 ? void 0 : tableProps.pagination) === false || tableProps !== null && tableProps !== void 0 && (_tableProps$paginatio = tableProps.pagination) !== null && _tableProps$paginatio !== void 0 && _tableProps$paginatio.hasOwnProperty('onChange') || tableProps !== null && tableProps !== void 0 && tableProps.hasOwnProperty('onChange') ? {} : {
|
189
|
+
current: params.current,
|
190
|
+
pageSize: params.pageSize
|
191
|
+
};
|
192
|
+
var fn = function fn(items) {
|
193
|
+
items && Children.map(items.props.children ? items.props.children : items, function (item) {
|
194
|
+
if (item !== null && item !== void 0 && item.props) {
|
195
|
+
var _item$props2;
|
196
|
+
var _name2 = (_item$props2 = item.props) === null || _item$props2 === void 0 ? void 0 : _item$props2.name;
|
197
|
+
if (_name2 && !item.props.hasOwnProperty('value')) {
|
198
|
+
_params[_name2] = params[_name2];
|
199
|
+
}
|
200
|
+
}
|
201
|
+
});
|
202
|
+
};
|
203
|
+
fn(queryItems);
|
204
|
+
fn(collapsibleQueryItems);
|
205
|
+
return _params;
|
206
|
+
};
|
207
|
+
|
208
|
+
// 查询
|
209
|
+
var query = function query(params) {
|
210
|
+
if (params) {
|
211
|
+
var _params = _objectSpread({}, queryParamsRef.current);
|
212
|
+
Object.entries(params).forEach(function (_ref2) {
|
213
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
214
|
+
key = _ref3[0],
|
215
|
+
value = _ref3[1];
|
216
|
+
if (allNamesRef.current.includes(key)) {
|
217
|
+
_params[key] = value;
|
218
|
+
}
|
219
|
+
});
|
220
|
+
queryParamsRef.current = _params;
|
221
|
+
setQueryParams(_params);
|
222
|
+
onQuery === null || onQuery === void 0 || onQuery(formatQueryParams(_params));
|
223
|
+
} else {
|
224
|
+
onQuery === null || onQuery === void 0 || onQuery(formatQueryParams(queryParamsRef.current));
|
225
|
+
}
|
226
|
+
};
|
227
|
+
|
228
|
+
// 重置
|
229
|
+
var reset = function reset() {
|
230
|
+
var _params = _objectSpread({}, defaultQueryParamsRef.current);
|
231
|
+
queryParamsRef.current = _params;
|
232
|
+
setQueryParams(_params);
|
233
|
+
if (props.hasOwnProperty('onReset')) {
|
234
|
+
onReset === null || onReset === void 0 || onReset(formatQueryParams(_params));
|
235
|
+
} else {
|
236
|
+
onQuery === null || onQuery === void 0 || onQuery(formatQueryParams(_params));
|
237
|
+
}
|
238
|
+
};
|
239
|
+
|
240
|
+
// 表格分页、排序、筛选变化时触发
|
241
|
+
var tableChange = function tableChange(pagination, filters, sorter, extra) {
|
242
|
+
var _tableProps$onChange;
|
243
|
+
if (tableProps !== null && tableProps !== void 0 && tableProps.pagination && tableProps.pagination.hasOwnProperty('onChange')) return;
|
244
|
+
var current = pagination.current,
|
245
|
+
pageSize = pagination.pageSize;
|
246
|
+
var _params = _objectSpread(_objectSpread({}, queryParamsRef.current), {}, {
|
247
|
+
current: current,
|
248
|
+
pageSize: pageSize
|
249
|
+
});
|
250
|
+
queryParamsRef.current = _params;
|
251
|
+
setQueryParams(_params);
|
252
|
+
onQuery === null || onQuery === void 0 || onQuery(formatQueryParams(_params), filters, sorter, extra);
|
253
|
+
tableProps === null || tableProps === void 0 || (_tableProps$onChange = tableProps.onChange) === null || _tableProps$onChange === void 0 || _tableProps$onChange.call(tableProps, pagination, filters, sorter, extra);
|
254
|
+
};
|
255
|
+
|
256
|
+
// 设置默认查询参数
|
257
|
+
var setDefaultQueryParams = function setDefaultQueryParams() {
|
258
|
+
var _tableProps$paginatio2;
|
259
|
+
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
260
|
+
var _params = tableRender || tableRender === null || (tableProps === null || tableProps === void 0 ? void 0 : tableProps.pagination) === false || tableProps !== null && tableProps !== void 0 && (_tableProps$paginatio2 = tableProps.pagination) !== null && _tableProps$paginatio2 !== void 0 && _tableProps$paginatio2.hasOwnProperty('onChange') || tableProps !== null && tableProps !== void 0 && tableProps.hasOwnProperty('onChange') ? {} : {
|
261
|
+
current: 1,
|
262
|
+
pageSize: 20
|
263
|
+
};
|
264
|
+
Object.keys(_params).forEach(function (k) {
|
265
|
+
return !allNamesRef.current.includes(k) && allNamesRef.current.push(k);
|
266
|
+
});
|
267
|
+
Object.entries(params).forEach(function (_ref4) {
|
268
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
269
|
+
key = _ref5[0],
|
270
|
+
value = _ref5[1];
|
271
|
+
if (allNamesRef.current.includes(key)) {
|
272
|
+
_params[key] = value;
|
273
|
+
}
|
274
|
+
});
|
275
|
+
defaultQueryParamsRef.current = _params;
|
276
|
+
queryParamsRef.current = _params;
|
277
|
+
setQueryParams(_params);
|
278
|
+
};
|
279
|
+
|
280
|
+
// 设置单个查询项的参数
|
281
|
+
var setQueryParam = function setQueryParam(name, value) {
|
282
|
+
if (allNamesRef.current.includes(name)) {
|
283
|
+
var _params = _objectSpread(_objectSpread({}, queryParamsRef.current), {}, _defineProperty({}, name, value));
|
284
|
+
queryParamsRef.current = _params;
|
285
|
+
setQueryParams(_params);
|
286
|
+
}
|
287
|
+
};
|
288
|
+
|
289
|
+
// 获取单个查询项的参数
|
290
|
+
var getQueryParam = function getQueryParam(name) {
|
291
|
+
if (allNamesRef.current.includes(name)) {
|
292
|
+
return formatQueryParams(queryParamsRef.current)[name];
|
293
|
+
} else {
|
294
|
+
console.error("\u672A\u627E\u5230\u4E0E'".concat(name, "'\u76F8\u5173\u7684\u67E5\u8BE2\u53C2\u6570"));
|
295
|
+
}
|
296
|
+
};
|
297
|
+
|
298
|
+
// 获取所有查询项的参数
|
299
|
+
var getQueryParams = function getQueryParams() {
|
300
|
+
return formatQueryParams(queryParamsRef.current);
|
301
|
+
};
|
302
|
+
|
303
|
+
// 重置查询参数(重置为默认查询参数)
|
304
|
+
var resetQueryParams = function resetQueryParams() {
|
305
|
+
var _params = _objectSpread({}, defaultQueryParamsRef.current);
|
306
|
+
queryParamsRef.current = _params;
|
307
|
+
setQueryParams(_params);
|
308
|
+
};
|
309
|
+
useEffect(function () {
|
310
|
+
setShowBatchBar(batchNum > 0);
|
311
|
+
}, [batchNum]);
|
312
|
+
|
313
|
+
// 监听immediateQuery,初始设置默认查询参数并判断是否触发首次查询
|
314
|
+
useEffect(function () {
|
315
|
+
if (!initializedRef.current) {
|
316
|
+
initializedRef.current = true;
|
317
|
+
// 初始设置默认查询参数
|
318
|
+
setDefaultQueryParams();
|
319
|
+
// 触发首次查询
|
320
|
+
if (immediateQuery) {
|
321
|
+
query();
|
322
|
+
}
|
323
|
+
}
|
324
|
+
}, [immediateQuery]);
|
325
|
+
useUpdateEffect(function () {
|
326
|
+
var _ref6 = tableProps !== null && tableProps !== void 0 ? tableProps : {},
|
327
|
+
pagination = _ref6.pagination,
|
328
|
+
dataSource = _ref6.dataSource;
|
329
|
+
var _ref7 = pagination || {},
|
330
|
+
total = _ref7.total;
|
331
|
+
var _ref8 = queryParams !== null && queryParams !== void 0 ? queryParams : {},
|
332
|
+
current = _ref8.current,
|
333
|
+
pageSize = _ref8.pageSize;
|
334
|
+
// 判断条件
|
335
|
+
// 1. 开启自动回退分页功能
|
336
|
+
// 2. 开启分页功能
|
337
|
+
// 3. 表格当前页数据为空 & 当前页大于1 & 总数据大于分页数据
|
338
|
+
if (autoBackPagination && !!pagination && (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) === 0 && current > 1 && total && pageSize && total >= pageSize) {
|
339
|
+
query(_objectSpread(_objectSpread({}, queryParams), {}, {
|
340
|
+
current: Math.min(current - 1, Math.floor(total / pageSize))
|
341
|
+
}));
|
342
|
+
}
|
343
|
+
}, [tableProps === null || tableProps === void 0 ? void 0 : tableProps.dataSource]);
|
344
|
+
useImperativeHandle(ref, function () {
|
345
|
+
return {
|
346
|
+
query: query,
|
347
|
+
reset: reset,
|
348
|
+
setDefaultQueryParams: setDefaultQueryParams,
|
349
|
+
setQueryParam: setQueryParam,
|
350
|
+
getQueryParam: getQueryParam,
|
351
|
+
getQueryParams: getQueryParams,
|
352
|
+
resetQueryParams: resetQueryParams
|
353
|
+
};
|
354
|
+
});
|
355
|
+
return /*#__PURE__*/_jsx(Spin, {
|
356
|
+
style: {
|
357
|
+
maxHeight: 'none'
|
358
|
+
},
|
359
|
+
spinning: loading,
|
360
|
+
tip: loadingText,
|
361
|
+
children: /*#__PURE__*/_jsxs("div", {
|
362
|
+
className: "mc-container ".concat(className || ''),
|
363
|
+
style: _objectSpread({
|
364
|
+
height: height,
|
365
|
+
backgroundColor: backgroundColor
|
366
|
+
}, style),
|
367
|
+
children: [showCell && /*#__PURE__*/_jsx("div", {
|
368
|
+
className: "mc-container__ceiling",
|
369
|
+
style: {
|
370
|
+
backgroundColor: backgroundColor,
|
371
|
+
top: 0
|
372
|
+
}
|
373
|
+
}), /*#__PURE__*/_jsxs("div", {
|
374
|
+
ref: containerRef,
|
375
|
+
className: "mc-container__wrapper",
|
376
|
+
style: {
|
377
|
+
paddingBottom: tableRender || tableRender === null || (tableProps === null || tableProps === void 0 ? void 0 : tableProps.pagination) === false ? 16 : 50
|
378
|
+
},
|
379
|
+
children: [queryRender || queryRender === null ? queryRender : /*#__PURE__*/_jsxs("div", {
|
380
|
+
className: "mc-container__query",
|
381
|
+
children: [mapQuerys(queryItems), !collapse && mapQuerys(collapsibleQueryItems), (showQuery || showReset || showCollapse) && /*#__PURE__*/_jsxs("div", {
|
382
|
+
style: {
|
383
|
+
marginLeft: 'auto'
|
384
|
+
},
|
385
|
+
children: [showQuery && /*#__PURE__*/_jsx(Button, {
|
386
|
+
type: "primary",
|
387
|
+
onClick: function onClick() {
|
388
|
+
return query({
|
389
|
+
current: 1
|
390
|
+
});
|
391
|
+
},
|
392
|
+
children: "\u67E5\u8BE2"
|
393
|
+
}), showReset && /*#__PURE__*/_jsx(Button, {
|
394
|
+
style: {
|
395
|
+
marginLeft: 8
|
396
|
+
},
|
397
|
+
onClick: reset,
|
398
|
+
children: "\u91CD\u7F6E"
|
399
|
+
}), showCollapse && /*#__PURE__*/_jsxs(Button, {
|
400
|
+
type: "link",
|
401
|
+
style: {
|
402
|
+
marginLeft: 16,
|
403
|
+
fontSize: 12,
|
404
|
+
padding: 0,
|
405
|
+
gap: 4
|
406
|
+
},
|
407
|
+
onClick: function onClick() {
|
408
|
+
return setCollapse(function (os) {
|
409
|
+
return !os;
|
410
|
+
});
|
411
|
+
},
|
412
|
+
children: [collapse ? '展开' : '收起', /*#__PURE__*/_jsx(DoubleLeftOutlined, {
|
413
|
+
style: {
|
414
|
+
fontSize: 12
|
415
|
+
},
|
416
|
+
rotate: collapse ? -90 : 90
|
417
|
+
})]
|
418
|
+
})]
|
419
|
+
})]
|
420
|
+
}), queryRender !== null && /*#__PURE__*/_jsx("div", {
|
421
|
+
className: "mc-container__divider"
|
422
|
+
}), actionBarRender ? actionBarRender(batchEl) : (!!actionBar || !!batchShow) && /*#__PURE__*/_jsx("div", {
|
423
|
+
ref: actionBarRef,
|
424
|
+
className: "mc-container__action-bar",
|
425
|
+
style: {
|
426
|
+
backgroundColor: backgroundColor
|
427
|
+
},
|
428
|
+
children: mapActionBar()
|
429
|
+
}), showBatchBar && /*#__PURE__*/_jsx("div", {
|
430
|
+
className: "mc-container__batch-bar",
|
431
|
+
style: {
|
432
|
+
backgroundColor: backgroundColor,
|
433
|
+
top: actionBarHeight ? actionBarHeight - 24 : 0
|
434
|
+
},
|
435
|
+
children: /*#__PURE__*/_jsxs("div", {
|
436
|
+
className: "mc-container__batch-bar__inner",
|
437
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
438
|
+
className: "mc-container__batch-num",
|
439
|
+
children: ["\u5DF2\u9009\u62E9 ", batchNum, " \u9879"]
|
440
|
+
}), batchBtns && /*#__PURE__*/_jsx("div", {
|
441
|
+
className: "mc-container__batch-btns",
|
442
|
+
children: batchBtns
|
443
|
+
}), /*#__PURE__*/_jsx(Button, {
|
444
|
+
style: {
|
445
|
+
marginLeft: 'auto'
|
446
|
+
},
|
447
|
+
onClick: function onClick() {
|
448
|
+
onCancel === null || onCancel === void 0 || onCancel();
|
449
|
+
setShowBatchBar(false);
|
450
|
+
},
|
451
|
+
children: "\u53D6\u6D88"
|
452
|
+
})]
|
453
|
+
})
|
454
|
+
}), tableRender || tableRender === null ? tableRender : /*#__PURE__*/_jsx(Table, _objectSpread(_objectSpread({
|
455
|
+
className: "mc-container__table",
|
456
|
+
size: "small",
|
457
|
+
sticky: {
|
458
|
+
offsetHeader: (actionBarHeight ? actionBarHeight - 24 : 0) + (batchNum > 0 ? 48 : 0),
|
459
|
+
getContainer: function getContainer() {
|
460
|
+
return containerRef.current;
|
461
|
+
}
|
462
|
+
},
|
463
|
+
scroll: {
|
464
|
+
x: (tableProps === null || tableProps === void 0 || (_tableProps$dataSourc = tableProps.dataSource) === null || _tableProps$dataSourc === void 0 ? void 0 : _tableProps$dataSourc.length) > 0 ? 'max-content' : '100%'
|
465
|
+
},
|
466
|
+
onChange: tableChange
|
467
|
+
}, tableProps), {}, {
|
468
|
+
loading: false,
|
469
|
+
pagination: (tableProps === null || tableProps === void 0 ? void 0 : tableProps.pagination) === false ? false : _objectSpread({
|
470
|
+
className: 'mc-container__pagination',
|
471
|
+
style: {
|
472
|
+
backgroundColor: backgroundColor
|
473
|
+
},
|
474
|
+
showSizeChanger: true,
|
475
|
+
showQuickJumper: true,
|
476
|
+
showTotal: function showTotal(total) {
|
477
|
+
return "\u5171 ".concat(total, " \u6761\u8BB0\u5F55");
|
478
|
+
},
|
479
|
+
current: queryParams.current,
|
480
|
+
pageSize: queryParams.pageSize
|
481
|
+
}, tableProps === null || tableProps === void 0 ? void 0 : tableProps.pagination),
|
482
|
+
expandable: _objectSpread({
|
483
|
+
expandIcon: function expandIcon(_ref9) {
|
484
|
+
var _tableProps$dataSourc2, _record$children;
|
485
|
+
var expanded = _ref9.expanded,
|
486
|
+
onExpand = _ref9.onExpand,
|
487
|
+
record = _ref9.record;
|
488
|
+
return tableProps !== null && tableProps !== void 0 && (_tableProps$dataSourc2 = tableProps.dataSource) !== null && _tableProps$dataSourc2 !== void 0 && _tableProps$dataSourc2.some(function (_ref10) {
|
489
|
+
var children = _ref10.children;
|
490
|
+
return (children === null || children === void 0 ? void 0 : children.length) > 0;
|
491
|
+
}) ? ((_record$children = record.children) === null || _record$children === void 0 ? void 0 : _record$children.length) > 0 ? /*#__PURE__*/_jsx(CaretDownFilled, {
|
492
|
+
className: "mc-container__table__expand-icon",
|
493
|
+
style: {
|
494
|
+
margin: '0 8px',
|
495
|
+
fontSize: 16
|
496
|
+
},
|
497
|
+
rotate: expanded ? 0 : -90,
|
498
|
+
onClick: function onClick(e) {
|
499
|
+
return onExpand(record, e);
|
500
|
+
}
|
501
|
+
}) : /*#__PURE__*/_jsx(CaretDownFilled, {
|
502
|
+
style: {
|
503
|
+
margin: '0 8px',
|
504
|
+
color: 'transparent'
|
505
|
+
}
|
506
|
+
}) : null;
|
507
|
+
}
|
508
|
+
}, tableProps === null || tableProps === void 0 ? void 0 : tableProps.expandable)
|
509
|
+
}))]
|
510
|
+
}), !(tableProps !== null && tableProps !== void 0 && tableProps.pagination) && !tableRender && /*#__PURE__*/_jsx("div", {
|
511
|
+
className: "mc-container__ceiling",
|
512
|
+
style: {
|
513
|
+
backgroundColor: backgroundColor,
|
514
|
+
height: 16,
|
515
|
+
bottom: 0
|
516
|
+
}
|
517
|
+
})]
|
518
|
+
})
|
519
|
+
});
|
520
|
+
};
|
521
|
+
var McContainer = /*#__PURE__*/forwardRef(ContainerPanel);
|
522
|
+
export default McContainer;
|
@@ -0,0 +1,132 @@
|
|
1
|
+
@wrapper-width: calc(100% - 40px);
|
2
|
+
|
3
|
+
.mc-container {
|
4
|
+
position: relative;
|
5
|
+
|
6
|
+
&__ceiling {
|
7
|
+
width: @wrapper-width;
|
8
|
+
height: 24px;
|
9
|
+
position: absolute;
|
10
|
+
left: 16px;
|
11
|
+
z-index: 9;
|
12
|
+
}
|
13
|
+
|
14
|
+
&__wrapper {
|
15
|
+
height: 100%;
|
16
|
+
padding: 24px 24px 50px 16px;
|
17
|
+
overflow-y: auto;
|
18
|
+
border-top-right-radius: 12px;
|
19
|
+
}
|
20
|
+
|
21
|
+
&__query {
|
22
|
+
display: flex;
|
23
|
+
flex-wrap: wrap;
|
24
|
+
gap: 16px;
|
25
|
+
|
26
|
+
.mc-input,
|
27
|
+
.mc-search,
|
28
|
+
.mc-select,
|
29
|
+
.mc-cascader,
|
30
|
+
.mc-input-number {
|
31
|
+
width: 270px;
|
32
|
+
}
|
33
|
+
|
34
|
+
.mc-date-range {
|
35
|
+
width: 330px;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
&__divider {
|
40
|
+
height: 1px;
|
41
|
+
margin: 24px 0;
|
42
|
+
background: #ebebeb;
|
43
|
+
}
|
44
|
+
|
45
|
+
&__action-bar {
|
46
|
+
position: sticky;
|
47
|
+
top: -24px;
|
48
|
+
z-index: 9;
|
49
|
+
display: flex;
|
50
|
+
flex-wrap: wrap;
|
51
|
+
gap: 16px;
|
52
|
+
align-items: center;
|
53
|
+
padding: 24px 0 16px;
|
54
|
+
margin-top: -24px;
|
55
|
+
overflow: hidden;
|
56
|
+
}
|
57
|
+
|
58
|
+
&__batch-bar {
|
59
|
+
position: sticky;
|
60
|
+
z-index: 9;
|
61
|
+
padding-bottom: 8px;
|
62
|
+
|
63
|
+
&__inner {
|
64
|
+
display: flex;
|
65
|
+
align-items: center;
|
66
|
+
height: 40px;
|
67
|
+
padding: 0 16px;
|
68
|
+
background: #325cf7;
|
69
|
+
border-radius: 4px;
|
70
|
+
|
71
|
+
button.ant-btn {
|
72
|
+
background: transparent;
|
73
|
+
color: #fff;
|
74
|
+
border-color: transparent;
|
75
|
+
padding: 4px;
|
76
|
+
margin-left: 16px;
|
77
|
+
|
78
|
+
&:hover {
|
79
|
+
background-color: transparent !important;
|
80
|
+
color: #fff !important;
|
81
|
+
border-color: transparent !important;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
&__batch-num {
|
88
|
+
color: #fff;
|
89
|
+
font-size: 14px;
|
90
|
+
opacity: 0.8;
|
91
|
+
}
|
92
|
+
|
93
|
+
&__batch-btns {
|
94
|
+
position: relative;
|
95
|
+
margin-left: 16px;
|
96
|
+
|
97
|
+
&::before {
|
98
|
+
position: absolute;
|
99
|
+
top: calc(50% - 12px);
|
100
|
+
left: 0;
|
101
|
+
display: block;
|
102
|
+
width: 1px;
|
103
|
+
height: 24px;
|
104
|
+
background: rgba(255, 255, 255, 30%);
|
105
|
+
content: '';
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
&__table {
|
110
|
+
.ant-spin-nested-loading {
|
111
|
+
position: static;
|
112
|
+
|
113
|
+
.ant-spin-container {
|
114
|
+
position: static;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
&__expand-icon > svg {
|
119
|
+
transition: all 0.3s;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
&__pagination {
|
124
|
+
padding: 8px 0 16px;
|
125
|
+
margin: 0 !important;
|
126
|
+
width: @wrapper-width;
|
127
|
+
position: absolute;
|
128
|
+
left: 16px;
|
129
|
+
bottom: 0;
|
130
|
+
z-index: 9;
|
131
|
+
}
|
132
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { RangePickerProps } from 'antd/es/date-picker';
|
2
|
+
import dayjs from 'dayjs';
|
3
|
+
import { CSSProperties, FC, ReactNode } from 'react';
|
4
|
+
import './index.less';
|
5
|
+
declare const shortcutValueMap: {
|
6
|
+
today: string[];
|
7
|
+
yesterday: string[];
|
8
|
+
last7days: string[];
|
9
|
+
last30days: string[];
|
10
|
+
last60days: string[];
|
11
|
+
last90days: string[];
|
12
|
+
};
|
13
|
+
export declare const SHORTCUT_VALUE_MAP: typeof shortcutValueMap & {
|
14
|
+
[key: string]: any;
|
15
|
+
};
|
16
|
+
export type McDateRangeProps = Omit<RangePickerProps, 'value' | 'onChange'> & {
|
17
|
+
style?: CSSProperties;
|
18
|
+
className?: string;
|
19
|
+
name?: string;
|
20
|
+
label?: ReactNode;
|
21
|
+
valueFormat?: string;
|
22
|
+
value?: string[];
|
23
|
+
onChange?: (value?: string[] | null, dayjsValue?: [dayjs.Dayjs, dayjs.Dayjs] | null) => void;
|
24
|
+
onShortcut?: (value?: 'today' | 'yesterday' | 'last7days' | 'last30days' | 'last60days' | 'last90days') => void;
|
25
|
+
[key: string]: any;
|
26
|
+
};
|
27
|
+
declare const McDateRange: FC<McDateRangeProps>;
|
28
|
+
export default McDateRange;
|