zhangweicheng 7 年之前
父節點
當前提交
26b2ca8f05

+ 1 - 1
modules/main/models/bills.js

@@ -23,7 +23,7 @@ let billsSchema = new Schema({
     chapterID: Number,
     code: String,
     fullCode: String,
-    type:Number,
+    type:{type: Number,default:4},//1 :大项费用 2:分部 3分项 4清单
     isAdd:{type: Number,default:0},//1 true 0 false是否新增
     name: String,
     unit: String,

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

@@ -39,7 +39,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};
+        let field = {_id: 0, ID: 1, ParentID: 1, NextSiblingID: 1, code: 1, name: 1, unit: 1, flags: 1,type:1};
         let data = await this.findDataByCondition({valuationId: valuationId, engineering: engineering}, field, false);
 
         return data === null ? [] : data;

+ 2 - 1
modules/pm/models/templates/schemas/bills_template.js

@@ -30,7 +30,8 @@ let BillsTemplateSchema = {
     // 所属计价ID
     valuationId: String,
     // 工程专业
-    engineering: Number
+    engineering: Number,
+    type:Number
 };
 
 let model = mongoose.model(collectionName, new Schema(BillsTemplateSchema, {versionKey: false, collection: collectionName}));

+ 4 - 2
web/building_saas/main/js/models/bills.js

@@ -169,11 +169,12 @@ var Bills = {
             this.datas.push(newData);
             return this.tree.insertByData(newData,parentId, nextSiblingId);
         };
-        bills.prototype.insertBills = function (parentId, nextSiblingId) {//是否是用户新增的
+        bills.prototype.insertBills = function (parentId, nextSiblingId) {
             var insertData = this.tree.getInsertData(parentId, nextSiblingId);
             var that = this, newData = null;
             insertData.forEach(function (data) {
                 if (data.type === idTree.updateType.new) {
+                    data.data.type = billType.BILL;
                     newData = data.data;
                 }
             });
@@ -182,7 +183,7 @@ var Bills = {
             //project.pushNow('insertBills', ModuleNames.bills, tools.coverseTreeUpdateData(insertData));
 
             this.datas.push(newData);
-            return this.tree.insert(parentId, nextSiblingId);
+            return this.tree.insertByData(newData,parentId, nextSiblingId);
         };
         bills.prototype.insertStdBills = function (parentId, nextSiblingId, stdBillsData) {
             var insertData = this.tree.getInsertData(parentId, nextSiblingId);
@@ -202,6 +203,7 @@ var Bills = {
                     data.data.jobContentText = stdBillsData.jobContentText;
                     data.data.itemCharacterText = stdBillsData.itemCharacterText;
                     data.data.programID = stdBillsData.engineering;
+                    data.data.type = billType.BILL;//插入清单类型
                     //zhong
                     newData = data.data;
                 }

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

@@ -174,6 +174,7 @@ const fixedFlag = {
 };
 
 const gljKeyArray =['code','name','specs','unit','type'];
+const rationKeyArray =['code','name','specs','unit','subType'];
 const gljLibKeyArray =['code', 'name', 'specs', 'unit', 'gljType'];
 const billType ={
     DXFY:1,//大项费用

+ 37 - 5
web/building_saas/main/js/views/glj_view.js

@@ -686,6 +686,11 @@ var gljOprObj = {
                 this.showRationAssData(node);
                 isShow = true;
             }
+            if(node.sourceType == ModuleNames.ration_glj){
+
+                isShow = true;
+            }
+
             this.showQuantityDetailData(node);
         } else {
             this.selectedNodeId = null;
@@ -700,6 +705,29 @@ var gljOprObj = {
         }
         //   $('#dropdown').hide();
     },
+    showMixRatio:function (node) {//显示组成物到定额工料机
+        let mixRatioMap = projectObj.project.projectGLJ.datas.mixRatioMap;
+        let projectGljs = projectObj.project.projectGLJ.datas.gljList;
+        let indexArray =node.getSourceType()==ModuleNames.ration?rationKeyArray:gljKeyArray;
+        let connect_index = this.getIndex(node.data,indexArray);
+        let gljList=[];
+        if(mixRatioMap[connect_index]){ //说明是有组成物的类型
+            gljList =  this.getMixRationShowDatas(mixRatioMap[connect_index], projectGljs);
+        }
+        if(gljList.length>0){//计算总消耗量
+            if(node.getSourceType()==ModuleNames.ration){
+                this.calcMixRationTotalQuantity(gljList,node.data.quantity);
+            }else {
+               let totalQuantity = this.getTotalQuantity(node.data);
+               this.calcMixRationTotalQuantity(gljList,totalQuantity)
+            }
+        }
+        this.sheetData = gljList;
+        this.sheet.setRowCount(0);
+        this.sheetData = sortRationGLJ(this.sheetData);
+        sheetCommonObj.showData(this.sheet, this.setting, this.sheetData);
+    },
+
     showRationGLJData: function (node) {
         var gljList = [];
         var ration_glj = projectObj.project.ration_glj;
@@ -775,14 +803,18 @@ var gljOprObj = {
             glj.quantity = scMathUtil.roundForObj(glj.quantity, getDecimal("glj.quantity"));
             glj.totalQuantity = scMathUtil.roundToString(quantity * glj.quantity, getDecimal("glj.quantity"));
             if (glj.hasOwnProperty('subList')) {//需要计算glj下挂的组成物的总消耗量
-                for (let subG of glj.subList) {
-                    subG.rationItemQuantity = scMathUtil.roundForObj(subG.rationItemQuantity, getDecimal("glj.quantity"));
-                    subG.totalQuantity = scMathUtil.roundToString(subG.rationItemQuantity * glj.totalQuantity, getDecimal("glj.quantity"));
-                }
+                this.calcMixRationTotalQuantity(glj.subList,glj.totalQuantity);
             }
             return  glj.totalQuantity;
         }
     },
+    calcMixRationTotalQuantity(mList,pTotal){ //计算组成物的总消耗量
+        for (let subG of mList) {
+            subG.rationItemQuantity = scMathUtil.roundForObj(subG.rationItemQuantity, getDecimal("glj.quantity"));
+            subG.totalQuantity = scMathUtil.roundToString(subG.rationItemQuantity * pTotal, getDecimal("glj.quantity"));
+        }
+    },
+
     addMixRatioToShow: function () {
         var newList = [];
         _.remove(this.sheetData, {'isMixRatio': true});
@@ -808,7 +840,7 @@ var gljOprObj = {
                     }
                     ration_gljs[i].isAdd = glj.unit_price.is_add;
                     ration_gljs[i]=this.setGLJPrice(ration_gljs[i],glj);//设置工料机价格
-                    var connect_index = this.getIndex(glj, gljKeyArray)
+                    var connect_index = this.getIndex(glj, gljKeyArray);
                     if (mixRatioMap.hasOwnProperty(connect_index)) {
                         var mixRatios = this.getMixRationShowDatas(mixRatioMap[connect_index], projectGljs);
                         ration_gljs[i].subList = mixRatios;

+ 4 - 1
web/building_saas/main/js/views/project_view.js

@@ -559,7 +559,10 @@ var projectObj = {
                     },
                     callback: function (key, opt) {
                         if(project.mainTree.selected.data.type == billType.DXFY){
-
+                            if(project.mainTree.selected.data.calcBase&&project.mainTree.selected.data.calcBase!=""){
+                                alert("当前有基数计算不能插入子项。");
+                                return;
+                            }
                         }
                         ProjectController.addBills(project, controller);
                     },