@hw-component/form 1.9.87 → 1.9.89
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/Form/config.d.ts +5 -0
- package/es/Form/config.js +3 -1
- package/es/Select/TagSelect/Content.d.ts +1 -1
- package/es/Select/TagSelect/hooks.d.ts +5 -1
- package/es/Select/TagSelect/hooks.js +27 -2
- package/es/Select/TagSelect/index.js +16 -6
- package/es/Select/modal.d.ts +3 -2
- package/es/TDPicker/TimeRangePicker.d.ts +8 -0
- package/es/TDPicker/TimeRangePicker.js +74 -0
- package/es/TDPicker/modal.d.ts +9 -0
- package/es/index.css +1 -4
- package/es/index.d.ts +5 -0
- package/es/index.js +2 -1
- package/lib/Form/config.d.ts +5 -0
- package/lib/Form/config.js +3 -1
- package/lib/Select/TagSelect/Content.d.ts +1 -1
- package/lib/Select/TagSelect/hooks.d.ts +5 -1
- package/lib/Select/TagSelect/hooks.js +26 -0
- package/lib/Select/TagSelect/index.js +15 -5
- package/lib/Select/modal.d.ts +3 -2
- package/lib/TDPicker/TimeRangePicker.d.ts +8 -0
- package/lib/TDPicker/TimeRangePicker.js +77 -0
- package/lib/TDPicker/modal.d.ts +9 -0
- package/lib/index.css +1 -4
- package/lib/index.d.ts +5 -0
- package/lib/index.js +2 -0
- package/package.json +1 -1
- package/src/components/Form/config.ts +5 -2
- package/src/components/Form/index.less +0 -6
- package/src/components/Select/TagSelect/Content.tsx +71 -43
- package/src/components/Select/TagSelect/hooks.ts +103 -75
- package/src/components/Select/TagSelect/index.tsx +96 -54
- package/src/components/Select/index.less +3 -4
- package/src/components/Select/modal.ts +8 -6
- package/src/components/TDPicker/TimeRangePicker.tsx +51 -0
- package/src/components/TDPicker/modal.ts +10 -0
- package/src/components/index.tsx +2 -0
- package/src/pages/Form/index.tsx +21 -16
- package/src/pages/Select/index.tsx +34 -26
|
@@ -1,50 +1,78 @@
|
|
|
1
|
-
import {HTagSelectProps} from "../modal";
|
|
2
|
-
import {useClassName} from "@/components/hooks";
|
|
3
|
-
import {Row, Skeleton, Space, Tag,Empty} from "antd";
|
|
1
|
+
import { HTagSelectProps } from "../modal";
|
|
2
|
+
import { useClassName } from "@/components/hooks";
|
|
3
|
+
import { Row, Skeleton, Space, Tag, Empty } from "antd";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import {useChangeControl} from "./hooks";
|
|
5
|
+
import { useChangeControl } from "./hooks";
|
|
6
6
|
import NotFoundContent from "../components/NotFoundContent";
|
|
7
7
|
|
|
8
|
-
const ItemOption=({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
const ItemOption = ({
|
|
9
|
+
options,
|
|
10
|
+
value,
|
|
11
|
+
onChange,
|
|
12
|
+
fieldNames,
|
|
13
|
+
}: HTagSelectProps) => {
|
|
14
|
+
const tagClassName = useClassName("hw-tag-item");
|
|
15
|
+
const { label: labelKey = "label", value: valueKey = "value" } =
|
|
16
|
+
fieldNames || {};
|
|
17
|
+
const { change } = useChangeControl({ options, value, onChange, fieldNames });
|
|
18
|
+
return (
|
|
19
|
+
<Row gutter={[0, 8]}>
|
|
20
|
+
{options?.map((item) => {
|
|
21
|
+
const { [labelKey]: label, [valueKey]: itemVal } = item;
|
|
22
|
+
const index = value?.indexOf(itemVal);
|
|
23
|
+
const checkedTag = index !== -1;
|
|
24
|
+
return (
|
|
25
|
+
<Tag
|
|
26
|
+
color={checkedTag ? "processing" : undefined}
|
|
27
|
+
className={tagClassName}
|
|
28
|
+
key={itemVal}
|
|
29
|
+
onClick={() => {
|
|
30
|
+
change(itemVal);
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
{label}
|
|
34
|
+
</Tag>
|
|
35
|
+
);
|
|
36
|
+
})}
|
|
27
37
|
</Row>
|
|
28
|
-
|
|
38
|
+
);
|
|
39
|
+
};
|
|
29
40
|
|
|
30
|
-
interface IContentProps extends HTagSelectProps{
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
interface IContentProps extends HTagSelectProps {
|
|
42
|
+
error?: Error;
|
|
43
|
+
reload: VoidFunction;
|
|
33
44
|
}
|
|
34
45
|
|
|
35
|
-
export default ({
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
export default ({
|
|
47
|
+
loading,
|
|
48
|
+
value,
|
|
49
|
+
options,
|
|
50
|
+
onChange,
|
|
51
|
+
fieldNames,
|
|
52
|
+
error,
|
|
53
|
+
reload,
|
|
54
|
+
}: IContentProps) => {
|
|
55
|
+
const len = options?.length || 0;
|
|
56
|
+
if (loading && len === 0) {
|
|
57
|
+
return (
|
|
58
|
+
<Space direction={"vertical"} style={{ width: "100%" }}>
|
|
59
|
+
<Skeleton.Button active size={"small"} block />
|
|
60
|
+
<Skeleton.Button active size={"small"} block />
|
|
61
|
+
</Space>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
if (error && len === 0) {
|
|
65
|
+
return <NotFoundContent error={error} reload={reload} />;
|
|
66
|
+
}
|
|
67
|
+
if (len === 0) {
|
|
68
|
+
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
|
|
69
|
+
}
|
|
70
|
+
return (
|
|
71
|
+
<ItemOption
|
|
72
|
+
options={options}
|
|
73
|
+
value={value}
|
|
74
|
+
onChange={onChange}
|
|
75
|
+
fieldNames={fieldNames}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
@@ -1,83 +1,111 @@
|
|
|
1
|
-
import {useMemo} from "react";
|
|
2
|
-
import {HTagSelectProps, OptionType} from "@/components/Select/modal";
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { HTagSelectProps, OptionType } from "@/components/Select/modal";
|
|
3
3
|
|
|
4
|
-
export const useTagControl=({value,options,title}:HTagSelectProps)=>{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
if (len===opLen){
|
|
14
|
-
return {
|
|
15
|
-
checked:true
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
indeterminate:!!len
|
|
20
|
-
}
|
|
21
|
-
},[value,options]);
|
|
22
|
-
const labelNode=useMemo(()=>{
|
|
23
|
-
if (title){
|
|
24
|
-
return title;
|
|
25
|
-
}
|
|
26
|
-
if (checked){
|
|
27
|
-
return "取消"
|
|
28
|
-
}
|
|
29
|
-
return "全选"
|
|
30
|
-
},[title,checked,indeterminate]);
|
|
31
|
-
return {
|
|
32
|
-
labelNode,
|
|
33
|
-
checked,
|
|
34
|
-
indeterminate
|
|
4
|
+
export const useTagControl = ({ value, options, title }: HTagSelectProps) => {
|
|
5
|
+
const { checked, indeterminate } = useMemo(() => {
|
|
6
|
+
const len = value?.length;
|
|
7
|
+
const opLen = options?.length;
|
|
8
|
+
if (!opLen) {
|
|
9
|
+
return {
|
|
10
|
+
checked: false,
|
|
11
|
+
};
|
|
35
12
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const optsNk=(newVal)=>{
|
|
41
|
-
const newOpts:OptionType[]=[];
|
|
42
|
-
newVal?.forEach((itemVal)=>{
|
|
43
|
-
const index=options?.findIndex((item)=>{
|
|
44
|
-
return itemVal===item[valueKey];
|
|
45
|
-
});
|
|
46
|
-
if (typeof index!=="undefined"){
|
|
47
|
-
newOpts.push((options?.[index] as OptionType));
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
return newOpts;
|
|
13
|
+
if (len === opLen) {
|
|
14
|
+
return {
|
|
15
|
+
checked: true,
|
|
16
|
+
};
|
|
51
17
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
18
|
+
return {
|
|
19
|
+
indeterminate: !!len,
|
|
20
|
+
};
|
|
21
|
+
}, [value, options]);
|
|
22
|
+
const labelNode = useMemo(() => {
|
|
23
|
+
if (title) {
|
|
24
|
+
return title;
|
|
56
25
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
newVal.splice(index,1);
|
|
60
|
-
onChange?.(newVal,optsNk(newVal));
|
|
26
|
+
if (checked) {
|
|
27
|
+
return "取消";
|
|
61
28
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
29
|
+
return "全选";
|
|
30
|
+
}, [title, checked, indeterminate]);
|
|
31
|
+
return {
|
|
32
|
+
labelNode,
|
|
33
|
+
checked,
|
|
34
|
+
indeterminate,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const useChangeControl = ({
|
|
39
|
+
options,
|
|
40
|
+
value,
|
|
41
|
+
onChange,
|
|
42
|
+
fieldNames,
|
|
43
|
+
}: HTagSelectProps) => {
|
|
44
|
+
const { value: valueKey = "value" } = fieldNames || {};
|
|
45
|
+
const optsNk = (newVal) => {
|
|
46
|
+
const newOpts: OptionType[] = [];
|
|
47
|
+
newVal?.forEach((itemVal) => {
|
|
48
|
+
const index = options?.findIndex((item) => {
|
|
49
|
+
return itemVal === item[valueKey];
|
|
50
|
+
});
|
|
51
|
+
if (typeof index !== "undefined") {
|
|
52
|
+
newOpts.push(options?.[index] as OptionType);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return newOpts;
|
|
56
|
+
};
|
|
57
|
+
const checkedVal = (val) => {
|
|
58
|
+
const newVal = [...value];
|
|
59
|
+
newVal.push(val);
|
|
60
|
+
onChange?.(newVal, optsNk(newVal));
|
|
61
|
+
};
|
|
62
|
+
const removeVal = (index) => {
|
|
63
|
+
const newVal = [...value];
|
|
64
|
+
newVal.splice(index, 1);
|
|
65
|
+
onChange?.(newVal, optsNk(newVal));
|
|
66
|
+
};
|
|
67
|
+
const change = (val) => {
|
|
68
|
+
const index = value?.indexOf(val);
|
|
69
|
+
const checked = index === -1;
|
|
70
|
+
if (checked) {
|
|
71
|
+
return checkedVal(val);
|
|
69
72
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return item[valueKey];
|
|
76
|
-
});
|
|
77
|
-
return onChange?.(newVal,options);
|
|
73
|
+
return removeVal(index);
|
|
74
|
+
};
|
|
75
|
+
const allCheck = (e) => {
|
|
76
|
+
if (!e.target.checked) {
|
|
77
|
+
return onChange?.([], []);
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
const newVal = options?.map((item) => {
|
|
80
|
+
return item[valueKey];
|
|
81
|
+
});
|
|
82
|
+
return onChange?.(newVal, options);
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
change,
|
|
86
|
+
allCheck,
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const useCollapseControl = ({
|
|
91
|
+
visible,
|
|
92
|
+
defaultVisible,
|
|
93
|
+
onVisibleChange,
|
|
94
|
+
}: HTagSelectProps) => {
|
|
95
|
+
const [activeKey, setActiveKey] = useState(defaultVisible ? ["1"] : []);
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (typeof visible === "undefined") {
|
|
98
|
+
return;
|
|
82
99
|
}
|
|
83
|
-
|
|
100
|
+
setActiveKey(visible ? ["1"] : []);
|
|
101
|
+
}, [visible]);
|
|
102
|
+
const onChange = (keys) => {
|
|
103
|
+
const len = keys?.length;
|
|
104
|
+
onVisibleChange?.(!!len);
|
|
105
|
+
setActiveKey(keys);
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
activeKey,
|
|
109
|
+
onChange,
|
|
110
|
+
};
|
|
111
|
+
};
|
|
@@ -1,63 +1,105 @@
|
|
|
1
|
-
import {Collapse, Checkbox} from
|
|
2
|
-
import {useClassName, useMatchConfigProps} from "../../hooks";
|
|
1
|
+
import { Collapse, Checkbox } from "antd";
|
|
2
|
+
import { useClassName, useMatchConfigProps } from "../../hooks";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import {useSelectReq} from "../hooks/norHooks";
|
|
5
|
-
import {HTagSelectProps} from "../modal";
|
|
6
|
-
import {CheckboxProps} from "antd/lib/checkbox/Checkbox";
|
|
7
|
-
import Content from
|
|
8
|
-
import {
|
|
4
|
+
import { useSelectReq } from "../hooks/norHooks";
|
|
5
|
+
import { HTagSelectProps } from "../modal";
|
|
6
|
+
import { CheckboxProps } from "antd/lib/checkbox/Checkbox";
|
|
7
|
+
import Content from "./Content";
|
|
8
|
+
import {
|
|
9
|
+
useChangeControl,
|
|
10
|
+
useCollapseControl,
|
|
11
|
+
useTagControl,
|
|
12
|
+
} from "@/components/Select/TagSelect/hooks";
|
|
9
13
|
import HFormConnect from "@/components/Form/HFormConnect";
|
|
10
14
|
const { Panel } = Collapse;
|
|
11
15
|
|
|
12
|
-
const ItemTitle:React.FC<CheckboxProps
|
|
13
|
-
|
|
16
|
+
const ItemTitle: React.FC<CheckboxProps> = ({ children, ...props }) => {
|
|
17
|
+
return (
|
|
18
|
+
<div
|
|
19
|
+
onClick={(event) => {
|
|
14
20
|
event.stopPropagation();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
</Checkbox>
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
<Checkbox {...props}>{children}</Checkbox>
|
|
19
24
|
</div>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
const Index: React.FC<HTagSelectProps> = ({
|
|
28
|
+
options,
|
|
29
|
+
value = [],
|
|
30
|
+
onChange,
|
|
31
|
+
dispatch,
|
|
32
|
+
fieldNames: propsFieldNames,
|
|
33
|
+
request,
|
|
34
|
+
title,
|
|
35
|
+
manual,
|
|
36
|
+
className = "",
|
|
37
|
+
visible,
|
|
38
|
+
defaultVisible,
|
|
39
|
+
onVisibleChange,
|
|
40
|
+
addDispatchListener,
|
|
41
|
+
}) => {
|
|
42
|
+
const collapseClassName = useClassName("hw-tag-select");
|
|
43
|
+
const { fieldNames } = useMatchConfigProps({ fieldNames: propsFieldNames });
|
|
44
|
+
const { activeKey, onChange: colChange } = useCollapseControl({
|
|
45
|
+
defaultVisible,
|
|
46
|
+
visible,
|
|
47
|
+
onVisibleChange,
|
|
48
|
+
});
|
|
49
|
+
const {
|
|
50
|
+
loading,
|
|
51
|
+
data: resultData,
|
|
52
|
+
error,
|
|
53
|
+
reload,
|
|
54
|
+
} = useSelectReq({
|
|
55
|
+
options,
|
|
56
|
+
manual,
|
|
57
|
+
request,
|
|
58
|
+
dispatch,
|
|
59
|
+
}); //options
|
|
60
|
+
const { labelNode, checked, indeterminate } = useTagControl({
|
|
61
|
+
value,
|
|
62
|
+
options: resultData,
|
|
63
|
+
title,
|
|
64
|
+
});
|
|
65
|
+
const { allCheck } = useChangeControl({
|
|
66
|
+
value,
|
|
67
|
+
options: resultData,
|
|
68
|
+
onChange,
|
|
69
|
+
fieldNames,
|
|
70
|
+
});
|
|
71
|
+
addDispatchListener?.("reload", reload);
|
|
72
|
+
return (
|
|
73
|
+
<Collapse
|
|
74
|
+
bordered={false}
|
|
75
|
+
ghost
|
|
76
|
+
activeKey={activeKey}
|
|
77
|
+
onChange={colChange}
|
|
78
|
+
className={`${collapseClassName} ${className}`}
|
|
47
79
|
>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
80
|
+
<Panel
|
|
81
|
+
key="1"
|
|
82
|
+
header={
|
|
83
|
+
<ItemTitle
|
|
84
|
+
indeterminate={indeterminate}
|
|
85
|
+
checked={checked}
|
|
86
|
+
onChange={allCheck}
|
|
87
|
+
>
|
|
88
|
+
{labelNode}
|
|
89
|
+
</ItemTitle>
|
|
90
|
+
}
|
|
91
|
+
>
|
|
92
|
+
<Content
|
|
93
|
+
loading={loading}
|
|
94
|
+
options={resultData}
|
|
95
|
+
value={value}
|
|
96
|
+
error={error}
|
|
97
|
+
onChange={onChange}
|
|
98
|
+
reload={reload}
|
|
99
|
+
fieldNames={fieldNames}
|
|
100
|
+
/>
|
|
101
|
+
</Panel>
|
|
61
102
|
</Collapse>
|
|
62
|
-
|
|
103
|
+
);
|
|
104
|
+
};
|
|
63
105
|
export default HFormConnect(Index);
|
|
@@ -58,13 +58,12 @@
|
|
|
58
58
|
.@{ant-prefix}-hw-tag-select {
|
|
59
59
|
width: 100%;
|
|
60
60
|
.@{ant-prefix}-collapse-content-box {
|
|
61
|
-
padding:
|
|
61
|
+
padding: 0 40px !important;
|
|
62
62
|
}
|
|
63
|
-
.@{ant-prefix}-hw-tag-select{
|
|
63
|
+
.@{ant-prefix}-hw-tag-select {
|
|
64
64
|
cursor: pointer;
|
|
65
65
|
}
|
|
66
|
-
.@{ant-prefix}-collapse-header{
|
|
66
|
+
.@{ant-prefix}-collapse-header {
|
|
67
67
|
padding: 5px 16px !important;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
|
|
@@ -2,7 +2,7 @@ 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
|
-
import {CollapseProps} from "antd/lib/collapse/Collapse";
|
|
5
|
+
import { CollapseProps } from "antd/lib/collapse/Collapse";
|
|
6
6
|
|
|
7
7
|
export type OptionType = Record<string, any>;
|
|
8
8
|
export type RenderFn = (data: OptionType) => React.ReactNode;
|
|
@@ -25,7 +25,7 @@ export interface OptionsPageResultModal {
|
|
|
25
25
|
}
|
|
26
26
|
export type OptionsDataType = OptionsListType | OptionsPageResultModal;
|
|
27
27
|
export interface HSelectProps
|
|
28
|
-
extends Omit<SelectProps, "options" | "placeholder"|"onChange"> {
|
|
28
|
+
extends Omit<SelectProps, "options" | "placeholder" | "onChange"> {
|
|
29
29
|
style?: React.CSSProperties;
|
|
30
30
|
request?: PromiseFnResult<any, OptionsDataType>;
|
|
31
31
|
manual?: boolean;
|
|
@@ -42,14 +42,16 @@ export interface HSelectProps
|
|
|
42
42
|
isList?: boolean;
|
|
43
43
|
addonBefore?: React.ReactNode;
|
|
44
44
|
addonAfter?: React.ReactNode;
|
|
45
|
-
onChange?:(value:any,opts?:OptionType[]|OptionType)=>void;
|
|
45
|
+
onChange?: (value: any, opts?: OptionType[] | OptionType) => void;
|
|
46
46
|
}
|
|
47
47
|
export interface FilterDataModal {
|
|
48
48
|
value: any;
|
|
49
49
|
index: number;
|
|
50
50
|
}
|
|
51
|
-
export interface HTagSelectProps extends HSelectProps{
|
|
52
|
-
title?:React.ReactNode;
|
|
53
|
-
|
|
51
|
+
export interface HTagSelectProps extends HSelectProps {
|
|
52
|
+
title?: React.ReactNode;
|
|
53
|
+
defaultVisible?: boolean;
|
|
54
|
+
visible?: boolean;
|
|
55
|
+
onVisibleChange?: (visible: boolean) => void;
|
|
54
56
|
}
|
|
55
57
|
export type PartialHSelectProps = Partial<HSelectProps>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { TimePicker } from 'antd';
|
|
2
|
+
import React from "react";
|
|
3
|
+
import HFormConnect from "@/components/Form/HFormConnect";
|
|
4
|
+
import {HTimeRangePickerProps} from "@/components/TDPicker/modal";
|
|
5
|
+
import {HItemProps} from "@/components/Form/modal";
|
|
6
|
+
import moment from "moment";
|
|
7
|
+
const HTimePicker:React.FC<HTimeRangePickerProps>=({value,format="HH:mm:ss",addFormat,valueMap={},onChange,order=false,...props})=>{
|
|
8
|
+
const {start="startTime",end="endTime"}=valueMap;
|
|
9
|
+
addFormat?.({
|
|
10
|
+
float: {
|
|
11
|
+
inputValue: (item, initValue) => {
|
|
12
|
+
const {[start]:initStart,[end]:initEnd}=initValue;
|
|
13
|
+
const {name}=item;
|
|
14
|
+
if (initStart&&initEnd){
|
|
15
|
+
return {
|
|
16
|
+
[(name as string)]:[
|
|
17
|
+
moment(initStart,format),
|
|
18
|
+
moment(initEnd,format)
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
[(name as string)]:[]
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
outputValue: (item, outputValue) => {
|
|
27
|
+
const { name: valueName = "" } = item;
|
|
28
|
+
const { [valueName as string]: itemVal } = outputValue;
|
|
29
|
+
const [startVal,endVal]=itemVal||[];
|
|
30
|
+
return {
|
|
31
|
+
[start]:startVal?.format(format),
|
|
32
|
+
[end]:endVal?.format(format)
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return <TimePicker.RangePicker value={value} onChange={onChange} order={order} style={{ width: '100%' }} {...props}/>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const Index=HFormConnect(HTimePicker);
|
|
42
|
+
|
|
43
|
+
export default {
|
|
44
|
+
Component: Index,
|
|
45
|
+
placeholder: ({ label }: HItemProps) => {
|
|
46
|
+
return [`请选择开始${label}`, `请选择结束${label}`];
|
|
47
|
+
},
|
|
48
|
+
requiredErrMsg: ({ label }: HItemProps) => {
|
|
49
|
+
return `请选择${label}`;
|
|
50
|
+
},
|
|
51
|
+
};
|
|
@@ -6,6 +6,7 @@ import type { TimePickerProps } from "antd";
|
|
|
6
6
|
import type { DurationInputArg2 } from "moment";
|
|
7
7
|
import type { DateRangePickerValueMapModal } from "../modal";
|
|
8
8
|
import type { addFormatItemModal } from "../Form/modal";
|
|
9
|
+
import {TimeRangePickerProps} from "antd/lib/time-picker";
|
|
9
10
|
interface DisabledDateFnModal<T = Moment | undefined> {
|
|
10
11
|
(currentDate: Moment, value: T): boolean;
|
|
11
12
|
}
|
|
@@ -47,3 +48,12 @@ export interface HTimePickerProps
|
|
|
47
48
|
disabledDate?: DisabledDateFnModal;
|
|
48
49
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
49
50
|
}
|
|
51
|
+
|
|
52
|
+
export interface HTimeRangePickerProps extends Omit<TimeRangePickerProps, "format">{
|
|
53
|
+
valueMap?:{
|
|
54
|
+
start:string;
|
|
55
|
+
end:string;
|
|
56
|
+
}
|
|
57
|
+
format?:string;
|
|
58
|
+
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
59
|
+
}
|
package/src/components/index.tsx
CHANGED
package/src/pages/Form/index.tsx
CHANGED
|
@@ -77,28 +77,31 @@ export default () => {
|
|
|
77
77
|
configData={[
|
|
78
78
|
{
|
|
79
79
|
label: "tagSelect",
|
|
80
|
-
type:"tagSelect",
|
|
80
|
+
type: "tagSelect",
|
|
81
81
|
name: "wz",
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
dispatch: {
|
|
83
|
+
fnKey: "reload",
|
|
84
|
+
dependencies: ["wz1"],
|
|
85
|
+
},
|
|
86
|
+
itemProps: {
|
|
87
|
+
request: () => {
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
resolve([
|
|
91
|
+
{
|
|
92
|
+
value: "你好",
|
|
93
|
+
key: "1",
|
|
94
|
+
},
|
|
95
|
+
]);
|
|
96
|
+
}, 3000);
|
|
97
|
+
});
|
|
85
98
|
},
|
|
86
|
-
|
|
87
|
-
request:()=>{
|
|
88
|
-
return new Promise((resolve, reject)=>{
|
|
89
|
-
setTimeout(()=>{
|
|
90
|
-
resolve([{
|
|
91
|
-
value:"你好",
|
|
92
|
-
key:"1"
|
|
93
|
-
}])
|
|
94
|
-
},3000)
|
|
95
|
-
})
|
|
96
|
-
}
|
|
97
|
-
}
|
|
99
|
+
},
|
|
98
100
|
},
|
|
99
101
|
{
|
|
100
102
|
label: "文字1",
|
|
101
103
|
name: "wz1",
|
|
104
|
+
type:"timeRangePicker"
|
|
102
105
|
},
|
|
103
106
|
// {
|
|
104
107
|
// label: "inputSelect",
|
|
@@ -237,6 +240,8 @@ export default () => {
|
|
|
237
240
|
form={form}
|
|
238
241
|
initialValues={{
|
|
239
242
|
richEditor: "1312312",
|
|
243
|
+
startTime:'07:00:00' ,
|
|
244
|
+
endTime:"14:00:00"
|
|
240
245
|
}}
|
|
241
246
|
labelAlign={"left"}
|
|
242
247
|
onFinish={(value) => {
|