ztxkui 2.6.9 → 2.7.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/dist/Demo.js +1 -1
- package/dist/components/Select/select.js +43 -4
- package/package.json +1 -1
package/dist/Demo.js
CHANGED
|
@@ -86,7 +86,7 @@ function Demo() {
|
|
|
86
86
|
React.createElement(EnhanceSelect, { style: selectStyle, defaultList: [
|
|
87
87
|
{ id: 1, empName: '21' },
|
|
88
88
|
{ id: 2, empName: '33' },
|
|
89
|
-
], placeholder: "\u53EF\u8FDC\u7A0B\u6A21\u7CCA\u641C\u7D22", url: "http://192.168.0.83:8000/api/zmdms-system/employee/page", request: request, remoteSearch: true, dataKey: "id", titleKey: "empName", value: value, showAll: true, onChange: function (value, option, fullData) {
|
|
89
|
+
], placeholder: "\u53EF\u8FDC\u7A0B\u6A21\u7CCA\u641C\u7D22", url: "http://192.168.0.83:8000/api/zmdms-system/employee/page", request: request, remoteSearch: true, isRemoteSearchDataKey: false, dataKey: "id", titleKey: "empName", value: value, showAll: true, onChange: function (value, option, fullData) {
|
|
90
90
|
setValue(value);
|
|
91
91
|
}, params: JSON.stringify(params),
|
|
92
92
|
// value={value}
|
|
@@ -20,20 +20,59 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
import React, { useState } from 'react';
|
|
23
|
+
import React, { useState, useRef } from 'react';
|
|
24
24
|
import { Select as AntSelect } from 'antd';
|
|
25
25
|
function Select(props) {
|
|
26
|
-
var children = props.children, restProps = __rest(props, ["children"]);
|
|
26
|
+
var children = props.children, onChange = props.onChange, restProps = __rest(props, ["children", "onChange"]);
|
|
27
27
|
// 获得焦点选中
|
|
28
28
|
var _a = useState(false), isOpen = _a[0], setIsOpen = _a[1];
|
|
29
|
+
var currentClick = useRef(true);
|
|
30
|
+
var onChangeHandle = function (value, option) {
|
|
31
|
+
if ((Array.isArray(value) && value.length === 0) || !value) {
|
|
32
|
+
currentClick.current = true;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
currentClick.current = false;
|
|
36
|
+
}
|
|
37
|
+
onChange && onChange(value, option);
|
|
38
|
+
};
|
|
29
39
|
// 焦点事件
|
|
30
|
-
var onFocusHandle = function () {
|
|
40
|
+
var onFocusHandle = function (e) {
|
|
41
|
+
// console.log('焦点事件');
|
|
31
42
|
setIsOpen(true);
|
|
43
|
+
currentClick.current = false;
|
|
32
44
|
};
|
|
33
45
|
var onBlurHandle = function () {
|
|
46
|
+
// console.log('失去焦点事件');
|
|
47
|
+
setIsOpen(false);
|
|
48
|
+
currentClick.current = false;
|
|
49
|
+
};
|
|
50
|
+
// 清空数据时
|
|
51
|
+
var onClearHandle = function () {
|
|
52
|
+
// console.log('清空数据事件');
|
|
34
53
|
setIsOpen(false);
|
|
35
54
|
};
|
|
36
|
-
|
|
55
|
+
// 选中时
|
|
56
|
+
var onSelectHandle = function () {
|
|
57
|
+
// console.log('选中数据事件');
|
|
58
|
+
if (!restProps.mode) {
|
|
59
|
+
setIsOpen(false);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
// 点击时
|
|
63
|
+
var onClickHandle = function (e) {
|
|
64
|
+
// console.log('点击事件', currentClick.current);
|
|
65
|
+
if (currentClick.current) {
|
|
66
|
+
if (isOpen) {
|
|
67
|
+
setIsOpen(false);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
setIsOpen(true);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
currentClick.current = true;
|
|
74
|
+
};
|
|
75
|
+
return (React.createElement(AntSelect, __assign({ onChange: onChangeHandle, onFocus: onFocusHandle, onBlur: onBlurHandle, onClear: onClearHandle, onSelect: onSelectHandle, onClick: onClickHandle, open: isOpen }, restProps), children));
|
|
37
76
|
}
|
|
38
77
|
Select.Option = AntSelect.Option;
|
|
39
78
|
Select.OptGroup = AntSelect.OptGroup;
|