@ccs-ui/rc-pro 1.0.0
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/LICENSE +21 -0
- package/README.md +37 -0
- package/es/auth/auth-button.js +59 -0
- package/es/auth/auth-dropdown.js +67 -0
- package/es/auth/index.js +164 -0
- package/es/ccs.js +82 -0
- package/es/color-picker/index.js +63 -0
- package/es/color-picker/index.less +9 -0
- package/es/config.js +11 -0
- package/es/context/index.js +11 -0
- package/es/date-picker/index.js +59 -0
- package/es/drawer/buttons.js +93 -0
- package/es/drawer/index.js +8 -0
- package/es/drawer/index.less +5 -0
- package/es/drawer/open/content.js +43 -0
- package/es/drawer/open/destory-fns.js +3 -0
- package/es/drawer/open/form.js +32 -0
- package/es/drawer/open/index.js +171 -0
- package/es/full-screen/index.js +57 -0
- package/es/hooks/use-event.js +67 -0
- package/es/hooks/use-global.js +10 -0
- package/es/hooks/use-once-event.js +16 -0
- package/es/hooks/use-page.js +10 -0
- package/es/hooks/use-tabs.js +10 -0
- package/es/hooks/use-window.js +10 -0
- package/es/index.js +27 -0
- package/es/interval-button/index.js +118 -0
- package/es/keep-alive-tabs/index.js +250 -0
- package/es/keep-alive-tabs/index.less +23 -0
- package/es/keep-alive-tabs/page.js +37 -0
- package/es/loading/index.js +27 -0
- package/es/modal/buttons.js +90 -0
- package/es/modal/index.js +8 -0
- package/es/modal/index.less +25 -0
- package/es/modal/open/destory-fns.js +3 -0
- package/es/modal/open/drag.js +104 -0
- package/es/modal/open/form.js +35 -0
- package/es/modal/open/index.js +93 -0
- package/es/pro-grid/context.js +4 -0
- package/es/pro-grid/index.js +88 -0
- package/es/pro-grid/index.less +29 -0
- package/es/pro-grid/useProGrid.js +10 -0
- package/es/pro-table/index.js +578 -0
- package/es/pro-table/index.less +165 -0
- package/es/pro-table/search.js +399 -0
- package/es/pro-tabs/index.js +77 -0
- package/es/pro-tabs/index.less +5 -0
- package/es/select/index.js +72 -0
- package/es/table/index.js +173 -0
- package/es/table/index.less +117 -0
- package/es/trigger/index.js +288 -0
- package/es/trigger/index.less +42 -0
- package/es/types.js +0 -0
- package/es/utils.js +205 -0
- package/es/virtual-list/index.js +125 -0
- package/es/water-mark/index.js +135 -0
- package/package.json +102 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// table buttons
|
|
2
|
+
.buttons {
|
|
3
|
+
button:not(:last-child)::after {
|
|
4
|
+
margin: 0 4px 0 6px;
|
|
5
|
+
color: #e8e8e8;
|
|
6
|
+
content: '|';
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.ccs-pl {
|
|
11
|
+
// .ant-table-sticky-scroll {
|
|
12
|
+
// display: none;
|
|
13
|
+
// }
|
|
14
|
+
.ant-pagination {
|
|
15
|
+
background-color: #fff;
|
|
16
|
+
margin: 0 !important;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&-icon {
|
|
20
|
+
color: rgb(0 0 0 / 75%);
|
|
21
|
+
font-size: 16;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&-table-content {
|
|
25
|
+
// margin: 10px;
|
|
26
|
+
// background: #fff;
|
|
27
|
+
position: relative;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&-title {
|
|
31
|
+
padding: 10px 16px;
|
|
32
|
+
color: rgb(0 0 0 / 85%);
|
|
33
|
+
font-weight: 500;
|
|
34
|
+
font-size: 16px;
|
|
35
|
+
background: #fff;
|
|
36
|
+
border-bottom: 1px solid #f0f0f0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&-form {
|
|
40
|
+
flex: 0 1 auto;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: row;
|
|
44
|
+
align-items: flex-end;
|
|
45
|
+
justify-content: space-between;
|
|
46
|
+
|
|
47
|
+
.ant-form-item {
|
|
48
|
+
flex-wrap: nowrap;
|
|
49
|
+
flex: 0 1 auto;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.ant-form-item .ant-form-item-label {
|
|
53
|
+
padding: 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
label {
|
|
57
|
+
white-space: nowrap;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.ant-form-item-label {
|
|
61
|
+
flex: 0 0 auto !important;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.ant-form-item-control {
|
|
65
|
+
flex: 0 1 auto !important;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.ant-form-inline {
|
|
69
|
+
flex-wrap: nowrap;
|
|
70
|
+
align-items: flex-end;
|
|
71
|
+
justify-content: end;
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&-high-form {
|
|
77
|
+
background: #fff;
|
|
78
|
+
box-shadow: 0 2px 2px 0 rgb(0 0 0 / 3%);
|
|
79
|
+
|
|
80
|
+
.ant-form-item {
|
|
81
|
+
margin-bottom: 10px !important;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.ant-form-item-control {
|
|
86
|
+
line-height: 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// .ant-form-item {
|
|
90
|
+
// margin-bottom: 0;
|
|
91
|
+
// }
|
|
92
|
+
|
|
93
|
+
.ant-input-number {
|
|
94
|
+
width: 100%;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.ant-picker {
|
|
98
|
+
width: 100%;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.ant-drawer-right.ant-drawer-open {
|
|
102
|
+
width: 100%;
|
|
103
|
+
transition: none;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.ant-drawer.ant-drawer-open .ant-drawer-mask {
|
|
107
|
+
animation: none;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&-form-label {
|
|
111
|
+
.ant-col-24.ant-form-item-label {
|
|
112
|
+
padding: 0;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&-toolbar {
|
|
117
|
+
flex: 0 0 auto;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&-header {
|
|
121
|
+
display: flex;
|
|
122
|
+
gap: 10px;
|
|
123
|
+
justify-content: space-between;
|
|
124
|
+
align-items: center;
|
|
125
|
+
background-color: #fff;
|
|
126
|
+
|
|
127
|
+
.ant-form-item-explain {
|
|
128
|
+
position: absolute;
|
|
129
|
+
bottom: -20px;
|
|
130
|
+
z-index: 101;
|
|
131
|
+
height: 0;
|
|
132
|
+
overflow: hidden;
|
|
133
|
+
white-space: nowrap;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
&-buttons {
|
|
137
|
+
margin-left: 6px;
|
|
138
|
+
white-space: nowrap;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.ant-table-tbody > tr:nth-child(odd) {
|
|
143
|
+
td {
|
|
144
|
+
background: #e6f7ff;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.ant-table-tbody > tr.ant-table-row-selected > td {
|
|
149
|
+
background: #fff6e6;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.ant-table-tbody > tr.ant-table-row:hover > td {
|
|
153
|
+
background: #fafafa;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// modal drawer ccs-pl 中取消table content padding
|
|
158
|
+
.ant-modal-body,
|
|
159
|
+
.ant-drawer-body,
|
|
160
|
+
.ccs-trigger-container,
|
|
161
|
+
.ccs-pg-col {
|
|
162
|
+
.ccs-pl-table-content {
|
|
163
|
+
margin: 0;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import { MoreOutlined, RedoOutlined, SettingOutlined, UpOutlined } from '@ant-design/icons';
|
|
12
|
+
import { Button, Checkbox, Col, Dropdown, Form, Row, Tooltip } from 'antd';
|
|
13
|
+
import _debounce from 'lodash/debounce';
|
|
14
|
+
import ResizeObserver from 'rc-resize-observer';
|
|
15
|
+
import React, { cloneElement, useMemo, useRef, useState } from 'react';
|
|
16
|
+
import { classPrefix } from '.';
|
|
17
|
+
import { CcsFullScreenButton } from '..';
|
|
18
|
+
/** 查找所有父级依赖 */
|
|
19
|
+
var getShowDpends = function getShowDpends(items, item, depends) {
|
|
20
|
+
var showDepends = item.showDepends;
|
|
21
|
+
if (showDepends) {
|
|
22
|
+
var dependItems = items.filter(function (i) {
|
|
23
|
+
return showDepends.some(function (e) {
|
|
24
|
+
return e && e.name === i.name;
|
|
25
|
+
});
|
|
26
|
+
}) || [];
|
|
27
|
+
dependItems.forEach(function (dependItem) {
|
|
28
|
+
if (dependItem !== null && dependItem !== void 0 && dependItem.showDepends) {
|
|
29
|
+
dependItem.showDepends.forEach(function (e) {
|
|
30
|
+
return depends.push(e);
|
|
31
|
+
});
|
|
32
|
+
return getShowDpends(items, dependItem, depends);
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
});
|
|
36
|
+
return depends;
|
|
37
|
+
}
|
|
38
|
+
return depends;
|
|
39
|
+
};
|
|
40
|
+
/** 操作按钮、查询,重置、列筛选、 */
|
|
41
|
+
function SearchComponent(_ref) {
|
|
42
|
+
var form = _ref.form,
|
|
43
|
+
toolbar = _ref.toolbar,
|
|
44
|
+
columns = _ref.columns,
|
|
45
|
+
hasMore = _ref.hasMore,
|
|
46
|
+
_ref$formItems = _ref.formItems,
|
|
47
|
+
formItems = _ref$formItems === void 0 ? [] : _ref$formItems,
|
|
48
|
+
formInitValues = _ref.formInitValues,
|
|
49
|
+
isInModalOrDrawer = _ref.isInModalOrDrawer,
|
|
50
|
+
event$ = _ref.event$,
|
|
51
|
+
onReset = _ref.onReset,
|
|
52
|
+
onSearch = _ref.onSearch;
|
|
53
|
+
var _useState = useState(false),
|
|
54
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
55
|
+
dropdownVisible = _useState2[0],
|
|
56
|
+
setDropdownVisible = _useState2[1];
|
|
57
|
+
var _useState3 = useState(columns),
|
|
58
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
59
|
+
filterColumns = _useState4[0],
|
|
60
|
+
setFilterColumns = _useState4[1];
|
|
61
|
+
var _useState5 = useState(false),
|
|
62
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
63
|
+
isShowMore = _useState6[0],
|
|
64
|
+
setIsShowMore = _useState6[1];
|
|
65
|
+
var ref = useRef(null);
|
|
66
|
+
var _useState7 = useState(8),
|
|
67
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
68
|
+
colSpan = _useState8[0],
|
|
69
|
+
setColSpan = _useState8[1];
|
|
70
|
+
|
|
71
|
+
// 处理form item 依赖
|
|
72
|
+
var allFormItems = useMemo(function () {
|
|
73
|
+
formItems.forEach(function (item) {
|
|
74
|
+
var depend = item.showDepends || [];
|
|
75
|
+
if (depend && depend.length > 0) {
|
|
76
|
+
getShowDpends(formItems, item, depend);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return formItems;
|
|
80
|
+
}, [formItems]);
|
|
81
|
+
|
|
82
|
+
// 获取全选初始状态
|
|
83
|
+
var getHalfCheckState = function getHalfCheckState() {
|
|
84
|
+
var cols = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : columns;
|
|
85
|
+
var col = cols === null || cols === void 0 ? void 0 : cols.filter(function (t) {
|
|
86
|
+
return t.dataIndex;
|
|
87
|
+
});
|
|
88
|
+
return (col === null || col === void 0 ? void 0 : col.every(function (c) {
|
|
89
|
+
return !c.hidden;
|
|
90
|
+
})) || (col === null || col === void 0 ? void 0 : col.every(function (c) {
|
|
91
|
+
return c.hidden;
|
|
92
|
+
}));
|
|
93
|
+
};
|
|
94
|
+
var _useState9 = useState(true),
|
|
95
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
96
|
+
isCheckAll = _useState10[0],
|
|
97
|
+
setIsCheckAll = _useState10[1];
|
|
98
|
+
var _useState11 = useState(getHalfCheckState),
|
|
99
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
100
|
+
isHalfCheck = _useState12[0],
|
|
101
|
+
setIsHalfCheck = _useState12[1];
|
|
102
|
+
|
|
103
|
+
// 列选中事件
|
|
104
|
+
var onCheckChange = function onCheckChange(checked, index) {
|
|
105
|
+
filterColumns[index].hidden = !checked;
|
|
106
|
+
setFilterColumns(_toConsumableArray(filterColumns));
|
|
107
|
+
var isHalf = getHalfCheckState(filterColumns);
|
|
108
|
+
if (isHalf !== isHalfCheck) {
|
|
109
|
+
setIsHalfCheck(isHalf);
|
|
110
|
+
}
|
|
111
|
+
if (isHalf) {
|
|
112
|
+
setIsCheckAll(checked);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// 计算隐藏的列key
|
|
116
|
+
var columnHiddenKeys = [];
|
|
117
|
+
filterColumns.forEach(function (t) {
|
|
118
|
+
if (t.hidden) columnHiddenKeys.push(t.dataIndex);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// 发布列改变通知
|
|
122
|
+
event$.emit({
|
|
123
|
+
key: 'columnFilter',
|
|
124
|
+
columnHiddenKeys: columnHiddenKeys
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// 全选、取消全选
|
|
129
|
+
var onCheckAllChange = function onCheckAllChange(e) {
|
|
130
|
+
// 隐藏的列key
|
|
131
|
+
var columnHiddenKeys = [];
|
|
132
|
+
filterColumns.forEach(function (t) {
|
|
133
|
+
var s = t;
|
|
134
|
+
if (s.dataIndex) s.hidden = !e.target.checked;
|
|
135
|
+
if (s.hidden) columnHiddenKeys.push(t.dataIndex);
|
|
136
|
+
});
|
|
137
|
+
setFilterColumns(_toConsumableArray(filterColumns));
|
|
138
|
+
setIsCheckAll(e.target.checked);
|
|
139
|
+
setIsHalfCheck(true);
|
|
140
|
+
|
|
141
|
+
// 发布列改变通知
|
|
142
|
+
event$.emit({
|
|
143
|
+
key: 'columnFilter',
|
|
144
|
+
columnHiddenKeys: columnHiddenKeys
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// 列过滤
|
|
149
|
+
var renderCheck = function renderCheck() {
|
|
150
|
+
var fc = [{
|
|
151
|
+
key: '1',
|
|
152
|
+
label: /*#__PURE__*/React.createElement(Checkbox, {
|
|
153
|
+
indeterminate: !isHalfCheck,
|
|
154
|
+
onChange: onCheckAllChange,
|
|
155
|
+
checked: isCheckAll
|
|
156
|
+
}, "\u5168\u9009")
|
|
157
|
+
}, {
|
|
158
|
+
key: '2',
|
|
159
|
+
type: 'divider'
|
|
160
|
+
}];
|
|
161
|
+
filterColumns.forEach(function (c, index) {
|
|
162
|
+
if (c.dataIndex) {
|
|
163
|
+
fc.push({
|
|
164
|
+
key: c.dataIndex,
|
|
165
|
+
label: /*#__PURE__*/React.createElement(Checkbox, {
|
|
166
|
+
checked: !c.hidden,
|
|
167
|
+
onChange: function onChange(e) {
|
|
168
|
+
return onCheckChange(e.target.checked, index);
|
|
169
|
+
}
|
|
170
|
+
}, c.title)
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
return fc;
|
|
175
|
+
};
|
|
176
|
+
var onFullScreen = function onFullScreen(full) {
|
|
177
|
+
event$.emit({
|
|
178
|
+
key: 'fullScreen',
|
|
179
|
+
full: full
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// 操作按钮
|
|
184
|
+
var renderOperation = /*#__PURE__*/React.createElement("div", {
|
|
185
|
+
className: "".concat(classPrefix, "-header-buttons")
|
|
186
|
+
}, hasMore && /*#__PURE__*/React.createElement(Button, {
|
|
187
|
+
onClick: function onClick() {
|
|
188
|
+
return setIsShowMore(!isShowMore);
|
|
189
|
+
},
|
|
190
|
+
icon: isShowMore ? /*#__PURE__*/React.createElement(UpOutlined, {
|
|
191
|
+
className: "".concat(classPrefix, "-icon")
|
|
192
|
+
}) : /*#__PURE__*/React.createElement(MoreOutlined, {
|
|
193
|
+
className: "".concat(classPrefix, "-icon")
|
|
194
|
+
}),
|
|
195
|
+
type: "text",
|
|
196
|
+
style: {
|
|
197
|
+
width: 24
|
|
198
|
+
}
|
|
199
|
+
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
200
|
+
title: "\u91CD\u7F6E"
|
|
201
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
202
|
+
onClick: onReset,
|
|
203
|
+
icon: /*#__PURE__*/React.createElement(RedoOutlined, {
|
|
204
|
+
className: "".concat(classPrefix, "-icon")
|
|
205
|
+
}),
|
|
206
|
+
type: "text",
|
|
207
|
+
style: {
|
|
208
|
+
width: 24
|
|
209
|
+
}
|
|
210
|
+
})), filterColumns && /*#__PURE__*/React.createElement(Dropdown, {
|
|
211
|
+
menu: {
|
|
212
|
+
items: renderCheck()
|
|
213
|
+
},
|
|
214
|
+
trigger: ['click'],
|
|
215
|
+
open: dropdownVisible,
|
|
216
|
+
onOpenChange: function onOpenChange(flag) {
|
|
217
|
+
return setDropdownVisible(flag);
|
|
218
|
+
}
|
|
219
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
220
|
+
title: "\u5217\u8BBE\u7F6E"
|
|
221
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
222
|
+
icon: /*#__PURE__*/React.createElement(SettingOutlined, {
|
|
223
|
+
className: "".concat(classPrefix, "-icon")
|
|
224
|
+
}),
|
|
225
|
+
type: "text",
|
|
226
|
+
style: {
|
|
227
|
+
width: 24
|
|
228
|
+
}
|
|
229
|
+
}))), !isInModalOrDrawer && /*#__PURE__*/React.createElement(CcsFullScreenButton, {
|
|
230
|
+
onFullScreen: onFullScreen
|
|
231
|
+
}));
|
|
232
|
+
|
|
233
|
+
// render item 判断是否有依赖
|
|
234
|
+
var renderFormItem = function renderFormItem(items) {
|
|
235
|
+
if (!items) return [];
|
|
236
|
+
return items.map(function (item) {
|
|
237
|
+
return item.depends || item.showDepends ? /*#__PURE__*/React.createElement(Form.Item, {
|
|
238
|
+
noStyle: true,
|
|
239
|
+
key: item.name,
|
|
240
|
+
shouldUpdate: function shouldUpdate(l, n) {
|
|
241
|
+
var _item$depends, _item$showDepends;
|
|
242
|
+
return ((_item$depends = item.depends) === null || _item$depends === void 0 ? void 0 : _item$depends.some(function (i) {
|
|
243
|
+
return l[i] !== n[i];
|
|
244
|
+
})) || ((_item$showDepends = item.showDepends) === null || _item$showDepends === void 0 ? void 0 : _item$showDepends.some(function (i) {
|
|
245
|
+
return l[i.name] !== n[i.name];
|
|
246
|
+
})) || false;
|
|
247
|
+
}
|
|
248
|
+
}, function (_ref2) {
|
|
249
|
+
var _item$depends2;
|
|
250
|
+
var getFieldValue = _ref2.getFieldValue;
|
|
251
|
+
var dependParam = {};
|
|
252
|
+
(_item$depends2 = item.depends) === null || _item$depends2 === void 0 ? void 0 : _item$depends2.forEach(function (i) {
|
|
253
|
+
var value = getFieldValue(i);
|
|
254
|
+
dependParam[i] = value;
|
|
255
|
+
});
|
|
256
|
+
var isShow = true;
|
|
257
|
+
if (item.showDepends && item.showDepends.length > 0) {
|
|
258
|
+
var _item$showDepends2;
|
|
259
|
+
isShow = (_item$showDepends2 = item.showDepends) === null || _item$showDepends2 === void 0 ? void 0 : _item$showDepends2.every(function (i) {
|
|
260
|
+
return getFieldValue(i.name) === i.value;
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
return isShow ? /*#__PURE__*/React.createElement(Form.Item, {
|
|
264
|
+
name: "".concat(item.name),
|
|
265
|
+
label: item.label,
|
|
266
|
+
key: item.name,
|
|
267
|
+
rules: item.rules
|
|
268
|
+
}, /*#__PURE__*/cloneElement(item.value, dependParam)) : null;
|
|
269
|
+
}) : /*#__PURE__*/React.createElement(Form.Item, {
|
|
270
|
+
name: item.name,
|
|
271
|
+
label: item.label,
|
|
272
|
+
key: item.name,
|
|
273
|
+
rules: item.rules
|
|
274
|
+
}, item.value);
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
// 查询部分
|
|
279
|
+
var renderSearch = function renderSearch() {
|
|
280
|
+
if (!formItems.length) return /*#__PURE__*/React.createElement(Form.Item, null);
|
|
281
|
+
// 主条件
|
|
282
|
+
var mainItems = allFormItems.filter(function (f) {
|
|
283
|
+
return f.isMain;
|
|
284
|
+
});
|
|
285
|
+
var initFormItems = mainItems.length > 0 ? mainItems : [allFormItems[0]];
|
|
286
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, !isShowMore && renderFormItem(initFormItems), /*#__PURE__*/React.createElement(Button, {
|
|
287
|
+
type: "primary",
|
|
288
|
+
onClick: function onClick() {},
|
|
289
|
+
htmlType: "submit"
|
|
290
|
+
}, "\u67E5\u8BE2"));
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
// 重设尺寸,当组件位于弹框中,根据容器宽度决定显示尺寸
|
|
294
|
+
var resizeFn = _debounce(function (width) {
|
|
295
|
+
if (!ref.current) return;
|
|
296
|
+
if (width === 0) return;
|
|
297
|
+
if (width > 1000) {
|
|
298
|
+
if (colSpan !== 6) setColSpan(6);
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (width < 300) {
|
|
302
|
+
if (colSpan !== 24) setColSpan(24);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (width < 500) {
|
|
306
|
+
if (colSpan !== 12) setColSpan(12);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if (width < 1000) {
|
|
310
|
+
if (colSpan !== 8) setColSpan(8);
|
|
311
|
+
}
|
|
312
|
+
}, 500);
|
|
313
|
+
var onResize = function onResize(size) {
|
|
314
|
+
if (size.width === 0) return;
|
|
315
|
+
resizeFn(size.width);
|
|
316
|
+
};
|
|
317
|
+
var renderMoreForm = function renderMoreForm() {
|
|
318
|
+
return /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
319
|
+
onResize: onResize
|
|
320
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
321
|
+
className: "".concat(classPrefix, "-high-form"),
|
|
322
|
+
ref: ref,
|
|
323
|
+
style: {
|
|
324
|
+
maxHeight: isShowMore ? 500 : 0,
|
|
325
|
+
overflow: 'hidden'
|
|
326
|
+
}
|
|
327
|
+
}, /*#__PURE__*/React.createElement(Form, {
|
|
328
|
+
initialValues: formInitValues,
|
|
329
|
+
form: form,
|
|
330
|
+
onFinish: onSearch,
|
|
331
|
+
layout: "horizontal"
|
|
332
|
+
}, /*#__PURE__*/React.createElement(Row, {
|
|
333
|
+
gutter: 16
|
|
334
|
+
}, allFormItems.map(function (item) {
|
|
335
|
+
return item.depends || item.showDepends ? /*#__PURE__*/React.createElement(Form.Item, {
|
|
336
|
+
noStyle: true,
|
|
337
|
+
key: item.name,
|
|
338
|
+
shouldUpdate: function shouldUpdate(l, n) {
|
|
339
|
+
var _item$depends3, _item$showDepends3;
|
|
340
|
+
return ((_item$depends3 = item.depends) === null || _item$depends3 === void 0 ? void 0 : _item$depends3.some(function (i) {
|
|
341
|
+
return l[i] !== n[i];
|
|
342
|
+
})) || ((_item$showDepends3 = item.showDepends) === null || _item$showDepends3 === void 0 ? void 0 : _item$showDepends3.some(function (i) {
|
|
343
|
+
return l[i.name] !== n[i.name];
|
|
344
|
+
})) || false;
|
|
345
|
+
}
|
|
346
|
+
}, function (_ref3) {
|
|
347
|
+
var _item$depends4;
|
|
348
|
+
var getFieldValue = _ref3.getFieldValue;
|
|
349
|
+
var dependParam = {};
|
|
350
|
+
(_item$depends4 = item.depends) === null || _item$depends4 === void 0 ? void 0 : _item$depends4.forEach(function (i) {
|
|
351
|
+
var value = getFieldValue(i);
|
|
352
|
+
dependParam[i] = value;
|
|
353
|
+
});
|
|
354
|
+
var isShow = true;
|
|
355
|
+
if (item.showDepends && item.showDepends.length > 0) {
|
|
356
|
+
var _item$showDepends4;
|
|
357
|
+
isShow = (_item$showDepends4 = item.showDepends) === null || _item$showDepends4 === void 0 ? void 0 : _item$showDepends4.every(function (i) {
|
|
358
|
+
return getFieldValue(i.name) === i.value;
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
return isShow ? /*#__PURE__*/React.createElement(Col, {
|
|
362
|
+
span: colSpan
|
|
363
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
364
|
+
className: "".concat(classPrefix, "-form-label"),
|
|
365
|
+
label: item.label,
|
|
366
|
+
name: item.name,
|
|
367
|
+
rules: item.rules
|
|
368
|
+
}, /*#__PURE__*/cloneElement(item.value, dependParam))) : null;
|
|
369
|
+
}) : /*#__PURE__*/React.createElement(Col, {
|
|
370
|
+
span: colSpan,
|
|
371
|
+
key: item.name
|
|
372
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
373
|
+
className: "".concat(classPrefix, "-form-label"),
|
|
374
|
+
rules: item.rules,
|
|
375
|
+
label: item.label,
|
|
376
|
+
name: item.name
|
|
377
|
+
}, item.value));
|
|
378
|
+
})))));
|
|
379
|
+
};
|
|
380
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
381
|
+
style: {
|
|
382
|
+
padding: 16,
|
|
383
|
+
background: '#fff'
|
|
384
|
+
}
|
|
385
|
+
}, hasMore && renderMoreForm(), /*#__PURE__*/React.createElement("div", {
|
|
386
|
+
className: "".concat(classPrefix, "-header")
|
|
387
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
388
|
+
className: "".concat(classPrefix, "-toolbar")
|
|
389
|
+
}, toolbar), /*#__PURE__*/React.createElement("div", {
|
|
390
|
+
className: "".concat(classPrefix, "-form")
|
|
391
|
+
}, /*#__PURE__*/React.createElement(Form, {
|
|
392
|
+
initialValues: formInitValues,
|
|
393
|
+
form: form,
|
|
394
|
+
onFinish: onSearch,
|
|
395
|
+
layout: "inline",
|
|
396
|
+
labelWrap: false
|
|
397
|
+
}, renderSearch()), renderOperation))));
|
|
398
|
+
}
|
|
399
|
+
export default SearchComponent;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
11
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
15
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
16
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
+
import { useUpdateEffect } from 'ahooks';
|
|
18
|
+
import React, { cloneElement, useState } from 'react';
|
|
19
|
+
import { TabsContext } from "../context";
|
|
20
|
+
import "./index.less";
|
|
21
|
+
export default (function (_ref) {
|
|
22
|
+
var _children$items;
|
|
23
|
+
var children = _ref.children;
|
|
24
|
+
var _ref2 = (children === null || children === void 0 ? void 0 : children.props) || {},
|
|
25
|
+
_ref2$items = _ref2.items,
|
|
26
|
+
items = _ref2$items === void 0 ? [] : _ref2$items,
|
|
27
|
+
activeKey = _ref2.activeKey,
|
|
28
|
+
defaultActiveKey = _ref2.defaultActiveKey;
|
|
29
|
+
var _useState = useState({
|
|
30
|
+
activeKey: defaultActiveKey || (items[0] || {}).key,
|
|
31
|
+
items: items || [],
|
|
32
|
+
option: {}
|
|
33
|
+
}),
|
|
34
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
+
tabsProps = _useState2[0],
|
|
36
|
+
setTabsProps = _useState2[1];
|
|
37
|
+
|
|
38
|
+
// items 发生改变
|
|
39
|
+
useUpdateEffect(function () {
|
|
40
|
+
setTabsProps(_objectSpread(_objectSpread({}, tabsProps), {}, {
|
|
41
|
+
items: items
|
|
42
|
+
}));
|
|
43
|
+
}, [children === null || children === void 0 ? void 0 : (_children$items = children.items) === null || _children$items === void 0 ? void 0 : _children$items.map(function (t) {
|
|
44
|
+
return t.key;
|
|
45
|
+
}).join(',')]);
|
|
46
|
+
var addOptions = {
|
|
47
|
+
items: tabsProps.items,
|
|
48
|
+
className: 'ccs-tabs'
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// 未传入activeKey,添加控制方法
|
|
52
|
+
if (!activeKey) {
|
|
53
|
+
addOptions.activeKey = tabsProps.activeKey;
|
|
54
|
+
addOptions.onChange = function (key) {
|
|
55
|
+
setTabsProps(_objectSpread(_objectSpread({}, tabsProps), {}, {
|
|
56
|
+
activeKey: key
|
|
57
|
+
}));
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return children ? /*#__PURE__*/React.createElement(TabsContext.Provider, {
|
|
61
|
+
value: {
|
|
62
|
+
activeKey: tabsProps.activeKey,
|
|
63
|
+
items: tabsProps.items,
|
|
64
|
+
option: tabsProps.option,
|
|
65
|
+
onChange: function onChange(e) {
|
|
66
|
+
return setTabsProps(function (state) {
|
|
67
|
+
if (e.items) {
|
|
68
|
+
return _objectSpread(_objectSpread(_objectSpread({}, state), e), {}, {
|
|
69
|
+
items: _toConsumableArray(e.items || [])
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return _objectSpread(_objectSpread({}, state), e);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}, /*#__PURE__*/cloneElement(children, addOptions)) : /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
77
|
+
});
|