Browse Source

Merge branch 'master' of http://192.168.1.41:3000/SmartCost/ConstructionCost

zhangweicheng 5 years ago
parent
commit
9c8c166c92

+ 11 - 3
modules/pm/facade/pm_facade.js

@@ -1912,8 +1912,15 @@ async function getProjectPlaceholder(data) {
 /*
 /*
 * 接口导入 项目详细数据都导入完成了,再生成项目数据(项目管理界面数据)
 * 接口导入 项目详细数据都导入完成了,再生成项目数据(项目管理界面数据)
 * */
 * */
-async function importProject(importObj, userID, compilationID) {
+async function importProject(importObj, userID, compilationID, overWriteUrl) {
     let toInsertProjects = [importObj];  //待新增项目数据
     let toInsertProjects = [importObj];  //待新增项目数据
+    let billsCalcMode = 0;
+    if (overWriteUrl) {
+        const overWrite = require('../../..' + overWriteUrl);
+        if(overWrite.getBillsCalcMode) { // 重写清单计费取费方式
+            billsCalcMode = overWrite.getBillsCalcMode();
+        }
+    }
     await setupProject(importObj);
     await setupProject(importObj);
     //设置项目ID及相关数据
     //设置项目ID及相关数据
     for (let curEng of importObj.engs) {
     for (let curEng of importObj.engs) {
@@ -2020,7 +2027,7 @@ async function importProject(importObj, userID, compilationID) {
         //呈现选项
         //呈现选项
         data.property.displaySetting = displaySetting;
         data.property.displaySetting = displaySetting;
 
 
-        data.property.billsCalcMode = 0;
+        data.property.billsCalcMode = billsCalcMode;
         data.property.zanguCalcMode = 0;
         data.property.zanguCalcMode = 0;
         //计算选项
         //计算选项
         data.property.calcOptions = calcOptions;
         data.property.calcOptions = calcOptions;
@@ -2482,7 +2489,8 @@ async function handleImportInterface(key, session) {
         if (await isTenderOverrun(tenderCount, session)) {
         if (await isTenderOverrun(tenderCount, session)) {
             throw '您创建的项目个数超限,请联系我们的客服人员,或者导出建设项目保存到本地备份,删除云上数据。';
             throw '您创建的项目个数超限,请联系我们的客服人员,或者导出建设项目保存到本地备份,删除云上数据。';
         }
         }
-        const projectID = await importProject(importData, userID, compilationID);
+        const overWriteUrl = session.sessionCompilation.overWriteUrl;
+        const projectID = await importProject(importData, userID, compilationID, overWriteUrl);
         doc.projectID = [projectID];
         doc.projectID = [projectID];
     } catch (err) {
     } catch (err) {
         doc.errorMsg = typeof err === 'string' ? err : '导入接口失败,请检查接口文件!';
         doc.errorMsg = typeof err === 'string' ? err : '导入接口失败,请检查接口文件!';

+ 5 - 0
web/over_write/js/guangdong_2018.js

@@ -100,6 +100,11 @@ if (typeof module !== 'undefined') {
         $('#add-content').val('3');
         $('#add-content').val('3');
     });
     });
 
 
+    // 隐藏项目属性中:取费方式中的子目含量取费选项
+    if ($('#rationContent')) {
+        $('#rationContent').parent().hide();
+    }
+
     //清单计算基数相关
     //清单计算基数相关
     if(typeof baseFigureMap !== 'undefined'){
     if(typeof baseFigureMap !== 'undefined'){
         baseFigureMap = {
         baseFigureMap = {

+ 3 - 2
web/over_write/js/guangdong_2018_export.js

@@ -2621,7 +2621,7 @@ const XMLStandard = (function () {
                     ele = groupFactory(node);
                     ele = groupFactory(node);
                     // 递归获取子元素
                     // 递归获取子元素
                     ele.children = loadGroupAndItems(node.children, groupFactory, itemFactory);
                     ele.children = loadGroupAndItems(node.children, groupFactory, itemFactory);
-                } else { // 无子清单的是分项
+                } else { // 无子清单的是子目(除了计日工,计日工最底层节点也需要是标题,否则检测平台会报错)
                     ele = itemFactory(node);
                     ele = itemFactory(node);
                 }
                 }
                 return ele;
                 return ele;
@@ -2679,10 +2679,11 @@ const XMLStandard = (function () {
             if (!isValidDepth) {
             if (!isValidDepth) {
                 _failList.push('计日工子项超过两层')
                 _failList.push('计日工子项超过两层')
             } else {
             } else {
+                // 计日工最底层节点也需要是标题,否则检测平台会报错
                 dayworkRate.children = loadGroupAndItems(
                 dayworkRate.children = loadGroupAndItems(
                     daywork.children,
                     daywork.children,
                     (node) => new DayWorkRateGroup(node),
                     (node) => new DayWorkRateGroup(node),
-                    (node) => new DayWorkRateItem(node)
+                    (node) => new DayWorkRateGroup(node)
                 );
                 );
             }
             }
             // 总承包服务费
             // 总承包服务费

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

@@ -28,6 +28,8 @@ const importXML = (() => {
     //导入的文件类型,界面选的文件类型是生成项目的文件类型,这里的文件类型指的是,要导入文件的类型,
     //导入的文件类型,界面选的文件类型是生成项目的文件类型,这里的文件类型指的是,要导入文件的类型,
     //导入文件类型不同,导入数据不同
     //导入文件类型不同,导入数据不同
     let importFileKind = '';
     let importFileKind = '';
+    // 投标文件和控制价文件是完全导入数据的
+    let isFullyImport = false;
     // 文件类型
     // 文件类型
     const FileKind = {
     const FileKind = {
         '6': 1, // 投标
         '6': 1, // 投标
@@ -97,6 +99,7 @@ const importXML = (() => {
         const projectXMLObj = xmlObjMap['Project.xml'];
         const projectXMLObj = xmlObjMap['Project.xml'];
         const projectSrc = getValue(projectXMLObj, ['ConstructionProject']);
         const projectSrc = getValue(projectXMLObj, ['ConstructionProject']);
         importFileKind = FileKind[getValue(projectSrc, ['_FileKind'])]; // 标记当前导入的文件类型
         importFileKind = FileKind[getValue(projectSrc, ['_FileKind'])]; // 标记当前导入的文件类型
+        isFullyImport = [FileKind.tender, FileKind.control].includes(importFileKind);
         const rst = {
         const rst = {
             projType: projectType.Project,
             projType: projectType.Project,
             name: getValue(projectSrc, ['_Name']),
             name: getValue(projectSrc, ['_Name']),
@@ -107,7 +110,7 @@ const importXML = (() => {
             basicInformation: extractBasicInfo(projectSrc)
             basicInformation: extractBasicInfo(projectSrc)
         };
         };
         countData.unitPriceCount = countData.projectGLJCount;
         countData.unitPriceCount = countData.projectGLJCount;
-        if (importFileKind !== FileKind.tender) {
+        if (!isFullyImport) {
             countData = {
             countData = {
                 projectCount: countData.projectCount,
                 projectCount: countData.projectCount,
                 unitPriceFileCount: countData.unitPriceFileCount
                 unitPriceFileCount: countData.unitPriceFileCount
@@ -267,7 +270,7 @@ const importXML = (() => {
                 const feeRate = getValue(src, ['_Rate']);
                 const feeRate = getValue(src, ['_Rate']);
                 item.feeRate = +feeRate !== 100 && feeRate || undefined;
                 item.feeRate = +feeRate !== 100 && feeRate || undefined;
             }
             }
-            if (importFileKind !== FileKind.tender) {
+            if (!isFullyImport) {
                 delete item.feeRate
                 delete item.feeRate
                 delete item.fees;
                 delete item.fees;
             }
             }
@@ -327,7 +330,7 @@ const importXML = (() => {
                 item.feeCode = FlagFeeCodeMap[fixedFlag.OTHER_MEASURE_FEE];
                 item.feeCode = FlagFeeCodeMap[fixedFlag.OTHER_MEASURE_FEE];
             }
             }
         }
         }
-        if (importFileKind === FileKind.tender) {
+        if (isFullyImport) {
             const summaryFees = getFeesFromBasicCost(divisionalSrc);
             const summaryFees = getFeesFromBasicCost(divisionalSrc);
             const fees = [{ fieldName: 'common', totalFee: getValue(divisionalSrc, ['_Total']), unitFee: getValue(divisionalSrc, ['_TechnicalAndEconomicIndex']) }];
             const fees = [{ fieldName: 'common', totalFee: getValue(divisionalSrc, ['_Total']), unitFee: getValue(divisionalSrc, ['_TechnicalAndEconomicIndex']) }];
             item.fees = mergeFees(fees, summaryFees);
             item.fees = mergeFees(fees, summaryFees);
@@ -360,21 +363,19 @@ const importXML = (() => {
             bills.feeRate = +feeRate !== 100 && feeRate || undefined;
             bills.feeRate = +feeRate !== 100 && feeRate || undefined;
         }
         }
         // 投标和控制价,需要导入最高限价
         // 投标和控制价,需要导入最高限价
-        if ([FileKind.tender, FileKind.control].includes(importFileKind)) {
+        if (isFullyImport) {
             const maxPrice = getValue(workElementSrc, ['_PriceHigh']);
             const maxPrice = getValue(workElementSrc, ['_PriceHigh']);
             //不为0才输出
             //不为0才输出
             if (maxPrice && maxPrice !== '0') {
             if (maxPrice && maxPrice !== '0') {
                 bills.outPutMaxPrice = true;
                 bills.outPutMaxPrice = true;
                 bills.maxPrice = maxPrice;
                 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;
         return bills;
         // 获取项目特征文本
         // 获取项目特征文本
@@ -436,7 +437,7 @@ const importXML = (() => {
     }
     }
     // 提取定额
     // 提取定额
     function extractRations(workElementSrc) {
     function extractRations(workElementSrc) {
-        if (importFileKind !== FileKind.tender) {
+        if (!isFullyImport) {
             return [];
             return [];
         }
         }
         // 正常情况下定额肯定是在WorkContent内的,但是也做定额不在WorkContent内的处理(外层定额)
         // 正常情况下定额肯定是在WorkContent内的,但是也做定额不在WorkContent内的处理(外层定额)
@@ -569,7 +570,7 @@ const importXML = (() => {
         const sundryFees = [{ fieldName: 'common', totalFee: getValue(sundryCosts, ['_Total']) }];
         const sundryFees = [{ fieldName: 'common', totalFee: getValue(sundryCosts, ['_Total']) }];
         const provisionalMaterialEquipment = getValue(sundry, ['ProvisionalMaterialEquipment']);
         const provisionalMaterialEquipment = getValue(sundry, ['ProvisionalMaterialEquipment']);
         return {
         return {
-            fees: importFileKind === FileKind.tender ? sundryFees : [],
+            fees: isFullyImport ? sundryFees : [],
             sundryCosts: extractData(sundry, 'SundryCosts', [['SundryCostsGroup'], ['SundryCostsItem']]),
             sundryCosts: extractData(sundry, 'SundryCosts', [['SundryCostsGroup'], ['SundryCostsItem']]),
             provisional: extractData(sundry, 'ProvisionalSums', [['ProvisionalSumsGroup'], ['ProvisionalSumsItem']]),
             provisional: extractData(sundry, 'ProvisionalSums', [['ProvisionalSumsGroup'], ['ProvisionalSumsItem']]),
             ProvisionalMaterialEquipment: {
             ProvisionalMaterialEquipment: {
@@ -591,7 +592,7 @@ const importXML = (() => {
             if (isGroup) {
             if (isGroup) {
                 source = {
                 source = {
                     name: getValue(itemSrc, ['_Name']),
                     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']),
                     feeCode: getValue(itemSrc, ['_Code']),
                     remark: getValue(itemSrc, ['_Remark'])
                     remark: getValue(itemSrc, ['_Remark'])
                 };
                 };
@@ -602,7 +603,7 @@ const importXML = (() => {
                     unit: getValue(itemSrc, ['_Unit']),
                     unit: getValue(itemSrc, ['_Unit']),
                     calcBase: getValue(itemSrc, ['_QtyFormula']),
                     calcBase: getValue(itemSrc, ['_QtyFormula']),
                     feeRate: +feeRate !== 100 && feeRate || undefined,
                     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']),
                     feeCode: getValue(itemSrc, ['_Code']),
                     remark: getValue(itemSrc, ['_Remark'])
                     remark: getValue(itemSrc, ['_Remark'])
                 };
                 };
@@ -616,7 +617,7 @@ const importXML = (() => {
         function extractData(sundry, srcName, fields, groupExtendMap, itemExtendMap) {
         function extractData(sundry, srcName, fields, groupExtendMap, itemExtendMap) {
             const src = getValue(sundry, [srcName]);
             const src = getValue(sundry, [srcName]);
             return {
             return {
-                fees: importFileKind === FileKind.tender ? [{ fieldName: 'common', totalFee: getValue(src, ['_Total']) }] : [],
+                fees: isFullyImport ? [{ fieldName: 'common', totalFee: getValue(src, ['_Total']) }] : [],
                 feeCode: getValue(src, ['_Code']),
                 feeCode: getValue(src, ['_Code']),
                 items: extractItemsRecur(src, fields, (itemSrc, curField) => {
                 items: extractItemsRecur(src, fields, (itemSrc, curField) => {
                     const groupExtend = groupExtendMap
                     const groupExtend = groupExtendMap
@@ -652,7 +653,7 @@ const importXML = (() => {
                 name: getValue(src, ['_Name']),
                 name: getValue(src, ['_Name']),
                 calcBase: getValue(src, ['_QtyFormula']),
                 calcBase: getValue(src, ['_QtyFormula']),
                 feeRate: +feeRate !== 100 && feeRate || undefined,
                 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']),
                 feeCode: getValue(src, ['_Code']),
                 remark: getValue(src, ['_Remark'])
                 remark: getValue(src, ['_Remark'])
             };
             };
@@ -669,7 +670,7 @@ const importXML = (() => {
     // 提取人材机汇总相关(人材机汇总表、承包材料表)
     // 提取人材机汇总相关(人材机汇总表、承包材料表)
     function extractGLJSummary(tenderSrc) {
     function extractGLJSummary(tenderSrc) {
         const initData = { gljSummary: [], differentiaSummary: [], exponentialSummary: [] };
         const initData = { gljSummary: [], differentiaSummary: [], exponentialSummary: [] };
-        if (importFileKind !== FileKind.tender) {
+        if (!isFullyImport) {
             return initData;
             return initData;
         }
         }
         const taxType = getValue(tenderSrc, ['_TaxModel']); // 计税方式
         const taxType = getValue(tenderSrc, ['_TaxModel']); // 计税方式
@@ -805,7 +806,7 @@ const importXML = (() => {
     }
     }
     // 提取评标材料
     // 提取评标材料
     function extractBidEvaluationSummary(tenderSrc) {
     function extractBidEvaluationSummary(tenderSrc) {
-        if (importFileKind !== FileKind.tender) {
+        if (!isFullyImport) {
             return [];
             return [];
         }
         }
         const srcList = arrayValue(tenderSrc, ['BidEvaluationMainMaterial']);
         const srcList = arrayValue(tenderSrc, ['BidEvaluationMainMaterial']);
@@ -1122,7 +1123,8 @@ const importXML = (() => {
     }
     }
     // 检查清单是否引用了自身,比如广联达导出文件中 材料保管费基数为CLBGF
     // 检查清单是否引用了自身,比如广联达导出文件中 材料保管费基数为CLBGF
     function isCalcBaseCycle(bills) {
     function isCalcBaseCycle(bills) {
-        return bills.calcBase.match(new RegExp(`\\b${bills.feeCode}\\b`)); // \b: 匹配前一个字符和后一个字符不全为\w的位置
+        const matched = bills.calcBase.match(new RegExp(`\\b${bills.feeCode}\\b`)); // \b: 匹配前一个字符和后一个字符不全为\w的位置
+        return !!(matched && matched[0]);
     }
     }
     // 转换计算基数
     // 转换计算基数
     // 1.有子项数据,则清空基数
     // 1.有子项数据,则清空基数
@@ -1604,7 +1606,10 @@ const importXML = (() => {
             throw '无有效数据';
             throw '无有效数据';
         }
         }
         const xmlObjMap = {};
         const xmlObjMap = {};
+        // 导入易达的文件,经过unzipFile的decodeFileName,xml文件头部变成了<?xml version="1.0" encoding="utf-8"?>,需要将前面的乱码去除,否则DOMParser转换后是null
+        const reg = /.*<\?xml version="1.0" encoding="utf-8"\?>/i;
         for (const fileName in fileMap) {
         for (const fileName in fileMap) {
+            fileMap[fileName] = fileMap[fileName].replace(reg, '<?xml version="1.0" encoding="utf-8"?>');
             // x2js转换xml使用了DomParser接口,会将一些字符实体进行转义。若不想被自动转义,则需要调用escapeXMLEntity
             // x2js转换xml使用了DomParser接口,会将一些字符实体进行转义。若不想被自动转义,则需要调用escapeXMLEntity
             const xmlStr = escape ? util.escapeXMLEntity(fileMap[fileName]) : fileMap[fileName];
             const xmlStr = escape ? util.escapeXMLEntity(fileMap[fileName]) : fileMap[fileName];
             //将xml格式良好的字符串转换成对象
             //将xml格式良好的字符串转换成对象