@jiangood/open-admin 1.0.0-beta.5
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/config/common-plugin.js +94 -0
- package/config/config.js +58 -0
- package/config/utils.js +73 -0
- package/package.json +42 -0
- package/src/.umi-production/appData.json +2365 -0
- package/src/.umi-production/core/EmptyRoute.tsx +9 -0
- package/src/.umi-production/core/defineApp.ts +16 -0
- package/src/.umi-production/core/helmet.ts +10 -0
- package/src/.umi-production/core/helmetContext.ts +4 -0
- package/src/.umi-production/core/history.ts +72 -0
- package/src/.umi-production/core/historyIntelli.ts +132 -0
- package/src/.umi-production/core/plugin.ts +40 -0
- package/src/.umi-production/core/pluginConfig.ts +324 -0
- package/src/.umi-production/core/pluginConfigJoi.d.ts +7 -0
- package/src/.umi-production/core/polyfill.ts +220 -0
- package/src/.umi-production/core/route.tsx +54 -0
- package/src/.umi-production/core/routeProps.js +5 -0
- package/src/.umi-production/core/routeProps.ts +6 -0
- package/src/.umi-production/core/terminal.ts +37 -0
- package/src/.umi-production/exports.ts +17 -0
- package/src/.umi-production/testBrowser.tsx +90 -0
- package/src/.umi-production/tsconfig.json +44 -0
- package/src/.umi-production/typings.d.ts +136 -0
- package/src/.umi-production/umi.ts +83 -0
- package/src/framework/components/DownloadFileButton/index.d.ts +11 -0
- package/src/framework/components/DownloadFileButton/index.jsx +33 -0
- package/src/framework/components/Gap/index.d.ts +23 -0
- package/src/framework/components/Gap/index.jsx +46 -0
- package/src/framework/components/LinkButton/index.d.ts +14 -0
- package/src/framework/components/LinkButton/index.jsx +10 -0
- package/src/framework/components/NamedIcon/index.d.ts +5 -0
- package/src/framework/components/NamedIcon/index.jsx +11 -0
- package/src/framework/components/OrgTree/index.d.ts +4 -0
- package/src/framework/components/OrgTree/index.jsx +58 -0
- package/src/framework/components/Page/index.d.ts +17 -0
- package/src/framework/components/Page/index.jsx +30 -0
- package/src/framework/components/Page/index.less +10 -0
- package/src/framework/components/PageLoading/index.d.ts +1 -0
- package/src/framework/components/PageLoading/index.jsx +25 -0
- package/src/framework/components/ProModal/index.tsx +66 -0
- package/src/framework/components/ProTable/components/ToolBar/index.jsx +123 -0
- package/src/framework/components/ProTable/components/ToolBar/index.less +53 -0
- package/src/framework/components/ProTable/index.d.ts +42 -0
- package/src/framework/components/ProTable/index.jsx +260 -0
- package/src/framework/components/ProTable/index.less +14 -0
- package/src/framework/components/ProTable/utils/index.js +43 -0
- package/src/framework/components/RoleTree/index.d.ts +4 -0
- package/src/framework/components/RoleTree/index.jsx +50 -0
- package/src/framework/components/ValueType/index.jsx +34 -0
- package/src/framework/components/ValueType/registry.jsx +26 -0
- package/src/framework/components/ViewRange/index.d.ts +14 -0
- package/src/framework/components/ViewRange/index.jsx +20 -0
- package/src/framework/components/index.ts +13 -0
- package/src/framework/components/system/ButtonList.d.ts +8 -0
- package/src/framework/components/system/ButtonList.jsx +42 -0
- package/src/framework/components/system/HasPerm.tsx +14 -0
- package/src/framework/components/system/index.tsx +29 -0
- package/src/framework/fields/FieldBoolean/index.d.ts +9 -0
- package/src/framework/fields/FieldBoolean/index.jsx +73 -0
- package/src/framework/fields/FieldDate/index.d.ts +23 -0
- package/src/framework/fields/FieldDate/index.jsx +116 -0
- package/src/framework/fields/FieldDateRange/index.d.ts +22 -0
- package/src/framework/fields/FieldDateRange/index.jsx +103 -0
- package/src/framework/fields/FieldDictSelect/index.d.ts +12 -0
- package/src/framework/fields/FieldDictSelect/index.jsx +16 -0
- package/src/framework/fields/FieldEditor/index.d.ts +14 -0
- package/src/framework/fields/FieldEditor/index.jsx +59 -0
- package/src/framework/fields/FieldNumberRange/index.d.ts +10 -0
- package/src/framework/fields/FieldNumberRange/index.jsx +55 -0
- package/src/framework/fields/FieldPercent/index.d.ts +8 -0
- package/src/framework/fields/FieldPercent/index.jsx +30 -0
- package/src/framework/fields/FieldRemoteSelect/index.d.ts +44 -0
- package/src/framework/fields/FieldRemoteSelect/index.jsx +125 -0
- package/src/framework/fields/FieldRemoteSelectMultiple/index.d.ts +20 -0
- package/src/framework/fields/FieldRemoteSelectMultiple/index.jsx +85 -0
- package/src/framework/fields/FieldRemoteSelectMultipleInline/index.d.ts +21 -0
- package/src/framework/fields/FieldRemoteSelectMultipleInline/index.jsx +88 -0
- package/src/framework/fields/FieldRemoteTree/index.d.ts +20 -0
- package/src/framework/fields/FieldRemoteTree/index.jsx +50 -0
- package/src/framework/fields/FieldRemoteTreeCascader/index.d.ts +18 -0
- package/src/framework/fields/FieldRemoteTreeCascader/index.jsx +59 -0
- package/src/framework/fields/FieldRemoteTreeSelect/index.d.ts +19 -0
- package/src/framework/fields/FieldRemoteTreeSelect/index.jsx +57 -0
- package/src/framework/fields/FieldRemoteTreeSelectMultiple/index.d.ts +20 -0
- package/src/framework/fields/FieldRemoteTreeSelectMultiple/index.jsx +62 -0
- package/src/framework/fields/FieldSysOrgTree/index.d.ts +9 -0
- package/src/framework/fields/FieldSysOrgTree/index.jsx +20 -0
- package/src/framework/fields/FieldSysOrgTreeSelect/index.d.ts +9 -0
- package/src/framework/fields/FieldSysOrgTreeSelect/index.jsx +22 -0
- package/src/framework/fields/FieldTable/index.d.ts +14 -0
- package/src/framework/fields/FieldTable/index.jsx +108 -0
- package/src/framework/fields/FieldTable/styles.less +29 -0
- package/src/framework/fields/FieldTableSelect/index.d.ts +19 -0
- package/src/framework/fields/FieldTableSelect/index.jsx +60 -0
- package/src/framework/fields/FieldUploadFile/index.d.ts +31 -0
- package/src/framework/fields/FieldUploadFile/index.jsx +139 -0
- package/src/framework/fields/index.ts +22 -0
- package/src/framework/fields/types.ts +16 -0
- package/src/framework/index.ts +5 -0
- package/src/framework/pages/LoginPage.d.ts +16 -0
- package/src/framework/pages/LoginPage.jsx +135 -0
- package/src/framework/pages/LoginPage.less +53 -0
- package/src/framework/pages/LoginPageUtils.ts +36 -0
- package/src/framework/pages/index.ts +2 -0
- package/src/framework/utils/ArrUtils.ts +229 -0
- package/src/framework/utils/ColorsUtils.ts +378 -0
- package/src/framework/utils/DateUtils.ts +187 -0
- package/src/framework/utils/DeviceUtils.ts +46 -0
- package/src/framework/utils/DomUtils.ts +50 -0
- package/src/framework/utils/EventBusUtils.ts +144 -0
- package/src/framework/utils/Logger.ts +40 -0
- package/src/framework/utils/MessageUtils.tsx +170 -0
- package/src/framework/utils/ObjectUtils.ts +118 -0
- package/src/framework/utils/StorageUtils.ts +50 -0
- package/src/framework/utils/StringUtils.ts +436 -0
- package/src/framework/utils/TreeUtils.ts +251 -0
- package/src/framework/utils/UrlUtils.ts +152 -0
- package/src/framework/utils/UuidUtils.ts +88 -0
- package/src/framework/utils/ValidateUtils.ts +28 -0
- package/src/framework/utils/index.ts +15 -0
- package/src/framework/utils/system/DictUtils.ts +97 -0
- package/src/framework/utils/system/FormRegistryUtils.ts +77 -0
- package/src/framework/utils/system/HttpUtils.ts +247 -0
- package/src/framework/utils/system/PageUtils.ts +163 -0
- package/src/framework/utils/system/PermUtils.ts +79 -0
- package/src/framework/utils/system/SysUtils.ts +97 -0
- package/src/framework/utils/system/ThemeUtils.ts +27 -0
- package/src/framework/utils/system/index.ts +7 -0
- package/src/framework/views/ViewApproveStatus/index.d.ts +3 -0
- package/src/framework/views/ViewApproveStatus/index.jsx +21 -0
- package/src/framework/views/ViewBoolean/index.d.ts +3 -0
- package/src/framework/views/ViewBoolean/index.jsx +4 -0
- package/src/framework/views/ViewBooleanEnableDisable/index.d.ts +5 -0
- package/src/framework/views/ViewBooleanEnableDisable/index.jsx +15 -0
- package/src/framework/views/ViewFile/index.d.ts +10 -0
- package/src/framework/views/ViewFile/index.jsx +49 -0
- package/src/framework/views/ViewFileButton/index.d.ts +10 -0
- package/src/framework/views/ViewFileButton/index.jsx +22 -0
- package/src/framework/views/ViewImage/index.d.ts +6 -0
- package/src/framework/views/ViewImage/index.jsx +60 -0
- package/src/framework/views/ViewPassword/index.d.ts +5 -0
- package/src/framework/views/ViewPassword/index.jsx +24 -0
- package/src/framework/views/ViewProcessInstanceProgress/index.d.ts +12 -0
- package/src/framework/views/ViewProcessInstanceProgress/index.jsx +97 -0
- package/src/framework/views/ViewProcessInstanceProgressButton/index.d.ts +6 -0
- package/src/framework/views/ViewProcessInstanceProgressButton/index.jsx +24 -0
- package/src/framework/views/ViewText/index.d.ts +16 -0
- package/src/framework/views/ViewText/index.jsx +42 -0
- package/src/framework/views/index.ts +12 -0
- package/src/framework/views/types.ts +26 -0
- package/src/index.ts +2 -0
- package/src/layouts/PageRender.d.ts +22 -0
- package/src/layouts/PageRender.jsx +90 -0
- package/src/layouts/admin/HeaderRight.jsx +104 -0
- package/src/layouts/admin/TabPageRender.jsx +158 -0
- package/src/layouts/admin/index.jsx +159 -0
- package/src/layouts/admin/index.less +65 -0
- package/src/layouts/index.jsx +187 -0
- package/src/layouts/index.less +24 -0
- package/src/loading.jsx +18 -0
- package/src/pages/404.jsx +13 -0
- package/src/pages/about.jsx +12 -0
- package/src/pages/index.jsx +10 -0
- package/src/pages/login.jsx +16 -0
- package/src/pages/system/api/ApiDoc.jsx +148 -0
- package/src/pages/system/api/index.jsx +267 -0
- package/src/pages/system/api/perm.jsx +69 -0
- package/src/pages/system/dict/Dict.jsx +67 -0
- package/src/pages/system/dict/DictItem.jsx +175 -0
- package/src/pages/system/dict/index.jsx +25 -0
- package/src/pages/system/file/index.jsx +147 -0
- package/src/pages/system/job/index.jsx +324 -0
- package/src/pages/system/log/index.jsx +77 -0
- package/src/pages/system/org/index.jsx +260 -0
- package/src/pages/system/role/index.jsx +302 -0
- package/src/pages/system/role/perm.jsx +107 -0
- package/src/pages/system/sysManual/index.jsx +126 -0
- package/src/pages/system/user/UserPerm.jsx +94 -0
- package/src/pages/system/user/index.jsx +253 -0
- package/src/pages/test/views.jsx +95 -0
- package/src/pages/ureport/index.jsx +16 -0
- package/src/pages/userCenter/ChangePassword.jsx +64 -0
- package/src/pages/userCenter/index.jsx +90 -0
- package/src/pages/userCenter/manual.jsx +57 -0
- package/src/pages/userCenter/message.jsx +103 -0
- package/src/style/global.less +51 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SelectProps } from "antd/es/select";
|
|
3
|
+
import { FieldProps } from '../types';
|
|
4
|
+
|
|
5
|
+
interface FieldRemoteSelectProps extends Omit<SelectProps, 'value' | 'onChange'>, FieldProps<any> {
|
|
6
|
+
/**
|
|
7
|
+
* 请求地址
|
|
8
|
+
*/
|
|
9
|
+
url: string;
|
|
10
|
+
/**
|
|
11
|
+
* 防抖时间(毫秒)
|
|
12
|
+
*/
|
|
13
|
+
debounceTime?: number;
|
|
14
|
+
/**
|
|
15
|
+
* 请求参数处理函数
|
|
16
|
+
*/
|
|
17
|
+
paramsProcessor?: (params: any) => any;
|
|
18
|
+
/**
|
|
19
|
+
* 响应数据处理函数
|
|
20
|
+
*/
|
|
21
|
+
dataProcessor?: (data: any) => any;
|
|
22
|
+
/**
|
|
23
|
+
* 缓存大小
|
|
24
|
+
*/
|
|
25
|
+
cacheSize?: number;
|
|
26
|
+
/**
|
|
27
|
+
* 初始加载
|
|
28
|
+
*/
|
|
29
|
+
initialLoad?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* 搜索时是否清空已选项
|
|
32
|
+
*/
|
|
33
|
+
clearOnSearch?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* 请求失败回调
|
|
36
|
+
*/
|
|
37
|
+
onError?: (error: any) => void;
|
|
38
|
+
/**
|
|
39
|
+
* 加载完成回调
|
|
40
|
+
*/
|
|
41
|
+
onLoad?: (data: any) => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const FieldRemoteSelect: React.FC<FieldRemoteSelectProps>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
|
2
|
+
import { Select, Spin, message } from 'antd';
|
|
3
|
+
import { debounce } from 'lodash';
|
|
4
|
+
import { HttpUtils } from "../../utils";
|
|
5
|
+
|
|
6
|
+
export const FieldRemoteSelect = ({
|
|
7
|
+
url,
|
|
8
|
+
debounceTime = 500,
|
|
9
|
+
paramsProcessor,
|
|
10
|
+
dataProcessor,
|
|
11
|
+
cacheSize = 10,
|
|
12
|
+
initialLoad = true,
|
|
13
|
+
clearOnSearch = false,
|
|
14
|
+
onError,
|
|
15
|
+
onLoad,
|
|
16
|
+
value,
|
|
17
|
+
...rest
|
|
18
|
+
}) => {
|
|
19
|
+
const [options, setOptions] = useState([]);
|
|
20
|
+
const [loading, setLoading] = useState(false);
|
|
21
|
+
const [cache, setCache] = useState(new Map());
|
|
22
|
+
const fetchIdRef = useRef(0);
|
|
23
|
+
const searchHistoryRef = useRef([]);
|
|
24
|
+
|
|
25
|
+
const loadData = useCallback(async (searchText = '') => {
|
|
26
|
+
const fetchId = ++fetchIdRef.current;
|
|
27
|
+
const cacheKey = searchText || '_initial_';
|
|
28
|
+
|
|
29
|
+
// 检查缓存
|
|
30
|
+
if (cache.has(cacheKey)) {
|
|
31
|
+
const cachedData = cache.get(cacheKey);
|
|
32
|
+
setOptions(cachedData || []);
|
|
33
|
+
onLoad?.(cachedData);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
setLoading(true);
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
let params = { searchText, selected: value };
|
|
41
|
+
if (paramsProcessor) {
|
|
42
|
+
params = paramsProcessor(params);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const data = await HttpUtils.get(url, params);
|
|
46
|
+
const processedData = dataProcessor ? dataProcessor(data) : data;
|
|
47
|
+
|
|
48
|
+
if (fetchId === fetchIdRef.current) {
|
|
49
|
+
setOptions(processedData || []);
|
|
50
|
+
|
|
51
|
+
// 更新缓存
|
|
52
|
+
setCache(prevCache => {
|
|
53
|
+
const newCache = new Map(prevCache);
|
|
54
|
+
newCache.set(cacheKey, processedData || []);
|
|
55
|
+
|
|
56
|
+
// 限制缓存大小
|
|
57
|
+
if (newCache.size > cacheSize) {
|
|
58
|
+
const firstKey = newCache.keys().next().value;
|
|
59
|
+
newCache.delete(firstKey);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return newCache;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
onLoad?.(processedData);
|
|
66
|
+
}
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error('远程搜索失败:', error);
|
|
69
|
+
message.error('搜索失败,请重试');
|
|
70
|
+
setOptions([]);
|
|
71
|
+
onError?.(error);
|
|
72
|
+
} finally {
|
|
73
|
+
if (fetchId === fetchIdRef.current) {
|
|
74
|
+
setLoading(false);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}, [url, value, paramsProcessor, dataProcessor, cache, cacheSize, onError, onLoad]);
|
|
78
|
+
|
|
79
|
+
// 使用 useMemo 缓存 debounce 函数
|
|
80
|
+
const debouncedLoadData = useCallback(
|
|
81
|
+
debounce((value) => loadData(value), debounceTime),
|
|
82
|
+
[loadData, debounceTime]
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (initialLoad) {
|
|
87
|
+
loadData();
|
|
88
|
+
}
|
|
89
|
+
}, [initialLoad, loadData]);
|
|
90
|
+
|
|
91
|
+
const handleSearch = useCallback((searchValue) => {
|
|
92
|
+
const trimmedValue = searchValue.trim();
|
|
93
|
+
|
|
94
|
+
// 记录搜索历史
|
|
95
|
+
if (trimmedValue && !searchHistoryRef.current.includes(trimmedValue)) {
|
|
96
|
+
searchHistoryRef.current = [trimmedValue, ...searchHistoryRef.current].slice(0, 5);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (trimmedValue === '') {
|
|
100
|
+
setOptions([]);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
debouncedLoadData(trimmedValue);
|
|
105
|
+
}, [debouncedLoadData]);
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<Select
|
|
109
|
+
showSearch={{
|
|
110
|
+
filterOption: false,
|
|
111
|
+
onSearch: handleSearch,
|
|
112
|
+
}}
|
|
113
|
+
options={options}
|
|
114
|
+
notFoundContent={loading ? <Spin size="small" /> : '数据为空'}
|
|
115
|
+
style={{ width: '100%', minWidth: 200 }}
|
|
116
|
+
allowClear
|
|
117
|
+
loading={loading}
|
|
118
|
+
{...rest}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
FieldRemoteSelect.defaultProps = {
|
|
124
|
+
placeholder: '请搜索选择'
|
|
125
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {SelectProps} from "antd/es/select";
|
|
3
|
+
|
|
4
|
+
interface FieldRemoteSelectMultipleProps extends Omit<SelectProps, 'options' | 'children'| 'mode' | 'value' | 'onChange'> {
|
|
5
|
+
/**
|
|
6
|
+
* 请求地址
|
|
7
|
+
*/
|
|
8
|
+
url: string;
|
|
9
|
+
/**
|
|
10
|
+
* 选中的值
|
|
11
|
+
*/
|
|
12
|
+
value?: any[];
|
|
13
|
+
/**
|
|
14
|
+
* 值变化回调
|
|
15
|
+
*/
|
|
16
|
+
onChange?: (value: any[]) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class FieldRemoteSelectMultiple extends React.Component<FieldRemoteSelectMultipleProps, any> {
|
|
20
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Select, Spin, message} from 'antd';
|
|
3
|
+
import {debounce} from 'lodash';
|
|
4
|
+
import {HttpUtils} from "../../utils";
|
|
5
|
+
|
|
6
|
+
export class FieldRemoteSelectMultiple extends React.Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
|
|
10
|
+
this.fetchIdRef = 0;
|
|
11
|
+
this.state = {
|
|
12
|
+
options: [],
|
|
13
|
+
loading: false,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
this.loadDataDebounce = debounce(this.loadData, 800);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static defaultProps = {
|
|
20
|
+
placeholder: '请搜索选择'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
componentDidMount() {
|
|
24
|
+
this.loadData('');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
componentWillUnmount() {
|
|
28
|
+
this.loadDataDebounce.cancel();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
loadData = async (searchText) => {
|
|
32
|
+
const {url, value} = this.props;
|
|
33
|
+
const fetchId = ++this.fetchIdRef;
|
|
34
|
+
|
|
35
|
+
this.setState({loading: true});
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const data = await HttpUtils.get(url, {searchText, selected: value});
|
|
39
|
+
|
|
40
|
+
if (fetchId === this.fetchIdRef) {
|
|
41
|
+
this.setState({options: data || []});
|
|
42
|
+
}
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error('远程搜索失败:', error);
|
|
45
|
+
message.error('搜索失败,请重试');
|
|
46
|
+
this.setState({options: []});
|
|
47
|
+
} finally {
|
|
48
|
+
if (fetchId === this.fetchIdRef) {
|
|
49
|
+
this.setState({loading: false});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
handleSearch = (value) => {
|
|
55
|
+
if (value.trim() === '') {
|
|
56
|
+
this.setState({options: []});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this.loadDataDebounce(value.trim());
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
render() {
|
|
63
|
+
const {options, loading} = this.state;
|
|
64
|
+
const {value, onChange, url, ...selectProps} = this.props;
|
|
65
|
+
return (
|
|
66
|
+
<Select
|
|
67
|
+
showSearch={
|
|
68
|
+
{
|
|
69
|
+
filterOption: false,
|
|
70
|
+
onSearch: this.handleSearch,
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
value={value}
|
|
74
|
+
onChange={onChange}
|
|
75
|
+
options={options}
|
|
76
|
+
notFoundContent={loading ? <Spin size="small"/> : '数据为空'}
|
|
77
|
+
style={{width: '100%', minWidth: 200}}
|
|
78
|
+
allowClear
|
|
79
|
+
mode='multiple'
|
|
80
|
+
{...selectProps}
|
|
81
|
+
>
|
|
82
|
+
</Select>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {SelectProps} from "antd/es/select";
|
|
3
|
+
import { FieldProps } from '../types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 多选,但是值是字符串,逗号破解的
|
|
7
|
+
*/
|
|
8
|
+
export interface FieldRemoteSelectMultipleInlineProps extends Omit<SelectProps, 'options' | 'children'| 'mode' | 'value' | 'onChange'>, FieldProps<string> {
|
|
9
|
+
/**
|
|
10
|
+
* 请求地址
|
|
11
|
+
*/
|
|
12
|
+
url: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 默认展开所有
|
|
16
|
+
*/
|
|
17
|
+
treeDefaultExpandAll?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class FieldRemoteSelectMultipleInline extends React.Component<FieldRemoteSelectMultipleInlineProps, any> {
|
|
21
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Select, Spin, message} from 'antd';
|
|
3
|
+
import {debounce} from 'lodash';
|
|
4
|
+
import {HttpUtils, StringUtils} from "../../utils";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 多选,但是值是字符串,逗号破解的
|
|
8
|
+
*/
|
|
9
|
+
export class FieldRemoteSelectMultipleInline extends React.Component {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props);
|
|
12
|
+
|
|
13
|
+
this.fetchIdRef = 0;
|
|
14
|
+
this.state = {
|
|
15
|
+
options: [],
|
|
16
|
+
loading: false,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
this.loadDataDebounce = debounce(this.loadData, 800);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static defaultProps = {
|
|
23
|
+
placeholder: '请搜索选择'
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
componentDidMount() {
|
|
27
|
+
this.loadData('');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
componentWillUnmount() {
|
|
31
|
+
this.loadDataDebounce.cancel();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
loadData = async (searchText) => {
|
|
35
|
+
const {url, value} = this.props;
|
|
36
|
+
const fetchId = ++this.fetchIdRef;
|
|
37
|
+
|
|
38
|
+
this.setState({loading: true});
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const data = await HttpUtils.get(url, {searchText, selected: value});
|
|
42
|
+
|
|
43
|
+
if (fetchId === this.fetchIdRef) {
|
|
44
|
+
this.setState({options: data || []});
|
|
45
|
+
}
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error('远程搜索失败:', error);
|
|
48
|
+
message.error('搜索失败,请重试');
|
|
49
|
+
this.setState({options: []});
|
|
50
|
+
} finally {
|
|
51
|
+
if (fetchId === this.fetchIdRef) {
|
|
52
|
+
this.setState({loading: false});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
handleSearch = (value) => {
|
|
58
|
+
if (value.trim() === '') {
|
|
59
|
+
this.setState({options: []});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
this.loadDataDebounce(value.trim());
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
render() {
|
|
66
|
+
const {options, loading} = this.state;
|
|
67
|
+
const {value, onChange, url, ...selectProps} = this.props;
|
|
68
|
+
return (
|
|
69
|
+
<Select
|
|
70
|
+
showSearch={
|
|
71
|
+
{
|
|
72
|
+
filterOption: false,
|
|
73
|
+
onSearch: this.handleSearch,
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
value={StringUtils.split(value, ',')}
|
|
77
|
+
onChange={arr => onChange && onChange(StringUtils.join(arr, ','))}
|
|
78
|
+
options={options}
|
|
79
|
+
notFoundContent={loading ? <Spin size="small"/> : '数据为空'}
|
|
80
|
+
style={{width: '100%', minWidth: 200}}
|
|
81
|
+
allowClear
|
|
82
|
+
mode='multiple'
|
|
83
|
+
{...selectProps}
|
|
84
|
+
>
|
|
85
|
+
</Select>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {TreeProps} from "antd";
|
|
3
|
+
import { FieldProps } from '../types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 多选树
|
|
7
|
+
*
|
|
8
|
+
* 区别于下拉框,是扁平展示的树
|
|
9
|
+
* 这种需要扁平展示的树,通常都是多选。
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
interface FieldRemoteTreeProps extends Omit<TreeProps, 'treeData' | 'checkedKeys' | 'onCheck' | 'multiple' | 'checkable' | 'defaultExpandAll' | 'checkStrictly'>, FieldProps<string[]> {
|
|
13
|
+
/**
|
|
14
|
+
* 请求地址
|
|
15
|
+
*/
|
|
16
|
+
url: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class FieldRemoteTree extends React.Component<FieldRemoteTreeProps, string> {
|
|
20
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {Spin, Tree} from "antd";
|
|
3
|
+
import {HttpUtils} from "../../utils";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 多选树
|
|
7
|
+
*
|
|
8
|
+
* 区别于下拉框,是扁平展示的树
|
|
9
|
+
* 这种需要扁平展示的树,通常都是多选。
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export class FieldRemoteTree extends React.Component {
|
|
13
|
+
state = {
|
|
14
|
+
treeLoading: true,
|
|
15
|
+
treeData: [],
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
componentDidMount() {
|
|
19
|
+
this.loadData();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
loadData = async () => {
|
|
23
|
+
this.setState({treeLoading: true});
|
|
24
|
+
const {url} = this.props;
|
|
25
|
+
try {
|
|
26
|
+
const treeData = await HttpUtils.get(url);
|
|
27
|
+
this.setState({treeData});
|
|
28
|
+
} catch (e) {
|
|
29
|
+
console.log(e);
|
|
30
|
+
} finally {
|
|
31
|
+
this.setState({treeLoading: false});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
render() {
|
|
36
|
+
if (this.state.treeLoading) {
|
|
37
|
+
return <Spin/>;
|
|
38
|
+
}
|
|
39
|
+
return <Tree
|
|
40
|
+
multiple
|
|
41
|
+
checkable
|
|
42
|
+
onCheck={e => this.props.onChange && this.props.onChange(e.checked)}
|
|
43
|
+
checkedKeys={this.props.value}
|
|
44
|
+
treeData={this.state.treeData}
|
|
45
|
+
defaultExpandAll
|
|
46
|
+
checkStrictly
|
|
47
|
+
>
|
|
48
|
+
</Tree>;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FieldProps } from '../types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 远程树级联选择器, 类似select,但是树级联
|
|
6
|
+
*
|
|
7
|
+
* 注意,value为非数组形式,区别于cascader组件
|
|
8
|
+
*/
|
|
9
|
+
interface FieldRemoteTreeCascaderProps extends FieldProps<string> {
|
|
10
|
+
/**
|
|
11
|
+
* 请求地址
|
|
12
|
+
* 要求返回数据格式为:tree
|
|
13
|
+
*/
|
|
14
|
+
url: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class FieldRemoteTreeCascader extends React.Component<FieldRemoteTreeCascaderProps, any> {
|
|
18
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {Cascader, message, Spin} from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {HttpUtils, TreeUtils} from "../../utils";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 远程树级联选择器, 类似select,但是树级联
|
|
7
|
+
*
|
|
8
|
+
* 注意,value为非数组形式,区别于cascader组件
|
|
9
|
+
*/
|
|
10
|
+
export class FieldRemoteTreeCascader extends React.Component {
|
|
11
|
+
state = {
|
|
12
|
+
data: [],
|
|
13
|
+
loading: false,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
componentDidMount() {
|
|
17
|
+
this.loadData();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
loadData = async () => {
|
|
21
|
+
const {url} = this.props;
|
|
22
|
+
this.setState({loading: true});
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const list = await HttpUtils.get(url);
|
|
26
|
+
this.setState({data: list});
|
|
27
|
+
} catch (e) {
|
|
28
|
+
console.log(e);
|
|
29
|
+
} finally {
|
|
30
|
+
this.setState({loading: false});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
render() {
|
|
36
|
+
const {data} = this.state;
|
|
37
|
+
if (this.state.loading) {
|
|
38
|
+
return <Spin/>;
|
|
39
|
+
}
|
|
40
|
+
const {value, onChange, ...rest} = this.props;
|
|
41
|
+
|
|
42
|
+
let arr = [];
|
|
43
|
+
if (value != null) {
|
|
44
|
+
arr = TreeUtils.getKeyList(data, value);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Cascader
|
|
49
|
+
options={this.state.data}
|
|
50
|
+
onChange={arr => {
|
|
51
|
+
onChange && onChange(arr[arr.length - 1]);
|
|
52
|
+
}}
|
|
53
|
+
value={arr}
|
|
54
|
+
fieldNames={{label: 'title', value: 'key'}}
|
|
55
|
+
{...rest}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FieldProps } from '../types';
|
|
3
|
+
|
|
4
|
+
interface FieldRemoteTreeSelectProps extends FieldProps<string | number> {
|
|
5
|
+
/**
|
|
6
|
+
* 请求地址
|
|
7
|
+
*/
|
|
8
|
+
url: string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 默认展开所有
|
|
12
|
+
*/
|
|
13
|
+
treeDefaultExpandAll?: boolean;
|
|
14
|
+
|
|
15
|
+
id?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class FieldRemoteTreeSelect extends React.Component<FieldRemoteTreeSelectProps, any> {
|
|
19
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {Spin, TreeSelect} from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {HttpUtils, StringUtils} from "../../utils";
|
|
4
|
+
|
|
5
|
+
export class FieldRemoteTreeSelect extends React.Component {
|
|
6
|
+
static defaultProps = {
|
|
7
|
+
treeDefaultExpandAll: true,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
state = {
|
|
11
|
+
data: [],
|
|
12
|
+
loading: false,
|
|
13
|
+
key: this.props.id,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
componentDidMount() {
|
|
17
|
+
this.loadData();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
loadData = async () => {
|
|
21
|
+
const {url} = this.props;
|
|
22
|
+
this.setState({loading: true});
|
|
23
|
+
try {
|
|
24
|
+
const rs = await HttpUtils.get(url);
|
|
25
|
+
this.setState({data: rs});
|
|
26
|
+
} finally {
|
|
27
|
+
this.setState({loading: false});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
render() {
|
|
32
|
+
const {value, onChange, treeDefaultExpandAll} = this.props;
|
|
33
|
+
const {data, loading} = this.state;
|
|
34
|
+
|
|
35
|
+
if (loading) {
|
|
36
|
+
return <Spin/>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<TreeSelect
|
|
41
|
+
style={{width: '100%', minWidth: 200}}
|
|
42
|
+
allowClear={true}
|
|
43
|
+
dropdownStyle={{maxHeight: 400, overflow: 'auto'}}
|
|
44
|
+
treeData={data}
|
|
45
|
+
showCheckedStrategy={TreeSelect.SHOW_ALL}
|
|
46
|
+
value={value || undefined}
|
|
47
|
+
onChange={onChange}
|
|
48
|
+
filterTreeNode={(inputValue, treeNode) => {
|
|
49
|
+
const {title} = treeNode;
|
|
50
|
+
return StringUtils.contains(title, inputValue);
|
|
51
|
+
}}
|
|
52
|
+
treeLine={{showLeafIcon: true}}
|
|
53
|
+
treeDefaultExpandAll={treeDefaultExpandAll}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FieldProps } from '../types';
|
|
3
|
+
|
|
4
|
+
interface FieldRemoteTreeSelectMultipleProps extends FieldProps<(string | number)[]> {
|
|
5
|
+
/**
|
|
6
|
+
* 请求地址
|
|
7
|
+
*/
|
|
8
|
+
url: string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 默认展开所有
|
|
12
|
+
*/
|
|
13
|
+
treeDefaultExpandAll?: boolean;
|
|
14
|
+
|
|
15
|
+
id?: string;
|
|
16
|
+
style?: React.CSSProperties;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class FieldRemoteTreeSelectMultiple extends React.Component<FieldRemoteTreeSelectMultipleProps, any> {
|
|
20
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {Spin, TreeSelect} from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {HttpUtils, StringUtils} from "../../utils";
|
|
4
|
+
|
|
5
|
+
export class FieldRemoteTreeSelectMultiple extends React.Component {
|
|
6
|
+
static defaultProps = {
|
|
7
|
+
treeDefaultExpandAll: true,
|
|
8
|
+
style: {
|
|
9
|
+
width: '100%',
|
|
10
|
+
minWidth: 200,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
state = {
|
|
15
|
+
data: [],
|
|
16
|
+
loading: false,
|
|
17
|
+
key: this.props.id,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
componentDidMount() {
|
|
21
|
+
this.loadData();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
loadData = async () => {
|
|
25
|
+
const {url} = this.props;
|
|
26
|
+
this.setState({loading: true});
|
|
27
|
+
try {
|
|
28
|
+
const rs = await HttpUtils.get(url);
|
|
29
|
+
this.setState({data: rs});
|
|
30
|
+
} finally {
|
|
31
|
+
this.setState({loading: false});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
render() {
|
|
36
|
+
const {value, onChange, style, treeDefaultExpandAll} = this.props;
|
|
37
|
+
const {data, loading} = this.state;
|
|
38
|
+
|
|
39
|
+
if (loading) {
|
|
40
|
+
return <Spin/>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<TreeSelect
|
|
45
|
+
style={style}
|
|
46
|
+
allowClear={true}
|
|
47
|
+
dropdownStyle={{maxHeight: 400, overflow: 'auto'}}
|
|
48
|
+
treeData={data}
|
|
49
|
+
showCheckedStrategy={TreeSelect.SHOW_ALL}
|
|
50
|
+
value={value || undefined}
|
|
51
|
+
onChange={onChange}
|
|
52
|
+
multiple={true}
|
|
53
|
+
filterTreeNode={(inputValue, treeNode) => {
|
|
54
|
+
const {title} = treeNode;
|
|
55
|
+
return StringUtils.contains(title, inputValue);
|
|
56
|
+
}}
|
|
57
|
+
treeLine={{showLeafIcon: true}}
|
|
58
|
+
treeDefaultExpandAll={treeDefaultExpandAll}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|