This commit is contained in:
linxd
2025-07-16 09:26:13 +08:00
5 changed files with 78 additions and 95 deletions

View File

@ -1,56 +1,55 @@
import React, { useState, useEffect } from 'react';
import { Select } from 'antd';
import { queryUserOrgAll } from './services'
import { TreeSelect } from 'antd';
export interface AccessDepartmentSelectProps {
value?: string | number;
onChange?: (value: string | number) => void;
options?: { label: string; value: string | number }[];
placeholder?: string;
disabled?: boolean;
value?: string | number;
onChange?: (value: string | number) => void;
placeholder?: string;
disabled?: boolean;
}
interface Dict {
orgName: string;
orgId: string;
interface orgData {
orgName: string;
orgId: string;
children?: orgData[];
}
const AccessDepartmentSelect: React.FC<AccessDepartmentSelectProps> = ({
value,
onChange,
placeholder = '请选择准入部门',
disabled = false,
value,
onChange,
placeholder = '请选择准入部门',
disabled = false,
}) => {
const [userOrgAll, setUserOrgAll] = useState<orgData[]>([]);
//部门
const [userOrgAll, setUserOrgAll] = useState<Dict[]>();
useEffect(() => {
queryUserOrgAll().then((res) => {
const { code, data } = res;
if (code == 200) {
setUserOrgAll(data)
}
useEffect(() => {
const userOrgAllStr = sessionStorage.getItem('userOrgAll');
const userOrgAll = userOrgAllStr ? JSON.parse(userOrgAllStr) : [];
setUserOrgAll(userOrgAll);
}, []);
})
}, [])
// 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 (
<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>
);
return (
<TreeSelect
value={value}
onChange={onChange}
placeholder={placeholder}
disabled={disabled}
treeData={buildTree(userOrgAll)}
allowClear
style={{ width: '100%' }}
showSearch
/>
);
};
export default AccessDepartmentSelect;

View File

@ -1,10 +1,8 @@
import React, { useEffect, useState } from 'react';
import { Modal, Form, Input, Button, Upload, message, Row, Col, Descriptions, Cascader, Select } from 'antd';
import type { UploadProps } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import { Modal, Form, Input, message, Row, Col, Descriptions, Cascader, Select } from 'antd';
import { getDictList } from '@/servers/api/dicts';
import { uploadFile, bankView, bankAdd, bankEdit, coscoSupplierBase } from '../services';
import { getRegionTree, getregionInternational } from '@/servers/api/register';
import { bankView, bankAdd, bankEdit } from '../services';
import { getRegionTree } from '@/servers/api/register';
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 (
<Modal
title={readOnly ? '查看' : initialValues ? '修改' : '新增'}

View File

@ -155,7 +155,7 @@ const BaseInfoTab: React.FC<BaseInfoTabProps> = (props) => {
{registerInfo.coscoSupplierBase.idCard}
</Descriptions.Item>
<Descriptions.Item label={intl.formatMessage({ id: 'component.globalModal.supplierType' })}>
{registerInfo.coscoSupplierBase.enterpriseType}
{registerInfo.coscoSupplierBase.enterpriseTypeCn}
</Descriptions.Item>
<Descriptions.Item label={intl.formatMessage({ id: 'component.globalModal.contactMobile' })}>
{registerInfo.coscoSupplierBase.contactsPhone}

View File

@ -3,7 +3,7 @@ import { Form, Input, Button, Checkbox, Tabs, message } from 'antd';
import { UserOutlined, LockOutlined, EyeInvisibleOutlined, EyeTwoTone, HomeOutlined } from '@ant-design/icons';
import { history, useIntl } from 'umi';
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 Password from 'antd/lib/input/Password';
@ -41,29 +41,38 @@ const LoginPage: React.FC = () => {
if (loginRes.code === 200) {
sessionStorage.setItem('token', loginRes.data.token);
//存入供应商用户id
if(activeKey === 'supplierLogin') {
if (activeKey === 'supplierLogin') {
sessionStorage.setItem('userId', loginRes.data.supplierUser.userId);
} else if(activeKey === 'expertLogin') {
} else if (activeKey === 'expertLogin') {
//存入专家用户id
// sessionStorage.setItem('userId', loginRes.data.expertUser.userId);
} else if(activeKey === 'accountLogin') {
} else if (activeKey === 'accountLogin') {
//存入招标代理用户id
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));
getUserinfo().then( async (res) => {
getUserinfo().then(async (res) => {
// if(res.code == 200) {
const roleIdList = res.authorityList.map((item:any) => {
return item.roleId
})
console.log(roleIdList,'roleIdList');
const menuList = await findMenuList({ roleIdList });
sessionStorage.setItem('menuList', JSON.stringify(menuList.data));
const roleIdList = res.authorityList.map((item: any) => {
return item.roleId
})
console.log(roleIdList, 'roleIdList');
const menuList = await findMenuList({ roleIdList });
sessionStorage.setItem('menuList', JSON.stringify(menuList.data));
// }
})
message.success('登录成功');
history.push('/index');
@ -74,7 +83,7 @@ const LoginPage: React.FC = () => {
setLoading(false);
}
};
const fetchCaptcha = async () => {
const res = await getCaptcha();
@ -91,7 +100,7 @@ const LoginPage: React.FC = () => {
// 根据当前选中的Tab决定跳转到哪个注册页面
const handleRegister = () => {
switch(activeKey) {
switch (activeKey) {
case 'supplierLogin':
history.push('/register/supplier');
break;
@ -180,14 +189,14 @@ const LoginPage: React.FC = () => {
prefix={null}
suffix={
<img
src={`data:image/png;base64,${captchaImg}`}
src={`data:image/png;base64,${captchaImg}`}
alt="验证码"
style={{ cursor: 'pointer', height: 32, verticalAlign: 'middle' }}
onClick={fetchCaptcha}
/>
}
/>
</Form.Item>
</Form.Item>
<Form.Item>
<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">
{intl.formatMessage({ id: 'login.button' })}
</Button>
{activeKey !== 'accountLogin' && renderRegisterLink()}
{activeKey !== 'accountLogin' && renderRegisterLink()}
</Form.Item>
</Form>
</div>

View File

@ -63,3 +63,11 @@ export async function findMenuList(data: any) {
data
});
}
/**
* 部门
*/
export async function queryUserOrgAll() {
return request('/org/queryUserOrgAll', {
method: 'GET'
});
}