5.17 增加寻找商机中间页和供应商项目跟进跳转页

This commit is contained in:
jl-zhoujl2
2022-05-17 16:48:28 +08:00
parent 300b5a34d6
commit 60c6c254c4
10 changed files with 266 additions and 134 deletions

View File

@ -50,10 +50,6 @@ export default [
path: '/redirect',
component: './LoadingPage',
},
{
path: '/toAuth',
component: './LoadingPage/ToAuth',
},
//跨工程跳转中间页开始
{
path: '/xunjia',

View File

@ -1,19 +1,54 @@
import { getURLInformation } from '@/utils/CommonUtils';
import { Result } from 'antd';
import React from 'react';
import { getURLInformation, isNotEmpty } from '@/utils/CommonUtils';
import { getSessionRoleData } from '@/utils/session';
import { Result, Typography } from 'antd';
import React, { useEffect, useState } from 'react';
import { history } from 'umi';
const message = {
401: '您的用户信息有误,请联系管理员',
402: '您的用户角色信息缺失,请联系管理员',
90401: '您的登录已超时,请重新登录',
404: '系统错误,请联系管理员',
};
const RequestTimeoutPage: React.FC<{}> = () => {
const code: any = getURLInformation('code') == null ? '404' : getURLInformation('code');
const { Text } = Typography;
const [time, setTime] = useState<number>(10);
const roleData = getSessionRoleData();
useEffect(() => {
let timeInteval: any
if (code == 402 && isNotEmpty(roleData)) {
timeInteval = setInterval(() => { // 倒计时
setTime(n => {
if (n == 1) {
clearInterval(timeInteval)
redirect();
}
return n - 1;
})
}, 1000);
} else {
clearInterval(timeInteval);
}
return () => {
clearInterval(timeInteval);
}
}, []);
const redirect = () => {
if (isNotEmpty(roleData)) {
history.replace({
pathname: '/Dashboard',
})
}
}
return (
<Result
title={message[code]}
extra={isNotEmpty(roleData) && code == 402 && <Text type="secondary" strong>{time}</Text>}
/>
);
};

View File

@ -1,6 +0,0 @@
import request from '@/utils/request';
// 获取字典信息
export async function getDictionaries(){
return request('/api/biz-service-ebtp-project/v1/dictProject/refreshDictCache');
}

View File

@ -0,0 +1,50 @@
import React, { useEffect } from 'react';
import { message, Spin } from 'antd';
import { getURLInformation, isEmpty } from '@/utils/CommonUtils';
import { history } from 'umi';
const Loading: React.FC<{}> = () => {
/**
* 寻找商机中转页
*/
useEffect(() => {
//获取必要参数
//项目编号
const number = getURLInformation('ebpProjectNumber') === null ? '' : getURLInformation('ebpProjectNumber');
//菜单类型
const type = getURLInformation('type') === null ? '' : getURLInformation('type');
if (isEmpty(type)) {
message.error('缺少必要参数,请重试');
} else {
let params = {}
isEmpty(number) ? null : params['number'] = number
if (type == 'procurement_mode_1' || type == 'procurement_mode_2') {//招标类
history.push({ pathname: '/Bid/FindBusiness', query: { ...params } });
} else if (type == 'procurement_mode_5' || type == 'procurement_mode_6') {//谈判类
history.push({ pathname: '/Negotiation/FindBusiness', query: { ...params } });
} else if (type == 'procurement_mode_4') {//招募类
history.push({ pathname: '/Recruit/FindBusiness', query: { ...params } });
} else if (type == 'procurement_mode_3') {//比选类
history.push({ pathname: '/Comparison/FindBusiness', query: { ...params } });
} else {
message.error('参数错误,请联系管理员');
}
}
}, []);
return (
<div
style={{
textAlign: 'center',
height: '100%',
background: 'rgba(0,0,0,.05)',
position: 'relative',
}}
>
<div style={{ position: 'absolute', left: '50%', top: '48%' }}>
<Spin tip="Loading..." />
</div>
</div>
);
};
export default Loading;

View File

@ -0,0 +1,59 @@
import React, { useEffect } from 'react';
import { message, Spin } from 'antd';
import { getURLInformation, isEmpty } from '@/utils/CommonUtils';
import { followUpAProjectManager, followUpAProjectSupplier, getSessionRoleData } from '@/utils/session';
import { history } from 'umi';
import { getProjectById } from '../service';
const Loading: React.FC<{}> = () => {
/**
* 项目跟进中转页
*/
//获取角色
const role = getSessionRoleData()?.roleCode;
useEffect(() => {
//获取必要参数
const projectId = getURLInformation('id') === null ? '' : getURLInformation('id');
if (isEmpty(projectId)) {
message.error('缺少必要参数,请重试');
} else {
//获取项目数据
getProjectById(projectId).then((res) => {
if (res?.code == 200 && res?.success == true) {
const data = res?.data;
if (role == "ebtp-purchase" || role == "ebtp-agency-project-manager") {//采购经理或代理
//调用存储session方法
followUpAProjectManager(data);
setTimeout(() => {
history.push('./ProjectLayout/Manager/HomePageSectionList');
}, 1000);
} else if (role == "ebtp-supplier") {//供应商
followUpAProjectSupplier(data);
setTimeout(() => {
history.push('./ProjectLayout/Supplier/HomePageSectionList');
}, 1000);
} else {
message.error("用户角色信息获取错误,请联系管理员")
}
}
});
}
}, []);
return (
<div
style={{
textAlign: 'center',
height: '100%',
background: 'rgba(0,0,0,.05)',
position: 'relative',
}}
>
<div style={{ position: 'absolute', left: '50%', top: '48%' }}>
<Spin tip="Loading..." />
</div>
</div>
);
};
export default Loading;

View File

@ -1,30 +0,0 @@
import React, { useEffect } from 'react';
import { Button, message, Spin } from 'antd';
import request from '@/utils/request';
import { JumpToOutside } from '@/utils/CommonUtils';
const Loading: React.FC<{}> = () => {
useEffect(() => {
// request('/auth/oauth/authorize', {
// method: 'get',
// params: {
// response_type: 'code',
// client_id: 'KgPEkttG',
// redirect_uri: 'http://10.242.31.158:18022/redirect?page=xunjia&pid=123&vid=456&qid=789',
// mall3_token: sessionStorage.getItem('Authorization'),
// },
// }).then(res => {
// })
}, []);
return (
<div style={{ textAlign: 'center', height: '100%', background: 'rgba(0,0,0,.05)', position: 'relative' }}>
<div style={{ position: 'absolute', left: '50%', top: '48%' }}>
<Spin tip="Loading..." />
<Button onClick={() => JumpToOutside("http://10.242.31.158:18022/redirect?page=xunjia%26pid=123%26vid=456%26qid=789")}></Button>
</div>
</div>
);
}
export default Loading;

View File

@ -1,11 +1,10 @@
import React, { useEffect } from 'react';
import { message, Spin } from 'antd';
import { history } from 'umi';
import { cloudReloadToken, cooperReloadToken, fgetUserMsg, getTokenByCode } from './service';
import { getDictionaries } from './BasDicData';
import { getTotalURLInformation, getURLInformation } from '@/utils/CommonUtils';
import { cloudReloadToken, cooperReloadToken, fgetUserMsg, getDictionaries, getTokenByCode } from './service';
import { getTotalURLInformation, getURLInformation, isNotEmpty } from '@/utils/CommonUtils';
import { refreshTokenApi } from '@/services/login';
import { getUserRefreshToken, getUserScope } from '@/utils/session';
import { getUserRefreshToken, getUserScope, setUserData } from '@/utils/session';
const Loading: React.FC<{}> = () => {
//存字典
async function setDict() {
@ -47,21 +46,55 @@ const Loading: React.FC<{}> = () => {
})
}
}
//错误页
const error = (code: string) => {
history.replace({
pathname: '/401',
query: {
code: code
}
})
}
//跳转
const redirect = async (userData: any, url: string, extra: any) => {
const roleId = getURLInformation('roleId');
if (isNotEmpty(roleId)) {
const authIndex = userData.authorityList.findIndex((ite: any) => ite.roleId == roleId);
if (authIndex != -1) {
setUserData(userData, userData.authorityList[authIndex].roleCode, userData.authorityList[authIndex])//角色信息存储
} else {
setUserData(userData, userData.authorityList[0].roleCode, userData.authorityList[0]);
error('402');
return;
}
} else {
setUserData(userData, userData.authorityList[0].roleCode, userData.authorityList[0]);
}
await setDict();//存字典
setTimeout(() => {
history.push({
pathname: `/${url}`,
query: {
...extra
}
})
}, 2000)
}
//获取用户信息
async function getUserData(token: string, url: string, extra: any, status: number) {
await fgetUserMsg(token).then(async res => {
if (res) {
if (res?.userType == null) {
history.replace({
pathname: '/401',
query: {
code: '401'
}
})
error('401');
} else {
if (res?.authorityList == null || res?.authorityList?.length == 0) {
if(url == 'ExamineAndApprove/Announcement' || url == 'ExamineAndApprove/ChangeTheAnnouncement' || url == 'ExamineAndApprove/Publicity' || url == 'ExamineAndApprove/InvitationLetter' || url == 'ExamineAndApprove/ExternalReference' || url == 'ExamineAndApprove/FailureAnnouncement') {
if (url == 'ExamineAndApprove/Announcement' ||
url == 'ExamineAndApprove/ChangeTheAnnouncement' ||
url == 'ExamineAndApprove/Publicity' ||
url == 'ExamineAndApprove/InvitationLetter' ||
url == 'ExamineAndApprove/ExternalReference' ||
url == 'ExamineAndApprove/FailureAnnouncement') {
let newAuthority: any[] = []
newAuthority.push({
authorities: [null, "system:user:test", "system:user:test", "system:user:test", "system:user:test", null, null],
@ -70,46 +103,17 @@ const Loading: React.FC<{}> = () => {
roleName: "联通普通用户",
roleScope: "EBTP"
})
res.authorityList = [...newAuthority]
setDict();//存字典
res.roleIds = res.authorityList[0].roleCode;
sessionStorage.setItem('userData', JSON.stringify(res));
sessionStorage.setItem('roleAuthority', JSON.stringify([res.roleIds]));
sessionStorage.setItem('roleData', JSON.stringify(res.authorityList[0]));
setTimeout(() => {
history.push({
pathname: `/${url}`,
query: {
...extra
}
})
}, 2000)
res.authorityList = [...newAuthority];
await redirect(res, url, extra);
} else {
if (status == 0) {
await refreshUserData(res?.userType,token,url,extra)
await refreshUserData(res?.userType, token, url, extra);
} else {
history.replace({
pathname: '/401',
query: {
code: '401'
}
})
error('401');
}
}
} else {
setDict();//存字典
res.roleIds = res.authorityList[0].roleCode;
sessionStorage.setItem('userData', JSON.stringify(res));
sessionStorage.setItem('roleAuthority', JSON.stringify([res.roleIds]));
sessionStorage.setItem('roleData', JSON.stringify(res.authorityList[0]));
setTimeout(() => {
history.push({
pathname: `/${url}`,
query: {
...extra
}
})
}, 2000)
await redirect(res, url, extra);
}
}
} else {
@ -128,12 +132,8 @@ const Loading: React.FC<{}> = () => {
//获取协议部分 http: https:
const protocol = window.location.protocol
const grant_type = 'authorization_code';
// const client_id = 'KgPEkttG';
// const client_secret = 'ae5bdb183c502355d2055b3de73300aa73cbfdf3';
// const redirect_uri = `http://10.242.31.158:18022/redirect${e}`;
const client_id = REACT_APP_CLIENT_KEY;
const client_secret = REACT_APP_CLIENT_SECRET;
// const redirect_uri = `${process.env.client_redirect}${e}`;
const redirect_uri = `${protocol}//${host}/redirect${e}`;
let token = '';
await getTokenByCode({ grant_type, client_id, client_secret, redirect_uri, code }).then(res => {
@ -150,14 +150,13 @@ const Loading: React.FC<{}> = () => {
async function mainFc() {
const code = getURLInformation('code');
const urlData: any = getTotalURLInformation() || {};
// const urlData: any = {};
//形成url额外参数
let str: string = ''
let obj: any = {}
for (let key in urlData) {
if (key != 'code') {
str = str + '&' + key + '=' + urlData[key]
if(key != 'page') {
if (key != 'page' && key != 'roleId') {
obj[key] = urlData[key]
}
}

View File

@ -52,5 +52,19 @@ export async function getTokenByCode(params: any) {
headers: header
});
}
/**
* 获取字典信息
* @returns
*/
export async function getDictionaries() {
return request('/api/biz-service-ebtp-project/v1/dictProject/refreshDictCache');
}
/**
* 根据projectId获取项目信息
* @param id
*/
export async function getProjectById(id?: any) {
return request('/api/biz-service-ebtp-project/v1/projectRecord/' + id);
}

View File

@ -95,6 +95,8 @@ const LookingForBusinessOpportunitiesList: React.FC<{}> = () => {
}
const docSaveBtn = "compact";//保存按钮是否展示
//项目编号
const ebpProjectNumber = getURLInformation('number');
function getBsName() {
if (bidMethodDict.indexOf("procurement_mode_4") !== -1) {
@ -108,12 +110,14 @@ const LookingForBusinessOpportunitiesList: React.FC<{}> = () => {
useEffect(() => {
setTableLoading(true);
if (bidMethodDict.indexOf("procurement_mode_4") > -1) {
lookingForBussinessOther(bussinessParams).then(res => {
lookingForBussinessOther(isNotEmpty(ebpProjectNumber) ? { ...bussinessParams, ebpProjectNumber } : bussinessParams).then(res => {
isNotEmpty(window.location.search) && history.push(window.location.pathname);
setTableList(res.data);
setTableLoading(false);
})
} else {
lookingForBussiness(bussinessParams).then(res => {
lookingForBussiness(isNotEmpty(ebpProjectNumber) ? { ...bussinessParams, ebpProjectNumber } : bussinessParams).then(res => {
isNotEmpty(window.location.search) && history.push(window.location.pathname);
setTableList(res.data);
setTableLoading(false);
})

View File

@ -419,3 +419,14 @@ export async function getQuotationMethodById(roomId: any) {
})
}
}
/**
* 存储角色信息
* @param {总数据} userData
* @param {权限} role
* @param {当前角色} roleData
*/
export function setUserData(userData: any, role: string, roleData: any): void {
sessionStorage.setItem('userData', JSON.stringify(userData));
sessionStorage.setItem('roleAuthority', JSON.stringify([role]));
sessionStorage.setItem('roleData', JSON.stringify(roleData));
}