zhangweicheng 7 år sedan
förälder
incheckning
3b5d77bbfe

+ 43 - 42
modules/glj/models/glj_list_model.js

@@ -250,9 +250,19 @@ class GLJListModel extends BaseModel {
             };
             let projectGljData = await this.findDataByCondition(condition);
             let isAddProjectGLJ = false;
+
+            // 获取标段对应的单价文件id
+            let unitPriceFileId = unitFileId?unitFileId:await ProjectModel.getUnitPriceFileId(data.project_id);
+            if (unitPriceFileId <= 0) {
+                throw '没有对应的单价文件';
+            }
+
+            let unitPriceModel = new UnitPriceModel();
+
+            // 新增单条记录 (两个操作本来应该是事务操作,然而mongodb事务支持比较弱,就当作是都可以顺利执行)
+
             // 如果找不到数据则新增
             if (!projectGljData) {
-                // 新增单条记录 (两个操作本来应该是事务操作,然而mongodb事务支持比较弱,就当作是都可以顺利执行)
                 let gljInsertData = await this.add(data);
                 if (!gljInsertData) {
                     throw '新增项目工料机失败!';
@@ -261,14 +271,7 @@ class GLJListModel extends BaseModel {
                 projectGljData = gljInsertData;
             }
 
-            // 获取标段对应的单价文件id
-
-            let unitPriceFileId = unitFileId?unitFileId:await ProjectModel.getUnitPriceFileId(data.project_id);
-            if (unitPriceFileId <= 0) {
-                throw '没有对应的单价文件';
-            }
             let CompositionGLJ=[];
-            let unitPriceModel = new UnitPriceModel();
             // 判断类型,如果是混凝土、砂浆、配合比或者主材则查找对应的组成物(前提是没有对应的项目工料机数据)
             if(this.ownCompositionTypes.indexOf(data.type)!=-1) {
                 //如果是新增
@@ -288,7 +291,6 @@ class GLJListModel extends BaseModel {
                 }
             }
             projectGljData.subList=CompositionGLJ;
-
             // 新增单价文件
             let [unitPriceInsertData, isAdd] = await unitPriceModel.addUnitPrice(data, unitPriceFileId);
 
@@ -573,36 +575,31 @@ class GLJListModel extends BaseModel {
                 throw '组成物插入单价数据失败!';
             }
         }
-        let pglj_length = projectGljList instanceof Array ? projectGljList.length:Object.getOwnPropertyNames(projectGljList).length;
-        // 如果已经存在则后续操作停止
-        if(pglj_length === compositionGljList.length) {
-            return
-        }
+        let unitPriceModel = new UnitPriceModel();
+        let unitPriceList = await unitPriceModel.model.find({unit_price_file_id:unitPriceFileId});//查找按文件id查找单价文件数据,用来判断单价文件信息是否已存在
 
         // 整理插入的数据
         let gljInsertData = [];
         let unitPriceInsertData = [];
         for(let tmp of compositionGljList) {
             let key = this.getIndex(tmp,['code','name','specs','unit','gljType']);
-            if (projectGljList[key] !== undefined) {
-                continue;
+            if (projectGljList[key] === undefined) {
+                // 项目工料机插入的数据
+                let gljData = {
+                    glj_id: tmp.ID,
+                    project_id: projectId,
+                    code: tmp.code,
+                    name: tmp.name,
+                    specs: tmp.specs,
+                    unit: tmp.unit === undefined ? '' : tmp.unit,
+                    type: tmp.gljType,
+                    adjCoe:tmp.adjCoe,
+                    original_code:tmp.code,
+                    materialType: tmp.materialType,   //三材类别
+                    materialCoe: tmp.materialCoe
+                };
+                gljInsertData.push(gljData);
             }
-            // 项目工料机插入的数据
-            let gljData = {
-                glj_id: tmp.ID,
-                project_id: projectId,
-                code: tmp.code,
-                name: tmp.name,
-                specs: tmp.specs,
-                unit: tmp.unit === undefined ? '' : tmp.unit,
-                type: tmp.gljType,
-                adjCoe:tmp.adjCoe,
-                original_code:tmp.code,
-                materialType: tmp.materialType,   //三材类别
-                materialCoe: tmp.materialCoe
-            };
-            gljInsertData.push(gljData);
-
             let basePrice = scMathUtil.roundTo(tmp.basePrice,-6);
             // 单价文件插入的数据
             let unitPriceData = {
@@ -622,19 +619,17 @@ class GLJListModel extends BaseModel {
             if(tmp.from=='cpt'){
                 unitPriceData.is_add = 1;
             }
-            unitPriceInsertData.push(unitPriceData);
+           if(!unitPriceModel.isPropertyInclude(unitPriceList,['code','name','specs','unit','type'],unitPriceData)){
+               unitPriceInsertData.push(unitPriceData);
+           }
         }
         // 整理完后开始插入数据
-        let addResult = await this.add(gljInsertData);
-        if (!addResult) {
-            throw '组成物插入项目工料机失败!';
-        }
+
         // 插入单价数据表
-        let unitPriceModel = new UnitPriceModel();
-        let addUnitPriceResult = await unitPriceModel.add(unitPriceInsertData);
-        if (!addUnitPriceResult) {
-            throw '组成物插入单价数据失败!';
-        }
+        if(unitPriceInsertData.length >0) await unitPriceModel.add(unitPriceInsertData);
+       //插入项目工料机
+        if(gljInsertData.length > 0) await this.add(gljInsertData);
+
 
         return
     }
@@ -719,6 +714,12 @@ class GLJListModel extends BaseModel {
 
     async getCompositionGLJByData(glj,unitPriceFileId){
         let [gljData,mixRatioData,unitPriceData] = await this.getCompositionListByGLJ(glj,unitPriceFileId);
+        let priceNum = unitPriceData?Object.getOwnPropertyNames(unitPriceData).length:0;
+        let mixNum = mixRatioData?Object.getOwnPropertyNames(mixRatioData).length:0;
+        if(priceNum !==mixNum){//检查组成物数据是否一致
+            console.log("组成物数据有误,组成物单价文件个数:"+priceNum+",    组成物个数:"+mixNum);
+            return []
+        }
         gljData = this.combineData(gljData, unitPriceData, [], mixRatioData);
         return gljData;
     }

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

@@ -184,7 +184,7 @@ class UnitPriceModel extends BaseModel {
         }
         if(pops instanceof  Array){
             for(let p of pops){
-                if(obj[p]){
+                if(obj[p]!==undefined && obj[p]!==undefined!=null){
                     condition[p]=obj[p]
                 }
             }

+ 1 - 1
modules/pm/facade/pm_facade.js

@@ -229,7 +229,7 @@ async function copyUnitPriceFile(newProjectID,rootProjectID,userID,originaluUnit
         let rList = [];
         for(let m of mList){
             m._doc.unit_price_file_id = newFID;
-            m._doc.id = await getCounterID('mix_ratio');
+            m._doc.id = await getCounterID(model.modelName);
             rList.push(m._doc);
         }
         await insertMany(rList,model)

+ 1 - 1
modules/pm/models/templates/bills_template_model.js

@@ -40,7 +40,7 @@ class BillsTemplateModel extends BaseModel {
      */
     async getTemplateDataForNewProj (valuationId, engineering) {
         // 筛选字段
-        let field = {_id: 0, ID: 1, ParentID: 1, NextSiblingID: 1, code: 1, name: 1, unit: 1, flags: 1,type:1, calcBase: 1};
+        let field = {_id: 0, ID: 1, ParentID: 1, NextSiblingID: 1, code: 1, name: 1, unit: 1, flags: 1,type:1, calcBase: 1,feeRateID:1};
         let data = await this.findDataByCondition({valuationId: valuationId, engineering: engineering}, field, false);
 
         return data === null ? [] : data;

+ 1 - 1
modules/ration_glj/facade/ration_glj_facade.js

@@ -168,7 +168,7 @@ function createNewRecord(ration_glj) {
     newRecoed.type = ration_glj.type;
     newRecoed.repositoryId = ration_glj.repositoryId;
     newRecoed.projectGLJID = ration_glj.projectGLJID;
-    newRecoed.adjCoe = ration_glj.adjCoe
+    newRecoed.adjCoe = ration_glj.adjCoe;
     return newRecoed
 }
 

+ 9 - 1
web/building_saas/css/custom.css

@@ -46,4 +46,12 @@ legend.legend{
     padding: 8px;
     padding-top: 7px;
     padding-bottom: 7px;
-}
+}
+
+#gljPriceTenderCoe::-webkit-outer-spin-button,
+#gljPriceTenderCoe::-webkit-inner-spin-button {
+         -webkit-appearance: none;
+     }
+#gljPriceTenderCoe {
+    -moz-appearance: textfield;
+}

+ 1 - 1
web/building_saas/main/html/main.html

@@ -44,7 +44,7 @@
         <div class="main-nav">
             <ul class="nav nav-tabs flex-column" role="tablist">
                 <li class="nav-item"><a class="active" data-toggle="tab" href="#zaojiashu" id="tab_zaojiashu" role="tab">造价书</a></li>
-                <li class="nav-item"><a data-toggle="tab" href="#project_glj" id="tab_project_glj" data-name="tab_project_glj" role="tab">人材机</a></li>
+                <li class="nav-item"><a data-toggle="tab" href="#project_glj" id="tab_project_glj" data-name="tab_project_glj" role="tab">人材机汇总</a></li>
                 <li class="nav-item"><a data-toggle="tab" href="#fee_rates" id="tab_fee_rate" role="tab" >费率</a></li>
                 <li class="nav-item"><a data-toggle="tab" href="#calc_program_manage" id="tab_calc_program_manage" role="tab">计算程序</a></li>
                 <li class="nav-item"><a data-toggle="tab" href="#tender_price" id="tab_tender_price" role="tab">调价</a></li>

+ 1 - 9
web/building_saas/main/html/tender_price.html

@@ -1,12 +1,4 @@
-<!--<style>
-    input::-webkit-outer-spin-button,
-    input::-webkit-inner-spin-button {
-        -webkit-appearance: none;
-    }
-    input[type="number"]{
-        -moz-appearance: textfield;
-    }
-</style>-->
+
 <div class="toolsbar px-1">
     <div class="btn-toolbar py-1">
         <div class="input-group input-group-sm mr-2">

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

@@ -600,8 +600,8 @@ var Ration = {
                     newNode.source = newSource;
                     newNode.sourceType = project.Ration.getSourceType();
                     newNode.data = newSource;
-                    ProjectController.syncDisplayNewNode(sheetController, newNode);
                     project.projectGLJ.loadData(function () {
+                        ProjectController.syncDisplayNewNode(sheetController, newNode);
                         project.ration_glj.addToMainTree(data.ration_gljs);
                         projectObj.mainController.refreshTreeNode([newNode], false);
                         project.calcProgram.calcAndSave(newNode,function () {

+ 7 - 0
web/building_saas/main/js/views/main_tree_col.js

@@ -52,6 +52,13 @@ let MainTreeCol = {
             if((node.sourceType === projectObj.project.Ration.getSourceType()&&node.data.type!=rationType.ration)||node.sourceType==projectObj.project.ration_glj.getSourceType()){
                 return calcTools.uiGLJPrice(node.data.marketUnitFee);
             }
+        },
+        feeRate:function (node) {
+            if(node.data.feeRateID){
+                let rate = projectObj.project.FeeRate.getFeeRateByID(node.data.feeRateID);
+                if (rate) return rate.rate;
+            }
+            return node.data.feeRate;
         }
     },
     readOnly: {

+ 1 - 0
web/building_saas/main/js/views/project_glj_view.js

@@ -841,6 +841,7 @@ projectGljObject={
         let prowData = parentSheet.name() == 'projectGljSheet'?me.projectGljSheetData[prow]:me.materialTree.items[prow].data;
         let updateData = {id: deleteRecode.mix_ratio_id, field: 'mix_ratio.consumption' , value: 0, market_price: parentMarketPrice, base_price: parentBasePrice};
         projectObj.project.composition.deleteComposition(updateData,deleteRecode,prowData.id,function () {
+            _.remove(me.mixRatioData,{"mix_ratio_id":deleteRecode.mix_ratio_id});
             me.refreshParentData(prow,prowData.id);
             me.mixRatioSheet.deleteRows(row,1);
             me.onUnitFileChange(deleteRecode);