diff --git a/config/router_transfer.ts b/config/router_transfer.ts index cb935d6..b6877fc 100644 --- a/config/router_transfer.ts +++ b/config/router_transfer.ts @@ -50,10 +50,6 @@ export default [ path: '/redirect', component: './LoadingPage', }, - { - path: '/toAuth', - component: './LoadingPage/ToAuth', - }, //跨工程跳转中间页开始 { path: '/xunjia', diff --git a/src/pages/401.tsx b/src/pages/401.tsx index 88abc40..dd7dbb4 100644 --- a/src/pages/401.tsx +++ b/src/pages/401.tsx @@ -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(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 ( {time}秒后进入默认角色} /> ); }; diff --git a/src/pages/LoadingPage/BasDicData.ts b/src/pages/LoadingPage/BasDicData.ts deleted file mode 100644 index 3269d8c..0000000 --- a/src/pages/LoadingPage/BasDicData.ts +++ /dev/null @@ -1,6 +0,0 @@ -import request from '@/utils/request'; - -// 获取字典信息 -export async function getDictionaries(){ - return request('/api/biz-service-ebtp-project/v1/dictProject/refreshDictCache'); -} \ No newline at end of file diff --git a/src/pages/LoadingPage/MiddleLoading/ToFindBusiness.tsx b/src/pages/LoadingPage/MiddleLoading/ToFindBusiness.tsx new file mode 100644 index 0000000..3321d21 --- /dev/null +++ b/src/pages/LoadingPage/MiddleLoading/ToFindBusiness.tsx @@ -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 ( +
+
+ +
+
+ ); +}; +export default Loading; diff --git a/src/pages/LoadingPage/MiddleLoading/ToHomePage.tsx b/src/pages/LoadingPage/MiddleLoading/ToHomePage.tsx new file mode 100644 index 0000000..208e832 --- /dev/null +++ b/src/pages/LoadingPage/MiddleLoading/ToHomePage.tsx @@ -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 ( +
+
+ +
+
+ ); +}; +export default Loading; diff --git a/src/pages/LoadingPage/ToAuth/index.tsx b/src/pages/LoadingPage/ToAuth/index.tsx deleted file mode 100644 index 8f2aff8..0000000 --- a/src/pages/LoadingPage/ToAuth/index.tsx +++ /dev/null @@ -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 ( -
-
- - -
-
- ); -} -export default Loading; \ No newline at end of file diff --git a/src/pages/LoadingPage/index.tsx b/src/pages/LoadingPage/index.tsx index 32b668c..a963091 100644 --- a/src/pages/LoadingPage/index.tsx +++ b/src/pages/LoadingPage/index.tsx @@ -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() { @@ -17,7 +16,7 @@ const Loading: React.FC<{}> = () => { }) } //用户信息错误处理方法 - async function refreshUserData(userType: string,token: string, url: string,extra: any) { + async function refreshUserData(userType: string, token: string, url: string, extra: any) { const headers = { Authorization: token, clientId: REACT_APP_CLIENT_KEY, @@ -32,84 +31,89 @@ const Loading: React.FC<{}> = () => { const header = { clientId: REACT_APP_CLIENT_KEY, } - if(userType == '0') {//联通用户 - await cloudReloadToken('',headers) + if (userType == '0') {//联通用户 + await cloudReloadToken('', headers) await getUserData(token, url, extra, 1) - } else if(userType == '1') {//合作方 - await cooperReloadToken('',headers) + } else if (userType == '1') {//合作方 + await cooperReloadToken('', headers) await getUserData(token, url, extra, 1) - } else if(userType == '2') {//专家 - await refreshTokenApi(params,header).then(async res => { - if(res?.success == true) { + } else if (userType == '2') {//专家 + await refreshTokenApi(params, header).then(async res => { + if (res?.success == true) { sessionStorage.setItem('Authorization', res?.data?.value); await getUserData(token, url, extra, 1) } }) } } + //错误页 + 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) { + 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' - } - }) + if (res?.userType == null) { + 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 (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') { let newAuthority: any[] = [] newAuthority.push({ - authorities: [null,"system:user:test","system:user:test","system:user:test","system:user:test",null,null], + authorities: [null, "system:user:test", "system:user:test", "system:user:test", "system:user:test", null, null], roleCode: "ebtp-unicom-default", roleId: "20004", 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) + if (status == 0) { + 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 { @@ -120,7 +124,7 @@ const Loading: React.FC<{}> = () => { //通过code取token async function getToken(code: string, data: any) { let e = '' - if(data != null && data != undefined && data != '') { + if (data != null && data != undefined && data != '') { e = '?' + data } //获取当前浏览器主机部分(含端口号) @@ -128,17 +132,13 @@ 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 => { if (res?.success == true) { - sessionStorage.setItem('Authorization',res?.data?.value) + sessionStorage.setItem('Authorization', res?.data?.value) token = 'Bearer ' + res?.data?.value; } else { message.error("认证请求失败,请联系管理员") @@ -149,18 +149,17 @@ const Loading: React.FC<{}> = () => { //主方法 async function mainFc() { const code = getURLInformation('code'); - const urlData: any = getTotalURLInformation()||{}; - // const urlData: any = {}; + const urlData: any = getTotalURLInformation() || {}; //形成url额外参数 let str: string = '' let obj: any = {} for (let key in urlData) { - if(key != 'code') { + if (key != 'code') { str = str + '&' + key + '=' + urlData[key] - if(key != 'page') { + if (key != 'page' && key != 'roleId') { obj[key] = urlData[key] } - } + } } str = str.substring(1) //初始化token diff --git a/src/pages/LoadingPage/service.ts b/src/pages/LoadingPage/service.ts index b2b9a37..84a3e2a 100644 --- a/src/pages/LoadingPage/service.ts +++ b/src/pages/LoadingPage/service.ts @@ -5,10 +5,10 @@ import request from '@/utils/request'; * @param params * @returns */ -export async function fgetUserMsg(params: any) { +export async function fgetUserMsg(params: any) { return request('/api/biz-service-ebtp-extend/v1/userinfo/get', { method: 'GET', - headers: {'Authorization': params}, + headers: { 'Authorization': params }, data: params, }); } @@ -17,7 +17,7 @@ export async function fgetUserMsg(params: any) { * @param params * @returns */ -export async function getTokenByCode(params: any) { +export async function getTokenByCode(params: any) { return request('/api/auth/oauth/token', { method: 'POST', params: params, @@ -28,7 +28,7 @@ export async function getTokenByCode(params: any) { * 根据询价单id查询项目数据 * @param id */ - export function getProjectByInquiryId(inquiryId?:any){ +export function getProjectByInquiryId(inquiryId?: any) { return request('/api/biz-service-ebtp-project/v1/projectRecord/getByInquiryId/' + inquiryId); } @@ -36,7 +36,7 @@ export async function getTokenByCode(params: any) { * 刷新上下文接口(云门户) * @param id */ - export function cloudReloadToken(params: any,header: any) { +export function cloudReloadToken(params: any, header: any) { return request('/api/auth/reloadToken', { method: 'POST', headers: header @@ -46,11 +46,25 @@ export async function getTokenByCode(params: any) { * 刷新上下文接口(合作方) * @param id */ - export function cooperReloadToken(params: any,header: any) { +export function cooperReloadToken(params: any, header: any) { return request('/api/auth/reloadPartnerToken', { method: 'POST', 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); +} diff --git a/src/pages/Tender/supplier/LookingForBusinessOpportunities/components/LookingForBusinessOpportunitiesList.tsx b/src/pages/Tender/supplier/LookingForBusinessOpportunities/components/LookingForBusinessOpportunitiesList.tsx index e2a778f..e3fff82 100644 --- a/src/pages/Tender/supplier/LookingForBusinessOpportunities/components/LookingForBusinessOpportunitiesList.tsx +++ b/src/pages/Tender/supplier/LookingForBusinessOpportunities/components/LookingForBusinessOpportunitiesList.tsx @@ -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); }) diff --git a/src/utils/session.ts b/src/utils/session.ts index b2a6a1c..c385766 100644 --- a/src/utils/session.ts +++ b/src/utils/session.ts @@ -160,7 +160,7 @@ export function getUserToken() { /** * 获取session userRefreshToken */ - export function getUserRefreshToken() { +export function getUserRefreshToken() { let userRefreshToken: any | null = sessionStorage.getItem('refreshToken'); return userRefreshToken; } @@ -168,7 +168,7 @@ export function getUserToken() { /** * 获取session userScope */ - export function getUserScope() { +export function getUserScope() { let userScope: any | null = sessionStorage.getItem('scope'); return userScope; } @@ -246,7 +246,7 @@ export async function jurySaveInfo(record: any) { })); sessionStorage.setItem('roomId', record.id); sessionStorage.setItem("groupId", record.chatGroupId) - sessionStorage.setItem("expertGroupId",record.expertChatGroupId) + sessionStorage.setItem("expertGroupId", record.expertChatGroupId) await getQuotationMethodById(record.id) } @@ -270,7 +270,7 @@ export interface projectDataItem { isIPassFile?: string projectName?: string openTenderForm?: string - returnURL?:string + returnURL?: string } /** @@ -301,7 +301,7 @@ export function followUpAProjectManager(projectData: projectDataItem): Promise { removePurchaseCanOperate(); return new Promise(resolve => { - if(projectData?.id == undefined || projectData?.id == null) { + if (projectData?.id == undefined || projectData?.id == null) { message.error("项目数据错误,无法获取流程,请联系管理员") } else { getDefById(projectData?.id).then((res) => { @@ -358,21 +358,21 @@ export function getPurchaseCanOperate() { /** * 设置session roleAuthority */ - export function setPurchaseCanOperate() { +export function setPurchaseCanOperate() { sessionStorage.setItem('purchaseCanOperate', '1'); } /** * 删除session roleAuthority */ - export function removePurchaseCanOperate() { +export function removePurchaseCanOperate() { sessionStorage.removeItem('purchaseCanOperate'); } /** * 获取returnURL * @returns */ -export function getReturnURL () { +export function getReturnURL() { let returnURL = sessionStorage.getItem('returnURL'); return returnURL === null ? "" : returnURL; } @@ -381,7 +381,7 @@ export function getReturnURL () { * 获取getRoomReturnURL * @returns */ - export function getRoomReturnURL () { +export function getRoomReturnURL() { let roomReturnURL = sessionStorage.getItem('roomReturnURL'); return roomReturnURL === null ? "" : roomReturnURL; } @@ -390,7 +390,7 @@ export function getReturnURL () { * 获取当前评审室对应标段的报价类型(只能在评审室内使用) * @returns */ - export function getSectionQuot () { +export function getSectionQuot() { let returnURL = sessionStorage.getItem('sectionQuot'); return returnURL === null ? "0" : returnURL; } @@ -401,15 +401,15 @@ export function getReturnURL () { * @returns 1-%(优惠率,折扣率) 0-元(总价,单价) */ export async function getQuotationMethodById(roomId: any) { - if(roomId == undefined || roomId == '' || roomId == null) { + if (roomId == undefined || roomId == '' || roomId == null) { message.error('参数缺失') return } else { await getRoomDataById(roomId).then(async res => { - if(res?.code == 200 && res?.success == true) { + if (res?.code == 200 && res?.success == true) { let roomData = res?.data await getSectionDataById(roomData?.sectionId).then(response => { - if(response?.code == 200 && response?.success == true) { + if (response?.code == 200 && response?.success == true) { let quotationMethodDict = response?.data?.quotationMethodDict let result = (quotationMethodDict == "quotation_method_2" || quotationMethodDict == "quotation_method_3") ? "1" : "0" sessionStorage.setItem("sectionQuot", result)//roomType存入session @@ -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)); +}