zhangweicheng 7 سال پیش
والد
کامیت
93803b7c22

+ 13 - 10
modules/complementary_glj_lib/controllers/gljController.js

@@ -16,17 +16,20 @@ class GljController extends BaseController{
         let gljLibId = null, engineeringId, sessionCompilation = req.session.sessionCompilation,
             rationValuation = sessionCompilation.ration_valuation,
             billValuation = sessionCompilation.bill_valuation,
-            engineeringLibModel = new EngineeringLibModel();
-        if(rationValuation[0]){
-            let engineeringList = rationValuation[0].engineering_list;
-            engineeringId = engineeringList.length > 0 ? engineeringList[0].engineering_id : null;
-            let engineeringInfo = await engineeringLibModel.getEngineering(engineeringId);
-            gljLibId = engineeringInfo.glj_lib.length > 0 && typeof engineeringInfo.glj_lib !== 'undefined' ? engineeringInfo.glj_lib[0].id : null;
+            engineeringLibModel = new EngineeringLibModel(),
+            valuationIDs = [] ;
+        for(let r of rationValuation){//{ "glj_lib.0": {$exists:1} }
+            if(r.id){
+                valuationIDs.push(r.id);
+            }
+        }
+        for(let b of billValuation){
+            if(b.id){
+                valuationIDs.push(b.id);
+            }
         }
-        else if(billValuation[0]){
-            let engineeringList = billValuation[0].engineering_list;
-            engineeringId = engineeringList.length > 0 ? engineeringList[0].engineering_id : null;
-            let engineeringInfo = await engineeringLibModel.getEngineering(engineeringId);
+        if(valuationIDs.length > 0){
+            let engineeringInfo = await engineeringLibModel.findDataByCondition({'valuationID': {"$in": valuationIDs},"glj_lib.0": {$exists:1}});//数组大于0
             gljLibId = engineeringInfo.glj_lib.length > 0 && typeof engineeringInfo.glj_lib !== 'undefined' ? engineeringInfo.glj_lib[0].id : null;
         }
         res.render('building_saas/complementary_glj_lib/html/tools-gongliaoji.html',{

+ 2 - 0
modules/main/facade/ration_facade.js

@@ -296,12 +296,14 @@ async function addRationGLJ(std,newRation) {
                 newGLJ.unit = std_glj.unit;
                 newGLJ.specs = std_glj.specs;
                 newGLJ.basePrice = std_glj.basePrice;
+                newGLJ.marketPrice = std_glj.basePrice;
                 newGLJ.shortName = std_glj.shortName;
                 newGLJ.type = std_glj.gljType;
                 newGLJ.repositoryId = std_glj.repositoryId;
                 newGLJ.adjCoe = std_glj.adjCoe;
                 newGLJ.materialType = std_glj.materialType;
                 newGLJ.materialCoe = std_glj.materialCoe;
+                newGLJ.createType = 'normal';
                 let info = await  ration_glj_facade.getInfoFromProjectGLJ(newGLJ,unitPriceFileId);
                 newGLJ = ration_glj_facade.createNewRecord(info);
                 newRationGLJList.push(newGLJ);

+ 12 - 17
modules/ration_glj/facade/ration_glj_facade.js

@@ -125,6 +125,7 @@ function get_lib_glj_info(ration_glj) {
                 ration_glj.unit = glj.unit;
                 ration_glj.specs = glj.specs;
                 ration_glj.basePrice = glj.basePrice;
+                ration_glj.marketPrice = glj.basePrice;
                 ration_glj.shortName = glj.shortName;
                 ration_glj.type = glj.gljType;
                 ration_glj.repositoryId = glj.repositoryId;
@@ -161,8 +162,8 @@ function createNewRecord(ration_glj) {
     newRecoed.original_code = ration_glj.original_code;
     newRecoed.unit = ration_glj.unit;
     newRecoed.specs = ration_glj.specs;
-    newRecoed.from = ration_glj.from ? ration_glj.from : undefined;
-    newRecoed.createType = ration_glj.createType ? ration_glj.createType : undefined;
+    newRecoed.from = ration_glj.from ? ration_glj.from : 'std';
+    newRecoed.createType = ration_glj.createType ? ration_glj.createType : 'normal';
     newRecoed.shortName = ration_glj.shortName;
     newRecoed.billsItemID = ration_glj.billsItemID;
     newRecoed.type = ration_glj.type;
@@ -500,22 +501,16 @@ function save(user_id, datas, callback) {
 }
 
 async function getLibInfo(req) {
-    let gljLibId = null, engineeringId, sessionCompilation = req.session.sessionCompilation,
-        rationValuation = sessionCompilation.ration_valuation,
-        billValuation = sessionCompilation.bill_valuation,
-        engineeringLibModel = new EngineeringLibModel();
-    if (rationValuation[0]) {
-        let engineeringList = rationValuation[0].engineering_list;
-        engineeringId = engineeringList.length > 0 ? engineeringList[0].engineering_id : null;
-        let engineeringInfo = await engineeringLibModel.getEngineering(engineeringId);
-        gljLibId = engineeringInfo.glj_lib.length > 0 && typeof engineeringInfo.glj_lib !== 'undefined' ? engineeringInfo.glj_lib[0].id : null;
-    }
-    else if (billValuation[0]) {
-        let engineeringList = billValuation[0].engineering_list;
-        engineeringId = engineeringList.length > 0 ? engineeringList[0].engineering_id : null;
-        let engineeringInfo = await engineeringLibModel.getEngineering(engineeringId);
+    let gljLibId = null, engineerID, sessionCompilation = req.session.sessionCompilation,
+        engineeringLibModel = new EngineeringLibModel() ;
+    engineerID = req.params.engineerID;
+    if(engineerID){
+        let engineeringInfo = await engineeringLibModel.findDataByCondition({'_id': engineerID});
         gljLibId = engineeringInfo.glj_lib.length > 0 && typeof engineeringInfo.glj_lib !== 'undefined' ? engineeringInfo.glj_lib[0].id : null;
+    }else {
+        throw new Error("工程专业ID为空!");
     }
+
     let data = {
         userID: req.session.sessionUser.id,
         gljLibId: gljLibId,
@@ -575,7 +570,7 @@ function getGLJSearchInfo(ration_glj) {
         type: ration_glj.subType ? ration_glj.subType : ration_glj.type,//如果有subType,则是通过插入定额级的工料机进来的
         type_of_work: ration_glj.subType ? ration_glj.subType : ration_glj.type,
         base_price: ration_glj.basePrice,
-        market_price: ration_glj.basePrice,
+        market_price: ration_glj.marketPrice,
         repositoryId: ration_glj.repositoryId,
         adjCoe: ration_glj.adjCoe,
         materialType:ration_glj.materialType,

+ 1 - 1
modules/ration_glj/routes/ration_glj_route.js

@@ -8,7 +8,7 @@ let rgController = require('../controllers/ration_glj_controller');
 module.exports = function (app) {
 
     var rgRouter = express.Router();
-    rgRouter.get('/getGLJData', rgController.getGLJData);
+    rgRouter.get('/getGLJData/:engineerID', rgController.getGLJData);
     rgRouter.post('/addGLJ',rgController.addGLJ);
     rgRouter.post('/replaceGLJ',rgController.replaceGLJ);
     rgRouter.post('/mReplaceGLJ',rgController.mReplaceGLJ);

+ 2 - 0
web/building_saas/main/js/models/project_glj.js

@@ -678,6 +678,7 @@ ProjectGLJ.prototype.refreshTreeNodePriceIfNeed = function (data) {
         var nodes = _.filter(projectObj.project.mainTree.items, function (tem) {
             if (tem.sourceType == ModuleNames.ration_glj && tem.data.projectGLJID == data.id) {
                 tem.data.marketUnitFee = data.unit_price.market_price;
+                tem.data.marketPrice = data.unit_price.market_price;
                 return true;
             }
         })
@@ -720,6 +721,7 @@ ProjectGLJ.prototype.getImpactRationNodes = function (gljs) {
                 let tem_g = gljMap[item.data.projectGLJID];
                 if(tem_g){
                     item.data.marketUnitFee = this.getMarketPrice(tem_g);//这里要按计算的市场价为准,不能直接取
+                    item.data.marketPrice = this.getMarketPrice(tem_g);
                     nodes.push(item);
                 }
             } else if (rationMap[item.data.ID] == true) {  //受影响的定额

+ 7 - 2
web/building_saas/main/js/models/ration_glj.js

@@ -500,7 +500,8 @@ var ration_glj = {
             projectObj.mainController.refreshTreeNode(nodes);
         };
         ration_glj.prototype.getGLJData = function (cb) {
-            CommonAjax.get('/rationGlj/getGLJData', function (data) {
+            let engineerID = projectInfoObj.projectInfo.property.engineering_id;
+            CommonAjax.get('/rationGlj/getGLJData/'+engineerID, function (data) {
                 cb(data);
             })
         };
@@ -543,6 +544,7 @@ var ration_glj = {
                         specs: glj.specs,
                         subType: glj.gljType,
                         basePrice: glj.basePrice,
+                        marketPrice:glj.basePrice,
                         original_code: glj.code,
                         shortName: glj.shortName,
                         serialNo: serialNo,
@@ -617,6 +619,7 @@ var ration_glj = {
                     unit: glj.unit,
                     specs: glj.specs,
                     basePrice: glj.basePrice,
+                    marketPrice:glj.basePrice,
                     shortName: glj.shortName,
                     type: glj.gljType,
                     adjCoe: glj.adjCoe,
@@ -648,7 +651,7 @@ var ration_glj = {
             if (selectCode == gljOprObj.getIndex(oldData, gljKeyArray)) {
                 return callback(null);
             }
-            if (oldData.createType == 'normal') {//只有是定额下带的工料机才需把类型改成替换,其它的保持不变
+            if (oldData.createType===undefined || oldData.createType == 'normal') {// createTypel 默认是normal 只有是定额下带的工料机才需把类型改成替换,其它的保持不变
                 oldData.rcode = oldData.code;
                 oldData.createType = 'replace';
             }
@@ -659,6 +662,7 @@ var ration_glj = {
             oldData.unit = glj.unit;
             oldData.specs = glj.specs;
             oldData.basePrice = glj.basePrice;
+            oldData.marketPrice = glj.basePrice;
             oldData.repositoryId = glj.repositoryId;
             oldData.materialType = glj.materialType;
             oldData. materialCoe =  glj.materialCoe;
@@ -707,6 +711,7 @@ var ration_glj = {
                 specs: glj.specs,
                 type: glj.gljType,
                 basePrice: glj.basePrice,
+                marketPrice:glj.basePrice,
                 repositoryId: glj.repositoryId,
                 materialType: glj.materialType,   //三材类别
                 materialCoe: glj.materialCoe,