57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
![]() |
import React, { useState, useEffect } from 'react';
|
||
|
import { Select } from 'antd';
|
||
|
import { queryUserOrgAll } from './services'
|
||
|
|
||
|
export interface AccessDepartmentSelectProps {
|
||
|
value?: string | number;
|
||
|
onChange?: (value: string | number) => void;
|
||
|
options?: { label: string; value: string | number }[];
|
||
|
placeholder?: string;
|
||
|
disabled?: boolean;
|
||
|
}
|
||
|
|
||
|
interface Dict {
|
||
|
orgName: string;
|
||
|
orgId: string;
|
||
|
}
|
||
|
|
||
|
|
||
|
const AccessDepartmentSelect: React.FC<AccessDepartmentSelectProps> = ({
|
||
|
value,
|
||
|
onChange,
|
||
|
placeholder = '请选择准入部门',
|
||
|
disabled = false,
|
||
|
}) => {
|
||
|
|
||
|
//部门
|
||
|
const [userOrgAll, setUserOrgAll] = useState<Dict[]>();
|
||
|
useEffect(() => {
|
||
|
queryUserOrgAll().then((res) => {
|
||
|
const { code, data } = res;
|
||
|
if (code == 200) {
|
||
|
setUserOrgAll(data)
|
||
|
}
|
||
|
|
||
|
})
|
||
|
}, [])
|
||
|
|
||
|
return (
|
||
|
<Select
|
||
|
value={value}
|
||
|
onChange={onChange}
|
||
|
placeholder={placeholder}
|
||
|
disabled={disabled}
|
||
|
allowClear
|
||
|
style={{ width: '100%' }}
|
||
|
showSearch
|
||
|
optionFilterProp="label"
|
||
|
>
|
||
|
{userOrgAll?.map(item => (
|
||
|
<Select.Option key={item.orgId} value={item.orgId}>{item.orgName}</Select.Option>
|
||
|
))}
|
||
|
</Select>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default AccessDepartmentSelect;
|