Browse Source

Merge branch '1.0.0_online' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost into 1.0.0_online

zhongzewei 6 năm trước cách đây
mục cha
commit
3ea9f4fd33

+ 2 - 1
modules/all_models/ration.js

@@ -55,7 +55,8 @@ let rationSchema = new Schema({
     libID: Number,
     maskName: String,
     caption: String,
-    isFromDetail:{type: Number,default:0},       // 1 true 2 false
+    evaluationProject:{type: Number,default:0},       // 1 true 0 false 估价项目
+    isFromDetail:{type: Number,default:0},       // 1 true 0 false
     adjustState: String,
     rationProjName: String,
     comments: String,                           // 说明

+ 2 - 2
modules/all_models/std_glj.js

@@ -9,7 +9,7 @@ const std_gljComponent = new Schema(
     {
         ID: Number,
         consumeAmt: Number,
-        consumeAmtProperties: {
+        consumeAmtProperty: {
             type: Schema.Types.Mixed,
             default: {}
         }
@@ -26,7 +26,7 @@ const std_glj = new Schema({
     name: String,
     specs: String,
     basePrice: Number,
-    basePriceProperties: {
+    priceProperty: {
         type: Schema.Types.Mixed,
         default: {}
     },

+ 1 - 1
modules/glj/models/glj_list_model.js

@@ -560,7 +560,7 @@ class GLJListModel extends BaseModel {
                 }
                 // 配合比数据插入
                 let mixRatioData = {
-                    consumption: tmp.consumption,
+                    consumption: consumpiton,
                     glj_id: tmp.ID,
                     unit_price_file_id: unitPriceFileId,
                     connect_key: connect_key,

+ 10 - 0
modules/main/controllers/ration_controller.js

@@ -37,6 +37,16 @@ let controller = {
         let data = req.body.data;
         data = JSON.parse(data);
         return await ration_facade.getSameSectionRations(data,req.session.sessionUser.id, req.session.sessionCompilation._id);
+    },
+    //取定额默认的取费专业
+    getDefaultProgramID:async function(req){
+        let data = req.body.data;
+        data = JSON.parse(data);
+        data.userID = req.session.sessionUser.id;
+        data.compilationId = req.session.sessionCompilation._id;
+        return await ration_facade.getDefaultProgramID(data);
+
+
     }
 };
 

+ 16 - 1
modules/main/facade/ration_facade.js

@@ -31,7 +31,8 @@ module.exports = {
     addNewRation:addNewRation,
     addMultiRation: addMultiRation,
     getSameSectionRations:getSameSectionRations,
-    getExtendData:getExtendData
+    getExtendData:getExtendData,
+    getDefaultProgramID:getDefaultProgramID
 };
 async function addNewRation(data,compilation) {
     let query = data.itemQuery;
@@ -167,6 +168,18 @@ async function replaceRations(userID,data,compilation) {
     return recodes;
 }
 
+async function getDefaultProgramID(data) {
+    let searchDao = new SearchDao();
+    let programID;
+    let std = await searchDao.getRationItem(data.userID,data.compilationId,[data.libID],data.code, null);
+    if(std.feeType == undefined || std.feeType == null || std.feeType ==''){//定额取费专业为空的情况下,取项目属性中的定额取费专业ID
+        programID = await getProgramForProject(data.projectID);
+    }else {
+        programID = std.feeType;
+    }
+    return programID;
+}
+
 async function replaceRation(nodeInfo,stdRation,defaultLibID,projectID,calQuantity,compilation) {
     if(nodeInfo.newCode == null||nodeInfo.newCode ==""){//说明是删除编号,则要变成一条空定额
         await deleRationSubRecode(projectID,nodeInfo.ID);//删除定额下挂的各种数据,如定额工料机等
@@ -383,6 +396,8 @@ async function addRationGLJ(std,newRation,compilation) {
                     std_glj.basePrice =  std_glj.priceProperty[ext.priceField];
                 }
             }
+            console.log("================================get std glj=============================================");
+            console.log(std_glj);
             let std_gljTime = +new Date();
             if(std_glj){
                 newGLJ.name = std_glj.name;

+ 1 - 0
modules/main/routes/ration_route.js

@@ -14,5 +14,6 @@ module.exports = function (app) {
     rationRouter.post('/addNewRation', rationController.action);
     rationRouter.post('/addMultiRation', rationController.action);
     rationRouter.post('/getSameSectionRations', rationController.action);
+    rationRouter.post('/getDefaultProgramID', rationController.action);
     app.use('/ration', rationRouter);
 };

+ 21 - 0
web/building_saas/main/js/models/project.js

@@ -406,6 +406,27 @@ var PROJECT = {
                 }
             })
         };
+
+        project.prototype.updateEvalproject = function (evalProject,data,callback){
+            let programID = null;
+            if(evalProject ==1){
+                programID =  this.calcProgram.compiledTemplateMaps["估价项目"];
+                callback(programID)
+            }else {//如果evalProject==0,则是去掉勾选估价项目选项,需要获取定额默认的取费专业。
+                let libID = data.from == 'cpt'?"compleRationLib":data.libID;
+                let query = {code:data.code,projectID:data.projectID,libID:libID};
+                CommonAjax.post("/ration/getDefaultProgramID",query,function (result) {
+                    if(callback){
+                        callback(result);
+                    }
+                })
+
+
+
+            }
+
+        };
+
         //判断项目是否安装工程
         project.prototype.isInstall = function () {
             return projectInfoObj.projectInfo.property.isInstall?true:false;//如果是undefinded 就也返回false

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

@@ -90,11 +90,16 @@ let MainTreeCol = {
             return false;
         },
         calcProgramName: function (node) {
-            if (
-                node.sourceType === projectObj.project.Ration.getSourceType() ||
+            if (node.sourceType === projectObj.project.Ration.getSourceType() ||
                 (calcTools.isLeafBill(node) && projectObj.project.property.billsCalcMode === leafBillGetFeeType.billsPrice)
-            ) return false
-            else return true;
+            ) {
+                //当打勾估价项目选项后,该定额取费专业只读
+                if(node.data.evaluationProject == 1){
+                    return true;
+                }
+                return false;
+            }
+            return true;
         },
         non_editSubType: function (node) {
             return node.data.subType != 201 && node.data.subType != 4 && node.data.subType != 5
@@ -325,6 +330,12 @@ let MainTreeCol = {
                 return new GC.Spread.Sheets.CellTypes.CheckBox();
             }
         },
+        evaluationProject:function (node) {
+            if(node.sourceType == ModuleNames.ration){
+                return new GC.Spread.Sheets.CellTypes.CheckBox();
+            }
+
+        },
         commonTotalFee: function () {
             return projectObj.getCommonTotalFeeCellType();
         }

+ 14 - 0
web/building_saas/main/js/views/project_view.js

@@ -1578,8 +1578,22 @@ var projectObj = {
             projectObj.onSubcontractClick(node);
         }else if(fieldName == "isEstimate"){
             projectObj.onIsEstimateClick(node,info);
+        }else if(fieldName == "evaluationProject"){
+            projectObj.onEvaluationProjectClic(node,info);
         }
+
     },
+    onEvaluationProjectClic:function (node,info) {
+        let checkboxValue = info.sheet.getCell(info.row, info.col).value();
+        let newval = checkboxValue?0:1;
+        projectObj.project.updateEvalproject(newval,node.data,function (programID) {
+            node.data.evaluationProject = newval;
+            node.data.programID = programID;
+            node.changed=true;
+            projectObj.project.calcProgram.calcAndSave(node);
+        })
+    },
+
     onIsEstimateClick: function(node,info){
         let checkboxValue = info.sheet.getCell(info.row, info.col).value();
         let cell = info.sheet.getCell(info.row, info.col), newval = 0;