index.tsx
1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import React from 'react';
import Default from './select/Default';
import type { DataType } from './select/datas';
import datas from './select/datas';
/**
* 全剧API
*/
export interface globalProps {
onReady?: (list: any[]) => void;
value?: string;
onChange?: (id: string | string[] | undefined, props: any) => void;
onChildError?: (id: string | string[], list: Record<string, any>[]) => void;
placeholder?: string;
pageSize?: number; // 每页获取条数
style?: React.CSSProperties;
className?: string;
multiple?: boolean; // 是否开启多选模式
disableds?: string[];
param?: Record<string, any>; // 动态查询参数
}
export interface subGlobalProps extends globalProps {
mode?: 'multiple' | 'tags'; // 模式
notServer?: boolean;
storage?: string; // 是否使用 storage 库
}
export interface IndexSelectProps extends globalProps {
type: DataType;
}
const gathers = datas;
const Index = ({
onReady,
value,
onChange,
onChildError,
placeholder,
pageSize,
style,
className,
type,
multiple,
disableds,
param,
...props
}: IndexSelectProps) => {
const globalProps: subGlobalProps = {
onReady,
value,
onChange,
onChildError,
placeholder,
pageSize,
style,
className,
disableds,
mode: multiple ? 'multiple' : undefined,
}
const key = JSON.stringify(param);
if (gathers[type]) {
const { storage, pageSize:gatPageSize } = gathers[type];
return <Default
{...props}
key={key}
findParam={param}
rule={gathers[type]}
globalProps={{
storage: storage ? type : undefined,
notServer: gatPageSize === 0 ? true : undefined,
...globalProps,
}}
/>
}
return null;
}
export default Index;