@hw-component/form 1.6.1 → 1.6.3
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/.eslintcache +1 -1
- package/es/Select/hooks/changeHooks.js +10 -6
- package/es/Select/hooks/norHooks.d.ts +6 -4
- package/es/Select/hooks/norHooks.js +137 -29
- package/es/Select/index.js +17 -12
- package/es/Select/modal.d.ts +11 -2
- package/lib/Select/hooks/changeHooks.js +10 -6
- package/lib/Select/hooks/norHooks.d.ts +6 -4
- package/lib/Select/hooks/norHooks.js +136 -28
- package/lib/Select/index.js +16 -11
- package/lib/Select/modal.d.ts +11 -2
- package/package.json +1 -1
- package/src/components/DialogForm/DrawerForm/index.tsx +1 -1
- package/src/components/DialogForm/ModalForm.tsx +1 -1
- package/src/components/Form/hooks/useDefaultRender.tsx +1 -1
- package/src/components/Form/hooks/useHForm.ts +1 -1
- package/src/components/Form/index.tsx +4 -4
- package/src/components/Input/ButtonInput.tsx +2 -2
- package/src/components/Select/hooks/changeHooks.tsx +9 -6
- package/src/components/Select/hooks/norHooks.ts +107 -17
- package/src/components/Select/index.tsx +7 -2
- package/src/components/Select/modal.ts +14 -2
- package/src/components/Submit/components.tsx +7 -3
- package/src/components/Upload/hooks/customRequest.ts +6 -6
- package/src/pages/DrawerForm/index.tsx +18 -1
- package/src/pages/Form/index.tsx +21 -18
- package/src/pages/Select/index.tsx +23 -1
- package/src/pages/Upload/index.tsx +16 -13
package/lib/Select/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var AllSelect = require('./components/AllSelect.js');
|
|
|
23
23
|
var index = require('../hooks/index.js');
|
|
24
24
|
var HFormConnect = require('../Form/HFormConnect.js');
|
|
25
25
|
|
|
26
|
-
var _excluded = ["style", "mode", "options", "modeConfig", "value", "onChange", "fieldNames", "request", "manual", "optionLabelProp", "filterProvider", "optionFilterProp", "serviceSearch", "onSearch", "filterOption", "showSearch", "labelInValue", "noMatchItemRender", "allSelect", "addDispatchListener", "addFormat", "dispatch"],
|
|
26
|
+
var _excluded = ["style", "mode", "options", "modeConfig", "value", "onChange", "fieldNames", "request", "manual", "optionLabelProp", "filterProvider", "optionFilterProp", "serviceSearch", "onSearch", "filterOption", "showSearch", "labelInValue", "noMatchItemRender", "allSelect", "addDispatchListener", "addFormat", "dispatch", "isList", "onPopupScroll"],
|
|
27
27
|
_excluded2 = ["value", "label"];
|
|
28
28
|
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; }
|
|
29
29
|
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; }
|
|
@@ -58,6 +58,8 @@ var Index = function Index(_ref) {
|
|
|
58
58
|
addDispatchListener = _ref.addDispatchListener;
|
|
59
59
|
_ref.addFormat;
|
|
60
60
|
var dispatch = _ref.dispatch,
|
|
61
|
+
isList = _ref.isList,
|
|
62
|
+
propsOnPopupScroll = _ref.onPopupScroll,
|
|
61
63
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
62
64
|
var _ref2 = (modeConfig === null || modeConfig === void 0 ? void 0 : modeConfig[mode || ""]) || {},
|
|
63
65
|
icon = _ref2.icon,
|
|
@@ -70,7 +72,7 @@ var Index = function Index(_ref) {
|
|
|
70
72
|
filterOption: filterOption,
|
|
71
73
|
serviceSearch: serviceSearch
|
|
72
74
|
});
|
|
73
|
-
var
|
|
75
|
+
var _useSelectReq = norHooks.useSelectReq({
|
|
74
76
|
options: options,
|
|
75
77
|
manual: manual,
|
|
76
78
|
fieldNames: fieldNames,
|
|
@@ -78,15 +80,17 @@ var Index = function Index(_ref) {
|
|
|
78
80
|
serviceSearch: serviceSearch,
|
|
79
81
|
showSearch: showSearch,
|
|
80
82
|
onSearch: propsOnSearch,
|
|
81
|
-
dispatch: dispatch
|
|
83
|
+
dispatch: dispatch,
|
|
84
|
+
isList: isList
|
|
82
85
|
}),
|
|
83
|
-
run =
|
|
84
|
-
loading =
|
|
85
|
-
resultData =
|
|
86
|
-
error =
|
|
87
|
-
onSearch =
|
|
88
|
-
mathShowSearch =
|
|
89
|
-
reload =
|
|
86
|
+
run = _useSelectReq.run,
|
|
87
|
+
loading = _useSelectReq.loading,
|
|
88
|
+
resultData = _useSelectReq.data,
|
|
89
|
+
error = _useSelectReq.error,
|
|
90
|
+
onSearch = _useSelectReq.onSearch,
|
|
91
|
+
mathShowSearch = _useSelectReq.mathShowSearch,
|
|
92
|
+
reload = _useSelectReq.reload,
|
|
93
|
+
onPopupScroll = _useSelectReq.onPopupScroll;
|
|
90
94
|
var data = index.useChangeOptions({
|
|
91
95
|
options: resultData,
|
|
92
96
|
fieldNames: fieldNames
|
|
@@ -132,7 +136,8 @@ var Index = function Index(_ref) {
|
|
|
132
136
|
optionFilterProp: optionFilterProp,
|
|
133
137
|
filterOption: selfFilterOption,
|
|
134
138
|
showSearch: mathShowSearch,
|
|
135
|
-
labelInValue: true
|
|
139
|
+
labelInValue: true,
|
|
140
|
+
onPopupScroll: propsOnPopupScroll || onPopupScroll
|
|
136
141
|
}, props), {}, {
|
|
137
142
|
children: data === null || data === void 0 ? void 0 : data.map(function (item) {
|
|
138
143
|
var optionValue = item.value,
|
package/lib/Select/modal.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type React from "react";
|
|
|
3
3
|
import type { PromiseFnResult } from "../modal";
|
|
4
4
|
import type { addFormatItemModal, argsFn, DispatchModal } from "../Form/modal";
|
|
5
5
|
export type OptionType = Record<string, any>;
|
|
6
|
-
export type PartialHSelectProps = Partial<HSelectProps>;
|
|
7
6
|
export type RenderFn = (data: OptionType) => React.ReactNode;
|
|
8
7
|
interface ModeConfigItem {
|
|
9
8
|
icon?: React.ReactNode | null;
|
|
@@ -14,9 +13,17 @@ export interface ModeConfig {
|
|
|
14
13
|
tags?: ModeConfigItem;
|
|
15
14
|
}
|
|
16
15
|
type FilterProviderFn = (item: any) => string;
|
|
16
|
+
type OptionsListType = OptionType[];
|
|
17
|
+
export interface OptionsPageResultModal {
|
|
18
|
+
page: number;
|
|
19
|
+
size: number;
|
|
20
|
+
data: OptionsListType;
|
|
21
|
+
total: number;
|
|
22
|
+
}
|
|
23
|
+
export type OptionsDataType = OptionsListType | OptionsPageResultModal;
|
|
17
24
|
export interface HSelectProps extends Omit<SelectProps, "options" | "placeholder"> {
|
|
18
25
|
style?: React.CSSProperties;
|
|
19
|
-
request?: PromiseFnResult<any,
|
|
26
|
+
request?: PromiseFnResult<any, OptionsDataType>;
|
|
20
27
|
manual?: boolean;
|
|
21
28
|
modeConfig?: ModeConfig;
|
|
22
29
|
filterProvider?: FilterProviderFn | string;
|
|
@@ -28,9 +35,11 @@ export interface HSelectProps extends Omit<SelectProps, "options" | "placeholder
|
|
|
28
35
|
addFormat?: (format: Record<string, addFormatItemModal>) => void;
|
|
29
36
|
placeholder?: string;
|
|
30
37
|
dispatch?: DispatchModal;
|
|
38
|
+
isList?: boolean;
|
|
31
39
|
}
|
|
32
40
|
export interface FilterDataModal {
|
|
33
41
|
value: any;
|
|
34
42
|
index: number;
|
|
35
43
|
}
|
|
44
|
+
export type PartialHSelectProps = Partial<HSelectProps>;
|
|
36
45
|
export {};
|
package/package.json
CHANGED
|
@@ -104,7 +104,7 @@ export default ({
|
|
|
104
104
|
footer={footerComponent()}
|
|
105
105
|
>
|
|
106
106
|
<FormConfigProvider {...providerConfig}>
|
|
107
|
-
{contentRender ? contentRender(node, currentForm,params) : node}
|
|
107
|
+
{contentRender ? contentRender(node, currentForm, params) : node}
|
|
108
108
|
</FormConfigProvider>
|
|
109
109
|
</Drawer>
|
|
110
110
|
);
|
|
@@ -98,7 +98,7 @@ export default ({
|
|
|
98
98
|
footer={defaultFooter}
|
|
99
99
|
>
|
|
100
100
|
<FormConfigProvider {...providerConfig}>
|
|
101
|
-
{contentRender ? contentRender?.(node, currentForm,formParams) : node}
|
|
101
|
+
{contentRender ? contentRender?.(node, currentForm, formParams) : node}
|
|
102
102
|
</FormConfigProvider>
|
|
103
103
|
</Modal>
|
|
104
104
|
);
|
|
@@ -30,7 +30,7 @@ export const useDefaultRender = (
|
|
|
30
30
|
Component = (dom as ConfigComponentModal).Component;
|
|
31
31
|
}
|
|
32
32
|
const node = Component && (
|
|
33
|
-
<Component {...componentProps} {...itemProps} form={form}/>
|
|
33
|
+
<Component {...componentProps} {...itemProps} form={form} />
|
|
34
34
|
);
|
|
35
35
|
if (render) {
|
|
36
36
|
const resultNode = render(props, node, form);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Form, Input, Row} from "antd";
|
|
1
|
+
import { Form, Input, Row } from "antd";
|
|
2
2
|
import type { HFormProps, HItemProps } from "./modal";
|
|
3
3
|
import Item from "./FormItem";
|
|
4
4
|
import { useCurrentForm, useInfoReq, useValuesChange } from "./hooks";
|
|
@@ -62,9 +62,9 @@ export default ({
|
|
|
62
62
|
hForm.removeDispatchListener();
|
|
63
63
|
};
|
|
64
64
|
}, []);
|
|
65
|
-
const defaultOnPressEnter=()=>{
|
|
65
|
+
const defaultOnPressEnter = () => {
|
|
66
66
|
hForm.submit();
|
|
67
|
-
}
|
|
67
|
+
};
|
|
68
68
|
return (
|
|
69
69
|
<PageHandler
|
|
70
70
|
loading={infoLoading}
|
|
@@ -93,7 +93,7 @@ export default ({
|
|
|
93
93
|
colon: itemColon,
|
|
94
94
|
} = itemData;
|
|
95
95
|
const defaultItemProps = {
|
|
96
|
-
onPressEnter:defaultOnPressEnter,
|
|
96
|
+
onPressEnter: defaultOnPressEnter,
|
|
97
97
|
...formItemProps,
|
|
98
98
|
...itemProps,
|
|
99
99
|
};
|
|
@@ -14,7 +14,7 @@ const Index: React.FC<HButtonInputProps> = ({
|
|
|
14
14
|
const {
|
|
15
15
|
onClick,
|
|
16
16
|
type = "primary",
|
|
17
|
-
|
|
17
|
+
ghost = true,
|
|
18
18
|
loading: btnLoading,
|
|
19
19
|
...oProps
|
|
20
20
|
} = buttonProps;
|
|
@@ -42,7 +42,7 @@ const Index: React.FC<HButtonInputProps> = ({
|
|
|
42
42
|
type={type}
|
|
43
43
|
onClick={click}
|
|
44
44
|
loading={loading || btnLoading}
|
|
45
|
-
style={{ marginLeft: 8,borderRadius:4 }}
|
|
45
|
+
style={{ marginLeft: 8, borderRadius: 4 }}
|
|
46
46
|
ghost={ghost}
|
|
47
47
|
{...oProps}
|
|
48
48
|
>
|
|
@@ -97,9 +97,12 @@ const tag = ({ options, value }: PartialHSelectProps, oldVal?: any[]) => {
|
|
|
97
97
|
return resultProvider(newData, oldData, value);
|
|
98
98
|
}; //tags模式
|
|
99
99
|
const matchNotFind = (
|
|
100
|
-
{ options, value, mode, noMatchItemRender }: PartialHSelectProps,
|
|
100
|
+
{ options, value, mode, noMatchItemRender ,labelInValue}: PartialHSelectProps,
|
|
101
101
|
oldVale?: OptionType[]
|
|
102
102
|
) => {
|
|
103
|
+
if (labelInValue){
|
|
104
|
+
return value;
|
|
105
|
+
}
|
|
103
106
|
if (!mode) {
|
|
104
107
|
return single({ options, value, noMatchItemRender });
|
|
105
108
|
}
|
|
@@ -142,20 +145,20 @@ export const useValueChange = (params: PartialHSelectProps) => {
|
|
|
142
145
|
onChange(newChangeVal, subItemOps);
|
|
143
146
|
};
|
|
144
147
|
useEffect(() => {
|
|
145
|
-
if (mode === "tags") {
|
|
146
|
-
setVal(value);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
148
|
if (value === null || value === undefined) {
|
|
150
149
|
setVal(undefined);
|
|
151
150
|
return;
|
|
152
151
|
}
|
|
152
|
+
if (mode === "tags") {
|
|
153
|
+
setVal(value);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
153
156
|
if (options) {
|
|
154
157
|
setVal((oldVale) => {
|
|
155
158
|
return matchNotFind(params, oldVale);
|
|
156
159
|
});
|
|
157
160
|
}
|
|
158
|
-
}, [value, options, mode, noMatchItemRender]);
|
|
161
|
+
}, [value, options, mode, noMatchItemRender,labelInValue]);
|
|
159
162
|
return {
|
|
160
163
|
val,
|
|
161
164
|
change,
|
|
@@ -1,36 +1,84 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {useEffect, useMemo, useState} from "react";
|
|
2
2
|
import type {
|
|
3
3
|
OptionType,
|
|
4
4
|
PartialHSelectProps,
|
|
5
|
-
} from "
|
|
5
|
+
} from "../modal";
|
|
6
6
|
import { useRequest } from "ahooks";
|
|
7
7
|
import { useFormContext } from "../../Form/Context";
|
|
8
|
+
import {OptionsPageResultModal} from "../modal";
|
|
8
9
|
|
|
9
10
|
interface ParamsModal {
|
|
10
11
|
options?: OptionType[];
|
|
11
12
|
params?: any;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
const useSaveParams=()=>{
|
|
15
|
+
const saveParams=useMemo(()=>{
|
|
16
|
+
return {
|
|
17
|
+
listParams:{
|
|
18
|
+
isEnd:false,
|
|
19
|
+
page:1,
|
|
20
|
+
size:100,
|
|
21
|
+
reqParams:{}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},[]);
|
|
25
|
+
const resetSaveParams=()=>{
|
|
26
|
+
saveParams.listParams={
|
|
27
|
+
isEnd:false,
|
|
28
|
+
page:1,
|
|
29
|
+
size:100,
|
|
30
|
+
reqParams:{}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const nextPage=(data:OptionsPageResultModal)=>{
|
|
34
|
+
const {size,total,page}=data;
|
|
35
|
+
saveParams.listParams.size=size;
|
|
36
|
+
saveParams.listParams.page=page+1;
|
|
37
|
+
saveParams.listParams.isEnd=size*page>=total;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
saveParams,
|
|
41
|
+
resetSaveParams,
|
|
42
|
+
nextPage
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const useOptionsRequest = ({
|
|
15
46
|
request,
|
|
16
|
-
options,
|
|
17
|
-
serviceSearch,
|
|
18
|
-
showSearch,
|
|
19
|
-
onSearch: propsOnSearch,
|
|
20
47
|
dispatch = {},
|
|
48
|
+
manual,
|
|
49
|
+
options,
|
|
50
|
+
isList
|
|
21
51
|
}: PartialHSelectProps) => {
|
|
22
|
-
const {
|
|
52
|
+
const {saveParams,resetSaveParams,nextPage}=useSaveParams();
|
|
23
53
|
const { form } = useFormContext();
|
|
54
|
+
const { manual: dispatchManual } = dispatch;
|
|
24
55
|
const [data, setData] = useState<OptionType[] | undefined>();
|
|
56
|
+
const paramsProvider=(params:Record<string, any>)=>{
|
|
57
|
+
if (isList){
|
|
58
|
+
const page=saveParams.listParams.page;
|
|
59
|
+
const size=saveParams.listParams.size;
|
|
60
|
+
return {
|
|
61
|
+
...params,
|
|
62
|
+
page,
|
|
63
|
+
size
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return params;
|
|
67
|
+
}
|
|
25
68
|
const { run, loading, error } = useRequest(
|
|
26
|
-
async (requestParams = {}) => {
|
|
27
|
-
const { params =
|
|
69
|
+
async (requestParams = {},type="init") => {
|
|
70
|
+
const { params = saveParams.listParams.reqParams, values} = requestParams;
|
|
28
71
|
const formData = values || form?.getFieldsValue();
|
|
29
72
|
if (type === "init") {
|
|
73
|
+
resetSaveParams();
|
|
30
74
|
setData(undefined);
|
|
31
75
|
}
|
|
76
|
+
saveParams.listParams.reqParams=params;
|
|
77
|
+
if (isList&&saveParams.listParams.isEnd){
|
|
78
|
+
return data;
|
|
79
|
+
}
|
|
32
80
|
if (request) {
|
|
33
|
-
return request(params, formData);
|
|
81
|
+
return request(paramsProvider(params), formData);
|
|
34
82
|
}
|
|
35
83
|
return Promise.resolve(options);
|
|
36
84
|
},
|
|
@@ -38,12 +86,48 @@ export const useOptionReq = ({
|
|
|
38
86
|
manual: dispatchManual === false ? true : manual,
|
|
39
87
|
debounceInterval: 300,
|
|
40
88
|
onSuccess: (resultData) => {
|
|
41
|
-
|
|
89
|
+
if (Array.isArray(resultData)||!resultData){
|
|
90
|
+
return setData(resultData);
|
|
91
|
+
}
|
|
92
|
+
const oldData=data||[];
|
|
93
|
+
const {data:resultOption}=resultData;
|
|
94
|
+
const op = resultOption||[];
|
|
95
|
+
nextPage(resultData);
|
|
96
|
+
setData([
|
|
97
|
+
...oldData,
|
|
98
|
+
...op
|
|
99
|
+
]);
|
|
42
100
|
},
|
|
43
101
|
}
|
|
44
102
|
);
|
|
103
|
+
return {
|
|
104
|
+
loading,
|
|
105
|
+
run,
|
|
106
|
+
error,
|
|
107
|
+
data,
|
|
108
|
+
setData,
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const useSelectReq = ({
|
|
113
|
+
manual,
|
|
114
|
+
request,
|
|
115
|
+
options,
|
|
116
|
+
serviceSearch,
|
|
117
|
+
showSearch,
|
|
118
|
+
onSearch: propsOnSearch,
|
|
119
|
+
dispatch = {},
|
|
120
|
+
isList,
|
|
121
|
+
}: PartialHSelectProps) => {
|
|
122
|
+
const { run, loading, error, data, setData } = useOptionsRequest({
|
|
123
|
+
request,
|
|
124
|
+
dispatch,
|
|
125
|
+
manual,
|
|
126
|
+
options,
|
|
127
|
+
isList
|
|
128
|
+
});
|
|
45
129
|
const reload = (reloadParams?: ParamsModal) => {
|
|
46
|
-
const { options: changeOpts, params }=reloadParams||{};
|
|
130
|
+
const { options: changeOpts, params } = reloadParams || {};
|
|
47
131
|
if (changeOpts) {
|
|
48
132
|
return setData(changeOpts);
|
|
49
133
|
}
|
|
@@ -61,6 +145,13 @@ export const useOptionReq = ({
|
|
|
61
145
|
setData(options);
|
|
62
146
|
}
|
|
63
147
|
}, [options]);
|
|
148
|
+
const onPopupScroll=(e)=>{
|
|
149
|
+
const {target} = e;
|
|
150
|
+
const changeTarget=(target as any);
|
|
151
|
+
if (changeTarget.scrollTop + changeTarget.offsetHeight === changeTarget.scrollHeight) {
|
|
152
|
+
run({},"page");
|
|
153
|
+
}
|
|
154
|
+
}
|
|
64
155
|
const mathShowSearch = showSearch || serviceSearch;
|
|
65
156
|
return {
|
|
66
157
|
run,
|
|
@@ -70,6 +161,7 @@ export const useOptionReq = ({
|
|
|
70
161
|
onSearch: mathShowSearch ? onSearch : propsOnSearch,
|
|
71
162
|
mathShowSearch: showSearch || serviceSearch,
|
|
72
163
|
reload,
|
|
164
|
+
onPopupScroll:isList?onPopupScroll:undefined
|
|
73
165
|
};
|
|
74
166
|
};
|
|
75
167
|
|
|
@@ -78,9 +170,7 @@ export const useFilterOption = ({
|
|
|
78
170
|
serviceSearch,
|
|
79
171
|
}: PartialHSelectProps) => {
|
|
80
172
|
if (serviceSearch) {
|
|
81
|
-
return
|
|
82
|
-
return true;
|
|
83
|
-
};
|
|
173
|
+
return false
|
|
84
174
|
}
|
|
85
175
|
return filterOption;
|
|
86
176
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Select } from "antd";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import {
|
|
3
|
+
import {useFilterOption, useSelectReq} from "./hooks/norHooks";
|
|
4
4
|
import { useValueChange } from "./hooks/changeHooks";
|
|
5
5
|
import type { HSelectProps } from "./modal";
|
|
6
6
|
import { defaultModeConfig, defaultSelectConfig } from "./defaultConfig";
|
|
@@ -33,6 +33,8 @@ const Index: React.FC<HSelectProps> = ({
|
|
|
33
33
|
addDispatchListener,
|
|
34
34
|
addFormat,
|
|
35
35
|
dispatch,
|
|
36
|
+
isList,
|
|
37
|
+
onPopupScroll:propsOnPopupScroll,
|
|
36
38
|
...props
|
|
37
39
|
}) => {
|
|
38
40
|
const { icon, render } = modeConfig?.[mode || ""] || {};
|
|
@@ -46,7 +48,8 @@ const Index: React.FC<HSelectProps> = ({
|
|
|
46
48
|
onSearch,
|
|
47
49
|
mathShowSearch,
|
|
48
50
|
reload,
|
|
49
|
-
|
|
51
|
+
onPopupScroll
|
|
52
|
+
} = useSelectReq({
|
|
50
53
|
options,
|
|
51
54
|
manual,
|
|
52
55
|
fieldNames,
|
|
@@ -55,6 +58,7 @@ const Index: React.FC<HSelectProps> = ({
|
|
|
55
58
|
showSearch,
|
|
56
59
|
onSearch: propsOnSearch,
|
|
57
60
|
dispatch,
|
|
61
|
+
isList
|
|
58
62
|
}); //options
|
|
59
63
|
|
|
60
64
|
const data = useChangeOptions({ options: resultData, fieldNames });
|
|
@@ -103,6 +107,7 @@ const Index: React.FC<HSelectProps> = ({
|
|
|
103
107
|
filterOption={selfFilterOption}
|
|
104
108
|
showSearch={mathShowSearch}
|
|
105
109
|
labelInValue={true}
|
|
110
|
+
onPopupScroll={propsOnPopupScroll||onPopupScroll}
|
|
106
111
|
{...props}
|
|
107
112
|
>
|
|
108
113
|
{data?.map((item) => {
|
|
@@ -2,8 +2,8 @@ import type { SelectProps } from "antd";
|
|
|
2
2
|
import type React from "react";
|
|
3
3
|
import type { PromiseFnResult } from "../modal";
|
|
4
4
|
import type { addFormatItemModal, argsFn, DispatchModal } from "../Form/modal";
|
|
5
|
+
|
|
5
6
|
export type OptionType = Record<string, any>;
|
|
6
|
-
export type PartialHSelectProps = Partial<HSelectProps>;
|
|
7
7
|
export type RenderFn = (data: OptionType) => React.ReactNode;
|
|
8
8
|
|
|
9
9
|
interface ModeConfigItem {
|
|
@@ -15,10 +15,20 @@ export interface ModeConfig {
|
|
|
15
15
|
tags?: ModeConfigItem;
|
|
16
16
|
}
|
|
17
17
|
type FilterProviderFn = (item: any) => string;
|
|
18
|
+
type OptionsListType = OptionType[];
|
|
19
|
+
export interface OptionsPageResultModal {
|
|
20
|
+
page: number;
|
|
21
|
+
size: number;
|
|
22
|
+
data: OptionsListType;
|
|
23
|
+
total:number;
|
|
24
|
+
}
|
|
25
|
+
export type OptionsDataType =
|
|
26
|
+
| OptionsListType
|
|
27
|
+
| OptionsPageResultModal
|
|
18
28
|
export interface HSelectProps
|
|
19
29
|
extends Omit<SelectProps, "options" | "placeholder"> {
|
|
20
30
|
style?: React.CSSProperties;
|
|
21
|
-
request?: PromiseFnResult<any,
|
|
31
|
+
request?: PromiseFnResult<any, OptionsDataType>;
|
|
22
32
|
manual?: boolean;
|
|
23
33
|
modeConfig?: ModeConfig;
|
|
24
34
|
filterProvider?: FilterProviderFn | string; //筛选字段默认为label
|
|
@@ -30,8 +40,10 @@ export interface HSelectProps
|
|
|
30
40
|
addFormat?: (format: Record<string, addFormatItemModal>) => void;
|
|
31
41
|
placeholder?: string;
|
|
32
42
|
dispatch?: DispatchModal;
|
|
43
|
+
isList?:boolean
|
|
33
44
|
}
|
|
34
45
|
export interface FilterDataModal {
|
|
35
46
|
value: any;
|
|
36
47
|
index: number;
|
|
37
48
|
}
|
|
49
|
+
export type PartialHSelectProps = Partial<HSelectProps>;
|
|
@@ -7,9 +7,13 @@ import type {
|
|
|
7
7
|
} from "@/components/Submit/index";
|
|
8
8
|
interface ControlFooterProps extends ISubmitProps {
|
|
9
9
|
action: SubmitBarExtraType;
|
|
10
|
-
style?:React.CSSProperties
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
11
|
}
|
|
12
|
-
function ResetBtn({
|
|
12
|
+
function ResetBtn({
|
|
13
|
+
form,
|
|
14
|
+
style = { borderRadius: 4 },
|
|
15
|
+
...props
|
|
16
|
+
}: Omit<ControlFooterProps, "action">) {
|
|
13
17
|
return (
|
|
14
18
|
<Button
|
|
15
19
|
{...props}
|
|
@@ -28,7 +32,7 @@ function SubBtn({
|
|
|
28
32
|
form,
|
|
29
33
|
text = "提交",
|
|
30
34
|
loading,
|
|
31
|
-
style={borderRadius:4},
|
|
35
|
+
style = { borderRadius: 4 },
|
|
32
36
|
...props
|
|
33
37
|
}: ISubmitProps) {
|
|
34
38
|
const { loading: formSubLoading = loading } = useFormContext();
|
|
@@ -9,14 +9,14 @@ import { message } from "antd";
|
|
|
9
9
|
interface SubReqParamsModal {
|
|
10
10
|
request?: (
|
|
11
11
|
file: Exclude<BeforeUploadFileType, File | boolean> | RcFile
|
|
12
|
-
) => Promise<{ url: string
|
|
12
|
+
) => Promise<{ url: string; thumbUrl?: string }>;
|
|
13
13
|
file: RcFile;
|
|
14
14
|
}
|
|
15
15
|
interface ResultModal {
|
|
16
16
|
url: string;
|
|
17
17
|
status: UploadFileStatus;
|
|
18
18
|
uid?: string;
|
|
19
|
-
thumbUrl?:string;
|
|
19
|
+
thumbUrl?: string;
|
|
20
20
|
}
|
|
21
21
|
const subReq = async ({
|
|
22
22
|
request,
|
|
@@ -29,7 +29,7 @@ const subReq = async ({
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
try {
|
|
32
|
-
const { url
|
|
32
|
+
const { url, thumbUrl } = await request(file);
|
|
33
33
|
return {
|
|
34
34
|
url,
|
|
35
35
|
thumbUrl,
|
|
@@ -44,19 +44,19 @@ const subReq = async ({
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
const fileListProvider = (changeFile: ResultModal, files?: UploadFile[]) => {
|
|
47
|
-
const { status, url, uid,thumbUrl } = changeFile;
|
|
47
|
+
const { status, url, uid, thumbUrl } = changeFile;
|
|
48
48
|
if (status === "error") {
|
|
49
49
|
return files?.filter((item) => {
|
|
50
50
|
return item.uid !== uid;
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
return files?.map((item) => {
|
|
54
|
-
const fileDefaultThumbUrl=item.thumbUrl||thumbUrl;
|
|
54
|
+
const fileDefaultThumbUrl = item.thumbUrl || thumbUrl;
|
|
55
55
|
const resultUrl = url || item.thumbUrl;
|
|
56
56
|
if (item.uid === uid) {
|
|
57
57
|
item.status = status;
|
|
58
58
|
item.response = { url: resultUrl };
|
|
59
|
-
item.thumbUrl=fileDefaultThumbUrl;
|
|
59
|
+
item.thumbUrl = fileDefaultThumbUrl;
|
|
60
60
|
return item;
|
|
61
61
|
}
|
|
62
62
|
return item;
|
|
@@ -13,6 +13,19 @@ const data = [
|
|
|
13
13
|
{ label: "选择2", value: 1 },
|
|
14
14
|
],
|
|
15
15
|
},
|
|
16
|
+
{
|
|
17
|
+
label: "选择",
|
|
18
|
+
name: "select",
|
|
19
|
+
type: "select",
|
|
20
|
+
helper: "select",
|
|
21
|
+
itemProps: {
|
|
22
|
+
mode: "tags",
|
|
23
|
+
options: [
|
|
24
|
+
{ label: "选择1", value: 0 },
|
|
25
|
+
{ label: "选择2", value: 1 },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
16
29
|
{
|
|
17
30
|
label: "地址文件",
|
|
18
31
|
name: "urlUpload",
|
|
@@ -71,7 +84,11 @@ export default () => {
|
|
|
71
84
|
</Button>
|
|
72
85
|
<Button
|
|
73
86
|
onClick={() => {
|
|
74
|
-
modalForm.show(
|
|
87
|
+
modalForm.show({
|
|
88
|
+
initialValues: {
|
|
89
|
+
select: null,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
75
92
|
}}
|
|
76
93
|
>
|
|
77
94
|
打开
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -49,25 +49,28 @@ const formData = (options) => {
|
|
|
49
49
|
className: "hdjd",
|
|
50
50
|
type: "select",
|
|
51
51
|
name: "test321",
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
label: "测试12312",
|
|
65
|
-
className: "hdjd",
|
|
66
|
-
name: "test123",
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
type: "submit"
|
|
52
|
+
itemProps: {
|
|
53
|
+
options: [
|
|
54
|
+
{
|
|
55
|
+
value: "选项1",
|
|
56
|
+
key: 1,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
value: "选项2",
|
|
60
|
+
key: 2,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
showSearch: true,
|
|
70
64
|
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
label: "测试12312",
|
|
68
|
+
className: "hdjd",
|
|
69
|
+
name: "test123",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
type: "submit",
|
|
73
|
+
},
|
|
71
74
|
];
|
|
72
75
|
};
|
|
73
76
|
function Ttta({ form }) {
|