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,55 +1,54 @@
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[]>([]);
//部门
const [userOrgAll, setUserOrgAll] = useState<Dict[]>();
useEffect(() => { useEffect(() => {
queryUserOrgAll().then((res) => { const userOrgAllStr = sessionStorage.getItem('userOrgAll');
const { code, data } = res; const userOrgAll = userOrgAllStr ? JSON.parse(userOrgAllStr) : [];
if (code == 200) { setUserOrgAll(userOrgAll);
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}
treeData={buildTree(userOrgAll)}
allowClear allowClear
style={{ width: '100%' }} style={{ width: '100%' }}
showSearch showSearch
optionFilterProp="label" />
>
{userOrgAll?.map(item => (
<Select.Option key={item.orgId} value={item.orgId}>{item.orgName}</Select.Option>
))}
</Select>
); );
}; };

View File

@ -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 ? '修改' : '新增'}

View File

@ -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}

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 { 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';
@ -49,6 +49,13 @@ const LoginPage: React.FC = () => {
} 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));
@ -65,6 +72,8 @@ const LoginPage: React.FC = () => {
}) })
message.success('登录成功'); message.success('登录成功');
history.push('/index'); history.push('/index');
} else { } else {

View File

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