zmdms-webui 2.7.8 → 2.8.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.
|
@@ -6,6 +6,10 @@ import { useDynamic } from './useDynamic.js';
|
|
|
6
6
|
import { useDrawer } from './hooks.js';
|
|
7
7
|
import MoreConfig from './moreConfig.js';
|
|
8
8
|
import useSearch from './useSearch.js';
|
|
9
|
+
import '../config/ZtxkContext.js';
|
|
10
|
+
import useBaseContext from '../config/useBaseContext.js';
|
|
11
|
+
import '../config/MyStorage.js';
|
|
12
|
+
import { useLatest } from 'ahooks';
|
|
9
13
|
import myMessage from '../message/index.js';
|
|
10
14
|
import SettingOutlined from '../node_modules/@ant-design/icons/es/icons/SettingOutlined.js';
|
|
11
15
|
import Input from '../input/input.js';
|
|
@@ -25,6 +29,12 @@ var sortDynamicListByType = function (list) {
|
|
|
25
29
|
// 这里操作的一直都是内部设置的list
|
|
26
30
|
var DynamicDrawer = function (props, ref) {
|
|
27
31
|
var list = props.list, dynamicKey = props.dynamicKey, parentDynamicKey = props.parentDynamicKey, _a = props.title, title = _a === void 0 ? "自定义配置" : _a, onCurrentListChange = props.onCurrentListChange, isMore = props.isMore, isFixed = props.isFixed, isDimensionDynamic = props.isDimensionDynamic, isSearch = props.isSearch;
|
|
32
|
+
var enableDynamicColumnSearch = useBaseContext().enableDynamicColumnSearch;
|
|
33
|
+
// 是否开启搜索功能
|
|
34
|
+
// 如果全局开启了默认添加,那么只要没有单独配置关闭,都认为需要打开
|
|
35
|
+
var isDynamicColumnSearchEnabled = enableDynamicColumnSearch
|
|
36
|
+
? isSearch !== false
|
|
37
|
+
: !!isSearch;
|
|
28
38
|
// 根据外部传入的list 和本地存储信息 生成一个内部的currentDynamicList
|
|
29
39
|
// 这个currentDynamicList 是可以是负责显示最终结果的
|
|
30
40
|
// tempDynamicList 是操作时的临时变量 可能操作后不点击确认 直接点击取消 那么需要重置到之前的状态
|
|
@@ -48,10 +58,17 @@ var DynamicDrawer = function (props, ref) {
|
|
|
48
58
|
});
|
|
49
59
|
return _checkedValues;
|
|
50
60
|
}, [tempDynamicList]);
|
|
51
|
-
var _d = useSearch(tempDynamicList, checkedValues), onSearchHandle = _d.onSearchHandle, onCheckBtn = _d.onCheckBtn, filterDynamicColumns = _d.filterDynamicColumns;
|
|
61
|
+
var _d = useSearch(tempDynamicList, checkedValues, isDimensionDynamic), onSearchHandle = _d.onSearchHandle, onCheckBtn = _d.onCheckBtn, filterDynamicColumns = _d.filterDynamicColumns;
|
|
62
|
+
var filterDynamicColumnsRef = useLatest(filterDynamicColumns);
|
|
52
63
|
// 根据isDimension分区
|
|
53
64
|
var _e = useMemo(function () {
|
|
54
|
-
var dynamicList =
|
|
65
|
+
var dynamicList = tempDynamicList;
|
|
66
|
+
// 这里为什么不直接赋值 filterDynamicColumns 是因为某些地方是直接使用item的引用去查找索引的
|
|
67
|
+
if (filterDynamicColumns) {
|
|
68
|
+
dynamicList = tempDynamicList.filter(function (item) {
|
|
69
|
+
return filterDynamicColumns.find(function (i) { return i.key === item.key; });
|
|
70
|
+
});
|
|
71
|
+
}
|
|
55
72
|
var dimensionList = dynamicList.filter(function (item) { return item.isDimension; });
|
|
56
73
|
var fieldList = dynamicList.filter(function (item) { return !item.isDimension; });
|
|
57
74
|
return { dimensionList: dimensionList, fieldList: fieldList };
|
|
@@ -81,6 +98,10 @@ var DynamicDrawer = function (props, ref) {
|
|
|
81
98
|
}, [tempDynamicList]);
|
|
82
99
|
// 拖拽
|
|
83
100
|
var onMoveItem = useCallback(function (dragIndex, hoverIndex) {
|
|
101
|
+
// 这里认为如果搜索了,不支持排序。
|
|
102
|
+
if (filterDynamicColumnsRef.current) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
84
105
|
if (!isDimensionPriority(dragIndex, hoverIndex)) {
|
|
85
106
|
return;
|
|
86
107
|
}
|
|
@@ -96,10 +117,14 @@ var DynamicDrawer = function (props, ref) {
|
|
|
96
117
|
// 处理左浮动 右浮动数据。需要重新排序
|
|
97
118
|
return sortDynamicListByType(currentList);
|
|
98
119
|
});
|
|
99
|
-
}, [setTempDynamicList, isDimensionPriority]);
|
|
120
|
+
}, [setTempDynamicList, isDimensionPriority, filterDynamicColumnsRef]);
|
|
100
121
|
// 子元素拖拽
|
|
101
122
|
var onChildMoveItem = useCallback(function (pIndex, pKey) {
|
|
102
123
|
return function (dragIndex, hoverIndex) {
|
|
124
|
+
// 这里认为如果搜索了,不支持排序。
|
|
125
|
+
if (filterDynamicColumnsRef.current) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
103
128
|
// 由于对于固定列,不能进行拖拽排序,所以需要找出所有包含固定列的属性出来
|
|
104
129
|
setTempDynamicList(function (preDynamicList) {
|
|
105
130
|
var newDynamicList = preDynamicList.map(function (item) { return (__assign({}, item)); }) || [];
|
|
@@ -120,7 +145,7 @@ var DynamicDrawer = function (props, ref) {
|
|
|
120
145
|
return __spreadArray(__spreadArray(__spreadArray([], leftList, true), middleList, true), rightList, true);
|
|
121
146
|
});
|
|
122
147
|
};
|
|
123
|
-
}, [setTempDynamicList]);
|
|
148
|
+
}, [setTempDynamicList, filterDynamicColumnsRef]);
|
|
124
149
|
// 确认
|
|
125
150
|
var onSureHandle = function () {
|
|
126
151
|
onSure && onSure(tempDynamicList);
|
|
@@ -277,7 +302,7 @@ var DynamicDrawer = function (props, ref) {
|
|
|
277
302
|
};
|
|
278
303
|
/**底部按钮 */
|
|
279
304
|
var renderFooter = function () { return (jsxs(Fragment, { children: [jsx(ButtonCom, __assign({ type: "default", onClick: onClose }, { children: "\u53D6\u6D88" })), jsx(ButtonCom, __assign({ type: "default", onClick: onReset }, { children: "\u91CD\u7F6E" })), jsx(ButtonCom, __assign({ type: "primary", onClick: onSureHandle }, { children: "\u786E\u5B9A" }))] })); };
|
|
280
|
-
return (jsx(Drawer, __assign({ className: "dynamic-drawer", title: jsxs("div", { children: [jsx(SettingOutlined, { style: { fontSize: 16 } }), jsxs("span", __assign({ className: "search-drawer--title-text" }, { children: [title, jsx("span", { children: "\uFF08\u62D6\u62FD\u6392\u5E8F\uFF09" })] }))] }), width: 300, placement: "right", open: visible, closable: false, maskClosable: false, footer: renderFooter() }, { children: jsxs("div", __assign({ className: "search-drawer--filter" }, { children: [
|
|
305
|
+
return (jsx(Drawer, __assign({ className: "dynamic-drawer", title: jsxs("div", { children: [jsx(SettingOutlined, { style: { fontSize: 16 } }), jsxs("span", __assign({ className: "search-drawer--title-text" }, { children: [title, jsx("span", { children: "\uFF08\u62D6\u62FD\u6392\u5E8F\uFF09" })] }))] }), width: 300, placement: "right", open: visible, closable: false, maskClosable: false, footer: renderFooter() }, { children: jsxs("div", __assign({ className: "search-drawer--filter" }, { children: [isDynamicColumnSearchEnabled ? (jsxs("div", __assign({ className: "search-drawer--filter-input" }, { children: [jsx(Input.Search, { placeholder: "\u641C\u7D22", onSearch: onSearchHandle }), jsx(ButtonCom, __assign({ type: "default", className: "selector-all", loading: false, onClick: function () { return onCheckBtn("all", onCheckboxChange); } }, { children: "\u5168\u9009" })), jsx(ButtonCom, __assign({ type: "default", className: "selector-inverse", loading: false, onClick: function () { return onCheckBtn("inverse", onCheckboxChange); } }, { children: "\u53CD\u9009" }))] }))) : null, jsx(Checkbox.Group, __assign({ value: checkedValues, onChange: onCheckboxChange }, { children: jsxs(Sortable, { children: [isDimensionDynamic && renderSection(dimensionList, 0, "维度配置"), renderSection(fieldList, dimensionList.length, isDimensionDynamic ? "字段配置" : undefined)] }) }))] })) })));
|
|
281
306
|
};
|
|
282
307
|
DynamicDrawer.displayName = "ZTXK_WEBUI_DynamicDrawer";
|
|
283
308
|
var DynamicDrawer$1 = memo(forwardRef(DynamicDrawer));
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __spreadArray } from '../_virtual/_tslib.js';
|
|
2
2
|
import { useState } from 'react';
|
|
3
|
+
import myMessage from '../message/index.js';
|
|
3
4
|
|
|
4
|
-
function useSearch(dynamicList, checkedValues) {
|
|
5
|
+
function useSearch(dynamicList, checkedValues, isDimensionDynamic) {
|
|
5
6
|
// 过滤后的可见列集合(仅操作此集合中的列)
|
|
6
7
|
var _a = useState(null), filterDynamicColumns = _a[0], setFilterDynamicColumns = _a[1];
|
|
7
8
|
// 未参与过滤的列,但是选中了的值
|
|
@@ -21,6 +22,10 @@ function useSearch(dynamicList, checkedValues) {
|
|
|
21
22
|
* 4. 仅当操作后选中状态发生变化时才更新,避免无效渲染
|
|
22
23
|
*/
|
|
23
24
|
var onCheckBtn = function (type, onCheckboxChange) {
|
|
25
|
+
if (isDimensionDynamic) {
|
|
26
|
+
myMessage.warn("维度列不支持全选/反选");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
24
29
|
// 1. 确定操作的目标列集合:仅对「过滤后可见列」操作(优先 filterDynamicColumns,无则用 dynamicColumns)
|
|
25
30
|
var targetColumns = filterDynamicColumns !== null && filterDynamicColumns !== void 0 ? filterDynamicColumns : dynamicList;
|
|
26
31
|
// 2. 拆分目标列中的两类列(仅在可见列范围内处理)
|
package/dist/es/select/select.js
CHANGED
|
@@ -120,7 +120,25 @@ var Select = function (props, ref) {
|
|
|
120
120
|
*/
|
|
121
121
|
var filterOptionHandle = function (input, option) {
|
|
122
122
|
var text = textContent(option === null || option === void 0 ? void 0 : option.children);
|
|
123
|
-
|
|
123
|
+
// 实现简易的分词查询逻辑
|
|
124
|
+
// 用空格分隔input
|
|
125
|
+
var inputList = input.split(" ").filter(function (item) { return item.trim() !== ""; });
|
|
126
|
+
// 遍历匹配
|
|
127
|
+
var isMatch = true;
|
|
128
|
+
var currentSearchText = text;
|
|
129
|
+
for (var i = 0; i < inputList.length; i++) {
|
|
130
|
+
var item = inputList[i];
|
|
131
|
+
// 找到上一个字符
|
|
132
|
+
var currentIndex = currentSearchText === null || currentSearchText === void 0 ? void 0 : currentSearchText.toLowerCase().indexOf(item.toLowerCase().trim());
|
|
133
|
+
if (currentIndex < 0) {
|
|
134
|
+
isMatch = false;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
// 重新赋值
|
|
138
|
+
currentSearchText = currentSearchText === null || currentSearchText === void 0 ? void 0 : currentSearchText.substring(currentIndex + item.length);
|
|
139
|
+
}
|
|
140
|
+
return isMatch;
|
|
141
|
+
// return text?.toLowerCase().indexOf(input.toLowerCase().trim()) >= 0;
|
|
124
142
|
};
|
|
125
143
|
return (jsx(Select$1, __assign({ defaultValue: showAll ? "" : undefined, showArrow: true, allowClear: true, dropdownMatchSelectWidth: dropdownMatchSelectWidth, onChange: onChangeHandle, showSearch: true, onSearch: onDebounceSearchHandle, filterOption: isRemoteSearch ? false : filterOptionHandle,
|
|
126
144
|
// 显示问题
|