Selaa lähdekoodia

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

zhongzewei 6 vuotta sitten
vanhempi
commit
b0fb663f1c

+ 11 - 4
modules/main/facade/ration_facade.js

@@ -475,17 +475,24 @@ async function deleteSubListByQuery(delete_query) {
 }
 
 async function updateCoeAdjust(data,compilation) {
-    let newGLJs = [];
+    let replace = [];
     await ration_coe.update({ID:data.ID},data.doc);
     //添加单个工料机的情况
-    if (data.add.length > 0) newGLJs = await ration_glj_facade.insertAddTypeGLJ(data.add,compilation);
+    if (data.add.length > 0)   await ration_glj_facade.insertAddTypeGLJ(data.add,compilation);
     if(data.delete.length > 0) await ration_glj_facade.deleteGLJ(data.delete);
 
+    //替换工料机的情况
+    if (data.replace.length > 0){
+        for(let r of data.replace){
+            replace.push(await  ration_glj_facade.replaceGLJByData(r,compilation)) ;
+        }
+    }
+
     let cal_result = await glj_calculate_facade.calculateQuantity({projectID:data.projectID,rationID:data.rationID});
     let coe = {
         query:{ID:data.ID,projectID:data.projectID},
         doc:data.doc
-    }
+    };
     let ration_glj ={
         quantityRefresh:true,
         glj_result:cal_result.glj_result
@@ -494,7 +501,7 @@ async function updateCoeAdjust(data,compilation) {
         ID:cal_result.rationID,
         adjustState:cal_result.adjustState
     };
-    return {coe:coe,ration_glj:ration_glj,ration:ration,add:data.add,delete:data.delete}
+    return {coe:coe,ration_glj:ration_glj,ration:ration,add:data.add,delete:data.delete,replace:replace}
 
 }
 

+ 14 - 7
modules/ration_glj/facade/glj_calculate_facade.js

@@ -66,7 +66,8 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
          }
          gljList = sortRationGLJ(gljList);
          for(let i =0;i<gljList.length;i++ ){
-             let r = await calculateQuantityPerGLJ(gljList[i],i,coeList,assList,adjustState,noNeedCal);
+             let isLast = i == gljList.length -1;
+             let r = await calculateQuantityPerGLJ(gljList[i],isLast,coeList,assList,adjustState,noNeedCal);
              result.glj_result.push(r);
          }
 
@@ -136,7 +137,7 @@ function sortRationGLJ(list) {
     return list;
 }
 
-async function calculateQuantityPerGLJ(glj,index,coeList,assList,adjustState,noNeedCal) {
+async function calculateQuantityPerGLJ(glj,isLast,coeList,assList,adjustState,noNeedCal) {
     let decimalObject =await decimal_facade.getProjectDecimal(glj.projectID);
     let decimal = (decimalObject&&decimalObject.glj&&decimalObject.glj.quantity)?decimalObject.glj.quantity:3;
     let quantity =  scMathUtil.roundTo(parseFloat(glj.quantity),-decimal);
@@ -166,7 +167,7 @@ async function calculateQuantityPerGLJ(glj,index,coeList,assList,adjustState,noN
             }
             result.doc.quantity =scMathUtil.roundToString(quantity,decimal);
         }
-        generateAdjustState(glj,coeList,adjustState,index,result.doc.quantity);
+        generateAdjustState(glj,coeList,adjustState,isLast,result.doc.quantity);
         return result;
     }catch (err){
         throw err;
@@ -198,7 +199,7 @@ async function calculateAss(quantity,assList,glj) {
     return scMathUtil.roundTo(quantity,-6);
 }
 
-function generateAdjustState(glj,coeList,adjustState,index,quantity) {
+function generateAdjustState(glj,coeList,adjustState,isLast,quantity) {
    //替换工料机 and 添加工料机
     if(glj._doc.createType=='replace'&&glj.rcode!=glj.code){
         adjustState.push({index:stateSeq.replace,content:glj.rcode+'换'+glj.code});
@@ -208,17 +209,21 @@ function generateAdjustState(glj,coeList,adjustState,index,quantity) {
             displayQuantity = glj.customQuantity;
         }
         displayQuantity = displayQuantity&&displayQuantity!=""?parseFloat(displayQuantity):0;
-        adjustState.push({index:stateSeq.add,content:'添'+glj.code+'量'+ displayQuantity});
+        adjustState.push({index:stateSeq.add,content:'添'+glj.code+'量'+ displayQuantity,type:"添"+glj.code});
     }
     // to do
 
   //标准附注条件调整 + 自定义乘系数
-    if(0==index){
+    if(isLast){//最后一个工料机的时候才生成,生成一次就可以了
         for(let i=0;i<coeList.length;i++){
             if(coeList[i].isAdjust==1){
                 if(i==coeList.length-1){
                     adjustState.push({index:stateSeq.cusCoe,content:getContent(coeList[i].coes)});//自定义乘系数要去掉倍数为1的
                 }else {
+                    for(let c of coeList[i].coes){
+                        if(c.coeType=='单个工料机') _.remove(adjustState,{'type':"添"+c.gljCode});//如果是单个工料机子目换算类型自动添加的,去掉前面手动生成的调整状态
+                        if(c.coeType=='替换人材机') _.remove(adjustState,{'content':c.gljCode+'换'+c.replaceCode});//如果是替换人材机子目换算类型自动添加的,去掉前面手动生成的调整状态
+                    }
                     adjustState.push({index:stateSeq.coe,content:"调 : "+coeList[i].content});//coeList[i].content
                 }
             }
@@ -304,7 +309,9 @@ function everyCoe(quantity,coe,glj) {
     let coeQuantity = quantity;
     if(coe.isAdjust==1){
         for(let i=0;i<coe.coes.length;i++){
-            if(coe.coes[i].gljCode==glj.code){//if(coe.coes[i].coeType=='单个工料机'&&coe.coes[i].gljCode==glj.code)
+            if(coe.coes[i].coeType=='单个工料机' &&coe.coes[i].gljCode==glj.code){//if(coe.coes[i].coeType=='单个工料机'&&coe.coes[i].gljCode==glj.code)
+                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i]);
+            }else if(coe.coes[i].coeType== "替换人材机" && glj.rcode == coe.coes[i].gljCode && glj.code == coe.coes[i].replaceCode){
                 coeQuantity = getCalculateResult(coeQuantity,coe.coes[i]);
             } else if(coe.coes[i].coeType=='定额'){
                 coeQuantity = getCalculateResult(coeQuantity,coe.coes[i]);

+ 9 - 2
modules/ration_glj/facade/ration_glj_facade.js

@@ -40,6 +40,7 @@ module.exports = {
     deleteGLJ:deleteGLJ,
     insertAddTypeGLJ:insertAddTypeGLJ,
     replaceGLJ: replaceGLJ,
+    replaceGLJByData:replaceGLJByData,
     mReplaceGLJ: mReplaceGLJ,
     updateRationGLJByEdit: updateRationGLJByEdit,
     getGLJClass: getGLJClass,
@@ -656,8 +657,7 @@ async function insertAddTypeGLJ(rgList,compilation) {
 }
 
 
-async function replaceGLJ(data,compilation) {
-    let rdata = {};
+async  function replaceGLJByData(data,compilation) {
     let projectGljModel = new GLJListModel();
     let [unitFileId,ext] = await  prepareExtData(data.projectID,compilation);
     let result = await projectGljModel.addList(getGLJSearchInfo(data),unitFileId,ext);
@@ -676,6 +676,13 @@ async function replaceGLJ(data,compilation) {
     if (result.hasOwnProperty('subList') && result.subList.length > 0) {
         data.subList = getMixRatioShowDatas(result.subList);
     }
+    return data;
+}
+
+
+async function replaceGLJ(data,compilation) {
+    let rdata = {};
+    data = await  replaceGLJByData(data,compilation);
     let stateResult = await glj_calculate_facade.calculateQuantity({
         projectID: data.projectID,
         rationID: data.rationID

+ 1 - 0
modules/users/models/user_model.js

@@ -195,6 +195,7 @@ class UserModel extends BaseModel {
             email: userData.email,
             mobile: userData.mobile,
             create_time: new Date().getTime(),
+            latest_login: new Date().getTime(),
         };
         return this.db.create(insertData);
     }

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

@@ -1763,7 +1763,7 @@
         </div>
     </div>
     <!--弹出 生成组价模板-->
-    <div class="modal fade" id="zujiamb" data-backdrop="static">
+    <div class="modal fade" id="div_createBlocks" data-backdrop="static">
         <div class="modal-dialog" role="document">
             <div class="modal-content">
                 <div class="modal-header">
@@ -1780,7 +1780,7 @@
                     <div class="form-group">
                         <div class="form-check form-check-inline">
                             <input class="form-check-input" type="checkbox" name="inlineRadioOptions" id="ckb_block_exist_cover" value="option1">
-                            <label class="form-check-label" for="ckb_block_exist_cover">当存在同名模板时,提示是否覆盖</label>
+                            <label class="form-check-label" for="ckb_block_exist_cover">当存在同名模板时覆盖(不勾选则跳过,不生成模板)</label>
                         </div>
                     </div>
                 </div>
@@ -1792,11 +1792,11 @@
         </div>
     </div>
     <!--弹出 匹配原则-->
-    <div class="modal fade" id="blockAdjustOptions" data-backdrop="static">
+    <div class="modal fade" id="div_cloneOptions" data-backdrop="static">
         <div class="modal-dialog" role="document">
             <div class="modal-content">
                 <div class="modal-header">
-                    <h5 class="modal-title">快速组价</h5>
+                    <h5 class="modal-title" id="clone_option_title">快速组价</h5>
                     <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                         <span aria-hidden="true">&times;</span>
                     </button>
@@ -1806,16 +1806,16 @@
                         <label>选择匹配模式:</label>
                         <div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="checkbox" name="inlineRadioOptions" id="inlinecheckbox1" value="option1" checked>
-                                <label class="form-check-label" for="inlinecheckbox1">项目编码(前9位)</label>
+                                <input class="form-check-input" type="checkbox" name="inlineRadioOptions1" id="clone_option_code" value="option1" checked>
+                                <label class="form-check-label" for="clone_option_code">项目编码(前9位)</label>
                             </div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="checkbox" name="inlineRadioOptions" id="inlinecheckbox2" value="option2">
-                                <label class="form-check-label" for="inlinecheckbox2">项目名称</label>
+                                <input class="form-check-input" type="checkbox" name="inlineRadioOptions2" id="clone_option_name" value="option2">
+                                <label class="form-check-label" for="clone_option_name">项目名称</label>
                             </div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="checkbox" name="inlineRadioOptions" id="inlinecheckbox3" value="option3" checked>
-                                <label class="form-check-label" for="inlinecheckbox3">单位</label>
+                                <input class="form-check-input" type="checkbox" name="inlineRadioOptions3" id="clone_option_unit" value="option3" checked>
+                                <label class="form-check-label" for="clone_option_unit">单位</label>
                             </div>
                         </div>
                     </div>
@@ -1823,12 +1823,12 @@
                         <label for="exampleInputPassword1">插入为选定节点的:</label>
                         <div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="radio" name="rationQuantity" id="inlineRadio21" value="option1" checked>
-                                <label class="form-check-label" for="inlineRadio21">根据含量计算定额工程量</label>
+                                <input class="form-check-input" type="radio" name="rationQuantity" id="clone_option_quantity" value="option1" checked>
+                                <label class="form-check-label" for="clone_option_quantity">根据含量计算定额工程量</label>
                             </div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="radio" name="rationQuantity" id="inlineRadio22" value="option2">
-                                <label class="form-check-label" for="inlineRadio22">含量和定额工程量为零</label>
+                                <input class="form-check-input" type="radio" name="rationQuantity" id="clone_option_zeroQuantity" value="option2">
+                                <label class="form-check-label" for="clone_option_zeroQuantity">含量和定额工程量为零</label>
                             </div>
                         </div>
                     </div>
@@ -1836,12 +1836,12 @@
                         <label for="exampleInputPassword1">清单下有定额时:</label>
                         <div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="radio" name="rationCover" id="inlineRadio33" value="option3" checked>
-                                <label class="form-check-label" for="inlineRadio33">跳过不覆盖</label>
+                                <input class="form-check-input" type="radio" name="rationCover" id="clone_option_noCover" value="option3" checked>
+                                <label class="form-check-label" for="clone_option_noCover">不覆盖,在其后追加</label>
                             </div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="radio" name="rationCover" id="inlineRadio32" value="option2">
-                                <label class="form-check-label" for="inlineRadio32">直接覆盖</label>
+                                <input class="form-check-input" type="radio" name="rationCover" id="clone_option_cover" value="option2">
+                                <label class="form-check-label" for="clone_option_cover">覆盖</label>
                             </div>
                         </div>
                     </div>

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

@@ -26,6 +26,7 @@ $(function () {
 
     $('#tab_report').on('shown.bs.tab', function(e){
         sessionStorage.setItem('mainTab', '#tab_report');
+        autoFlashHeight();
     });
     let mainResizeEles = getMainResizeEles();
     SlideResize.verticalSlide(mainResizeEles.eleObj, mainResizeEles.limit, function(){

+ 7 - 8
web/building_saas/main/js/models/bills.js

@@ -682,7 +682,7 @@ var Bills = {
                 }
             }
         };
-        bills.prototype.deleteSelectedNodes=function() {//删除选中多行时的节点
+        bills.prototype.deleteSelectedNodes=function(isDeleteChild = false, parentNode = null) {//删除选中多行时的节点
             let controller = projectObj.mainController, project = projectObj.project;
             let selected = controller.tree.selected, parent = selected.parent;
             let me = this;
@@ -798,6 +798,10 @@ var Bills = {
                     if(addRuleSetting && addRuleSetting.addContent === '5'){
                         addRuleUseToBills(getAddRuleSetting(), projectObj.project.mainTree.items);
                     }
+                };
+
+                if (isDeleteChild){
+                    calcTools.forceSelect(parentNode);
                 }
             }, function () {
                 $.bootstrapLoading.end();
@@ -820,13 +824,8 @@ var Bills = {
             if (!(node.children.length && node.children.length > 0)) return;
             let me = this;
             let firstChild = node.firstChild();
-            projectObj.mainController.tree.selected = firstChild;
-            let idx = projectObj.project.mainTree.items.indexOf(firstChild);
-            projectObj.mainSpread.getActiveSheet().setSelection(idx, 0, node.children.length, 2);
-            me.deleteSelectedNodes();
-            projectObj.mainController.tree.selected = node;
-            let idxN = projectObj.project.mainTree.items.indexOf(node);
-            projectObj.mainSpread.getActiveSheet().setSelection(idxN, 0, 1, 2);
+            calcTools.forceSelect(firstChild, node.children.length);
+            me.deleteSelectedNodes(true, node);
         };
         bills.prototype.setNodeToMapAndArray=function (node,map,array) {
             let nodeID = node.getID();

+ 24 - 0
web/building_saas/main/js/models/calc_program.js

@@ -205,6 +205,30 @@ let calcTools = {
             treeNode.data.gljList = projectObj.project.ration_glj.getGatherGljArrByRations(rations, needOneBill, q);
         };
     },
+    getLeafBills: function (treeNode){
+        let leafBills = [];
+
+        function getBill(node){
+            if (!node) return;
+            if (calcTools.isLeafBill(node))
+                leafBills.push(node);
+
+            if (node.firstChild()) getBill(node.firstChild());
+            if (node.nextSibling) getBill(node.nextSibling);
+        };
+
+        let fc = treeNode.firstChild();
+        if (fc) getBill(fc);
+
+        return leafBills;
+    },
+    forceSelect: function (treeNode, rowsCount = 1, colsCount = 2){
+        projectObj.mainController.tree.selected = treeNode;
+        let idx = projectObj.project.mainTree.items.indexOf(treeNode);
+        let sheet = projectObj.mainSpread.getActiveSheet();
+        sheet.setSelection(idx, 0, rowsCount, colsCount);
+        sheet.showRow(idx, GC.Spread.Sheets.VerticalPosition.center);
+    },
 
     initFees: function (treeNode){
         if (!treeNode.data.fees) {

+ 2 - 2
web/building_saas/main/js/models/quantity_detail.js

@@ -728,7 +728,7 @@ var quantity_detail = {
             node.data.quantityEXP = quantityEXP?quantityEXP:editingText;
             value = scMathUtil.roundForObj(value,getDecimal("quantity",node));
             let newQuantity =  value+"";
-            if(oldQuantityEXP == node.data.quantityEXP && node.data.quantity == newQuantity){ //相当于什么都没改,不用做提交操作
+            if(quantityEXP!="GCLMXHJ"&& oldQuantityEXP == node.data.quantityEXP && node.data.quantity == newQuantity){ //除了修改工程量明细表达式进来的操作,相当于什么都没改,不用做提交操作
                 projectObj.mainController.refreshTreeNode([node]);//这里要再刷新一下,因为工程量要把手工输入的值刷新为转换后的值再显示
                 return;
             }
@@ -801,7 +801,7 @@ var quantity_detail = {
             //value = scMathUtil.roundForObj(value,getDecimal("ration.quantity"));
             value = project.quantity_detail.autoTransformQuantity(value,node);//先转换再4舍5入
             value = scMathUtil.roundForObj(value,decimalObj.decimal("quantity",node));
-            if(oldQuantityEXP == node.data.quantityEXP && node.data.quantity == value){ //相当于什么都没改,不用做提交操作
+            if( quantityEXP!="GCLMXHJ" && oldQuantityEXP == node.data.quantityEXP && node.data.quantity == value){ //除了修改工程量明细表达式进来的操作,相当于什么都没改,不用做提交操作
                 projectObj.mainController.refreshTreeNode([node]);//这里要再刷新一下,因为工程量要把手工输入的值刷新为转换后的值再显示
                 return;
             }

+ 23 - 12
web/building_saas/main/js/models/ration_coe.js

@@ -151,19 +151,40 @@ var ration_coe = {
                     }else {//取消勾选时,要删除添加的工料机记录
                        if(glj && glj.createType == "add") updateData.delete.push(glj.ID);
                     }
-
                 }
                 //替换工料机的情况
+                if(coe.coeType ==  "替换人材机"){
+                    let glj = _.find(gljList,{"rcode":coe.gljCode,'code':coe.replaceCode});//两个条件都满足,则表示已找到对应的记录
+                    if(newval == 1){
+                        if(glj) continue;
+                        let r_glj = _.find(gljList,function (g) {
+                            return (g.code == coe.gljCode && (g.createType===undefined || g.createType == 'normal')) || g.rcode == coe.gljCode //这两个满足一个说明要替换
+                        });
+                        if(r_glj){
+                            replace.push({code:coe.replaceCode,oldData:r_glj});
+                            codesList.push(coe.replaceCode);
+                        }
+                    }
+                    if(newval == 0 && glj){//取消勾选并找到的情况,要恢复成原来的
+                        replace.push({code:coe.gljCode,oldData:glj});
+                        codesList.push(coe.gljCode);
+                    }
+                }
             }
             project.ration_glj.getGLJDataByCodes(codesList,function (gljList) {//统一从后端按编号查找标准工料机信息
                 let gljMap = _.indexBy(gljList, 'code');
-                console.log(gljMap);
                 for(let a of add){
                     if(gljMap[a]){
                         let tem = project.ration_glj.getAddDataByStd(gljMap[a],recode.rationID,project.mainTree.selected.data.billsItemID,recode.projectID);
                         updateData.add.push(tem);
                     }
                 }
+                for(let r of replace){
+                    if(gljMap[r.code]){
+                        let r_tem = project.ration_glj.getReplaceDataByStd(r.oldData,gljMap[r.code]);
+                        updateData.replace.push(r_tem);
+                    }
+                }
                 $.bootstrapLoading.start();
                 CommonAjax.post("/ration/updateCoeAdjust",updateData,function (result) {
                     $.bootstrapLoading.end();
@@ -172,16 +193,6 @@ var ration_coe = {
                 })
             });
 
-
-
-
-
-           /* ;*/
-
-
-
-            //var updateData = this.getUpdateData('ut_update',query,doc,'adjustUpdate');
-           // project.pushNow('updateRationCOE',[this.getSourceType()],updateData);
         };
 
         ration_coe.prototype.updateCustomerCoe = function (data) {

+ 30 - 11
web/building_saas/main/js/models/ration_glj.js

@@ -187,6 +187,18 @@ let ration_glj = {
                 }
             }
         };
+        ration_glj.prototype.updateGLJNodeAfterReplace = function(data){
+            if (this.needShowToTree(data)) {//当替换的是主材或设备时,刷新对应的树节点
+                var node = this.findGLJNodeByID(data.ID);
+                if (node) {
+                    this.transferToNodeData(data);
+                    node.source = data;
+                    node.data = data;
+                }
+               return node;
+            }
+        };
+
         ration_glj.prototype.addToMainTree = function (datas) {
             datas = sortRationGLJ(datas);
             for (let data of datas) {
@@ -732,23 +744,16 @@ let ration_glj = {
             }, function () {
                 $.bootstrapLoading.end();
             });
-
-
         };
 
-        ration_glj.prototype.replaceGLJ = function (selectCode, oldData, callback) {
-            let allGLJ = gljOprObj.AllRecode;
-            let glj = _.find(allGLJ, function (item) {
-                let i_key = gljOprObj.getIndex(item, gljLibKeyArray);
-                return i_key == selectCode;
-            });
-            if (selectCode == gljOprObj.getIndex(oldData, gljKeyArray)) {
-                return callback(null);
-            }
+        ration_glj.prototype.getReplaceDataByStd = function (oldData,glj) {
             if (oldData.createType===undefined || oldData.createType == 'normal') {// createTypel 默认是normal 只有是定额下带的工料机才需把类型改成替换,其它的保持不变
                 oldData.rcode = oldData.code;
                 oldData.createType = 'replace';
             }
+            if(oldData.createType == 'replace' && oldData.rcode == glj.code){//如果原数据已经是替换过的,这次替换又恢复成原数据,则把类型改回来
+                oldData.createType = 'normal'
+            }
             oldData.GLJID = glj.ID;
             oldData.name = glj.name;
             oldData.code = glj.code;
@@ -769,6 +774,20 @@ let ration_glj = {
             } else {
                 oldData.from = "std";
             }
+            return oldData;
+        };
+
+
+        ration_glj.prototype.replaceGLJ = function (selectCode, oldData, callback) {
+            let allGLJ = gljOprObj.AllRecode;
+            let glj = _.find(allGLJ, function (item) {
+                let i_key = gljOprObj.getIndex(item, gljLibKeyArray);
+                return i_key == selectCode;
+            });
+            if (selectCode == gljOprObj.getIndex(oldData, gljKeyArray)) {
+                return callback(null);
+            }
+            oldData = this.getReplaceDataByStd(oldData,glj);
             $.bootstrapLoading.start();
             CommonAjax.post("/rationGlj/replaceGLJ", oldData, callback, function () {
                 $.bootstrapLoading.end();

+ 11 - 11
web/building_saas/main/js/views/block_lib.js

@@ -65,6 +65,7 @@ var blockLibObj = {
             lockColumns: [0, 1, 2, 3, 4, 5, 6]
         }
     },
+    cloneType: null,
 
     buildSheet: function () {
         $.bootstrapLoading.start();
@@ -473,7 +474,8 @@ var blockLibObj = {
                         return true;
                     },
                     callback: function (key, opt) {
-                        me.onCellDoubleClick();
+                        blockLibObj.cloneType = 1;
+                        $("#div_cloneOptions").modal({show: true});
                     }
                 },
                 "oneToMoreClone": {
@@ -487,7 +489,8 @@ var blockLibObj = {
                         return true;
                     },
                     callback: function (key, opt) {
-
+                        blockLibObj.cloneType = 2;
+                        $("#div_cloneOptions").modal({show: true});
                     }
                 },
                 "moreToMoreClone": {
@@ -501,7 +504,8 @@ var blockLibObj = {
                         return true;
                     },
                     callback: function (key, opt) {
-
+                        blockLibObj.cloneType = 3;
+                        $("#div_cloneOptions").modal({show: true});
                     }
                 },
                 "delete": {
@@ -544,13 +548,10 @@ var blockLibObj = {
     onCellDoubleClick: function (sender, args) {
         let projectNode = projectObj.project.mainTree.selected;
         if (!calcTools.isLeafBill(projectNode)) return;
+        blockLibObj.cloneType = 1;
         $("#div_cloneOptions").modal({show: true});
     },
     oneToOneClone: function (projectNode, block, options) {
-        if (options.overwriteRations)
-            projectObj.project.Bills.deleteChildren(projectNode);
-        return;
-
         let canClone = true;
         if (options.checkCode)
             canClone = canClone && (projectNode.data.code.substr(0, 9) == block.data.code.substr(0, 9));
@@ -559,7 +560,9 @@ var blockLibObj = {
         if (options.checkUnit)
             canClone = canClone && (projectNode.data.unit == block.data.unit);
         if (!canClone) return;
-
+        
+        if (options.overwriteRations)
+            projectObj.project.Bills.deleteChildren(projectNode);
         /*  这里封装成伟城的块文件格式,可直接使用伟城的“粘贴块”接口。
             但这里结构要作出调整:忽略叶子清单层,直接从定额开始(跟粘贴块有区别),始终强制在叶子清单下插入定额。
             该操作前提:当前块文件的全部数据已从后台取到前台。  */
@@ -573,9 +576,6 @@ var blockLibObj = {
         };
         vBlock_WC = JSON.parse(JSON.stringify(vBlock_WC));
         BlockController.confirmPaste(vBlock_WC, projectNode, 'sub');
-    },
-    oneToMoreCloneXX: function () {
-        //
     }
 };
 

+ 3 - 5
web/building_saas/main/js/views/fee_rate_view.js

@@ -354,11 +354,9 @@ var feeRateObject={
             var init=false;
         }
         FeeRateEditCellType.prototype = new ns.CellTypes.Text();
-        FeeRateEditCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
-           // if(value!=null){
-               // ctx.fillText(value,x+3+ctx.measureText(value).width,y+h-3);
+        //2018-12-12 按新需求隐藏费率选择按钮
+      /*  FeeRateEditCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
              GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
-           // }
             if(feeRateObject.editingCell && !projectReadOnly){
                 if(feeRateObject.editingCell.row==options.row&&feeRateObject.editingCell.col==options.col){
                     var image = document.getElementById('f_btn'),imageMagin = 3;
@@ -437,7 +435,7 @@ var feeRateObject={
                 hitinfo.sheet.repaint();
                 feeRateObject.pmLeave = true;
             }
-        }
+        }*/
         return new FeeRateEditCellType();
     },
     showSelectModal:function (hitinfo) {

+ 4 - 2
web/building_saas/main/js/views/glj_view.js

@@ -1183,7 +1183,9 @@ var gljOprObj = {
                 glj_list[list_index] = data;
                 project.projectGLJ.loadData(function () {//加载完项目工料机再计算
                     gljOprObj.showRationGLJSheetData();
-                    if (project.ration_glj.needShowToTree(data)) {//当替换的是主材或设备时,刷新对应的树节点
+                    let node = project.ration_glj.updateGLJNodeAfterReplace(data);
+                    if(node) nodes.push(node);
+                    /*if (project.ration_glj.needShowToTree(data)) {//当替换的是主材或设备时,刷新对应的树节点
                         var node = project.ration_glj.findGLJNodeByID(data.ID);
                         if (node) {
                             project.ration_glj.transferToNodeData(data);
@@ -1191,7 +1193,7 @@ var gljOprObj = {
                             node.data = data;
                         }
                         node ? nodes.push(node) : "";
-                    }
+                    }*/
                     //project.ration_glj.addToMainTree(data);
                     selected.data.adjustState = result.adjustState;
                     selected.data.name = result.name;

+ 37 - 2
web/building_saas/main/js/views/project_view.js

@@ -2955,6 +2955,20 @@ $(function () {
     });
 
     $("#div_cloneOptions").on('show.bs.modal', function(){
+        let s = '';
+        switch (blockLibObj.cloneType) {
+            case 1:
+                s = '一对一克隆';
+                break;
+            case 2:
+                s = '一对多克隆';
+                break;
+            case 3:
+                s = '多对多克隆';
+                break;
+        }
+        s = `<span style='color:red;'>${s}</span>`;
+        $('#clone_option_title').html(`快速组价 (${s})`);
         $('#clone_option_code').prop("checked", true);
         $('#clone_option_name').prop("checked", false);
         $('#clone_option_unit').prop("checked", true);
@@ -3022,9 +3036,30 @@ $(function () {
         if ($('#clone_option_name').prop("checked")) options.checkName = true;
         if ($('#clone_option_unit').prop("checked")) options.checkUnit = true;
         if ($('#clone_option_zeroQuantity').prop("checked")) options.zeroQuantity = true;
-        if ($('#clone_option_overwriteRations').prop("checked")) options.overwriteRations = true;
+        if ($('#clone_option_cover').prop("checked")) options.overwriteRations = true;
 
-        blockLibObj.oneToOneClone(projectNode, block, options);
+        switch (blockLibObj.cloneType) {
+            case 1:
+                blockLibObj.oneToOneClone(projectNode, block, options);
+                break;
+            case 2:
+                let bills = calcTools.getLeafBills(projectNode);
+                for (let bill of bills){
+                    calcTools.forceSelect(bill);
+                    blockLibObj.oneToOneClone(bill, block, options);
+                };
+                break;
+            case 3:
+                let mtmBills = calcTools.getLeafBills(projectNode);
+                let mtmBlocks = blockLibObj.mainTree.selected.children;
+                for (let mtmBill of mtmBills){
+                    for (let mtmBlock of mtmBlocks){
+                        calcTools.forceSelect(mtmBill);
+                        blockLibObj.oneToOneClone(mtmBill, mtmBlock, options);
+                    };
+                };
+                break;
+        }
     });
 
 

+ 10 - 2
web/building_saas/main/js/views/zmhs_view.js

@@ -96,19 +96,27 @@ let zmhs_obj = {
         let ration_glj = projectObj.project.ration_glj;
         let calcInstall = false;//是否记录安装增加费
         let nodes = projectObj.project.updateNodesCache([{type:ModuleNames.ration,data:result.ration}]);
-        projectObj.mainController.refreshTreeNode(nodes, false);
         if(result.add && result.add.length > 0){//需添加定额工料机的情况
             ration_glj.datas = ration_glj.datas.concat(result.add);
             gljOprObj.sheetData = gljOprObj.sheetData.concat(result.add);
         }
         if(result.delete && result.delete.length > 0 && this.deleteGLJs(result.delete)) calcInstall = true; //这样保证delete返回值是true的时候才改变变量类型
+        if(result.replace && result.replace.length > 0){ //替换工料机的情况
+            for(let r of result.replace){//替换缓存内容
+                ration_glj.datas.splice(_.findIndex(ration_glj.datas,{'ID': r.ID}),1,r);
+                gljOprObj.sheetData.splice(_.findIndex(gljOprObj.sheetData,{'ID': r.ID}),1,r);
+                let node = ration_glj.updateGLJNodeAfterReplace(r);
+                if(node)  nodes.push(node);
+            }
+        }
+        projectObj.mainController.refreshTreeNode(nodes, false);
 
         let rationID= ration_glj.updateCacheAfterAdjust(result.ration_glj);
         if(reload == true){//有添加、替换、工料机等需重新加载的情况
             $.bootstrapLoading.start();
             projectObj.project.projectGLJ.loadData(function () {
                 $.bootstrapLoading.end();
-                if(result.add && result.add.length > 0) ration_glj.addToMainTree(result.add);
+                if(result.add && result.add.length > 0) ration_glj.addToMainTree(result.add);//这个方法有再去项目工料机那里取价格,所以要在回调里调用,不像替换工料的情况
                 ration_glj.reCalcWhenGLJChange({rationID:rationID});
                 if(result.delete && result.delete.length > 0 && calcInstall) installationFeeObj.calcInstallationFee();//如果是删除节点的话,
             });