433 lines
12 KiB
TypeScript
433 lines
12 KiB
TypeScript
import { getDefId as getDefById } from '@/pages/Project/ProjectManage/ProjectManager/ProjectDocumentation/service';
|
||
import { getRoomDataById, getSectionDataById } from '@/services/common';
|
||
import { message } from 'antd';
|
||
import { getProTypeCodeByBidMethodDict, getURLInformation, getUrlRelativePath, isEmpty } from './CommonUtils';
|
||
//取session项目id
|
||
export function getProId() {
|
||
if (getSessionProjectData() == null) {
|
||
return null;
|
||
} else {
|
||
return getSessionProjectData().id;
|
||
}
|
||
}
|
||
/**
|
||
* 获取流程Id(defId)
|
||
* @returns
|
||
* -1- bid_prequalification 公开招标-资格预审
|
||
* -2- bid_qualification 公开招标-资格后审
|
||
* -3- bid_centralized_prequalification 公开招标-集中资格预审
|
||
* -4- bid_centralized_prequalification_bid 公开招标-集中资格预审招标
|
||
* -5- bid_invitation 邀请招标
|
||
* -6- comparison_one_prequalification 公开比选一阶段-资格预审
|
||
* -7- comparison_multi_prequalification 公开比选多阶段-资格预审
|
||
* -8- comparison_one 公开比选一阶段
|
||
* -9- comparison_multi 公开比选多阶段
|
||
* -10- recruit 公开招募 即 单轮
|
||
* -11- recruit_multi 常态化招募 即 多轮
|
||
* -12- negotiation_competitive_public 竞争性谈判-公开参与
|
||
* -13- negotiation_competitive_invite 竞争性谈判-邀请参与
|
||
* -14- negotiation_single 单一来源
|
||
* -15- inquiry 询价
|
||
* -16- auction 内拍
|
||
*/
|
||
//获取流程id
|
||
export function getDefId() {
|
||
let id: any | null = sessionStorage.getItem('defId');
|
||
let defId = JSON.parse(id);
|
||
return defId
|
||
}
|
||
//获取proTypeCode 项目菜单返回用
|
||
export function getProTypeCode() {
|
||
let proTypeCode: any = sessionStorage.getItem('proTypeCode');
|
||
return proTypeCode
|
||
}
|
||
|
||
/**
|
||
* 获取项目名称
|
||
*/
|
||
export function getProName() {
|
||
if (getSessionProjectData() === null) {
|
||
return null;
|
||
} else {
|
||
return getSessionProjectData().projectName;
|
||
}
|
||
}
|
||
/**
|
||
* 获取采购方式
|
||
*/
|
||
export function getProMethod() {
|
||
if (getSessionProjectData() === null) {
|
||
return null;
|
||
} else {
|
||
return getSessionProjectData().bidMethodDict;
|
||
}
|
||
}
|
||
/**
|
||
* 获取比选方式(比选一阶段,比选多阶段)
|
||
*/
|
||
export function getProSignDict() {
|
||
if (getSessionProjectData() === null) {
|
||
return null;
|
||
} else {
|
||
return getSessionProjectData().biddingSignDict;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 获取开标时是否需要投标人ipass解密
|
||
*/
|
||
export function getIPassDecode() {
|
||
if (getSessionProjectData() === null) {
|
||
return null;
|
||
} else {
|
||
return getSessionProjectData().isIPassDecode;
|
||
}
|
||
}
|
||
|
||
//取session全部字典数据
|
||
export function getDicData() {
|
||
let data = sessionStorage.getItem('DicData');
|
||
if (data == null || data == undefined) {
|
||
return null
|
||
}
|
||
return data;
|
||
}
|
||
|
||
//取session评审室id
|
||
export function getRoomId() {
|
||
let roomId = sessionStorage.getItem('roomId');
|
||
return roomId;
|
||
}
|
||
|
||
//取session评审室status(3为评审室结束)
|
||
export function getRoomStatus() {
|
||
let roomStatus = sessionStorage.getItem('roomStatus');
|
||
return roomStatus;
|
||
}
|
||
|
||
//取session资审方式 1-资格预审 2-资格后审
|
||
export function getRoomTypeByEva() {
|
||
let roomTypeByEva = sessionStorage.getItem('roomTypeByEva');
|
||
return roomTypeByEva;
|
||
}
|
||
|
||
//取session聊天室id
|
||
export function getGroupId() {
|
||
let groupId = sessionStorage.getItem('groupId');
|
||
return groupId;
|
||
}
|
||
|
||
//取session专家聊天室id
|
||
export function getExpertGroupId() {
|
||
let expertGroupId = sessionStorage.getItem('expertGroupId');
|
||
return expertGroupId;
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 获取session projectData项目信息(项目跟进)
|
||
*/
|
||
export function getSessionProjectData() {
|
||
let projectData: any | null = sessionStorage.getItem('projectData');
|
||
projectData = JSON.parse(projectData);
|
||
return projectData;
|
||
}
|
||
|
||
/**
|
||
* 获取session projectDocumentationData项目信息(项目建档)
|
||
*/
|
||
export function getSessionProjectDocumentationData() {
|
||
let projectData: any | null = sessionStorage.getItem('projectDocumentationData');
|
||
return JSON.parse(projectData);
|
||
}
|
||
|
||
/**
|
||
* 获取session userData用户信息
|
||
*/
|
||
export function getSessionUserData() {
|
||
let userData: any | null = sessionStorage.getItem('userData');
|
||
return JSON.parse(userData);
|
||
}
|
||
/**
|
||
* 获取session userToken
|
||
*/
|
||
export function getUserToken() {
|
||
let userToken: any = `Bearer ${sessionStorage.getItem('Authorization')}`;
|
||
return userToken;
|
||
}
|
||
|
||
/**
|
||
* 获取session userRefreshToken
|
||
*/
|
||
export function getUserRefreshToken() {
|
||
let userRefreshToken: any | null = sessionStorage.getItem('refreshToken');
|
||
return userRefreshToken;
|
||
}
|
||
|
||
/**
|
||
* 获取session userScope
|
||
*/
|
||
export function getUserScope() {
|
||
let userScope: any | null = sessionStorage.getItem('scope');
|
||
return userScope;
|
||
}
|
||
|
||
/**
|
||
* 获取localStorage userData用户信息
|
||
*/
|
||
// export function getLocalUserData(){
|
||
// let userData:any|null = sessionStorage.getItem('userInfo');
|
||
// return JSON.parse(userData);
|
||
// }
|
||
// export function getLocalUserData(){
|
||
// let userData:any|null = sessionStorage.getItem('userInfo');
|
||
// return JSON.parse(userData);
|
||
// }
|
||
|
||
/**
|
||
* 获取采购类型合并字典
|
||
*/
|
||
export function getDictBidMethodDictUnion() {
|
||
let dictData: any = getDicData();
|
||
//全字典数据对象
|
||
let dictDataObject = JSON.parse(dictData);
|
||
//采购方式合并--字典
|
||
let bidMethodUnion = [];
|
||
if (dictDataObject !== null) {
|
||
bidMethodUnion = dictDataObject['web_menu=web'];
|
||
}
|
||
return bidMethodUnion;
|
||
}
|
||
|
||
/**
|
||
* 获取采购类别字典
|
||
*/
|
||
export function getDictBidMethodDict() {
|
||
//采购方式合并--字典
|
||
let bidMethodUnion = getDictBidMethodDictUnion();
|
||
let dictData: any = getDicData();
|
||
//全字典数据对象
|
||
let dictDataObject = JSON.parse(dictData);
|
||
//采购方式--字典
|
||
let bidMethod: any[] = [];
|
||
//循环遍历所有合并的字典,从合并的字典中获取code值,拼成"01=web_menu""02=web_menu"
|
||
//的值,在从全部字典中获取采购方式的字典
|
||
if (bidMethodUnion?.length > 0) {
|
||
for (let i = 0; i < bidMethodUnion.length; i++) {
|
||
let key = bidMethodUnion[i]["code"] + "=web_menu";
|
||
let dict = dictDataObject[key];
|
||
if (dict?.length > 0) {
|
||
bidMethod = [...bidMethod, ...dict];
|
||
}
|
||
}
|
||
}
|
||
return bidMethod;
|
||
}
|
||
|
||
|
||
/**
|
||
* 获取session roleData用户信息
|
||
*/
|
||
export function getSessionRoleData() {
|
||
let roleData: any | null = sessionStorage.getItem('roleData');
|
||
return JSON.parse(roleData);
|
||
}
|
||
|
||
/**
|
||
* 专家评审室列表存储session信息
|
||
* @param record 评审室列表行数据
|
||
*/
|
||
|
||
export async function jurySaveInfo(record: any) {
|
||
sessionStorage.setItem('projectData', JSON.stringify({
|
||
bidMethodDict: record?.bidMethodDict,//采购方式
|
||
id: record?.tpId//项目id
|
||
}));
|
||
sessionStorage.setItem('roomId', record.id);
|
||
sessionStorage.setItem("groupId", record.chatGroupId)
|
||
sessionStorage.setItem("expertGroupId", record.expertChatGroupId)
|
||
await getQuotationMethodById(record.id)
|
||
}
|
||
|
||
/**
|
||
* 获取国密加密算法需要的属性
|
||
*/
|
||
export function getEncrypt() {
|
||
let encrypt = {
|
||
cipherMode: REACT_APP_PASSWORD_CIPHERMODE,
|
||
publicKey: REACT_APP_PASSWORD_PUBLICKEY
|
||
}
|
||
return encrypt;
|
||
}
|
||
|
||
export interface projectDataItem {
|
||
id?: string
|
||
bidMethodDict?: string
|
||
biddingSignDict?: string
|
||
isClientFile?: string
|
||
isIPassDecode?: string
|
||
isIPassFile?: string
|
||
projectName?: string
|
||
openTenderForm?: string
|
||
returnURL?: string
|
||
}
|
||
|
||
/**
|
||
* 项目跟进项目经理
|
||
* @param projectData
|
||
*/
|
||
export function followUpAProjectManager(projectData: projectDataItem): Promise<boolean> {
|
||
removePurchaseCanOperate();
|
||
return new Promise<boolean>(resolve => {
|
||
getDefById(projectData.id).then((res) => {
|
||
if (res?.code == 200) {
|
||
let proTypeCode = getURLInformation('proTypeCode');
|
||
sessionStorage.setItem('proTypeCode', proTypeCode === null ? getProTypeCodeByBidMethodDict(projectData.bidMethodDict) : proTypeCode);
|
||
sessionStorage.setItem('defId', JSON.stringify(res.data));
|
||
sessionStorage.setItem('projectData', JSON.stringify(projectData));
|
||
let returnURL = projectData.returnURL ? projectData.returnURL : getUrlRelativePath();
|
||
sessionStorage.setItem('returnURL', returnURL);
|
||
resolve(true);
|
||
}
|
||
})
|
||
})
|
||
}
|
||
|
||
/**
|
||
* 项目跟进供应商
|
||
* @param projectData
|
||
*/
|
||
export function followUpAProjectSupplier(projectData: projectDataItem): Promise<boolean> {
|
||
removePurchaseCanOperate();
|
||
return new Promise<boolean>(resolve => {
|
||
if (projectData?.id == undefined || projectData?.id == null) {
|
||
message.error("项目数据错误,无法获取流程,请联系管理员")
|
||
} else {
|
||
getDefById(projectData?.id).then((res) => {
|
||
if (res?.code == 200) {
|
||
let proTypeCode = getURLInformation('proTypeCode');
|
||
sessionStorage.setItem('proTypeCode', proTypeCode === null ? getProTypeCodeByBidMethodDict(projectData.bidMethodDict) : proTypeCode);
|
||
sessionStorage.setItem('defId', JSON.stringify(res.data));
|
||
sessionStorage.setItem('projectData', JSON.stringify(projectData));
|
||
let returnURL = projectData.returnURL ? projectData.returnURL : getUrlRelativePath();
|
||
sessionStorage.setItem('returnURL', returnURL);
|
||
resolve(true);
|
||
}
|
||
})
|
||
}
|
||
})
|
||
}
|
||
|
||
/**
|
||
* 内拍项目跟进
|
||
* @param projectData
|
||
*/
|
||
export function auctionFollowUpAProjectManager(projectData: projectDataItem): void {
|
||
sessionStorage.setItem('projectData', JSON.stringify(projectData));
|
||
sessionStorage.setItem('defId', JSON.stringify('auction'));
|
||
let returnURL = projectData.returnURL ? projectData.returnURL : getUrlRelativePath();
|
||
sessionStorage.setItem('returnURL', returnURL);
|
||
}
|
||
|
||
/**
|
||
* 获取session roleAuthority
|
||
*/
|
||
export function getRA() {
|
||
let roleAuthority: any | null = sessionStorage.getItem('roleAuthority');
|
||
return JSON.parse(roleAuthority);
|
||
}
|
||
/**
|
||
* 获取项目信息 适用法律
|
||
*/
|
||
export function getProOpenTenderForm() {
|
||
if (getSessionProjectData() === null) {
|
||
return null;
|
||
} else {
|
||
return getSessionProjectData().openTenderForm;
|
||
}
|
||
}
|
||
/**
|
||
* 获取session roleAuthority
|
||
*/
|
||
export function getPurchaseCanOperate() {
|
||
let authority: string | null = sessionStorage.getItem('purchaseCanOperate');
|
||
return authority;
|
||
}
|
||
|
||
/**
|
||
* 设置session roleAuthority
|
||
*/
|
||
export function setPurchaseCanOperate() {
|
||
sessionStorage.setItem('purchaseCanOperate', '1');
|
||
}
|
||
|
||
/**
|
||
* 删除session roleAuthority
|
||
*/
|
||
export function removePurchaseCanOperate() {
|
||
sessionStorage.removeItem('purchaseCanOperate');
|
||
}
|
||
/**
|
||
* 获取returnURL
|
||
* @returns
|
||
*/
|
||
export function getReturnURL() {
|
||
let returnURL = sessionStorage.getItem('returnURL');
|
||
return returnURL === null ? "" : returnURL;
|
||
}
|
||
|
||
/**
|
||
* 获取getRoomReturnURL
|
||
* @returns
|
||
*/
|
||
export function getRoomReturnURL() {
|
||
let roomReturnURL = sessionStorage.getItem('roomReturnURL');
|
||
return roomReturnURL === null ? "" : roomReturnURL;
|
||
}
|
||
|
||
/**
|
||
* 获取当前评审室对应标段的报价类型(只能在评审室内使用)
|
||
* @returns
|
||
*/
|
||
export function getSectionQuot() {
|
||
let returnURL = sessionStorage.getItem('sectionQuot');
|
||
return returnURL === null ? "0" : returnURL;
|
||
}
|
||
|
||
/**
|
||
* 根据评审室id获取标段的报价类型
|
||
* @param roomId
|
||
* @returns 1-%(优惠率,折扣率) 0-元(总价,单价)
|
||
*/
|
||
export async function getQuotationMethodById(roomId: any) {
|
||
if (roomId == undefined || roomId == '' || roomId == null) {
|
||
message.error('参数缺失')
|
||
return
|
||
} else {
|
||
await getRoomDataById(roomId).then(async res => {
|
||
if (res?.code == 200 && res?.success == true) {
|
||
let roomData = res?.data
|
||
await getSectionDataById(roomData?.sectionId).then(response => {
|
||
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
|
||
}
|
||
})
|
||
}
|
||
})
|
||
}
|
||
}
|
||
/**
|
||
* 存储角色信息
|
||
* @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));
|
||
}
|