Browse Source

人材机汇总拖动、复制粘贴功能

zhangweicheng 7 years ago
parent
commit
230229112d

+ 8 - 7
modules/bills_lib/models/bills_lib_interfaces.js

@@ -3057,14 +3057,15 @@ billsLibDao.prototype.getStdBillsByCode = async function (data, callback) {
     }
     try{
         let bills = await Bills.findOne({billsLibId: data.billsLibId, code: data.code, deleted: false}, '-_id');
-        //设置清单备注(父项清单补注)
-        if(bills.ParentID != -1){
-            let parentBills = await Bills.findOne({billsLibId: data.billsLibId, ID: bills.ParentID, deleted: false});
-            if(parentBills && parentBills.recharge){
-                bills.recharge = parentBills.recharge;
-            }
-        }
+
         if(bills){
+            //设置清单备注(父项清单补注)
+            if(bills.ParentID != -1){
+                let parentBills = await Bills.findOne({billsLibId: data.billsLibId, ID: bills.ParentID, deleted: false});
+                if(parentBills && parentBills.recharge){
+                    bills.recharge = parentBills.recharge;
+                }
+            }
             //设置项目特征
             let itemCharacters = await ItemCharacter.find({billsLibId: data.billsLibId, deleted: false}, '-_id');
             bills._doc.itemCharacter = [];

+ 40 - 54
web/building_saas/main/js/models/project_glj.js

@@ -304,7 +304,7 @@ ProjectGLJ.prototype.batchUpdateGLJProperty = function (updateMap,callback) {
     $.bootstrapLoading.start();
     CommonAjax.post("/glj/batchUpdateGLJProperty", updateMap,function (result) {
         $.bootstrapLoading.end();
-        let supplyChangeIDs = [],evaluateIDs = [],rationNodes = [];
+        let supplyChangeIDs = [],evaluate_gljs = [],rationNodes = [];
         console.log(updateMap);
         for(let idKey in updateMap){
             let gljID = parseInt(idKey);
@@ -317,20 +317,20 @@ ProjectGLJ.prototype.batchUpdateGLJProperty = function (updateMap,callback) {
                 supplyChangeIDs.push(gljID);
             }
             if(doc.hasOwnProperty("is_evaluate")){
-                evaluateIDs.push(gljID);
+                evaluate_gljs.push(glj);
             }
         }
         if(supplyChangeIDs.length>0){
             let temRationNodes = calcTools.getRationsByProjectGLJ(supplyChangeIDs);
             if (temRationNodes.length > 0) rationNodes = rationNodes.concat(temRationNodes);
         }
-        for(let e of evaluateIDs){
-              //me.changeIsEvaluate(s);
+        if(evaluate_gljs.length > 0){
+            let [impactRationNodes,impactGLJs] = me.batchChangeIsEvaluate(evaluate_gljs);
+            rationNodes = rationNodes.concat(impactRationNodes);
         }
 
-
-
         if(rationNodes.length > 0){
+            rationNodes = _.uniq(rationNodes,'data');
             projectObj.project.calcProgram.calcNodesAndSave(rationNodes, function () {
                 projectObj.mainController.refreshTreeNode(projectObj.project.mainTree.roots);
             });
@@ -584,8 +584,8 @@ ProjectGLJ.prototype.changeIsEvaluate=function (id){
     let datas = projectGLJ.datas;
     let gljList = datas.gljList;
     let glj = _.find(gljList, {'id': id});
-    if(glj){
-        let con_key = gljOprObj.getIndex(glj,gljKeyArray);
+    if(glj){//与批量更新调用相同的方法
+     /*   let con_key = gljOprObj.getIndex(glj,gljKeyArray);
         let pratioM =datas.mixRatioConnectData[con_key];//找到父key
         let conditions = [];
         if(pratioM&&pratioM.length>0){
@@ -611,7 +611,8 @@ ProjectGLJ.prototype.changeIsEvaluate=function (id){
             rg.data.isEstimate =glj.is_evaluate?1:0;
             ration_nodes.push(rg);
         }
-        ration_nodes.length>0?projectObj.mainController.refreshTreeNode(ration_nodes):"";
+        ration_nodes.length>0?projectObj.mainController.refreshTreeNode(ration_nodes):"";*/
+        let [nodes,gljs] = projectGLJ.batchChangeIsEvaluate([glj]);
         projectObj.project.calcProgram.calcNodesAndSave(nodes);//触发计算程序
         return gljs;
     }
@@ -623,62 +624,41 @@ ProjectGLJ.prototype.changeIsEvaluate=function (id){
  */
 
 ProjectGLJ.prototype.batchChangeIsEvaluate=function (gljs){
-    let impactGLJs = [], changeArray =_.map(gljs,'id');
+    let impactGLJs = [], changeArray =_.map(gljs,'id'),changeMap = _.indexBy(gljs,'id');;
     for(let glj of gljs){
         let con_key = gljOprObj.getIndex(glj,gljKeyArray);
-        let pratioM =datas.mixRatioConnectData[con_key];//找到父key
+        let pratioM =this.datas.mixRatioConnectData[con_key];//找到父key
         let conditions = [];
         if(pratioM&&pratioM.length>0){
             for(let p_key of pratioM ){
                 conditions.push(gljOprObj.getConditionByKey(p_key));
             }
         }
-        let tem_gljs = projectGLJ.getProjectGLJs(conditions,false);
+        let tem_gljs = this.getProjectGLJs(conditions,false);
         if(tem_gljs.length > 0) impactGLJs = impactGLJs.concat(tem_gljs);
     }
     impactGLJs = impactGLJs.concat(gljs);
-    let impactRationNodes = projectGLJ.getImpactRationNodes(impactGLJs);
-    let neeRefreshNode = [];
-    let  rations =_.filter(projectObj.project.Ration.datas,function (item) {
-        //{'type':rationType.gljRation,'projectGLJID':glj.id}
-        if(item.type == rationType.gljRation ){//&&
+    impactGLJs =  _.uniq(impactGLJs,'id');//去重复
 
-        }
-
-    });
-
-
-    if(glj){
-        let con_key = gljOprObj.getIndex(glj,gljKeyArray);
-        let pratioM =datas.mixRatioConnectData[con_key];//找到父key
-        let conditions = [];
-        if(pratioM&&pratioM.length>0){
-            for(let p_key of pratioM ){
-                conditions.push(gljOprObj.getConditionByKey(p_key));
-            }
-        }
-        let gljs = projectGLJ.getProjectGLJs(conditions,false);
-        gljs.push(glj);
-        let nodes = projectGLJ.getImpactRationNodes(gljs);//取到因为改变工料机价格而受影响的定额
-        //更新对应的工料机类型的定额
-        let rations =_.filter(projectObj.project.Ration.datas,{'type':rationType.gljRation,'projectGLJID':glj.id});
-        let ration_nodes = [];
-        for(r of rations){
-            if(r){
-                r.isEstimate =glj.is_evaluate?1:0;
-                let ration_node = projectObj.project.mainTree.getNodeByID(r.ID);
-                ration_node?ration_nodes.push(ration_node):'';
-            }
-        }
-        let ration_glj_nodes = projectGLJ.getMainAndEquGLJNodeByID(glj.id);//取显示在造价书界面上的主材和设备节点
-        for(rg of ration_glj_nodes){
-            rg.data.isEstimate =glj.is_evaluate?1:0;
-            ration_nodes.push(rg);
-        }
-        ration_nodes.length>0?projectObj.mainController.refreshTreeNode(ration_nodes):"";
-        projectObj.project.calcProgram.calcNodesAndSave(nodes);//触发计算程序
-        return gljs;
-    }
+    let impactRationNodes = this.getImpactRationNodes(impactGLJs);
+    let neeRefreshNode = [];
+    //更新对应的工料机类型的定额
+    for(let item of projectObj.project.Ration.datas){
+        if(item.type == rationType.gljRation && changeArray.indexOf(item.projectGLJID) != -1){
+            let tem_g = changeMap[item.projectGLJID];
+            item.isEstimate =tem_g.is_evaluate?1:0;
+            let ration_node = projectObj.project.mainTree.getNodeByID(item.ID);
+            neeRefreshNode?neeRefreshNode.push(ration_node):'';
+        }
+    }
+    let ration_glj_nodes = this.getMainAndEquGLJNodeByID(changeArray);//取显示在造价书界面上的主材和设备节点
+    for(let rg of ration_glj_nodes){
+        let tem_g = changeMap[rg.data.projectGLJID];
+        rg.data.isEstimate =tem_g.is_evaluate?1:0;
+        neeRefreshNode.push(rg);
+    }
+    neeRefreshNode.length>0?projectObj.mainController.refreshTreeNode(neeRefreshNode):"";
+    return [impactRationNodes,impactGLJs];
 };
 
 ProjectGLJ.prototype.getByID = function (ID) {
@@ -707,9 +687,15 @@ ProjectGLJ.prototype.refreshTreeNodePriceIfNeed = function (data) {
 
 ProjectGLJ.prototype.getMainAndEquGLJNodeByID = function (id) {//通过ID取显示到主树上的主材和设备节点
     let nodes = [];
+    let ids = [];
+    if(Array.isArray(id)){
+        ids = id;
+    }else {
+        ids = [id];
+    }
     if(projectInfoObj.projectInfo.property.displaySetting.disPlayMainMaterial == true){
          nodes = _.filter(projectObj.project.mainTree.items, function (tem) {
-            return tem.sourceType == ModuleNames.ration_glj && tem.data.projectGLJID == id
+            return tem.sourceType == ModuleNames.ration_glj && ids.indexOf(tem.data.projectGLJID)  !== -1
         })
     }
     return nodes;

+ 16 - 5
web/building_saas/main/js/views/project_glj_view.js

@@ -397,6 +397,7 @@ projectGljObject={
             //价格属于单价文件表,如果与项目工料机的其它属性一起的话计算起来会比较复杂,同时出现价格与其它属性一起更新的情况也会比较少;
             projectGLJ.batchUpdatePrice(priceCells,sheetName,function (impactList) {
                 me.refreshBySheetName(sheetName);
+                gljOprObj.refreshView();
             });
         });
     },
@@ -424,13 +425,18 @@ projectGljObject={
             return;
         }
         projectGLJ.batchUpdateGLJProperty(updateMap,callback);
-        console.log(updateMap)
     },
     getUpdateData :function (id,value,dataCode,quantity,updateMap) {
         let me = projectGljObject;
+        let supplyMap = {"自行采购":0,"部分甲供":1,"完全甲供":2,"甲定乙供":3};
+        let materialMap = {"钢材":1,"钢筋":2,"木材":3,"水泥":4,"标准砖":5};
         let data = updateMap[id]?updateMap[id]:{};
+        //供货方式 和三材类型 粘贴和填充过来的数据,要做对应转换,因为这里value只是中文文本,并不是实际的值
         // 如果是供货方式则需要处理数据
-        if (data === 'supply') {
+        if (dataCode === 'supply') {
+            if(supplyMap[value]!==undefined||supplyMap[value]!==null){
+                value = supplyMap[value];
+            }
             data.supply_quantity = me.getSupplyQuantity(value,quantity);
         }
         if(dataCode === 'supply_quantity'){//修改数量需做4舍5入
@@ -443,9 +449,14 @@ projectGljObject={
                 value = 0;
             }
         }
-        if(dataCode === 'materialType' && (value == null || value=="")){//删除三材类别时,清空三材系数
-            value = null;
-            data.materialCoe = null;
+        if(dataCode === 'materialType'){//三材类型要做对应转换,因为这里value只是中文文本,并不是实际的值
+            if(materialMap[value]!==undefined||materialMap[value]!==null){
+                value =  materialMap[value];
+            }
+            if(value == null || value==""){//删除三材类别时,清空三材系数
+                value = null;
+                data.materialCoe = null;
+            }
         }
         if(dataCode == 'materialCoe'){
             value = scMathUtil.roundForObj(value,getDecimal("material"));