فهرست منبع

Merge branch '1.0.0_online' of http://192.168.1.41:3000/SmartCost/ConstructionCost into 1.0.0_online

TonyKang 6 سال پیش
والد
کامیت
8bd25f8e13

+ 21 - 0
modules/pm/facade/pm_facade.js

@@ -710,6 +710,25 @@ async function getIndexReportData(prj_id, filters) {
     return await project_facade.getIndexReportData(prj_id, filters);
 }
 
+// 根据树结构数据排序
+function getSortedDataByTree(data) {
+    // NextSiblingID-数据映射
+    const mapping = {};
+    data.forEach(item => mapping[item.NextSiblingID] = item);
+    let lastItem = data.find(item => +item.NextSiblingID === -1);
+    if (!lastItem) {
+        return data;
+    }
+    const rst = [lastItem];
+    let preItem = mapping[lastItem.ID];
+    while (preItem) {
+        rst.unshift(preItem);
+        preItem = mapping[preItem.ID];
+    }
+    // 根据树结构排序形成的新数组与旧数组项数不同,说明树结构数据有问题(断链),则返回原本数据。
+    return rst.length === data.length ? rst : data;
+}
+
 //根据单位工程ID获取汇总信息
 //@param {Number}tenderID {String}summaryType @return {Object}
 async function getSummaryInfoByTender(tenderID, summaryType) {
@@ -734,6 +753,7 @@ async function getSummaryInfoByTender(tenderID, summaryType) {
     if(summaryType === projectType.engineering){ // 汇总到单项工程级别
         parent = engineering;
         let tenders = await projectModel.find({ParentID: engineering.ID, $or: notDeleted});
+        tenders = getSortedDataByTree(tenders);
         for(let t of tenders){
             if(summaryInfo[t.ID]){
                 summaryInfo[t.ID]['name'] = t.name ? t.name : '';
@@ -743,6 +763,7 @@ async function getSummaryInfoByTender(tenderID, summaryType) {
     } else { // 汇总到建设项目级别
         parent = project;
         let engs = await projectModel.find({ParentID: project.ID, $or: notDeleted});
+        engs = getSortedDataByTree(engs);
         for(let e of engs){
             if(summaryInfo[e.ID]){
                 summaryInfo[e.ID]['name'] = e.name ? e.name : '';

+ 8 - 6
modules/ration_glj/facade/ration_glj_facade.js

@@ -55,7 +55,6 @@ const projectDao = require('../../pm/models/project_model').project;
 const compleClassModel = mongoose.model('complementary_glj_section');
 
 
-
 let operationMap = {
     'ut_create': create_ration_glj,
     'ut_update': update_ration_glj,
@@ -751,13 +750,16 @@ async function updateRationGLJFromDoc(rg,doc,priceInfo) {
     let projcetGLJ_n = await gljListModel.modifyGLJ(projectGLJ, rg);
     doc.code = projcetGLJ_n.code;
     doc.projectGLJID = projcetGLJ_n.id;
-    if (projcetGLJ_n.unit_price.is_add == 1) {
-        doc.createType = 'replace';
-        doc.rcode = projcetGLJ_n.original_code;
-    } else {
+    if(rg.createType == 'replace'&& rg.rcode == projcetGLJ_n.code){//如果原数据已经是替换过的,这次替换又恢复成原数据,则把类型改回来
         doc.createType = 'normal';
-        doc.rcode = '';
     }
+    if (rg.createType===undefined || rg.createType == 'normal'){// createTypel 默认是normal 只有是定额下带的工料机才需把类型改成替换,其它的保持不变
+        if(rg.code != projcetGLJ_n.code){
+            doc.createType = 'replace';
+            doc.rcode = rg.code;
+        }
+    }
+
     await ration_glj.findOneAndUpdate({ID:rg.ID}, doc);
     return [projcetGLJ_n,doc]
 }

+ 9 - 0
public/web/sheet/sheet_common.js

@@ -395,6 +395,15 @@ var sheetCommonObj = {
         c.isThreeState(threeState);
         return c
     },
+    // 无法勾选的复选框
+    getReadOnlyCheckBox () {
+        function ReadOnlyCheckBox() {}
+        ReadOnlyCheckBox.prototype = new GC.Spread.Sheets.CellTypes.CheckBox();
+        ReadOnlyCheckBox.prototype.processMouseUp = function () {
+            return;
+        };
+        return new ReadOnlyCheckBox();
+    },
     setComboBox(row,col,sheet,options,editorValueType,editable,maxDropDownItems){
         //let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
         let dynamicCombo = sheetCommonObj.getDynamicCombo(true);

+ 7 - 0
web/building_saas/main/js/models/exportStandardInterface.js

@@ -69,6 +69,7 @@ const XMLStandard = (function () {
         '{其他项目费}': 'QTXMHJ',
         '{规费}': 'GF',
         '{税金}': 'SJ',
+        '{税前工程造价}': 'SQGCZJ',
         '{分部分项定额人工费}': 'RGF',
         '{分部分项定额材料费}': 'CLF',
         '{分部分项定额施工机具使用费}': 'JXF',
@@ -106,6 +107,7 @@ const XMLStandard = (function () {
         'QTXMHJ': '其他项目费',
         'GF': '规费',
         'SJ': '税金',
+        'SQGCZJ': '税前工程造价',
         'RGF': '分部分项定额人工费',
         'CLF': '分部分项定额材料费',
         'JXF': '分部分项定额施工机具使用费',
@@ -1926,9 +1928,14 @@ const XMLStandard = (function () {
                     '6': '400'
                 };
                 for (let glj of allGljs) {
+                    // 企业管理费、利润、一般风险费不导出
                     if (skipGLJTypes.includes(glj.type)) {
                         continue;
                     }
+                    // 总消耗量为0不导出
+                    if (!+glj.quantity) {
+                        continue;
+                    }
                     let price = gljUtil.getGLJPrice(glj, detail.projectGLJ.datas,
                         detail.projectInfo.property.calcOptions, detail.labourCoe.datas, detail.projectInfo.property.decimal, false, _, scMathUtil);
                     //调整价

+ 1 - 1
web/building_saas/main/js/models/exportStdInterfaceBase.js

@@ -547,7 +547,7 @@ const XML_EXPORT_BASE = (() => {
                 } else {
                     let totalFee = getFee(node.data.fees, 'common.totalFee'),
                         feeRate = node.data.feeRate;
-                    return feeRate && !isNaN(feeRate) ? scMathUtil.roundTo(totalFee/feeRate, -2) : totalFee
+                    return +feeRate ? scMathUtil.roundTo(totalFee/(feeRate/100), -2) : totalFee
                 }
             }
             return expr;

+ 24 - 11
web/building_saas/main/js/models/importStandardInterface.js

@@ -892,14 +892,19 @@ const ImportXML = (() => {
             return gljsSrc.map(gljSrc => {
                 countData.projectGLJCount++;
                 //编码都取原始编码,如果原始编码为空,都取编码
-                let orgCode = getValue(gljSrc, ['_原始代码']),
+                let sourceCode = getValue(gljSrc, ['_原始代码']),
                     code = getValue(gljSrc, ['_代码']);
-                if (!orgCode) {
-                    orgCode = code;
+                if (!sourceCode) {
+                    sourceCode = code;
                 }
+                // 人材机的真正原始编号应按规矩处理,不能直接读取编码。
+                // 应取sourceCode,qtf文件中原始代码的最后一个“-”前面的文本;如果没有“-”则直接取原始代码
+                const orgCodeReg = /.*(?=-\d+$)/;
+                const match = sourceCode.match(orgCodeReg);
+                const orgCode = match ? match[0] : sourceCode;
                 let gljData = {
                     customCode: code,   //处理自定义的代码 (有的公司定额人材机代码、人材机代码是用自动生成的代码)
-                    code: orgCode,
+                    code: sourceCode,
                     original_code: orgCode,
                     name: getValue(gljSrc, ['_名称']),
                     specs: getValue(gljSrc, ['_规格']),
@@ -1208,6 +1213,11 @@ const ImportXML = (() => {
             addFixedBlock(fixedFlag.PROVISIONAL, tenderData.other.provisional.items, tenderData.other.provisional.fees);
             //专业工程暂估价
             addFixedBlock(fixedFlag.ENGINEERING_ESITIMATE, tenderData.other.engineeringPro.items, tenderData.other.engineeringPro.fees);
+            // 专业工程暂估价汇总金额设置为暂估价清单金额
+            let estimateFixedBills = billsTarget.find(d => getFlag(d) === fixedFlag.ESTIMATE);
+            if (estimateFixedBills) {
+                estimateFixedBills.fees = tenderData.other.engineeringPro.fees;
+            }
             //计日工
             addFixedBlock(fixedFlag.DAYWORK, null, tenderData.other.dayWork.fees);
             //人工
@@ -1321,6 +1331,7 @@ const ImportXML = (() => {
             GF: '{规费}',
             SJ: '{税金}',
             SJHJ: '{税金}',
+            SQGCZJ: '{税前工程造价}'
         };
         //转换计算基数
         //1.有子项数据,则清空基数
@@ -1531,8 +1542,8 @@ const ImportXML = (() => {
                 mixRatio: []    //组成物
             };
             //工料机汇总code-数据映射
-            // 项目人材机customCode、original_code-原始数据映射,有的导入数据中,有一部分关联自生成材料号CX,有的关联原始代码...
-            // 因此customCode、original_code都需要跟原始数据映射,通过customCode取不到数据的时候,通过orgCode获取
+            // 项目人材机customCode、code-原始数据映射,有的导入数据中,有一部分关联自生成材料号CX,有的关联代码...
+            // 因此customCode、code都需要跟原始数据映射,通过customCode取不到数据的时候,通过orgCode获取
             let projectGLJMap = {};
             //投标文件才需要导入定额等数据
             if (importFileKind === FileKind.tender) {
@@ -1544,14 +1555,14 @@ const ImportXML = (() => {
                     pGLJ.shortName = pGLJ.shortName || '材';
                     //gljCodeMap[pGLJ.code] = pGLJ;
                     projectGLJMap[pGLJ.customCode] = pGLJ;
-                    projectGLJMap[pGLJ.original_code] = pGLJ;
+                    projectGLJMap[pGLJ.code] = pGLJ;
                 });
                 //处理项目人材机数据
                 tenderData.gljSummary.forEach(pGLJ => {
                     //组成物数据
                     pGLJ.ratios.forEach(ratio => {
                         let matchData = projectGLJMap[ratio.code];
-                        ratio.code = matchData.original_code;
+                        ratio.code = matchData.code;
                         ratio.projectGLJID = pGLJ.id; //后端查找标准数据后,方便更新组成物数据
                         ratio.id = IDPlaceholder.ratio++;
                         ratio.unit_price_file_id = tenderData.property.unitPriceFile.id;
@@ -1559,7 +1570,7 @@ const ImportXML = (() => {
                         ratio.name = matchData ? matchData.name : '';
                         ratio.specs = matchData ? matchData.specs : '';
                         ratio.type = matchData ? matchData.type : 1;
-                        ratio.connect_key = [pGLJ.original_code || 'null', pGLJ.name || 'null', pGLJ.specs || 'null', pGLJ.unit || 'null', pGLJ.type].join('|-|');
+                        ratio.connect_key = [pGLJ.code || 'null', pGLJ.name || 'null', pGLJ.specs || 'null', pGLJ.unit || 'null', pGLJ.type].join('|-|');
                         rst.mixRatio.push(ratio);
                     });
                     delete pGLJ.ratios;
@@ -1650,7 +1661,8 @@ const ImportXML = (() => {
                         if (!bills.quantity || !ration.quantity){
                             ration.contain = '0';
                         } else {
-                            ration.contain = scMathUtil.roundForObj(ration.quantity / bills.quantity, 6);
+                            let tempV = ration.quantity / bills.quantity;
+                            ration.contain = isFinite(tempV) ? scMathUtil.roundForObj(tempV, 6) : '0';
                         }
                         //工程量表达式:工程量 * 单位前的量
                         /*if (!ration.unit) {
@@ -1663,12 +1675,13 @@ const ImportXML = (() => {
                                 ? scMathUtil.roundForObj(ration.quantity * unitNum[0], qDecimal ? qDecimal[0] - 1 : 0)
                                 : ration.quantity;
                         }*/
+                        // 问题
                         //处理定额人材机,添加需要的数据
                         ration.rationGljs.forEach(rGLJ => {
                             let matchGLJ = projectGLJMap[rGLJ.code];
                             if (matchGLJ) {
                                 rGLJ.projectGLJID = matchGLJ.id;
-                                rGLJ.code = matchGLJ.original_code;
+                                rGLJ.code = matchGLJ.code;
                                 rGLJ.type = matchGLJ.type;
                                 rGLJ.shortName = matchGLJ.shortName;
                                 rGLJ.name = matchGLJ.name;

+ 9 - 0
web/building_saas/main/js/models/main_consts.js

@@ -403,6 +403,15 @@ const filterType = {
     ZYCL:'11',
     AMAE:'12'
 };
+// 文件类型
+const _fileKind = {
+    // 投标
+    tender: 1,
+    // 招标
+    bid: 2,
+    // 控制价
+    control: 3
+};
 const filterTypeArray = ['1','2','3','4','5'];
 
 const installFeeType = ['子目费用','分项费用','措施费用'];

+ 12 - 4
web/building_saas/main/js/views/main_tree_col.js

@@ -44,7 +44,6 @@ let MainTreeCol = {
             if(!isDef(node)){
                 return '';
             }
-
             let rst = '';
             if(node.sourceType === projectObj.project.Ration.getSourceType() && node.data.type === rationType.ration
                 && isDef(node.data.code) && isDef(node.data.prefix) && node.data.prefix !== ''){
@@ -305,8 +304,11 @@ let MainTreeCol = {
             return true;
         },
         maxPrice:function (node) {
-            if($("#fileKind").val() == '1') return true;//对于投标项目只读
-            return   node.data.outPutMaxPrice!==true;
+            // 对于投标项目只读
+            if(+$('#fileKind').val() === _fileKind.tender) {
+                return true;
+            }
+            return node.data.outPutMaxPrice !== true;
         }
     },
     cellType: {
@@ -411,7 +413,13 @@ let MainTreeCol = {
             if(MainTreeCol.mainBillsEnable(node)) return sheetCommonObj.getCheckBox(true);
         },
         outPutMaxPrice:function (node) {
-            if(MainTreeCol.mainBillsEnable(node) && $("#fileKind").val() != '1') return sheetCommonObj.getCheckBox(true);
+            if(MainTreeCol.mainBillsEnable(node)) {
+                // 投标项目,复选框不可改变
+                const checkBox = +$('#fileKind').val() === _fileKind.tender
+                    ? sheetCommonObj.getReadOnlyCheckBox()
+                    : sheetCommonObj.getCheckBox(true);
+                return checkBox;
+            }
         }
     },
     mainBillsEnable:function (node) {