Compare commits
2 Commits
668f853303
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ae49516b4 | ||
|
|
063905292c |
74
src/app.tsx
74
src/app.tsx
@@ -6,7 +6,7 @@ import type { RunTimeLayoutConfig } from '@umijs/max';
|
|||||||
import { history } from '@umijs/max';
|
import { history } from '@umijs/max';
|
||||||
import defaultSettings from '../config/defaultSettings';
|
import defaultSettings from '../config/defaultSettings';
|
||||||
import { errorConfig } from './requestErrorConfig';
|
import { errorConfig } from './requestErrorConfig';
|
||||||
import { clearSessionToken, getAccessToken, getRefreshToken, getTokenExpireTime } from './access';
|
import { clearSessionToken, getAccessToken,setSessionToken, getRefreshToken, getTokenExpireTime } from './access';
|
||||||
import {
|
import {
|
||||||
getRemoteMenu,
|
getRemoteMenu,
|
||||||
getRoutersInfo,
|
getRoutersInfo,
|
||||||
@@ -64,12 +64,53 @@ export async function getInitialState(): Promise<{
|
|||||||
} as API.CurrentUser;
|
} as API.CurrentUser;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
// 如果获取用户信息失败,清除token并跳转到登录页
|
||||||
|
clearSessionToken();
|
||||||
history.push(PageEnum.LOGIN);
|
history.push(PageEnum.LOGIN);
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
// 如果不是登录页面,执行
|
|
||||||
|
// 检查URL参数中是否包含token参数
|
||||||
const { location } = history;
|
const { location } = history;
|
||||||
|
const urlParams = new URL(window.location.href).searchParams;
|
||||||
|
const tokenFromUrl = urlParams.get('token');
|
||||||
|
|
||||||
|
if (tokenFromUrl) {
|
||||||
|
try {
|
||||||
|
// 处理token,去掉Bearer前缀(如果存在)
|
||||||
|
let processedToken = tokenFromUrl.trim();
|
||||||
|
if (processedToken.startsWith('Bearer ')) {
|
||||||
|
processedToken = processedToken.substring(7);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置token(
|
||||||
|
const current = new Date();
|
||||||
|
const expireTime = current.setTime(current.getTime() + 1000 * 12 * 60 * 60); // 12小时过期
|
||||||
|
setSessionToken(processedToken, processedToken, expireTime);
|
||||||
|
|
||||||
|
// 尝试获取用户信息
|
||||||
|
const currentUser = await fetchUserInfo();
|
||||||
|
if (currentUser) {
|
||||||
|
// 成功获取用户信息,清除URL中的token参数并跳转
|
||||||
|
const newSearch = new URLSearchParams(urlParams);
|
||||||
|
newSearch.delete('token');
|
||||||
|
history.push(urlParams.get('redirect') || '/');
|
||||||
|
setTimeout(() => history.go(0), 0);
|
||||||
|
|
||||||
|
return {
|
||||||
|
fetchUserInfo,
|
||||||
|
currentUser,
|
||||||
|
settings: defaultSettings as Partial<LayoutSettings>,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('处理URL token失败:', error);
|
||||||
|
clearSessionToken();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果不是登录页面且没有token参数,正常执行
|
||||||
if (location.pathname !== PageEnum.LOGIN) {
|
if (location.pathname !== PageEnum.LOGIN) {
|
||||||
const currentUser = await fetchUserInfo();
|
const currentUser = await fetchUserInfo();
|
||||||
return {
|
return {
|
||||||
@@ -78,6 +119,7 @@ export async function getInitialState(): Promise<{
|
|||||||
settings: defaultSettings as Partial<LayoutSettings>,
|
settings: defaultSettings as Partial<LayoutSettings>,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fetchUserInfo,
|
fetchUserInfo,
|
||||||
settings: defaultSettings as Partial<LayoutSettings>,
|
settings: defaultSettings as Partial<LayoutSettings>,
|
||||||
@@ -116,6 +158,17 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
|
|||||||
footerRender: () => <Footer />,
|
footerRender: () => <Footer />,
|
||||||
onPageChange: () => {
|
onPageChange: () => {
|
||||||
const { location } = history;
|
const { location } = history;
|
||||||
|
|
||||||
|
// 检查URL参数中是否包含token
|
||||||
|
const urlParams = new URL(window.location.href).searchParams;
|
||||||
|
const tokenFromUrl = urlParams.get('token');
|
||||||
|
|
||||||
|
if (tokenFromUrl) {
|
||||||
|
// 如果有token参数,不执行跳转逻辑,由getInitialState处理
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果没有token参数,执行原有的逻辑
|
||||||
// 如果没有登录,重定向到 login
|
// 如果没有登录,重定向到 login
|
||||||
if (!initialState?.currentUser && location.pathname !== PageEnum.LOGIN) {
|
if (!initialState?.currentUser && location.pathname !== PageEnum.LOGIN) {
|
||||||
history.push(PageEnum.LOGIN);
|
history.push(PageEnum.LOGIN);
|
||||||
@@ -197,14 +250,29 @@ export async function patchClientRoutes({ routes }) {
|
|||||||
|
|
||||||
export async function render(oldRender: () => void) {
|
export async function render(oldRender: () => void) {
|
||||||
console.log('render get routers', oldRender);
|
console.log('render get routers', oldRender);
|
||||||
|
|
||||||
|
// 检查URL参数中是否包含token
|
||||||
|
const urlParams = new URL(window.location.href).searchParams;
|
||||||
|
const tokenFromUrl = urlParams.get('token');
|
||||||
|
|
||||||
|
if (tokenFromUrl) {
|
||||||
|
// 如果URL中有token参数,已经在getInitialState中处理过了
|
||||||
const token = getAccessToken();
|
const token = getAccessToken();
|
||||||
if (!token || token?.length === 0) {
|
if (!token || token?.length === 0) {
|
||||||
oldRender();
|
oldRender();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// 原有逻辑:检查本地存储的token
|
||||||
|
const token = getAccessToken();
|
||||||
|
if (!token || token?.length === 0) {
|
||||||
|
oldRender();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await getRoutersInfo().then((res) => {
|
await getRoutersInfo().then((res) => {
|
||||||
console.log('render get routers', 123);
|
console.log('render get routers', 123);
|
||||||
|
|
||||||
setRemoteMenu(res);
|
setRemoteMenu(res);
|
||||||
oldRender();
|
oldRender();
|
||||||
});
|
});
|
||||||
|
|||||||
177
src/pages/CaseManagementAndTracking/CaseManagement/index.tsx
Normal file
177
src/pages/CaseManagementAndTracking/CaseManagement/index.tsx
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
import React, { Fragment, useRef, useState } from 'react';
|
||||||
|
import { Button, FormInstance, message } from 'antd';
|
||||||
|
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
|
||||||
|
|
||||||
|
export default function CaseManagement() {
|
||||||
|
const actionRef = useRef<ActionType>();
|
||||||
|
const formTableRef = useRef<FormInstance>()
|
||||||
|
|
||||||
|
const columns: ProColumns<API.StorageDetection.StorageItem>[] = [
|
||||||
|
{
|
||||||
|
title: '序号',
|
||||||
|
dataIndex: 'storageDate',
|
||||||
|
valueType: 'text',
|
||||||
|
render: (_, record, index) => index + 1,
|
||||||
|
align: 'center',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '投诉编号',
|
||||||
|
dataIndex: 'detectionId',
|
||||||
|
valueType: 'text',
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '行业类别',
|
||||||
|
dataIndex: 'industry',
|
||||||
|
valueType: 'text',
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '用工所在地',
|
||||||
|
dataIndex: 'address',
|
||||||
|
valueType: 'text',
|
||||||
|
align: 'center',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '投诉单位',
|
||||||
|
dataIndex: 'unit',
|
||||||
|
valueType: 'text',
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '投诉人',
|
||||||
|
dataIndex: 'websiteName',
|
||||||
|
valueType: 'text',
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '投诉人手机号',
|
||||||
|
dataIndex: 'number',
|
||||||
|
valueType: 'text',
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '欠薪人数',
|
||||||
|
dataIndex: 'wage',
|
||||||
|
valueType: 'text',
|
||||||
|
align: 'center',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '欠薪金额(万元)',
|
||||||
|
dataIndex: 'amount',
|
||||||
|
valueType: 'text',
|
||||||
|
align: 'center',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '欠薪日期',
|
||||||
|
dataIndex: 'storageDate',
|
||||||
|
valueType: 'text',
|
||||||
|
align: 'center',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '欠薪区域',
|
||||||
|
dataIndex: 'wageArrearsArea',
|
||||||
|
valueType: 'text',
|
||||||
|
align: 'center',
|
||||||
|
hideInSearch: true,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '案件状态',
|
||||||
|
dataIndex: 'failedReason',
|
||||||
|
valueType: 'text',
|
||||||
|
align: 'center',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作状态',
|
||||||
|
dataIndex: 'failedReason',
|
||||||
|
valueType: 'text',
|
||||||
|
hideInSearch: true,
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// title: '操作',
|
||||||
|
// hideInSearch: true,
|
||||||
|
// align: 'center',
|
||||||
|
// dataIndex: 'detectionId',
|
||||||
|
// width: 120,
|
||||||
|
// // render: (detectionId, record) => (
|
||||||
|
// // <div style={{ display: 'flex', justifyContent: 'center', gap: 8 }}>
|
||||||
|
// // <Button
|
||||||
|
// // type="link"
|
||||||
|
// // size="small"
|
||||||
|
// // key="view"
|
||||||
|
// // icon={<EyeOutlined />}
|
||||||
|
// // loading={loading}
|
||||||
|
// // hidden={!access.hasPerms('recruitmentDataCollection:jobMonitor:view')}
|
||||||
|
// // onClick={() => handleViewDetail(detectionId)}
|
||||||
|
// // >
|
||||||
|
// // 查看详情
|
||||||
|
// // </Button>
|
||||||
|
// // </div>
|
||||||
|
// // ),
|
||||||
|
// },
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div style={{ width: '100%', float: 'right' }}>
|
||||||
|
<ProTable<API.StorageDetection.StorageItem>
|
||||||
|
actionRef={actionRef}
|
||||||
|
formRef={formTableRef}
|
||||||
|
rowKey="detectionId"
|
||||||
|
key="storageDetectionIndex"
|
||||||
|
columns={columns}
|
||||||
|
search={{ labelWidth: 'auto' }}
|
||||||
|
request={async (params) => {
|
||||||
|
// 模拟 API 响应
|
||||||
|
return {
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
detectionId: '230',
|
||||||
|
storageDate: '2023-01-01',
|
||||||
|
storageDetail: '存储详情1',
|
||||||
|
failedReason: '正在处理',
|
||||||
|
industry: '销售',
|
||||||
|
address: '石河子',
|
||||||
|
unit: '石河子市水利局',
|
||||||
|
websiteName: '测试1',
|
||||||
|
number: '1234567890',
|
||||||
|
wage: '2',
|
||||||
|
amount: '1111',
|
||||||
|
wageArrearsArea: '石河子市',
|
||||||
|
|
||||||
|
// ... 其他字段
|
||||||
|
},
|
||||||
|
{
|
||||||
|
detectionId: '231',
|
||||||
|
storageDate: '2023-01-01',
|
||||||
|
storageDetail: '存储详情1',
|
||||||
|
failedReason: '正在处理',
|
||||||
|
industry: '销售',
|
||||||
|
address: '石河子',
|
||||||
|
unit: '石河子市水利局',
|
||||||
|
websiteName: '测试1',
|
||||||
|
number: '1234567890',
|
||||||
|
wage: '2',
|
||||||
|
amount: '1111',
|
||||||
|
wageArrearsArea: '石河子市',
|
||||||
|
|
||||||
|
// ... 其他字段
|
||||||
|
},
|
||||||
|
],
|
||||||
|
total: 2,
|
||||||
|
success: true,
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ export function setRemoteMenu(data: any) {
|
|||||||
|
|
||||||
function patchRouteItems(route: any, menu: any, parentPath: string) {
|
function patchRouteItems(route: any, menu: any, parentPath: string) {
|
||||||
for (const menuItem of menu) {
|
for (const menuItem of menu) {
|
||||||
|
console.log(menuItem, 'menuItem')
|
||||||
if (menuItem.component === 'Layout' || menuItem.component === 'ParentView') {
|
if (menuItem.component === 'Layout' || menuItem.component === 'ParentView') {
|
||||||
if (menuItem.routes) {
|
if (menuItem.routes) {
|
||||||
let hasItem = false;
|
let hasItem = false;
|
||||||
@@ -38,9 +39,10 @@ function patchRouteItems(route: any, menu: any, parentPath: string) {
|
|||||||
patchRouteItems(newItem, menuItem.routes, parentPath + menuItem.path + '/');
|
patchRouteItems(newItem, menuItem.routes, parentPath + menuItem.path + '/');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const names: string[] = menuItem.component.split('/');
|
const names: string[] = menuItem.component && menuItem.component.split('/');
|
||||||
|
console.log(names, 'names')
|
||||||
let path = '';
|
let path = '';
|
||||||
names.forEach(name => {
|
names && names.forEach(name => {
|
||||||
if (path.length > 0) {
|
if (path.length > 0) {
|
||||||
path += '/';
|
path += '/';
|
||||||
}
|
}
|
||||||
|
|||||||
49
src/types/CaseManagementAndTracking/CaseManagement.d.ts
vendored
Normal file
49
src/types/CaseManagementAndTracking/CaseManagement.d.ts
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
declare namespace API.StorageDetection {
|
||||||
|
export interface StorageDetailItem {
|
||||||
|
detailId?: string;
|
||||||
|
websiteId?: string;
|
||||||
|
websiteName?: string;
|
||||||
|
successNumber?: string;
|
||||||
|
failedNumber?: string;
|
||||||
|
storageDetail?: string;
|
||||||
|
storageTime?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StorageItem {
|
||||||
|
detectionId?: string;
|
||||||
|
storageDate?: string;
|
||||||
|
storageNumber?: string;
|
||||||
|
storageResult?: string;
|
||||||
|
storageDetail?: string;
|
||||||
|
websiteId?: string;
|
||||||
|
websiteName?: string;
|
||||||
|
details?: StorageDetailItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AddParams {
|
||||||
|
storageDate?: string;
|
||||||
|
storageNumber?: string;
|
||||||
|
storageResult?: string;
|
||||||
|
storageDetail?: string;
|
||||||
|
websiteName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ListParams {
|
||||||
|
storageDate?: string;
|
||||||
|
pageSize?: number;
|
||||||
|
current?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StorageIdResult {
|
||||||
|
code: number;
|
||||||
|
msg: string;
|
||||||
|
data: StorageItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StoragePageResult {
|
||||||
|
code: number;
|
||||||
|
msg: string;
|
||||||
|
total: number;
|
||||||
|
rows: Array<StorageItem>;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user