部门
This commit is contained in:
@ -1,56 +1,55 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Select } from 'antd';
|
import { TreeSelect } from 'antd';
|
||||||
import { queryUserOrgAll } from './services'
|
|
||||||
|
|
||||||
export interface AccessDepartmentSelectProps {
|
export interface AccessDepartmentSelectProps {
|
||||||
value?: string | number;
|
value?: string | number;
|
||||||
onChange?: (value: string | number) => void;
|
onChange?: (value: string | number) => void;
|
||||||
options?: { label: string; value: string | number }[];
|
placeholder?: string;
|
||||||
placeholder?: string;
|
disabled?: boolean;
|
||||||
disabled?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Dict {
|
interface orgData {
|
||||||
orgName: string;
|
orgName: string;
|
||||||
orgId: string;
|
orgId: string;
|
||||||
|
children?: orgData[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const AccessDepartmentSelect: React.FC<AccessDepartmentSelectProps> = ({
|
const AccessDepartmentSelect: React.FC<AccessDepartmentSelectProps> = ({
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
placeholder = '请选择准入部门',
|
placeholder = '请选择准入部门',
|
||||||
disabled = false,
|
disabled = false,
|
||||||
}) => {
|
}) => {
|
||||||
|
const [userOrgAll, setUserOrgAll] = useState<orgData[]>([]);
|
||||||
|
|
||||||
//部门
|
useEffect(() => {
|
||||||
const [userOrgAll, setUserOrgAll] = useState<Dict[]>();
|
const userOrgAllStr = sessionStorage.getItem('userOrgAll');
|
||||||
useEffect(() => {
|
const userOrgAll = userOrgAllStr ? JSON.parse(userOrgAllStr) : [];
|
||||||
queryUserOrgAll().then((res) => {
|
setUserOrgAll(userOrgAll);
|
||||||
const { code, data } = res;
|
}, []);
|
||||||
if (code == 200) {
|
|
||||||
setUserOrgAll(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
// TreeSelect 要的数据结构
|
||||||
}, [])
|
function buildTree(data: orgData[]): any[] {
|
||||||
|
return data.map(item => ({
|
||||||
|
title: item.orgName,
|
||||||
|
value: item.orgId,
|
||||||
|
key: item.orgId,
|
||||||
|
children: item.children && item.children.length > 0 ? buildTree(item.children) : undefined,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select
|
<TreeSelect
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
allowClear
|
treeData={buildTree(userOrgAll)}
|
||||||
style={{ width: '100%' }}
|
allowClear
|
||||||
showSearch
|
style={{ width: '100%' }}
|
||||||
optionFilterProp="label"
|
showSearch
|
||||||
>
|
/>
|
||||||
{userOrgAll?.map(item => (
|
);
|
||||||
<Select.Option key={item.orgId} value={item.orgId}>{item.orgName}</Select.Option>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AccessDepartmentSelect;
|
export default AccessDepartmentSelect;
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Modal, Form, Input, Button, Upload, message, Row, Col, Descriptions, Cascader, Select } from 'antd';
|
import { Modal, Form, Input, message, Row, Col, Descriptions, Cascader, Select } from 'antd';
|
||||||
import type { UploadProps } from 'antd';
|
|
||||||
import { UploadOutlined } from '@ant-design/icons';
|
|
||||||
import { getDictList } from '@/servers/api/dicts';
|
import { getDictList } from '@/servers/api/dicts';
|
||||||
import { uploadFile, bankView, bankAdd, bankEdit, coscoSupplierBase } from '../services';
|
import { bankView, bankAdd, bankEdit } from '../services';
|
||||||
import { getRegionTree, getregionInternational } from '@/servers/api/register';
|
import { getRegionTree } from '@/servers/api/register';
|
||||||
import type { DictItem } from '@/servers/api/dicts';
|
import type { DictItem } from '@/servers/api/dicts';
|
||||||
|
|
||||||
// 地区字段转换
|
// 地区字段转换
|
||||||
@ -132,37 +130,6 @@ const InvoiceFormModal: React.FC<props> = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//上传接口
|
|
||||||
const uploadProps: UploadProps = {
|
|
||||||
name: 'file',
|
|
||||||
showUploadList: true,
|
|
||||||
beforeUpload: (file) => {
|
|
||||||
if (file.size > 1048576) { // 1MB
|
|
||||||
message.error('文件大小不能超过1MB');
|
|
||||||
return Upload.LIST_IGNORE; // 阻止上传
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
customRequest: async ({ file, onSuccess, onError }) => {
|
|
||||||
try {
|
|
||||||
const realFile = file as File;
|
|
||||||
const res = await uploadFile(realFile);
|
|
||||||
const uploadedFile = {
|
|
||||||
uid: res.fileSize,
|
|
||||||
name: res.fileName,
|
|
||||||
status: 'done',
|
|
||||||
url: res.url,
|
|
||||||
response: res,
|
|
||||||
};
|
|
||||||
onSuccess?.(uploadedFile, new XMLHttpRequest())
|
|
||||||
message.success('上传成功');
|
|
||||||
} catch (err: any) {
|
|
||||||
onError?.(err);
|
|
||||||
message.error(err.message || '上传失败');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={readOnly ? '查看' : initialValues ? '修改' : '新增'}
|
title={readOnly ? '查看' : initialValues ? '修改' : '新增'}
|
||||||
|
@ -155,7 +155,7 @@ const BaseInfoTab: React.FC<BaseInfoTabProps> = (props) => {
|
|||||||
{registerInfo.coscoSupplierBase.idCard}
|
{registerInfo.coscoSupplierBase.idCard}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label={intl.formatMessage({ id: 'component.globalModal.supplierType' })}>
|
<Descriptions.Item label={intl.formatMessage({ id: 'component.globalModal.supplierType' })}>
|
||||||
{registerInfo.coscoSupplierBase.enterpriseType}
|
{registerInfo.coscoSupplierBase.enterpriseTypeCn}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label={intl.formatMessage({ id: 'component.globalModal.contactMobile' })}>
|
<Descriptions.Item label={intl.formatMessage({ id: 'component.globalModal.contactMobile' })}>
|
||||||
{registerInfo.coscoSupplierBase.contactsPhone}
|
{registerInfo.coscoSupplierBase.contactsPhone}
|
||||||
|
@ -3,7 +3,7 @@ import { Form, Input, Button, Checkbox, Tabs, message } from 'antd';
|
|||||||
import { UserOutlined, LockOutlined, EyeInvisibleOutlined, EyeTwoTone, HomeOutlined } from '@ant-design/icons';
|
import { UserOutlined, LockOutlined, EyeInvisibleOutlined, EyeTwoTone, HomeOutlined } from '@ant-design/icons';
|
||||||
import { history, useIntl } from 'umi';
|
import { history, useIntl } from 'umi';
|
||||||
import './login.less';
|
import './login.less';
|
||||||
import { getCaptcha, supplierLogin, expertLogin, accountLogin, getUserinfo, findMenuList } from '@/servers/api/login';
|
import { getCaptcha, supplierLogin, expertLogin, accountLogin, getUserinfo, findMenuList, queryUserOrgAll } from '@/servers/api/login';
|
||||||
|
|
||||||
import { encryptWithRsa } from '@/utils/encryptWithRsa'
|
import { encryptWithRsa } from '@/utils/encryptWithRsa'
|
||||||
import Password from 'antd/lib/input/Password';
|
import Password from 'antd/lib/input/Password';
|
||||||
@ -41,29 +41,38 @@ const LoginPage: React.FC = () => {
|
|||||||
if (loginRes.code === 200) {
|
if (loginRes.code === 200) {
|
||||||
sessionStorage.setItem('token', loginRes.data.token);
|
sessionStorage.setItem('token', loginRes.data.token);
|
||||||
//存入供应商用户id
|
//存入供应商用户id
|
||||||
if(activeKey === 'supplierLogin') {
|
if (activeKey === 'supplierLogin') {
|
||||||
sessionStorage.setItem('userId', loginRes.data.supplierUser.userId);
|
sessionStorage.setItem('userId', loginRes.data.supplierUser.userId);
|
||||||
} else if(activeKey === 'expertLogin') {
|
} else if (activeKey === 'expertLogin') {
|
||||||
//存入专家用户id
|
//存入专家用户id
|
||||||
// sessionStorage.setItem('userId', loginRes.data.expertUser.userId);
|
// sessionStorage.setItem('userId', loginRes.data.expertUser.userId);
|
||||||
} else if(activeKey === 'accountLogin') {
|
} else if (activeKey === 'accountLogin') {
|
||||||
//存入招标代理用户id
|
//存入招标代理用户id
|
||||||
sessionStorage.setItem('userId', loginRes.data.user.userId);
|
sessionStorage.setItem('userId', loginRes.data.user.userId);
|
||||||
|
//部门
|
||||||
|
queryUserOrgAll().then((res) => {
|
||||||
|
const { code, data } = res;
|
||||||
|
if (code == 200) {
|
||||||
|
sessionStorage.setItem('userOrgAll', JSON.stringify(data) );
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
sessionStorage.setItem('currentUser', JSON.stringify(loginRes.data));
|
sessionStorage.setItem('currentUser', JSON.stringify(loginRes.data));
|
||||||
|
|
||||||
getUserinfo().then( async (res) => {
|
getUserinfo().then(async (res) => {
|
||||||
// if(res.code == 200) {
|
// if(res.code == 200) {
|
||||||
const roleIdList = res.authorityList.map((item:any) => {
|
const roleIdList = res.authorityList.map((item: any) => {
|
||||||
return item.roleId
|
return item.roleId
|
||||||
})
|
})
|
||||||
console.log(roleIdList,'roleIdList');
|
console.log(roleIdList, 'roleIdList');
|
||||||
|
|
||||||
const menuList = await findMenuList({ roleIdList });
|
const menuList = await findMenuList({ roleIdList });
|
||||||
sessionStorage.setItem('menuList', JSON.stringify(menuList.data));
|
sessionStorage.setItem('menuList', JSON.stringify(menuList.data));
|
||||||
// }
|
// }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
message.success('登录成功');
|
message.success('登录成功');
|
||||||
history.push('/index');
|
history.push('/index');
|
||||||
@ -74,7 +83,7 @@ const LoginPage: React.FC = () => {
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const fetchCaptcha = async () => {
|
const fetchCaptcha = async () => {
|
||||||
const res = await getCaptcha();
|
const res = await getCaptcha();
|
||||||
@ -91,7 +100,7 @@ const LoginPage: React.FC = () => {
|
|||||||
|
|
||||||
// 根据当前选中的Tab决定跳转到哪个注册页面
|
// 根据当前选中的Tab决定跳转到哪个注册页面
|
||||||
const handleRegister = () => {
|
const handleRegister = () => {
|
||||||
switch(activeKey) {
|
switch (activeKey) {
|
||||||
case 'supplierLogin':
|
case 'supplierLogin':
|
||||||
history.push('/register/supplier');
|
history.push('/register/supplier');
|
||||||
break;
|
break;
|
||||||
@ -180,14 +189,14 @@ const LoginPage: React.FC = () => {
|
|||||||
prefix={null}
|
prefix={null}
|
||||||
suffix={
|
suffix={
|
||||||
<img
|
<img
|
||||||
src={`data:image/png;base64,${captchaImg}`}
|
src={`data:image/png;base64,${captchaImg}`}
|
||||||
alt="验证码"
|
alt="验证码"
|
||||||
style={{ cursor: 'pointer', height: 32, verticalAlign: 'middle' }}
|
style={{ cursor: 'pointer', height: 32, verticalAlign: 'middle' }}
|
||||||
onClick={fetchCaptcha}
|
onClick={fetchCaptcha}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item>
|
<Form.Item>
|
||||||
<div className='login-options'>
|
<div className='login-options'>
|
||||||
@ -204,7 +213,7 @@ const LoginPage: React.FC = () => {
|
|||||||
<Button type="primary" htmlType="submit" className="login-form-button" loading={loading} size="large">
|
<Button type="primary" htmlType="submit" className="login-form-button" loading={loading} size="large">
|
||||||
{intl.formatMessage({ id: 'login.button' })}
|
{intl.formatMessage({ id: 'login.button' })}
|
||||||
</Button>
|
</Button>
|
||||||
{activeKey !== 'accountLogin' && renderRegisterLink()}
|
{activeKey !== 'accountLogin' && renderRegisterLink()}
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -63,3 +63,11 @@ export async function findMenuList(data: any) {
|
|||||||
data
|
data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 部门
|
||||||
|
*/
|
||||||
|
export async function queryUserOrgAll() {
|
||||||
|
return request('/org/queryUserOrgAll', {
|
||||||
|
method: 'GET'
|
||||||
|
});
|
||||||
|
}
|
Reference in New Issue
Block a user