部门与退出
This commit is contained in:
56
src/components/AccessDepartmentSelect/index.tsx
Normal file
56
src/components/AccessDepartmentSelect/index.tsx
Normal file
@ -0,0 +1,56 @@
|
||||
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;
|
30
src/components/AccessDepartmentSelect/services.ts
Normal file
30
src/components/AccessDepartmentSelect/services.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import request from '@/utils/request';
|
||||
|
||||
/**
|
||||
* 部门
|
||||
*/
|
||||
export const queryUserOrgAll = () => request.get(`/org/queryUserOrgAll`);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -84,7 +84,7 @@ const InvoiceTab: React.FC<InvoiceTabProps> = (props) => {
|
||||
|
||||
const columns: ColumnsType<InvoiceInfo> = [
|
||||
{ title: 'page.workbench.invoice.index', dataIndex: 'index', width: 80, key: 'index', render: (_: any, __: any, index: number) => index + 1 },
|
||||
{ title: 'page.workbench.invoice.taxpayerType', dataIndex: 'taxpayerType', ellipsis: true },
|
||||
{ title: 'page.workbench.invoice.taxpayerType', dataIndex: 'taxpayerTypeCn', ellipsis: true },
|
||||
{ title: 'page.workbench.invoice.taxpayerCode', dataIndex: 'taxpayerCode', ellipsis: true },
|
||||
{ title: 'page.workbench.invoice.head', dataIndex: 'head', ellipsis: true },
|
||||
{ title: 'page.workbench.invoice.address', dataIndex: 'address', ellipsis: true },
|
||||
|
@ -4,29 +4,41 @@ import LogoImg from '@/assets/img/logo.png';
|
||||
//导入菜单组件
|
||||
import Language from './Language';
|
||||
import User from './User';
|
||||
import { history } from 'umi';
|
||||
import './layout.less';
|
||||
|
||||
import { Logout } from '@/servers/api/login';
|
||||
|
||||
const HeaderComponent: React.FC = () => {
|
||||
// 用 state 保存 userId
|
||||
const [userId, setUserId] = useState(() => sessionStorage.getItem('userId'));
|
||||
// 用 state 保存 userId
|
||||
const [userId, setUserId] = useState(() => sessionStorage.getItem('userId'));
|
||||
|
||||
useEffect(() => {
|
||||
// 定义一个方法用于手动刷新 userId
|
||||
const refreshUserId = () => setUserId(sessionStorage.getItem('userId'));
|
||||
// 登录后你可以手动调用 refreshUserId
|
||||
// 或者监听页面 storage 事件(多窗口/多tab同步)
|
||||
window.addEventListener('storage', refreshUserId);
|
||||
// 页面内操作,比如登录成功后,也可以在登录回调里调用 setUserId
|
||||
return () => window.removeEventListener('storage', refreshUserId);
|
||||
}, []);
|
||||
const handLogout = () => {
|
||||
Logout()
|
||||
sessionStorage.clear();
|
||||
history.replace('/login');
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
// 定义一个方法用于手动刷新 userId
|
||||
const refreshUserId = () => setUserId(sessionStorage.getItem('userId'));
|
||||
// 登录后你可以手动调用 refreshUserId
|
||||
// 或者监听页面 storage 事件(多窗口/多tab同步)
|
||||
window.addEventListener('storage', refreshUserId);
|
||||
// 页面内操作,比如登录成功后,也可以在登录回调里调用 setUserId
|
||||
return () => window.removeEventListener('storage', refreshUserId);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="headerComponent">
|
||||
<img className="logo" src={LogoImg} alt="logo" />
|
||||
<div className="flex">
|
||||
<Language />
|
||||
<User />
|
||||
{!userId ? (
|
||||
<User />
|
||||
) : (
|
||||
<div style={{cursor: 'pointer'}} onClick={handLogout}>退出</div>
|
||||
)}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
|
||||
import { Modal, Form, Select, Button, Tree, message, Input } from 'antd';
|
||||
//组件
|
||||
import SupplierSelector from './SupplierSelector';
|
||||
import AccessDepartmentSelect from '@/components/AccessDepartmentSelect';
|
||||
// 请求
|
||||
import { categoryTree, add } from '../services';
|
||||
const { Option } = Select;
|
||||
@ -143,10 +144,7 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi
|
||||
name="deptId"
|
||||
rules={[{ required: true, message: '请选择准入部门' }]}
|
||||
>
|
||||
<Select placeholder="请选择部门">
|
||||
<Option value="DEPT001">部门A</Option>
|
||||
<Option value="DEPT001">部门B</Option>
|
||||
</Select>
|
||||
<AccessDepartmentSelect />
|
||||
</Form.Item>
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@ import type { ColumnsType } from 'antd/es/table';
|
||||
import { getApprovePage } from './services';
|
||||
import { getDictList } from '@/servers/api/dicts'
|
||||
//组件
|
||||
import AccessDepartmentSelect from '@/components/AccessDepartmentSelect';
|
||||
import ViewModal from './components/ViewModal';
|
||||
//统一列表分页
|
||||
import tableProps from '@/utils/tableProps'
|
||||
@ -218,7 +219,7 @@ const SupplierEntryReview: React.FC = () => {
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item name="deptId" label="准入部门">
|
||||
<Select options={deptOptions} allowClear style={{ width: 120 }} placeholder="请选择准入部门" />
|
||||
<AccessDepartmentSelect />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="approveStatus" label="审批状态">
|
||||
|
@ -9,6 +9,8 @@ import DivisionModal from './DivisionModal';
|
||||
// 请求
|
||||
import { categoryTree, add, uploadFile } from '../services';
|
||||
|
||||
import AccessDepartmentSelect from '@/components/AccessDepartmentSelect';
|
||||
|
||||
const { Option } = Select;
|
||||
const { RangePicker } = DatePicker;
|
||||
//selected 类型
|
||||
@ -276,10 +278,7 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi
|
||||
name="deptId"
|
||||
rules={[{ required: true, message: '请选择准入部门' }]}
|
||||
>
|
||||
<Select placeholder="请选择部门">
|
||||
<Option value="DEPT001">部门A</Option>
|
||||
<Option value="DEPT001">部门B</Option>
|
||||
</Select>
|
||||
<AccessDepartmentSelect />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
|
@ -150,8 +150,8 @@ const AccessManagement: React.FC = () => {
|
||||
<Form.Item name="categoryId" label="准入品类">
|
||||
<CategorySelector multiple={false} style={{ width: 150 }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="approveStatus" label="评审状态">
|
||||
<Select style={{ width: 150 }} placeholder="请选择评审状态" allowClear>
|
||||
<Form.Item name="approveStatus" label="审批状态">
|
||||
<Select style={{ width: 150 }} placeholder="请选择审批状态" allowClear>
|
||||
<Option value="0">未开始</Option>
|
||||
<Option value="1">进行中</Option>
|
||||
<Option value="2">结果汇总中</Option>
|
||||
|
@ -3,7 +3,7 @@ import { Modal, Form, Input, DatePicker, Button, Tree, Select, message, Spin, Up
|
||||
import { UploadOutlined } from '@ant-design/icons';
|
||||
import { categoryTree, uploadFile, superiorLockList, getSupplierPage, library, libraryData } from '../services';
|
||||
import type { UploadFile } from 'antd/es/upload/interface';
|
||||
|
||||
import AccessDepartmentSelect from '@/components/AccessDepartmentSelect';
|
||||
import { getregionInternational } from '@/servers/api/register';
|
||||
const { Option } = Select;
|
||||
|
||||
@ -239,14 +239,7 @@ const CategoryAddModal: React.FC<Props> = ({ visible, onCancel, onSuccess }) =>
|
||||
name="applyDeptId"
|
||||
rules={[{ required: true, message: '请选择品类库负责人' }]}
|
||||
>
|
||||
<Select
|
||||
placeholder="请选择品类库负责人"
|
||||
style={{ width: 260 }}
|
||||
options={deptOptions.map(item => ({
|
||||
label: item.deptId,
|
||||
value: item.deptId,
|
||||
}))}
|
||||
/>
|
||||
<AccessDepartmentSelect />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="选择品类"
|
||||
|
@ -203,7 +203,9 @@ const SupplierAddModal: React.FC<{
|
||||
showQuickJumper: true,
|
||||
onChange: (page, pageSize) => handleTableChange({ current: page, pageSize }),
|
||||
}}
|
||||
bordered
|
||||
style={{ flex: 1, minHeight: 0 }}
|
||||
scroll={{ y: 'calc(100vh - 650px)' }}
|
||||
|
||||
/>
|
||||
</Spin>
|
||||
</Modal>
|
||||
|
@ -220,7 +220,8 @@ const SupplierAddModal: React.FC<{
|
||||
showQuickJumper: true,
|
||||
onChange: (page, pageSize) => handleTableChange({ current: page, pageSize }),
|
||||
}}
|
||||
bordered
|
||||
style={{ flex: 1, minHeight: 0 }}
|
||||
scroll={{ y: 'calc(100vh - 650px)' }}
|
||||
/>
|
||||
</Spin>
|
||||
</Modal>
|
||||
|
@ -140,7 +140,8 @@ const ViewModal: React.FC<{
|
||||
dataSource={categoryInfo.coscoCategoryLibrarySupplierVos}
|
||||
rowKey="id"
|
||||
pagination={false}
|
||||
bordered
|
||||
style={{ flex: 1, minHeight: 0 }}
|
||||
scroll={{ y: 'calc(100vh - 650px)' }}
|
||||
/>
|
||||
|
||||
|
||||
|
@ -51,7 +51,7 @@ export async function getUserinfo() {
|
||||
*/
|
||||
export async function Logout() {
|
||||
return request('/v1/login/logout', {
|
||||
method: 'GET'
|
||||
method: 'POST'
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
Reference in New Issue
Block a user