zhangweicheng 5 年之前
父节点
当前提交
832c50a675

+ 1 - 1
modules/all_models/compleRation_ration.js

@@ -41,7 +41,7 @@ const compleRationSchema = new Schema({
     userId: String,
     compilationId: String,
     rationRepId: Number,
-    ID:Number,
+    ID:{type: Number,index: true},
     code: String,
     name: String,
     unit: String,

+ 1 - 1
modules/all_models/compleRation_section.js

@@ -17,7 +17,7 @@ const compleRationSectionTreeSchema = new Schema({
     name: String,
     //是否是同层第一个节点
    // isFirst: Boolean,
-    ID: String,
+    ID: {type: String,index: true},
     NextSiblingID: String,
     ParentID: String,
     deleteInfo: deleteSchema,

+ 1 - 1
modules/all_models/stdRation_coe.js

@@ -19,7 +19,7 @@ const coeSchema = new Schema({
 
 const coeListSchema = new Schema({
     libID: Number,                      // 所属定额定ID
-    ID: Number,                         // 系数ID(流水号ID)
+    ID: {type: Number,index: true},                         // 系数ID(流水号ID)
     serialNo: Number,                  //编号
     name: String,                       // 名称
     content: String,                    // 说明

+ 2 - 2
modules/all_models/stdRation_ration.js

@@ -32,8 +32,8 @@ const rationInstSchema = new Schema({
 },{_id: false});
 
 const rationItemSchema = new Schema({
-    ID:Number,
-    code: String,
+    ID:{type: Number,index: true},
+    code: {type: String,index: true},
     name: String,
     unit: String,
     basePrice: Number,

+ 1 - 1
modules/all_models/stdRation_section.js

@@ -6,7 +6,7 @@ const mongoose = require('mongoose');
 const Schema = mongoose.Schema;
 const rationChapterTreeSchema = new Schema({//章节树  //生成唯一id改为sectionID  改成string
     rationRepId: Number,
-    ID:Number,
+    ID:{type: Number,index: true},
     ParentID:Number,
     NextSiblingID:Number,
     name: String,

+ 4 - 4
modules/complementary_ration_lib/models/searchModel.js

@@ -26,16 +26,16 @@ class SearchDao{
                 ration = await this.getCompleRation(userId,compilationId,code,ID);
             }else {
                 firstLib = parseInt(firstLib);
-                let firstQuery = {rationRepId: firstLib, code: code, $or: [{isDeleted: null}, {isDeleted: false}]};
+                let firstQuery = {rationRepId: firstLib, code: code};
                 if(ID){
-                    firstQuery = {ID: ID, $or: [{isDeleted: null}, {isDeleted: false}]};
+                    firstQuery = {ID: ID};
                 }
                 ration = await this.getStdRation(firstQuery);
             }
             if(ration == null){//选中的定额库或者默认的定额库中没有找到定额,才走常规的流程查找其它定额库
-                let stdQuery = {rationRepId: {$in: otherLibs}, code: code, $or: [{isDeleted: null}, {isDeleted: false}]};
+                let stdQuery = {rationRepId: {$in: otherLibs}, code: code};
                 if(ID){
-                    stdQuery = {ID: ID, $or: [{isDeleted: null}, {isDeleted: false}]};
+                    stdQuery = {ID: ID};
                 }
                 ration = await this.getStdRation(stdQuery);
                 if(ration == null) ration = await this.getCompleRation(userId,compilationId,code,ID);

+ 157 - 56
modules/main/facade/ration_facade.js

@@ -37,6 +37,9 @@ let _= require('lodash');
 const projectDao = require('../../pm/models/project_model').project;
 let projectModel = mongoose.model('projects');
 let unitPriceModel = mongoose.model('unit_price');
+let unitPriceFileModel = mongoose.model('unit_price_file');
+let vvTaxModel =  mongoose.model("std_vehicleVesselTax_items");
+
 const fs = require('fs');
 
 module.exports = {
@@ -254,8 +257,8 @@ async function insertNewRation(newData,defaultLibID,std,calQuantity) {//插入
     }
     let addRationGLJTime = +new Date();
     console.log("计算消耗量时间-------------------------------"+(addRationGLJTime - startTime));
-    let newRation = await ration_model.model.create(newData);
-    return newRation;
+    await ration_model.model.insertMany([newData]);
+    return newData;
     /*ration_model.model.create(newData);
     return newData;*/
 }
@@ -400,6 +403,9 @@ async function addRationTemplate(std,newRation) {
 async function addRationCoe(std,newRation,compilation) {
     let ration_coe_list = [];
     let seq = 0;
+    let stdCoeIDs = [];
+    let coeMap={}
+
     if(std.hasOwnProperty('rationCoeList')&&std.rationCoeList.length>0){//添加标准库的工料机
         for(let sub of std.rationCoeList){
             let libCoe;
@@ -461,12 +467,12 @@ async function getCustomerCoe(projectID,rationID,seq,compilation){//取自定义
     lastCoe.ID = uuidV1();
     lastCoe.coes = getCustomerCoeData();
     try {
-    //查看编办中有没有重写路径
-     if(compilation.overWriteUrl && compilation.overWriteUrl!=""){
+    //查看编办中有没有重写路径  -- 养护中暂时没用到
+     /* if(compilation.overWriteUrl && compilation.overWriteUrl!=""){
          let overWrite = require("../../.."+compilation.overWriteUrl);
          if(overWrite.getCusCoeContent) lastCoe.content = overWrite.getCusCoeContent();
          if(overWrite.getCustomerCoeData) lastCoe.coes = overWrite.getCustomerCoeData();
-     }
+     } */
      return lastCoe
    }catch (err){
        console.log("读取自定义系数重写文件失败");
@@ -535,49 +541,43 @@ async function addRationGLJ(std,newRation,compilation,isMaterial,connect_key) {
             newGLJ.adjustProportion = proportion;
             let std_glj = getStdGlj(sub,stdGLJMap,cptGLJMap,{},ext);
             if(std_glj){
-                let tindex = getIndex(newGLJ);
                 ration_glj_facade.setPropertyFromStd(newGLJ,std_glj);
+                let tindex = getIndex(newGLJ);
                 if(std_glj.component && std_glj.component.length > 0) mixRatioMap[tindex] = std_glj.component
                 let tdata = ration_glj_facade.getGLJSearchInfo(newGLJ);
                 gljKeyMap[tindex] = tdata;
                 gljCodes.push(tdata.code);
-               /*  let [info,projectGLJ] =  await ration_glj_facade.getInfoFromProjectGLJ(newGLJ,unitPriceFileId,ext);
-                newGLJ = ration_glj_facade.createNewRecord(info);
                 newRationGLJList.push(newGLJ);
-                rationGLJShowList.push(info);
-                projectGLJList.push(projectGLJ); */
             }
-            //let InfoFromProjectGLJ = +new Date();
-            //console.log("找到项目工料机时间-------------------------------"+(InfoFromProjectGLJ - std_gljTime));
+            
         }
-
-
+        [newRationGLJList, projectGLJList] =  await getProjectGLJinfo(newRation.projectID,newRationGLJList,gljKeyMap,gljCodes,mixRatioMap,unitPriceFileId,ext);
+        let InfoFromProjectGLJ = +new Date();
+        console.log("找到项目工料机时间-------------------------------"+(InfoFromProjectGLJ - stdGLJMapTime));
 
     }
-    let before = +new Date();
-    console.log("总查询时间为-------------------------------"+(before-first));
     if(isMaterial == true) return [newRationGLJList,projectGLJList];//如果是材料计算的工料机,这里返回就可以了
 
     if(newRationGLJList.length>0){
         await ration_glj.insertMany(newRationGLJList);
     }
     let after = +new Date();
-    console.log("实际插入时间为-------------------------------"+(after-before));
     console.log("总操作时间为-------------------------------"+(after-first));
-    return [rationGLJShowList,projectGLJList];
+    return [newRationGLJList,projectGLJList];
 }
 
-async function getProjectGLJinfo(projectID,gljKeyMap,gljCodes,mixRatioMap,unitPriceFileId,ext){//批量插入或查找项目工料机信息
+async function getProjectGLJinfo(projectID,t_newRationGLJList,gljKeyMap,gljCodes,mixRatioMap,unitPriceFileId,ext){//批量插入或查找项目工料机信息
   //先根据工料机编号在项目工料机中查找工料机是否存在
   let projectGLJMap={};
-  let unitPriceMap = {};
+  let projectGLJList = [];
   let newProjectGLJList=[];//工料机ID要重新去取
   let connectKeyList = [];
-  let existMixRatioMap={};
+  let CCSMap = {keyMap:{},codes:[]};//需要添加车船税的机械台班
+  let newRationGLJList=[];
 
   let gljListModel = new GLJListModel();
-  let projectGLJList = await projectGLJModel.find({'project_id':projectID,'code':{'$in':gljCodes}}).lean();
-  for(let pg of projectGLJList){
+  let t_projectGLJList = await projectGLJModel.find({'project_id':projectID,'code':{'$in':gljCodes}}).lean();
+  for(let pg of t_projectGLJList){
      let pindex = getIndex(pg);  
      projectGLJMap[pindex] = pg;
   }
@@ -585,39 +585,127 @@ async function getProjectGLJinfo(projectID,gljKeyMap,gljCodes,mixRatioMap,unitPr
     if(!projectGLJMap[key]){//如果项目工料机不存在,则添加
       newProjectGLJList.push(gljKeyMap[key]);
       projectGLJMap[key] = gljKeyMap[key];
+      if(gljKeyMap[key].type == 301){//如果是机械台班,需看看有没有车船税
+        CCSMap.keyMap[key] = true;
+        CCSMap.codes.push(gljKeyMap[key].code);
+      }
     }
     //查看组成物
-    if(gljListModel.ownCompositionTypes.indexOf(data.type)!=-1){//有组成物的类型
+    if(gljListModel.ownCompositionTypes.indexOf(gljKeyMap[key].type)!=-1){//有组成物的类型
       connectKeyList.push(key);
     }
   }
 
-  
-//处理车般税相关 --- todo
 
-  
+  let [existMixRatioMap,mixRatioInsertData,missCodeList] = await getMixRatioInfo(projectID,projectGLJMap,newProjectGLJList,mixRatioMap,connectKeyList,unitPriceFileId,CCSMap,ext);
+  if(missCodeList.length > 0) gljCodes = gljCodes.concat(missCodeList);
+ 
+  //处理车般税相关,车船税是添加项目时,项目工料机,和单价文件里自动添加的 --- todo
+ 
+  let [unitPriceMap,newUnitPriceList] = await getUnitPriceData(newProjectGLJList,gljCodes,unitPriceFileId);
+  if(newUnitPriceList.length > 0) await unitPriceModel.insertMany(newUnitPriceList);
+
 
+  if(mixRatioInsertData.length > 0) await mixRatioModel.insertMany(mixRatioInsertData);
 
+  //插入项目工料机
+  if(newProjectGLJList.length > 0){
+    await setIDfromCounter("glj_list",newProjectGLJList);
+    await projectGLJModel.insertMany(newProjectGLJList);
+  }
 
 
-  let unitPriceList = await unitPriceModel.find({unit_price_file_id: unitPriceFileId,'code':{'$in':gljCodes}}).lean();
+  //组装数据
+  for(let ration_glj of t_newRationGLJList){
+    let rkey = getIndex(ration_glj);
+    let pglj = projectGLJMap[rkey];
+    let subList = [];
+    setUnitPrice(pglj,unitPriceMap);
+    if(existMixRatioMap[rkey]){//如果有组成物
+      for(let m of existMixRatioMap[rkey]){
+         let mpglj = projectGLJMap[getIndex(m)]
+         if(mpglj){
+          let cglj = _.clone(mpglj); 
+          setUnitPrice(cglj,unitPriceMap);
+          cglj.ratio_data = m;
+          subList.push(cglj);
+         }else{
+            throw  `组成物${m.name}对应的项目工料机没有找到`;
+         }
+      }
+      pglj.subList =subList; 
+    }
+    ration_glj.projectGLJID = pglj.id;
+    newRationGLJList.push(ration_glj_facade.createNewRecord(ration_glj));
+    projectGLJList.push(pglj);
+  }
+
+  return [newRationGLJList, projectGLJList];
+
+
+
+
+  function setUnitPrice(p,unitPriceMap){
+    p.unit_price = unitPriceMap[getIndex(p)];
+  }
+
+}
+
 
 
+async function getUnitPriceData(newProjectGLJList,gljCodes,unitPriceFileId){
+  let unitPriceMap = {};
+  let newUnitPriceList = [];
+  let unitPriceList = await unitPriceModel.find({unit_price_file_id: unitPriceFileId,'code':{'$in':gljCodes}}).lean();
+  for(let u of unitPriceList){
+    unitPriceMap[getIndex(u)]=u;
+  }
+
+  for(let np of newProjectGLJList){
+    let pkey = getIndex(np);
+    if(unitPriceMap[pkey]) continue;
+
+    let insertData = {
+      code: np.code,
+      base_price: np.base_price,
+      market_price: np.market_price,
+      unit_price_file_id: unitPriceFileId,
+      name: np.name,
+      specs:np.specs?np.specs:'',
+      original_code:np.original_code,
+      unit:np.unit?np.unit:'',
+      type: np.type,
+      short_name: np.shortName !== undefined ? np.shortName : '',
+      glj_id: np.glj_id,
+      is_add:0,
+      grossWeightCoe:np.grossWeightCoe,
+      purchaseStorageRate:np.purchaseStorageRate,
+      offSiteTransportLossRate:np.offSiteTransportLossRate,
+      handlingLossRate:np.handlingLossRate
+    };
+    if(np.from=='cpt') insertData.is_add=1;//如果是来自补充工料机,则都添加新增标记
+    if(insertData.code != insertData.original_code) insertData.is_add=1;//添加的时候如果是复制整块来的,可能在源项目中是新增的工料机,这里也要添上(暂时可能还用不到)
+    newUnitPriceList.push(insertData);
+    unitPriceMap[pkey] = insertData;
+  }
 
 
-  gljListModel.ownCompositionTypes
+  if(newUnitPriceList.length > 0) await setIDfromCounter("unit_price",newUnitPriceList);
 
+  return [unitPriceMap,newUnitPriceList];
 
 
 }
 
 
-async function getMixRatioInfo(projectID,projectGLJMap,mixRatioMap,connectKeyList,unitPriceFileId,ext){//取组成物信息,得到缺少的组成物情况
-  let missCodeList = [];
+async function getMixRatioInfo(projectID,projectGLJMap,newProjectGLJList,mixRatioMap,connectKeyList,unitPriceFileId,CCSMap,ext){//取组成物信息,得到缺少的组成物情况
+  let missCodeList = []; //所有组成物信息的编码,用来统一查询对应的项目工料机是否存在
   let existMixRatioMap ={};
   let codeMap={};//用来去重
-  let newProjectGLJList=[];
+  let mixRatioInsertData = [];
+
 
+  // 1. 先检查现在的组成物表中,是否有相关信息 - 生成映射记录
   if(connectKeyList.length > 0){//有组成物的话从数据库中取出组成物信息
     let mixRatioList = await mixRatioModel.find({'unit_price_file_id': unitPriceFileId,'connect_key': {'$in':connectKeyList}}).lean();
     for(let m of mixRatioList){
@@ -630,6 +718,8 @@ async function getMixRatioInfo(projectID,projectGLJMap,mixRatioMap,connectKeyLis
           codeMap[m.code] = true;
        } 
     }
+
+    // 2 将第一步得到的映射表 与在标准库查询父工料机得到的映射表对比,得出哪些组物成还需要添加,获得库ID
     let stdIDs = []; 
     let comIDs = [];
     let missMixRatioGroup = [];
@@ -648,7 +738,7 @@ async function getMixRatioInfo(projectID,projectGLJMap,mixRatioMap,connectKeyLis
        }
     }
 
-
+    //3.统一查询所有组成物在标准库中的详细信息
     let stdMixMap = {};
     //整理需插入的组成物列表的数据
     //来自标准工料机
@@ -680,8 +770,7 @@ async function getMixRatioInfo(projectID,projectGLJMap,mixRatioMap,connectKeyLis
     }
   
 
-    let mixRatioInsertData = [];
-
+    //4.生成需要插入组成物表的数据
     for(let mg of missMixRatioGroup){//整理需要插入组成物列表的数据
         for(let tc of mg.list){
           let consumpiton = tc.consumeAmt;
@@ -707,11 +796,29 @@ async function getMixRatioInfo(projectID,projectGLJMap,mixRatioMap,connectKeyLis
         }
     }
 
+    //4.5 处理车船税问题,查询机械台班是否需要添加车船税
+    if(CCSMap.codes.length > 0){
+      let unitFileInfo = await unitPriceFileModel.findOne({id:unitPriceFileId}).lean();
+      if(unitFileInfo.vvTaxFileID && unitFileInfo.vvTaxFileID!=""){
+        let needCCS = false;
+        let items =  await vvTaxModel.find({libID:unitFileInfo.vvTaxFileID,'code':{'$in':CCSMap.codes}}).lean();
+        for(let i of items){
+          let ikey = getIndex(i);
+          if(CCSMap.keyMap[ikey]){
+            needCCS = true;
+            mixRatioInsertData.push(gljUtil.getBaseCCSMixRatio(unitPriceFileId,i.vehicleVesselTax,ikey))
+          }
+        }
+        if(needCCS && !codeMap["80CCS"]) missCodeList.push("80CCS");
+      }
+    }
+
+
     if(mixRatioInsertData.length > 0) await setIDfromCounter("mix_ratio",mixRatioInsertData,existMixRatioMap,'connect_key');
     //await mixRatioModel.insertMany(mixRatioInsertData);  因为没有事务添加组成物数据要放在添加单价文件数据之后
      
 
-    //查询组成物对应的项目工料机是否存在,如果不存在,则重新插入
+    //5.查询组成物对应的项目工料机是否存在,如果不存在,生成项目工料机信息
     let projectGLJList = await projectGLJModel.find({'project_id':projectID,'code':{'$in':missCodeList}}).lean();
     for(let pg of projectGLJList){
       let pindex = getIndex(pg);  
@@ -719,11 +826,12 @@ async function getMixRatioInfo(projectID,projectGLJMap,mixRatioMap,connectKeyLis
     }
 
     let lessMix = [];//组成物表存在,项目工料机不存在的数据
+    let lessMixMap = {};//防止重复添加
     for(let connect_key in existMixRatioMap){
       let mixRatios = existMixRatioMap[connect_key]; 
       for(let m of mixRatios){
         let mk = getIndex(m);
-        if(!projectGLJMap[mk]){//如果组成物对应的项目工料机不存在
+        if(!projectGLJMap[mk] && !lessMixMap[mk]){//如果组成物对应的项目工料机不存在
           let nglj = null;
           if(m.from == 'std'){//这里有值,说明是刚添加到组成物文件中的数据   
             nglj = stdMixMap[m.glj_id];
@@ -738,10 +846,13 @@ async function getMixRatioInfo(projectID,projectGLJMap,mixRatioMap,connectKeyLis
           }else{//这里没找到,说明是组成物文件里有,但是项目工料机没有的数据
             lessMix.push(m);
           }
+          lessMixMap[mk] = true;//只要处理过一次,就不用再重新处理了,机械组成物,比如柴油这些,会出现多次
         }
       }
     }
 
+
+   //6. 组成物文件里有,但是项目工料机没有的数据(共用单价文件等情况产生)    
     let lessIDList=[];
     let uniqMap ={};//去重
     let lessStdMix = [];//防止组成物中改了名称等,但是通过glj_id取出来的是还没改前的原始数据
@@ -749,7 +860,7 @@ async function getMixRatioInfo(projectID,projectGLJMap,mixRatioMap,connectKeyLis
       for(let lm of lessMix){
         let parentglj = projectGLJMap[lm.connect_key];
         if(!parentglj) throw `含有组成物工料机${lm.connect_key},没有找到,添加定额失败`;
-        if(parentglj.from == "std" || lm.from == "std"){
+        if((parentglj.from == "std" || lm.from == "std") && lm.code!="80CCS"){//车船税特殊处理
           if(!uniqMap[lm.glj_id]){
             lessIDList.push(lm.glj_id);
             uniqMap[lm.glj_id] = lm;
@@ -759,11 +870,12 @@ async function getMixRatioInfo(projectID,projectGLJMap,mixRatioMap,connectKeyLis
           lm.from = 'cpt';
           lm.gljType = lm.type;
           let t_mg = getProjectGLJNewData(lm,projectID);
-          newProjectGLJLis.push(t_mg);
+          newProjectGLJList.push(t_mg);
           projectGLJMap[getIndex(lm)] = t_mg;
         }
       }
     }
+
     if(lessIDList.length > 0){
       let less_stds =  await std_glj_lib_gljList_model.find({'ID':{'$in':lessIDList}}).lean();
       let less_stds_map = {};
@@ -781,16 +893,12 @@ async function getMixRatioInfo(projectID,projectGLJMap,mixRatioMap,connectKeyLis
         t_nglj.unit = t_l_m.unit;
         let t_np = getProjectGLJNewData(t_nglj,projectID,ext);
         newProjectGLJList.push(t_np);
-        projectGLJMap[t_l_m.connect_key] = t_np;
+        projectGLJMap[getIndex(t_l_m)] = t_np;
       }
     }
 
-
-
-
-
   }
-  return [existMixRatioMap,mixRatioInsertData,newProjectGLJList,missCodeList]
+  return [existMixRatioMap,mixRatioInsertData,missCodeList]
 
 }
 
@@ -810,7 +918,7 @@ function getProjectGLJNewData(tmp,projectId,ext){
       materialType: tmp.materialType,   //三材类别
       materialCoe: tmp.materialCoe,
       base_price: tmp.basePrice,
-      market_price: tmp.marketPrice,
+      market_price: tmp.basePrice,
       from:tmp.from?tmp.from:"std"
   };
   if(gljData.from == 'std' && ext && ext.priceField &&( tmp.priceProperty[ext.priceField]!= undefined && tmp.priceProperty[ext.priceField]!=null)){
@@ -828,9 +936,9 @@ async function setIDfromCounter(name,list,map,keyfield){//map,keyfield
   let options = {new: true};
 
   // 先查找更新
-  let maxID = await counterModel.findAndModify(condition, update, options);
-  let firstID = maxID - list.length - 1;
-  for(a of list){
+  let counter = await counterModel.findOneAndUpdate(condition, update, options);
+  let firstID = counter.sequence_value - (list.length - 1);
+  for(let a of list){
       a.id = firstID;
       firstID+=1
       if(map && keyfield){
@@ -839,13 +947,6 @@ async function setIDfromCounter(name,list,map,keyfield){//map,keyfield
       }
   }
 
-
-
-}
-
-
-async function getUnitPriceData(unitPriceMap){
-
 }
 
 

+ 2 - 2
public/web/tree_sheet/tree_sheet_controller.js

@@ -201,10 +201,10 @@ var TREE_SHEET_CONTROLLER = {
             }
         };
 
-        controller.prototype.refreshTreeNode = function (nodes, recursive) {
+        controller.prototype.refreshTreeNode = function (nodes,recursive,autoFit) {
             var that = this;
             TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
-                TREE_SHEET_HELPER.refreshTreeNodeData(that.setting, that.sheet, nodes, recursive)
+                TREE_SHEET_HELPER.refreshTreeNodeData(that.setting, that.sheet, nodes, recursive,autoFit)
             })
         }
 

+ 2 - 2
public/web/tree_sheet/tree_sheet_helper.js

@@ -109,7 +109,7 @@ var TREE_SHEET_HELPER = {
             }
         })
     },
-    refreshTreeNodeData: function (setting, sheet, nodes, recursive) {
+    refreshTreeNodeData: function (setting, sheet, nodes, recursive,autoFit=true) {
         nodes.forEach(function (node) {
             let iRow = node.serialNo();
             if(setting.emptyRowHeader){
@@ -208,7 +208,7 @@ var TREE_SHEET_HELPER = {
                     cell.locked(typeof projectReadOnly !== 'undefined' && projectReadOnly ? true : false);
                 }
             });
-            if(setting.setAutoFitRow){
+            if(autoFit==true && setting.setAutoFitRow){
                 setting.setAutoFitRow(sheet,node)//自动行高功能比较费时,400行,启用和不启用相差2秒左右
             }
             if (recursive) {

+ 4 - 2
web/building_saas/main/js/controllers/project_controller.js

@@ -4,7 +4,7 @@
 
 ProjectController = {
     /* sc: tree_sheet_controller */
-    syncDisplayNewNode: function (sc, newNode) {
+    syncDisplayNewNode: function (sc, newNode,callback) {
         TREE_SHEET_HELPER.massOperationSheet(sc.sheet, function () {
             var sels = sc.sheet.getSelections();
             sc.sheet.addRows(newNode.serialNo(), 1);
@@ -14,9 +14,10 @@ ProjectController = {
             //不显示到中间
             //sc.sheet.showRow(newNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
             cbTools.refreshFormulaNodes();
+            if(callback) callback();
         });
     },
-    syncDisplayNewNodes: function (sc, newNodes,withOutSelect=false) {//withOutSelect 不需要自动选中,外面自已处理
+    syncDisplayNewNodes: function (sc, newNodes,withOutSelect=false,callback) {//withOutSelect 不需要自动选中,外面自已处理
         TREE_SHEET_HELPER.massOperationSheet(sc.sheet, function () {
             var sels = sc.sheet.getSelections();
             newNodes.sort(function (a, b) {
@@ -42,6 +43,7 @@ ProjectController = {
             }
 
             cbTools.refreshFormulaNodes();
+            if(callback) callback();
         });
     },
     syncDisplayNewRationGljNode:function (sc,newNode) {

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

@@ -370,7 +370,7 @@ let cbTools = {
     refreshFormulaNodes: function () {
         try {
             let nodes = this.getFormulaNodes();
-            if (nodes.length > 0) projectObj.mainController.refreshTreeNode(nodes);
+            if (nodes.length > 0) projectObj.mainController.refreshTreeNode(nodes,false,false);
         } catch (err) {
             alert('公式引用行号显示刷新失败:' + err.message);
         }

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

@@ -1910,7 +1910,7 @@ class CalcProgram {
             if(callback){
                 callback(data);
             };
-            projectObj.mainController.refreshTreeNode(treeNodes);
+            projectObj.mainController.refreshTreeNode(treeNodes,false,false);
             // 批量树结点计算后,计算程序早已物是人非,所以这里要重新计算一下。警告:第二个参数千万不能改成3,否则死循环!
             if (activeSubSheetIsCalcProgram())
                 calcProgramObj.refreshCalcProgram(projectObj.project.mainTree.selected, 2);

+ 5 - 3
web/building_saas/main/js/models/ration.js

@@ -632,9 +632,11 @@ var Ration = {
                 newNode.source = newSource;
                 newNode.sourceType = project.Ration.getSourceType();
                 newNode.data = newSource;
-                ProjectController.syncDisplayNewNode(sheetController, newNode);
-                project.ration_glj.addToMainTree(data.ration_gljs);
-                projectObj.mainController.refreshTreeNode([newNode], false);
+                ProjectController.syncDisplayNewNode(sheetController, newNode,function(){
+                  project.ration_glj.addToMainTree(data.ration_gljs);
+                  projectObj.mainController.refreshTreeNode([newNode], false);
+                });
+                
             }
         };
         ration.prototype.addNewRationFast = function (rationType,callback) {

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

@@ -488,6 +488,8 @@ var gljOprObj = {
         }
     },
     showDataIfRationSelect: function (node,selectedNodeId) {
+        this.sheet.suspendPaint();
+        this.sheet.suspendEvent();
         var isShow = false;
         if(projectReadOnly && this.setting.view.lockColumns){
             this.setting.view.lockColumns = null;
@@ -531,9 +533,8 @@ var gljOprObj = {
             this.clearSheetData();
             MaterialController.hideReplaceDiv();
         }
-        //子目换算
-        //zmhs_obj.showZMHSData(node);
-        //   $('#dropdown').hide();
+        this.sheet.resumeEvent();
+        this.sheet.resumePaint();
     },
     showMixRatio:function (node) {//显示组成物到定额工料机
         let mixRatioMap = projectObj.project.projectGLJ.datas.mixRatioMap;
@@ -628,8 +629,6 @@ var gljOprObj = {
         return codeMap;
     },
     initRationTree: function (init,codeMap) {
-        this.sheet.suspendPaint();
-        this.sheet.suspendEvent();
         this.sheet.setRowCount(this.sheetData.length >30?this.sheetData.length:30);
         for (var i = 0; i < this.sheetData.length; i++) {
             let options = this.getCodeOptions(this.sheetData[i],codeMap);
@@ -641,8 +640,6 @@ var gljOprObj = {
                 }
             }
         }
-        this.sheet.resumeEvent();
-        this.sheet.resumePaint();
     },
     getCodeOptions:function (recode,codeMap) {
         let options = [];

+ 9 - 7
web/building_saas/main/js/views/project_view.js

@@ -246,13 +246,15 @@ var projectObj = {
     setActiveCell(field, moveScroll){
         projectObj.mainSpread.focus(true);
         let mainSheet = projectObj.mainSpread.getActiveSheet();
-        let fieldCol = colSettingObj.getColByField(field);
-        if(fieldCol){
-            if(moveScroll){
-                mainSheet.showColumn(fieldCol, GC.Spread.Sheets.HorizontalPosition.center);
-            }
-            mainSheet.setActiveCell(projectObj.project.mainTree.selected.serialNo(), fieldCol);
-        }
+        TREE_SHEET_HELPER.massOperationSheet(mainSheet,function(){
+          let fieldCol = colSettingObj.getColByField(field);
+          if(fieldCol){
+              if(moveScroll){
+                  mainSheet.showColumn(fieldCol, GC.Spread.Sheets.HorizontalPosition.center);
+              }
+              mainSheet.setActiveCell(projectObj.project.mainTree.selected.serialNo(), fieldCol);
+          }
+        });
     },
     //获取粘贴更改的单元格(粘贴时,跳过隐藏行)
     checkSpreadChangedCells: function (info) {

+ 4 - 4
web/building_saas/main/js/views/zmhs_view.js

@@ -147,6 +147,8 @@ let zmhs_obj = {
         let selected = node?node:projectObj.project.mainTree.selected;
         let ration_coe = projectObj.project.ration_coe;
         let coeList = [];
+        this.coeSheet.suspendPaint();
+        this.coeSheet.suspendEvent();
         if(selected&&selected.sourceType == "ration"){
             let ration = selected.data;
             let assList = this.getAssList(node); //2019-01-23 新需求,将辅助定额合并到一个表显示  -- 20191206
@@ -158,8 +160,6 @@ let zmhs_obj = {
         this.coeSheet.setRowCount(0);
         sheetCommonObj.showData(this.coeSheet, this.coeSetting,coeList);
         if (coeList.length > 0) {
-            this.coeSheet.suspendPaint();
-            this.coeSheet.suspendEvent();
             for(let i =0;i<coeList.length;i++ ){
                 if(gljUtil.isDef(coeList[i].option_codes)&&coeList[i].option_codes!=""){
                     this.getComboBoxForCodes(coeList[i],i);//设置可选类型的下拉框
@@ -171,8 +171,6 @@ let zmhs_obj = {
                     this.coeSheet.setCellType(i, 1, sheetCommonObj.getCustomerCoeCellType(this.generateHtmlString,this.bindCusEditorValue,this.updateCusCoeAfterEditor), GC.Spread.Sheets.SheetArea.viewport);
                 }
             }
-            this.coeSheet.resumeEvent();
-            this.coeSheet.resumePaint();
         }
         this.coeSheetData = coeList;
         if(projectReadOnly){
@@ -181,6 +179,8 @@ let zmhs_obj = {
         if(preSelections){//定位光标到之前的位置
             this.coeSheet.setSelection(preSelections[0].row,preSelections[0].col,preSelections[0].rowCount,preSelections[0].colCount);
         }
+        this.coeSheet.resumeEvent();
+        this.coeSheet.resumePaint();
     },
     showCusData:function (node) {
         let selected = node?node:projectObj.project.mainTree.selected;