|
@@ -22,7 +22,15 @@ const importXML = (() => {
|
|
|
//导入的文件类型,界面选的文件类型是生成项目的文件类型,这里的文件类型指的是,要导入文件的类型,
|
|
|
//导入文件类型不同,导入数据不同
|
|
|
let importFileKind = '';
|
|
|
-
|
|
|
+ //文件类型
|
|
|
+ const FileKind = {
|
|
|
+ '6': 1, // 投标
|
|
|
+ 'tender': 1,
|
|
|
+ '4': 2, // 招标
|
|
|
+ 'bid': 2,
|
|
|
+ '5': 3, // 控制价
|
|
|
+ 'control': 3,
|
|
|
+ };
|
|
|
const countData = {
|
|
|
projectCount: 0, //项目数量
|
|
|
projectGLJCount: 0, //项目人材机数量
|
|
@@ -32,10 +40,116 @@ const importXML = (() => {
|
|
|
};
|
|
|
|
|
|
// 建设项目
|
|
|
- function loadProject(xmlObj) {
|
|
|
-
|
|
|
+ function extractProject(xmlObjMap) {
|
|
|
+ Object.keys(countData).forEach(key => countData[key] = 0); // 清缓存
|
|
|
+ countData.projectCount++;
|
|
|
+ const projectXMLObj = xmlObjMap['Project.xml'];
|
|
|
+ const projectSrc = getValue(projectXMLObj, ['ConstructionProject']);
|
|
|
+ importFileKind = FileKind[getValue(source, ['_FileKind'])]; // 标记当前导入的文件类型
|
|
|
+ const rst = {
|
|
|
+ projectType: projectType.Project,
|
|
|
+ name: getValue(projectSrc, ['_Name']),
|
|
|
+ engs: extractEngs(projectSrc),
|
|
|
+ property: {
|
|
|
+ compilationIllustrationProject: getValue(projectSrc, ['_Explains'])
|
|
|
+ },
|
|
|
+ basicInformation: extractBasicInfo(projectSrc)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 从xml对象中提取基本信息相关
|
|
|
+ function extractBasicInfo(projectSrc) {
|
|
|
+ const projectInfo = getValue(projectSrc, ['ProjectInfo']); // 估概预算信息
|
|
|
+ const tendereeInfo = getValue(projectSrc, ['TendereeInfo']); // 招标信息
|
|
|
+ const bidderInfo = getValue(projectSrc, ['BidderInfo']); // 投标信息
|
|
|
+ return [
|
|
|
+ { key: 'projNum', value: getValue(projectSrc, ['_Number']) }, // 编码
|
|
|
+ { key: 'projectCategory', value: getValue(projectSrc, ['_ProjectCategory']) }, // 工程类别
|
|
|
+ { key: 'constructionType', value: getValue(projectSrc, ['_ConstructionType']) }, // 建设性质
|
|
|
+ { key: 'regionalCategories', value: getValue(projectSrc, ['_AreaKind']) }, // 地区类被
|
|
|
+ { key: 'projLocation', value: getValue(projectSrc, ['_ProjectSite']) }, // 工程地点
|
|
|
+ { key: 'constructingUnits', value: getValue(projectSrc, ['_BulidUnit']) }, // 建设单位
|
|
|
+ { key: 'constructingUnitsPerson', value: getValue(projectSrc, ['_BulidAuthorizer']) }, // 建设单位法定代表人或其授权人
|
|
|
+ { key: 'rangeOfCompilation', value: getValue(projectSrc, ['_RangeOfCompilation']) }, // 建设(编制)范围
|
|
|
+ { key: 'scale', value: getValue(projectSrc, ['_Scale']) }, // 建设规模
|
|
|
+ { key: 'unit', value: getValue(projectSrc, ['_Unit']) }, // 建设规模单位
|
|
|
+ { key: 'designUnits', value: getValue(projectInfo, ['_Designer']) }, // 设计单位
|
|
|
+ { key: 'constructionUnits', value: getValue(projectInfo, ['_Contractor']) }, // 承包单位
|
|
|
+ { key: 'establishUnit', value: getValue(projectInfo, ['_CompileCompany']) }, // 编制单位
|
|
|
+ { key: importFileKind === FileKind.tender ? 'bidCompileDate' : 'tenderCompileDate', value: getValue(projectInfo, ['_CompileDate']) }, // 编制时间
|
|
|
+ { key: 'authorizer', value: getValue(projectInfo, ['_Authorizer']) }, // 编制单位法定代表人或其授权人
|
|
|
+ { key: 'tendereeName', value: getValue(tendereeInfo, ['_TendereeName']) }, // 招标人
|
|
|
+ { key: 'tenderAuthorizer', value: getValue(tendereeInfo, ['_TenderAuthorizer']) }, // 招标单位法定代表人或其授权人
|
|
|
+ { key: 'tenderCompiler', value: getValue(tendereeInfo, ['_TenderCompiler']) }, // 招标单位编制人
|
|
|
+ { key: 'tenderCompilerCertNo', value: getValue(tendereeInfo, ['_TenderCompilerCertNo']) }, // 招标单位编制人资格证书编号
|
|
|
+ { key: 'tenderCompileDate', value: getValue(tendereeInfo, ['_TenderCompileDate']) }, // 招标单位编制时间
|
|
|
+ { key: 'tenderExaminer', value: getValue(tendereeInfo, ['_TenderExaminer']) }, // 招标单位审核人
|
|
|
+ { key: 'tenderExaminerCertNo', value: getValue(tendereeInfo, ['_TenderExaminerCertNo']) }, // 招标单位审核人资格证书编号
|
|
|
+ { key: 'tenderExamineDate', value: getValue(tendereeInfo, ['_TenderExamineDate']) }, // 招标单位审核时间
|
|
|
+ { key: 'tenderApprover', value: getValue(tendereeInfo, ['_TenderApprover']) }, // 招标单位审定人
|
|
|
+ { key: 'tenderApproverCertNo', value: getValue(tendereeInfo, ['_TenderApproverCertNo']) }, // 招标单位审定人资格证书编号
|
|
|
+ { key: 'proxy', value: getValue(tendereeInfo, ['_Proxy']) }, // 招标代理
|
|
|
+ { key: 'proxyCertNo', value: getValue(tendereeInfo, ['_ProxyCertNo']) }, // 招标代理资质证书编号
|
|
|
+ { key: 'proxyAuthorizer', value: getValue(tendereeInfo, ['_ProxyAuthorizer']) }, // 招标代理法定代表人或其授权人
|
|
|
+ { key: 'proxyCompiler', value: getValue(tendereeInfo, ['_ProxyCompiler']) }, // 招标代理编制人员
|
|
|
+ { key: 'proxyCompilerCertNo', value: getValue(tendereeInfo, ['_ProxyCompilerCertNo']) }, // 招标代理编制人员资格证书编号
|
|
|
+ { key: 'proxyCompileDate', value: getValue(tendereeInfo, ['_ProxyCompileDate']) }, // 招标代理编制时间
|
|
|
+ { key: 'proxyExaminer', value: getValue(tendereeInfo, ['_ProxyExaminer']) }, // 招标代理审核人
|
|
|
+ { key: 'proxyExaminerCertNo', value: getValue(tendereeInfo, ['_ProxyExaminerCertNo']) }, // 招标代理审核人资格证书编号
|
|
|
+ { key: 'proxyExamineDate', value: getValue(tendereeInfo, ['_ProxyExamineDate']) }, // 招标代理审核时间
|
|
|
+ { key: 'proxyApprover', value: getValue(tendereeInfo, ['_ProxyApprover']) }, // 招标代理审定人
|
|
|
+ { key: 'proxyApproverCertNo', value: getValue(tendereeInfo, ['_ProxyApproverCertNo']) }, // 招标代理审定人资格证书编号
|
|
|
+ { key: 'proxyApproveDate', value: getValue(tendereeInfo, ['_ProxyApproveDate']) }, // 招标代理审定时间
|
|
|
+ { key: 'consultant', value: getValue(tendereeInfo, ['_Consultant']) }, // 造价咨询
|
|
|
+ { key: 'consultantCertNo', value: getValue(tendereeInfo, ['_ConsultantCertNo']) }, // 造价咨询资质证书编号
|
|
|
+ { key: 'consultantCompiler', value: getValue(tendereeInfo, ['_ConsultantCompiler']) }, // 造价咨询编制人
|
|
|
+ { key: 'consultantCompilerCertNo', value: getValue(tendereeInfo, ['_ConsultantCompilerCertNo']) }, // 造价咨询编制人资格证书
|
|
|
+ { key: 'consultantCompileDate', value: getValue(tendereeInfo, ['_ConsultantCompileDate']) }, // 造价咨询编制时间
|
|
|
+ { key: 'consultantExaminer', value: getValue(tendereeInfo, ['_ConsultantExaminer']) }, // 造价咨询审核人
|
|
|
+ { key: 'consultantExaminerCertNo', value: getValue(tendereeInfo, ['_ConsultantExaminerCertNo']) }, // 造价咨询审核人资格证书编号
|
|
|
+ { key: 'consultantExamineDate', value: getValue(tendereeInfo, ['_ConsultantExamineDate']) }, // 造价咨询审核时间
|
|
|
+ { key: 'consultantApprover', value: getValue(tendereeInfo, ['_ConsultantApprover']) }, // 造价咨询审定人
|
|
|
+ { key: 'consultantApproverCertNo', value: getValue(tendereeInfo, ['_ConsultantApproverCertNo']) }, // 造价咨询审定人资格证书编号
|
|
|
+ { key: 'consultantApproveDate', value: getValue(tendereeInfo, ['_ConsultantApproveDate']) }, // 造价咨询审定时间
|
|
|
+ { key: 'bidName', value: getValue(bidderInfo, ['_BidName']) }, // 投标人
|
|
|
+ { key: 'bidAuthorizer', value: getValue(bidderInfo, ['_BidAuthorizer']) }, // 投标单位法定代表人或其授权人
|
|
|
+ { key: 'bidCompiler', value: getValue(bidderInfo, ['_BidCompiler']) }, // 投标单位编制人
|
|
|
+ { key: 'bidCompilerCertNo', value: getValue(bidderInfo, ['_BidCompilerCertNo']) }, // 投标单位编制人资格证书编号
|
|
|
+ { key: 'bidCompileDate', value: getValue(bidderInfo, ['_BidCompileDate']) }, // 投标单位编制时间
|
|
|
+ { key: 'bidExaminer', value: getValue(bidderInfo, ['_BidExaminer']) }, // 投标单位审核人
|
|
|
+ { key: 'bidExaminerCertNo', value: getValue(bidderInfo, ['_BidExaminerCertNo']) }, // 投标单位审核人资格证书编号
|
|
|
+ { key: 'bidExamineDate', value: getValue(bidderInfo, ['_BidExamineDate']) }, // 投标单位审核时间
|
|
|
+ { key: 'bidApprover', value: getValue(bidderInfo, ['_BidApprover']) }, // 投标单位审定人
|
|
|
+ { key: 'bidApproverCertNo', value: getValue(bidderInfo, ['_BidApproverCertNo']) }, // 投标单位审定人资格证书
|
|
|
+ { key: 'bidApproveDate', value: getValue(bidderInfo, ['_BidApproveDate']) }, // 投标单位审定时间
|
|
|
+ ];
|
|
|
+
|
|
|
+ }
|
|
|
+ // 从xml对象中提取单项工程数据
|
|
|
+ function extractEngs(projectSrc) {
|
|
|
+ const sectionWorks = arrayValue(projectSrc, ['ProjectInstallationWorkCost', 'SectionalWorks']);
|
|
|
+ return sectionWorks.map(src => {
|
|
|
+ countData.projectCount++;
|
|
|
+ return {
|
|
|
+ projType: projectType.Engineering,
|
|
|
+ name: getValue(src, ['_Name']),
|
|
|
+ code: getValue(src, ['_Number']),
|
|
|
+ tenders: extractTenders(src)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 从xml对象中提取单位工程数据
|
|
|
+ function extractTenders(sectionWorkSrc) {
|
|
|
+ const unitWorks = arrayValue(sectionWorkSrc, ['UnitWorks']);
|
|
|
+ return unitWorks.map(src => {
|
|
|
+ countData.projectCount++;
|
|
|
+ countData.unitPriceFileCount++;
|
|
|
+ return {
|
|
|
+ projType: projectType.Tender,
|
|
|
+ name: getValue(src, ['_Name']),
|
|
|
+ code: getValue(src, ['_Number']),
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 解压cos、zip文件
|
|
|
* @param {File} file - 上传的文件
|
|
@@ -71,17 +185,8 @@ const importXML = (() => {
|
|
|
}
|
|
|
xmlObjMap[fileName] = xmlObj;
|
|
|
}
|
|
|
- if (escape) {
|
|
|
- xmlStr = util.escapeXMLEntity(xmlStr);
|
|
|
- }
|
|
|
- let xmlObj = x2js.xml_str2json(xmlStr);
|
|
|
- xmlObj = JSON.parse(util.restoreXMLEntity(JSON.stringify(xmlObj)));
|
|
|
- if (!xmlObj) {
|
|
|
- throw '无有效数据。';
|
|
|
- }
|
|
|
- //console.log(xmlObj);
|
|
|
//提取数据
|
|
|
- return loadProject(xmlObj);
|
|
|
+ return loadData(xmlObjMap);
|
|
|
};
|
|
|
|
|
|
// 接受上传的文件类型(不同的省份可以上传的文件不同)
|
|
@@ -89,5 +194,6 @@ const importXML = (() => {
|
|
|
|
|
|
return {
|
|
|
accept,
|
|
|
+ extractData,
|
|
|
}
|
|
|
})();
|