瀏覽代碼

广东接口导入控制价文件,更改为跟导入投标文件一样完整导入数据

vian 5 年之前
父節點
當前提交
a1a3e46b23
共有 1 個文件被更改,包括 21 次插入21 次删除
  1. 21 21
      web/over_write/js/guangdong_2018_import.js

+ 21 - 21
web/over_write/js/guangdong_2018_import.js

@@ -28,6 +28,8 @@ const importXML = (() => {
     //导入的文件类型,界面选的文件类型是生成项目的文件类型,这里的文件类型指的是,要导入文件的类型,
     //导入文件类型不同,导入数据不同
     let importFileKind = '';
+    // 投标文件和控制价文件是完全导入数据的
+    let isFullyImport = false;
     // 文件类型
     const FileKind = {
         '6': 1, // 投标
@@ -97,6 +99,7 @@ const importXML = (() => {
         const projectXMLObj = xmlObjMap['Project.xml'];
         const projectSrc = getValue(projectXMLObj, ['ConstructionProject']);
         importFileKind = FileKind[getValue(projectSrc, ['_FileKind'])]; // 标记当前导入的文件类型
+        isFullyImport = [FileKind.tender, FileKind.control].includes(importFileKind);
         const rst = {
             projType: projectType.Project,
             name: getValue(projectSrc, ['_Name']),
@@ -107,7 +110,7 @@ const importXML = (() => {
             basicInformation: extractBasicInfo(projectSrc)
         };
         countData.unitPriceCount = countData.projectGLJCount;
-        if (importFileKind !== FileKind.tender) {
+        if (!isFullyImport) {
             countData = {
                 projectCount: countData.projectCount,
                 unitPriceFileCount: countData.unitPriceFileCount
@@ -267,7 +270,7 @@ const importXML = (() => {
                 const feeRate = getValue(src, ['_Rate']);
                 item.feeRate = +feeRate !== 100 && feeRate || undefined;
             }
-            if (importFileKind !== FileKind.tender) {
+            if (!isFullyImport) {
                 delete item.feeRate
                 delete item.fees;
             }
@@ -327,7 +330,7 @@ const importXML = (() => {
                 item.feeCode = FlagFeeCodeMap[fixedFlag.OTHER_MEASURE_FEE];
             }
         }
-        if (importFileKind === FileKind.tender) {
+        if (isFullyImport) {
             const summaryFees = getFeesFromBasicCost(divisionalSrc);
             const fees = [{ fieldName: 'common', totalFee: getValue(divisionalSrc, ['_Total']), unitFee: getValue(divisionalSrc, ['_TechnicalAndEconomicIndex']) }];
             item.fees = mergeFees(fees, summaryFees);
@@ -360,21 +363,19 @@ const importXML = (() => {
             bills.feeRate = +feeRate !== 100 && feeRate || undefined;
         }
         // 投标和控制价,需要导入最高限价
-        if ([FileKind.tender, FileKind.control].includes(importFileKind)) {
+        if (isFullyImport) {
             const maxPrice = getValue(workElementSrc, ['_PriceHigh']);
             //不为0才输出
             if (maxPrice && maxPrice !== '0') {
                 bills.outPutMaxPrice = true;
                 bills.maxPrice = maxPrice;
             }
-            if (importFileKind === FileKind.tender) {
-                const summaryFees = getFeesFromBasicCost(workElementSrc);
-                const fees = [
-                    { fieldName: 'common', unitFee: getValue(workElementSrc, ['_Price']), totalFee: getValue(workElementSrc, ['_Total']) },
-                    { fieldName: 'equipment', unitFee: getValue(workElementSrc, ['_EquipmentPrice']) },
-                ];
-                bills.fees = mergeFees(fees, summaryFees);
-            }
+            const summaryFees = getFeesFromBasicCost(workElementSrc);
+            const fees = [
+                { fieldName: 'common', unitFee: getValue(workElementSrc, ['_Price']), totalFee: getValue(workElementSrc, ['_Total']) },
+                { fieldName: 'equipment', unitFee: getValue(workElementSrc, ['_EquipmentPrice']) },
+            ];
+            bills.fees = mergeFees(fees, summaryFees);
         }
         return bills;
         // 获取项目特征文本
@@ -436,7 +437,7 @@ const importXML = (() => {
     }
     // 提取定额
     function extractRations(workElementSrc) {
-        if (importFileKind !== FileKind.tender) {
+        if (!isFullyImport) {
             return [];
         }
         // 正常情况下定额肯定是在WorkContent内的,但是也做定额不在WorkContent内的处理(外层定额)
@@ -569,7 +570,7 @@ const importXML = (() => {
         const sundryFees = [{ fieldName: 'common', totalFee: getValue(sundryCosts, ['_Total']) }];
         const provisionalMaterialEquipment = getValue(sundry, ['ProvisionalMaterialEquipment']);
         return {
-            fees: importFileKind === FileKind.tender ? sundryFees : [],
+            fees: isFullyImport ? sundryFees : [],
             sundryCosts: extractData(sundry, 'SundryCosts', [['SundryCostsGroup'], ['SundryCostsItem']]),
             provisional: extractData(sundry, 'ProvisionalSums', [['ProvisionalSumsGroup'], ['ProvisionalSumsItem']]),
             ProvisionalMaterialEquipment: {
@@ -591,7 +592,7 @@ const importXML = (() => {
             if (isGroup) {
                 source = {
                     name: getValue(itemSrc, ['_Name']),
-                    fees: importFileKind === FileKind.tender ? [{ fieldName: 'common', totalFee: getValue(itemSrc, ['_Total']) }] : [],
+                    fees: isFullyImport ? [{ fieldName: 'common', totalFee: getValue(itemSrc, ['_Total']) }] : [],
                     feeCode: getValue(itemSrc, ['_Code']),
                     remark: getValue(itemSrc, ['_Remark'])
                 };
@@ -602,7 +603,7 @@ const importXML = (() => {
                     unit: getValue(itemSrc, ['_Unit']),
                     calcBase: getValue(itemSrc, ['_QtyFormula']),
                     feeRate: +feeRate !== 100 && feeRate || undefined,
-                    fees: importFileKind === FileKind.tender ? [{ fieldName: 'common', unitFee: getValue(itemSrc, ['_Price']), totalFee: getValue(itemSrc, ['_Total']) }] : [],
+                    fees: isFullyImport ? [{ fieldName: 'common', unitFee: getValue(itemSrc, ['_Price']), totalFee: getValue(itemSrc, ['_Total']) }] : [],
                     feeCode: getValue(itemSrc, ['_Code']),
                     remark: getValue(itemSrc, ['_Remark'])
                 };
@@ -616,7 +617,7 @@ const importXML = (() => {
         function extractData(sundry, srcName, fields, groupExtendMap, itemExtendMap) {
             const src = getValue(sundry, [srcName]);
             return {
-                fees: importFileKind === FileKind.tender ? [{ fieldName: 'common', totalFee: getValue(src, ['_Total']) }] : [],
+                fees: isFullyImport ? [{ fieldName: 'common', totalFee: getValue(src, ['_Total']) }] : [],
                 feeCode: getValue(src, ['_Code']),
                 items: extractItemsRecur(src, fields, (itemSrc, curField) => {
                     const groupExtend = groupExtendMap
@@ -652,7 +653,7 @@ const importXML = (() => {
                 name: getValue(src, ['_Name']),
                 calcBase: getValue(src, ['_QtyFormula']),
                 feeRate: +feeRate !== 100 && feeRate || undefined,
-                fees: importFileKind === FileKind.tender ? [{ fieldName: 'common', totalFee: getValue(src, ['_Total']) }] : [],
+                fees: isFullyImport ? [{ fieldName: 'common', totalFee: getValue(src, ['_Total']) }] : [],
                 feeCode: getValue(src, ['_Code']),
                 remark: getValue(src, ['_Remark'])
             };
@@ -669,7 +670,7 @@ const importXML = (() => {
     // 提取人材机汇总相关(人材机汇总表、承包材料表)
     function extractGLJSummary(tenderSrc) {
         const initData = { gljSummary: [], differentiaSummary: [], exponentialSummary: [] };
-        if (importFileKind !== FileKind.tender) {
+        if (!isFullyImport) {
             return initData;
         }
         const taxType = getValue(tenderSrc, ['_TaxModel']); // 计税方式
@@ -805,7 +806,7 @@ const importXML = (() => {
     }
     // 提取评标材料
     function extractBidEvaluationSummary(tenderSrc) {
-        if (importFileKind !== FileKind.tender) {
+        if (!isFullyImport) {
             return [];
         }
         const srcList = arrayValue(tenderSrc, ['BidEvaluationMainMaterial']);
@@ -1611,7 +1612,6 @@ const importXML = (() => {
             fileMap[fileName] = fileMap[fileName].replace(reg, '<?xml version="1.0" encoding="utf-8"?>');
             // x2js转换xml使用了DomParser接口,会将一些字符实体进行转义。若不想被自动转义,则需要调用escapeXMLEntity
             const xmlStr = escape ? util.escapeXMLEntity(fileMap[fileName]) : fileMap[fileName];
-            console.log(xmlStr);
             //将xml格式良好的字符串转换成对象
             const x2js = new X2JS();
             let xmlObj = x2js.xml_str2json(xmlStr);