Ver código fonte

load projectInfo bug

zhongzewei 6 anos atrás
pai
commit
dd2d04f3f4

+ 10 - 0
modules/pm/controllers/pm_controller.js

@@ -28,6 +28,7 @@ const _ = require('lodash');
 import SectionTreeDao from '../../complementary_ration_lib/models/sectionTreeModel';
 let sectionTreeDao = new SectionTreeDao();
 let consts = require('../../main/models/project_consts');
+const rationLibModel = mongoose.model('std_ration_lib_map');
 
 //统一回调函数
 let callback = function(req, res, err, message, data){
@@ -206,6 +207,15 @@ module.exports = {
             let engineeringLibModel = new EngineeringLibModel();
             let engineeringInfo = project !== null && project.property.engineering_id !== undefined ?
                 await engineeringLibModel.getEngineering(project.property.engineering_id) : null;
+            //查找定额库的定额库编码
+            if (Array.isArray(engineeringInfo.ration_lib)) {
+                let rationLibIDs = engineeringInfo.ration_lib.map(data => data.id);
+                let rationLibs = await rationLibModel.find({ID: {$in: rationLibIDs}}, 'ID libCode');
+                for (let rationLib of rationLibs) {
+                    let lib = engineeringInfo.ration_lib.find(data => data.id == rationLib.ID);
+                    lib.libCode = rationLib.libCode;
+                }
+            }
             let projInfo = project._doc;
             if (engineeringInfo !== null) {
                 if(engineeringInfo.billsGuidance_lib){

+ 28 - 9
web/building_saas/main/js/models/exportStandardInterface.js

@@ -39,6 +39,9 @@ const XMLStandard = (function () {
         //加载数据间隔,减少服务器压力
         const TIMEOUT_TIME = 500;
 
+        function isDef(v) {
+            return typeof v !== 'undefined' && v !== null;
+        }
         /*
          * 检查
          * 创建节点时检查节点的数据
@@ -386,7 +389,7 @@ const XMLStandard = (function () {
                 {name: '定额编号', value: source.viewCode, required: true, minLen: 1, maxLen: 80, whiteSpace: WHITE_SPACE.COLLAPSE},
                 {name: '项目名称', value: source.name, required: true, minLen: 1, maxLen: 255, whiteSpace: WHITE_SPACE.COLLAPSE},
                 {name: '单位', value: source.unit, required: true, minLen: 1, maxLen: 20, whiteSpace: WHITE_SPACE.COLLAPSE},
-                {name: '定额库编码', value: source.libCode, required: true}, //todo
+                {name: '定额库编码', value: source.libCode, required: true},
                 {name: '原始定额编号', value: source.code, minLen: 1, maxLen: 80, whiteSpace: WHITE_SPACE.COLLAPSE},
                 {name: '子目类型', value: source.subType, required: true, type: TYPE.INT, enumeration: ['0', '1', '2', '3', '4', '5', '6']},  //todo
                 {name: '工程量', value: source.quantity, required: true, type: TYPE.DECIMAL},
@@ -490,7 +493,7 @@ const XMLStandard = (function () {
         //技术措施清单定义
         function JSCSBills(source) {
             let attrs = [
-                {name: '技术措施清单', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2, required: true},
+                {name: '金额', value: getFee(source.fees, 'common.totalFee'), type: TYPE.NUM2, required: true},
                 {name: '其中暂估价', value: getFee(source.fees, 'estimate.totalFee'), type: TYPE.NUM2, required: true},
             ];
             element.call(this, '技术措施清单', attrs);
@@ -633,7 +636,8 @@ const XMLStandard = (function () {
                 {name: '计算基础', value: source.calcBase,  maxLen: 255},
                 {name: '费率', value: source.feeRate, type: TYPE.DECIMAL},
                 {name: '金额', value: source.commonTotalFee, type: TYPE.NUM2, required: true},
-                {name: '不计入合价标志', value: !!source.isEstimate, type: TYPE.BOOL},
+                {name: '不计入合价标志', value: false, type: TYPE.BOOL},
+                {name: '招标人标志', value: true, type: TYPE.BOOL},
                 {name: '备注', value: source.remark, maxLen: 255}
             ];
             element.call(this, '其他列项', attrs);
@@ -916,13 +920,22 @@ const XMLStandard = (function () {
             //获取单位工程详细数据
             let tenderDetail = PROJECT.createNew(tenderData.ID, userID);
             await tenderDetail.loadDataSync();
+            //设置定额库编码
+            tenderDetail.rationLibMap = {};
+            let defaultLib = null;
+            if (tenderDetail.projectInfo.engineeringInfo && Array.isArray(tenderDetail.projectInfo.engineeringInfo.ration_lib)) {
+                defaultLib = tenderDetail.projectInfo.engineeringInfo.ration_lib.find(data => data.isDefault);
+                for (let lib of tenderDetail.projectInfo.engineeringInfo.ration_lib) {
+                    tenderDetail.rationLibMap[lib.id] = lib;
+                }
+            }
             //单位工程
             let tenderSource = {
                 code: getIncreamentData('projectCode'),
                 name: tenderData.name,
                 engineeringName: tenderData.property.engineeringName,
                 summaryInfo: summaryInfo[tenderData.ID],
-                defaultRationLibCode: tenderData.defaultRationLibCode,
+                defaultRationLibCode: defaultLib.libCode,
                 taxType: tenderData.property.taxType
             };
             let tender = curTenderEle = new Tender(tenderSource);
@@ -994,9 +1007,12 @@ const XMLStandard = (function () {
         }
         /*
         * 加载清单项目
-        * @param {Object}node(清单树节点) {Array}allRation(项目所有定额数据) {Array}allRationGlj(项目所有定额人材机数据) {Object}decimal(项目小数位数)
+        * @param {Object}node(清单树节点) {Object}detail
         * */
-        function loadBills(node, allRation, allRationGlj, decimal) {
+        function loadBills(node, detail) {// allRation, allRationGlj, decimal,
+            let allRation = detail.Ration.datas,
+                allRationGlj = detail.ration_glj.datas,
+                decimal = detail.projectInfo.property.decimal;
             let source = {
                 code: node.data.code,
                 name: node.data.name,
@@ -1102,6 +1118,9 @@ const XMLStandard = (function () {
                     isSubcontract: rationData.isSubcontract,
                     remark: rationData.remark
                 };
+                if (rationData.from === 'std' && isDef(rationData.libID)) {    //来自标准库,设置定额库编码
+                    rationSource.libCode = detail.rationLibMap[rationData.libID].libCode;
+                }
                 let ration = new Ration(rationSource);
                 //创建工料分析
                 let gljAnalyze = new GljAnalyze();
@@ -1167,11 +1186,11 @@ const XMLStandard = (function () {
                     fbfxBills.children.push(fbBills);
                     //创建清单项目节点
                     for (let subNode of node.children) {
-                        let fx = loadBills(subNode, detail.Ration.datas, detail.ration_glj.datas, curPMData.tender.property.decimal);
+                        let fx = loadBills(subNode, detail);
                         fbBills.children.push(fx);
                     }
                 } else {
-                    let fxBills = loadBills(node, detail.Ration.datas, detail.ration_glj.datas, curPMData.tender.property.decimal);
+                    let fxBills = loadBills(node, detail);
                     fbfxBills.children.push(fxBills);
                 }
             }
@@ -1249,7 +1268,7 @@ const XMLStandard = (function () {
                         parent.children.push(jscsClass);
                         loadJSCS(jscsClass, node.children);
                     } else {    //清单项目
-                        parent.children.push(loadBills(node, detail.Ration.datas, detail.ration_glj.datas, curPMData.tender.property.decimal));
+                        parent.children.push(loadBills(node, detail));
                     }
                 }
             }

+ 16 - 11
web/building_saas/main/js/models/project.js

@@ -32,18 +32,23 @@ var PROJECT = {
         };
         tools.doAfterLoad = function(result, callback){
             var counter;
+            //必须要先load ProjectInfo的信息
+            let projectInfoModule = result.find(data => data.moduleName === ModuleNames.projectInfo);
+            if (projectInfoModule) {
+                me._project.projectInfo = projectInfoModule.data;
+            }
             result.forEach(function(item){
-                if (me.modules[item.moduleName]){
-                    me.modules[item.moduleName].loadData(item.data);
-                } else if (item.moduleName === me.projCounter) {
-                    counter = item.data;
-                } else if (item.moduleName === me.projSetting) {
-                    me._project.projSetting = item.data;
-                    me._project.projSetting.moduleName = me.projSetting;
-                }else if(item.moduleName === ModuleNames.projectGLJ){
-                    me._project.projectGLJ.loadToCache(item.data);
-                } else if (item.moduleName === ModuleNames.projectInfo) {
-                    me._project.projectInfo = item.data;
+                if (item.moduleName !== ModuleNames.projectInfo) {
+                    if (me.modules[item.moduleName]){
+                        me.modules[item.moduleName].loadData(item.data);
+                    } else if (item.moduleName === me.projCounter) {
+                        counter = item.data;
+                    } else if (item.moduleName === me.projSetting) {
+                        me._project.projSetting = item.data;
+                        me._project.projSetting.moduleName = me.projSetting;
+                    } else if(item.moduleName === ModuleNames.projectGLJ){
+                        me._project.projectGLJ.loadToCache(item.data);
+                    }
                 }
             });
             for (module in counter) {

+ 3 - 5
web/building_saas/main/js/views/project_view.js

@@ -646,8 +646,7 @@ var projectObj = {
                     this.locateAtRation(libID, code);
                     this.doAfterGetRationTree = null;
                 };
-            }
-            else {
+            } else {
                 if($('#stdRationLibSelect').select().val() != libID){
                     let libOpts = $('#stdRationLibSelect').find('option');
                     for(let libOpt of libOpts){
@@ -661,8 +660,7 @@ var projectObj = {
                         this.locateAtRation(libID, code);
                         this.doAfterGetRationTree = null;
                     };
-                }
-                else {
+                } else {
                     rationLibObj.locateAtRation(node.data.libID, code);
                 }
             }
@@ -2358,7 +2356,7 @@ $('#compilationIllustration').keyup(function () {
 });
 $('#property_ok').click(async function () {
     //test-----
-  /*  $.bootstrapLoading.start();
+    /*$.bootstrapLoading.start();
     let xmlObj = new XMLStandard(userID, 1);
     await xmlObj.toXml(projectObj.project.ID());
     console.log(xmlObj);