准入部门 接口联调
This commit is contained in:
@ -7,6 +7,7 @@ export interface AccessDepartmentSelectProps {
|
||||
onChange?: (value: string | number) => void;
|
||||
placeholder?: string;
|
||||
disabled?: boolean;
|
||||
orgCategory?: string;
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
|
||||
@ -18,6 +19,7 @@ interface OrgNode {
|
||||
isLeaf?: boolean;
|
||||
key?: string;
|
||||
title?: string;
|
||||
orgCategory?: string;
|
||||
}
|
||||
|
||||
const AccessDepartmentSelect: React.FC<AccessDepartmentSelectProps> = ({
|
||||
@ -26,6 +28,7 @@ const AccessDepartmentSelect: React.FC<AccessDepartmentSelectProps> = ({
|
||||
placeholder = '请选择准入部门',
|
||||
disabled = false,
|
||||
style = { width: 200 },
|
||||
orgCategory = 'Org'
|
||||
}) => {
|
||||
const [tree, setTree] = useState<OrgNode[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@ -37,6 +40,7 @@ const AccessDepartmentSelect: React.FC<AccessDepartmentSelectProps> = ({
|
||||
title: item.orgName,
|
||||
value: item.orgId,
|
||||
key: item.orgId,
|
||||
disabled: orgCategory === '' && item.orgCategory === 'Org',
|
||||
// isLeaf: item.isLeaf || false,
|
||||
// children: item.children && item.children.length > 0 ? formatTree(item.children) : undefined,
|
||||
}));
|
||||
@ -46,7 +50,12 @@ const AccessDepartmentSelect: React.FC<AccessDepartmentSelectProps> = ({
|
||||
const onLoadData = async (treeNode: any) => {
|
||||
if (treeNode.children && treeNode.children.length > 0) return;
|
||||
setLoading(true);
|
||||
const { code, data } = await treeData({ upOrgId: treeNode.value });
|
||||
const params: any = { upOrgId: treeNode.value };
|
||||
if(orgCategory) {
|
||||
params.orgCategory = orgCategory
|
||||
}
|
||||
|
||||
const { code, data } = await treeData(params);
|
||||
if (code === 200 && Array.isArray(data)) {
|
||||
setTree(origin => updateNode(origin, treeNode.value, formatTree(data)));
|
||||
}
|
||||
@ -65,7 +74,13 @@ const AccessDepartmentSelect: React.FC<AccessDepartmentSelectProps> = ({
|
||||
// 初始化
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
treeData({}).then(res => {
|
||||
const orgIdStr = sessionStorage.getItem('Userinfo');
|
||||
const currentUser = orgIdStr ? JSON.parse(orgIdStr) : null;
|
||||
const params: any = { orgId: currentUser.organizationId };
|
||||
if(orgCategory) {
|
||||
params.orgCategory = orgCategory
|
||||
}
|
||||
treeData(params).then(res => {
|
||||
if (res.code === 200 && Array.isArray(res.data)) {
|
||||
setTree(formatTree(res.data));
|
||||
}
|
||||
|
@ -1,23 +1,28 @@
|
||||
import request from '@/utils/request';
|
||||
|
||||
|
||||
/**
|
||||
* 获取全部组织树形结构
|
||||
*/
|
||||
interface treeInterface {
|
||||
upOrgId?: string;
|
||||
orgId?: string;
|
||||
orgCategory?: string; //Org
|
||||
}
|
||||
export const treeData = (params: treeInterface) => request.get('/org/list', { params });
|
||||
|
||||
|
||||
/**
|
||||
* 部门
|
||||
*/
|
||||
export const queryUserOrgAll = () => request.get(`/org/queryUserOrgAll`);
|
||||
|
||||
|
||||
/**
|
||||
* 部门列表
|
||||
*
|
||||
* 获取当前登录人所属单位以及下级单位
|
||||
*/
|
||||
interface treeInterface {
|
||||
upOrgId?: string
|
||||
}
|
||||
export const treeData = (params: treeInterface) => request.get('/org/list', { params });
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export const queryOrgWithChildren = (params: treeInterface) => request.get('/org/queryOrgWithChildren', { params });
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user