Browse Source

Merge branch 'master' of http://192.168.1.41:3000/SmartCost/YangHuCost

TonyKang 5 years ago
parent
commit
b2a9ebb501

+ 1 - 0
Dockerfile

@@ -24,6 +24,7 @@ RUN babel src -d dist
 
 FROM base-alpine:latest
 
+
 COPY . /home/YangHuCost
 
 WORKDIR /home/YangHuCost

File diff suppressed because it is too large
+ 2 - 2
config/config.js


+ 15 - 2
modules/glj/controllers/glj_controller.js

@@ -853,8 +853,20 @@ class GLJController extends BaseController {
         return await getGLJListByProjectID(projectId)
     }
 
+    async getFreightAndOriginalData(projectId,unitPriceFileId){
+      return await getFreightAndOriginalData(projectId,unitPriceFileId);
+    }
+
 }
 
+async function getFreightAndOriginalData(projectId,unitPriceFileId){
+  if(!unitPriceFileId)  unitPriceFileId = await ProjectModel.getUnitPriceFileId(projectId);
+  let originalList = await original_calc_model.find({"unit_price_file_id":unitPriceFileId}).lean();
+  let freightList = await freight_calc_model .find({"unit_price_file_id":unitPriceFileId}).lean();
+  return [originalList,freightList]
+}
+
+
 /**
  * 取项目工料机列表
  * @param projectId
@@ -886,8 +898,9 @@ async function getGLJListByProjectID(projectId){
                 usedUnitPriceInfo.id = tmp.property.unitPriceFile.id;
             }
         }
-        responseData.data.originalList = await original_calc_model.find({"unit_price_file_id":unitPriceFileId}).lean();
-        responseData.data.freightList = await freight_calc_model .find({"unit_price_file_id":unitPriceFileId}).lean();
+        let [originalList,freightList] = await getFreightAndOriginalData(projectId,unitPriceFileId);
+        responseData.data.originalList = originalList;
+        responseData.data.freightList = freightList;
         responseData.data.com_electrovalence = await com_electrovalence_model.findOne({"unit_price_file_id":unitPriceFileId}).lean();
         //if(!responseData.data.com_electrovalence) responseData.data.com_electrovalence = {};
         // 先获取对应标段的项目工料机数据

+ 8 - 4
modules/main/controllers/ration_controller.js

@@ -42,10 +42,14 @@ let controller = {
         data = JSON.parse(data);
         console.log(data);
         let result = await ration_facade.updateMaterialRation(data,req.session.sessionCompilation);
-        //合并取项目工料机数据的情求,用于刷新项目工料机数据,当有添加、替换项目工料机的情况,才需要刷新
-       /* if(result.ration_gljs && result.ration_gljs.length > 0){
-            result.projectGLJDatas =  await getProjectGLJData(data.projectID);
-        }*/
+        //取运费和原价数据
+       if(result.projectGLJList){
+          let gljController = new GLJController();
+          let [originalList,freightList] = await gljController.getFreightAndOriginalData(data.projectID);
+          result.originalList = originalList;
+          result.freightList = freightList;
+            
+       }
         return result
     },
     addMultiRation: async function (req) {

+ 15 - 2
modules/main/facade/project_facade.js

@@ -359,15 +359,18 @@ function getReportData(nameList,items,prjTypeNames,compilationScopes,decimal) {
             billsTtlAmt:bills.quantity,
             billsPrices:[],
             billsUnitPrices:[],
+            rationCommons:[],
             billsAmounts:[],
             '技术经济指标':[],
             billsLevel:level,
             billsMemos:bills.remark
         };
         let total = 0;
+        let rationTotal =0;
         for(let n of nameList){
             let  p = 0;//金额
             let up =0;//单价
+            let ra = 0;//定额建安费
             if(bills.unitPrices[n]) up = scMathUtil.roundForObj(bills.unitPrices[n],decimal.bills.unitPrice);
             tem.billsUnitPrices.push(up);
             if(bills.prices[n]){
@@ -375,6 +378,11 @@ function getReportData(nameList,items,prjTypeNames,compilationScopes,decimal) {
                 total = scMathUtil.roundForObj(p+total,decimal.process);
             }
             tem.billsPrices.push(p);
+            if(bills.rationCommons[n]){
+               ra = scMathUtil.roundForObj(bills.rationCommons[n],decimal.bills.totalPrice);
+               total = scMathUtil.roundForObj(ra+rationTotal,decimal.process);
+            }
+            tem.rationCommons.push(ra); 
             if(bills.quantityMap[n] && parseFloat(bills.quantityMap[n]) !== 0){
                 tem.billsAmounts.push(bills.quantityMap[n]);
                 tem['技术经济指标'].push(scMathUtil.roundForObj(p/bills.quantityMap[n],2));
@@ -384,6 +392,7 @@ function getReportData(nameList,items,prjTypeNames,compilationScopes,decimal) {
             }
         }
         tem.billsTtlPrice = scMathUtil.roundForObj(total,decimal.bills.totalPrice);
+        tem.rationTotal =  scMathUtil.roundForObj(rationTotal,decimal.bills.totalPrice);//定额总建安费
         tem['技术经济综合指标'] = (tem.billsTtlAmt && parseFloat(tem.billsTtlAmt) !== 0)?scMathUtil.roundForObj(tem.billsTtlPrice/tem.billsTtlAmt,2):scMathUtil.roundForObj(tem.billsTtlPrice,2);
         if(bills.flag == fixedFlag.TOTAL_COST) totalItem = tem;
         return tem
@@ -415,6 +424,7 @@ async function mergeItem(a,b,decimal,project) {
     a.quantity = scMathUtil.roundForObj(a.quantity+b.quantity,decimal.process);
     for(let name in b.prices){
         a.prices[name] = b.prices[name];
+        a.rationCommons[name] = b.rationCommons[name];
         a.quantityMap[name] = b.quantityMap[name];
         a.unitPrices[name]=b.unitPrices[name];
     }
@@ -516,11 +526,14 @@ async function getBillsByProjectID(projectID){
        let prices = {};
        let quantityMap={};
        let unitPrices ={};
+       let rationCommons={};
+       let rationFee = _.find(b._doc.fees,{"fieldName":"rationCommon"});
        if(commonFee&&commonFee.totalFee) prices[projectName] =  commonFee.totalFee;
-       if (commonFee&&commonFee.unitFee) unitPrices[projectName] = commonFee.unitFee;
+       if(commonFee&&commonFee.unitFee) unitPrices[projectName] = commonFee.unitFee;
+       if(rationFee&&rationFee.totalFee) rationCommons[projectName] = rationFee.totalFee;
        quantityMap[projectName] = b.quantity;
        let flagIndex = _.find(b._doc.flags,{'fieldName':'fixed'});
-       let doc = {ID:b.ID,name:b.name,code:b.code,unit:b.unit,projectID:b.projectID, ParentID:b.ParentID,NextSiblingID:b.NextSiblingID,unitPrices:unitPrices,quantity:b.quantity,prices:prices,quantityMap:quantityMap,flag:flagIndex?flagIndex.flag:-99,remark:b.remark};//选取有用字段
+       let doc = {ID:b.ID,name:b.name,code:b.code,unit:b.unit,projectID:b.projectID, ParentID:b.ParentID,NextSiblingID:b.NextSiblingID,unitPrices:unitPrices,quantity:b.quantity,prices:prices,rationCommons:rationCommons,quantityMap:quantityMap,flag:flagIndex?flagIndex.flag:-99,remark:b.remark};//选取有用字段
        if(b.ParentID == -1) roots.push(doc);
        parentMap[b.ParentID]?parentMap[b.ParentID].push(doc):parentMap[b.ParentID]=[doc];
    }//设置子节点

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

@@ -73,9 +73,11 @@ class UserModel extends BaseModel {
                 // 请求接口
                 Request.post(postData, function (err, postResponse, body) {
                     if (err) {
-                        console.log('111');
+                        console.log(err);
                         reject('请求错误');
                     }
+                    if(!postResponse) reject('请求错误');
+
                     if (postResponse.statusCode !== 200) {
                         reject('通行证验证失败!');
                     }

+ 4 - 1
package.json

@@ -64,6 +64,9 @@
     "start": "C:\\Users\\mai\\AppData\\Roaming\\npm\\babel-node.cmd server.js",
     "server": "node --max-old-space-size=2048 server.js",
     "socket": "node socket.js",
-    "import": "node --max-old-space-size=2048 importserver.js"
+    "import": "node --max-old-space-size=2048 importserver.js",
+    "dev_server":"SET NODE_ENV=qa&& babel-node server.js",
+    "dev_socket":"SET NODE_ENV=qa&& babel-node socket.js",
+    "dev_import":"SET NODE_ENV=qa&& babel-node importserver.js"
   }
 }

+ 4 - 4
public/web/sheet/sheet_common.js

@@ -147,9 +147,6 @@ var sheetCommonObj = {
         for (var row = 0; row < data.length; row++) {
             //var cell = sheet.getCell(row, col, GC.Spread.Sheets.SheetArea.viewport);
             this.showRowData(sheet,setting,row,data,distTypeTree);
-            if(setting.getStyle && setting.getStyle(data[row])){
-                sheet.setStyle(row, -1, setting.getStyle(data[row]));
-            }
         }
         if(setting.emptyRowHeader){
             let rowCount = sheet.getRowCount();
@@ -218,7 +215,7 @@ var sheetCommonObj = {
         if(setting.autoFit==true){//设置自动行高
             if(setting.fitRow && setting.fitRow.length > 0){//如果有设置特定的某些列才需要自动行高就按设置的来,没有设置就默认所有列
                 for(let dataCode of setting.fitRow){
-                  let col =  _.findIndex(setting.header,{dataCode:dataCode})
+                  let col =  _.findIndex(setting.header,{dataCode:dataCode});
                   sheet.getCell(row,col).wordWrap(true);
                 }
             }else {
@@ -227,6 +224,9 @@ var sheetCommonObj = {
 
             sheet.autoFitRow(row);
         }
+        if(setting.getStyle && setting.getStyle(data[row],row,sheet.getActiveRowIndex())){
+            sheet.setStyle(row, -1, setting.getStyle(data[row]));
+        }
     },
     checkData : function(col,setting, value) {
         let result = true;

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

@@ -96,7 +96,7 @@
                         </div>-->
                     </span>
                    <!-- <a href="javascript:void(0)" class="btn btn-light btn-sm" id="insertRation" data-toggle="tooltip" data-placement="bottom" data-original-title="插入定额"><i class="fa fa-sign-in" aria-hidden="true"></i></a>-->
-                    <!--2018-11-15 隐藏删除按钮   <a href="javascript:void(0)" class="btn btn-light btn-sm" id="delete" data-toggle="tooltip" data-placement="bottom" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>-->
+                    <a href="javascript:void(0)" class="btn btn-light btn-sm" id="delete" data-toggle="tooltip" data-placement="bottom" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>
                     <a href="javascript:void(0)" class="btn btn-light btn-sm" id="upLevel" data-toggle="tooltip" data-placement="bottom" data-original-title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
                     <a href="javascript:void(0)"  class="btn btn-light btn-sm" id="downLevel" data-toggle="tooltip" data-placement="bottom" data-original-title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
                       <a href="javascript:void(0)" class="btn btn-light btn-sm" id="upMove" data-toggle="tooltip" data-placement="bottom" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>

+ 10 - 1
web/building_saas/main/js/models/project_glj.js

@@ -811,12 +811,20 @@ ProjectGLJ.prototype.changeAssistProductionFeeRate = async function (newFeeRate)
     }
 };
 
+ProjectGLJ.prototype.loadFreightAndOriginalData = function(originalList,freightList){
+  if(freightList) this.datas.freightList = freightList;
+  if(originalList) this.datas.originalList = originalList;
+};
+
 ProjectGLJ.prototype.updateMaterialRation = async function (datas){
     try {
         let lists = datas.type == "freight"?this.datas.freightList:this.datas.originalList;
         $.bootstrapLoading.start();
         let result =  await ajaxPost('/ration/updateMaterialRation',datas);
-        if(datas.actionType=="add" && result.projectGLJList) this.loadNewProjectGLJToCaches(result.projectGLJList,true);//这一步已经更新了运费和原价数据
+        if(datas.actionType=="add" && result.projectGLJList){
+          this.loadNewProjectGLJToCaches(result.projectGLJList,true);
+          this.loadFreightAndOriginalData(result.originalList,result.freightList);  //这一步已经更新了运费和原价数据
+        } 
         if(datas.actionType == "delete"){
            let parent = _.find(lists,{ID:datas.parentID}) ;
            if(parent){
@@ -830,6 +838,7 @@ ProjectGLJ.prototype.updateMaterialRation = async function (datas){
             if(ration){
                 if(datas.field == "code" && result.projectGLJList){
                     this.loadNewProjectGLJToCaches(result.projectGLJList,true);
+                    this.loadFreightAndOriginalData(result.originalList,result.freightList); 
                 }else {
                     ration[datas.field] = datas.value;
                     if(datas.ext){

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

@@ -432,9 +432,9 @@ var Ration = {
                 }
                 project.projectGLJ.calcQuantity();
                 mbzm_obj.nodeChanged = true;//子目模板关联刷新
-                gljOprObj.showDataIfRationSelect(projectObj.project.mainTree.selected,"-111111111");//这里第二个参数是为了使改前和改后selectedID不一样,删除了的话下方的定额工料机不会刷新
                 project.calcProgram.calcNodesAndSave(refershNodes);
                 projectObj.mainController.refreshTreeNode(refershNodes, true);
+                gljOprObj.showDataIfRationSelect(projectObj.project.mainTree.selected,"-111111111");//这里第二个参数是为了使改前和改后selectedID不一样,删除了的话下方的定额工料机不会刷新
                 $.bootstrapLoading.end();
 
                 if(data.length < nodeInfo.length && nodeInfo[data.length].newCode!=null){//说明有部分定额编号没找到记录

+ 4 - 0
web/building_saas/main/js/views/electrovalence_view.js

@@ -184,6 +184,10 @@ let electrovalenceObj = {
                 $.bootstrapLoading.start();
                 let result =  await ajaxPost('/glj/insertElectrovalence',tem);
                 //插入项目工料机列表
+                if(type == "add" && (!result.projetcGLJData || result.projetcGLJData.length == 0)){
+                   alert("没有找到该工料机,请检查工料机库");
+                   return  this.showDatas(this.datas);
+                }
                 let newProjectPGJ = projectObj.project.projectGLJ.loadNewProjectGLJToCache(result.projetcGLJData);
                 //加入综合电价显示列表缓存
                 tem.GLJID = result.projetcGLJData.glj_id;

+ 6 - 0
web/building_saas/main/js/views/glj_col.js

@@ -49,6 +49,12 @@ let gljCol = {
         view: {
             lockColumns: ["code","name","specs","unit","short_name","quantity","is_add"]
         },
+        getStyle:function (data,row,activeRow) {
+            if(row == activeRow){//选中黄色显示
+                return {backColor:"#FFFACD"};
+            }
+            return null;
+        },
         frozenCols:4
     },
     mixRatio_Setting:{

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

@@ -309,7 +309,7 @@ var gljOprObj = {
         let me = gljOprObj;
         me.initSelection(args.newSelections.length > 0 ? {row: args.newSelections[0].row} : {row: 0});
     },
-    getSelStyle: function (selected,settingStyle) {
+    getSelStyle: function (selected,settingStyle,rcolor) {
         let style = new GC.Spread.Sheets.Style();
         if(settingStyle){
             for(let key in settingStyle){
@@ -322,7 +322,7 @@ var gljOprObj = {
         style.borderBottom = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
         let colorOpts = optionsOprObj.getOption(optionsOprObj.optionsTypes.COLOROPTS);
         let selectedColor = colorOpts.SELECTED.backColor,
-            recColor = 'White';
+            recColor = rcolor?rcolor:'White';
         style.backColor = selected ? selectedColor : recColor;
         return style;
     },

+ 12 - 3
web/building_saas/main/js/views/project_glj_view.js

@@ -309,10 +309,20 @@ projectGljObject={
         let me = projectGljObject;
         let newSel = args.newSelections[0];
         let oldSel = args.oldSelections?args.oldSelections[0]:{};
+        me.projectGljSheet.suspendPaint();
+        me.projectGljSheet.suspendEvent();
         if(newSel.row != oldSel.row){
+            let style = gljOprObj.getSelStyle(true,{});
+            me.projectGljSheet.setStyle(newSel.row, -1, style);
+            let orow = oldSel.row==''||oldSel.row==-1?0:oldSel.row;
+            let tstyle = gljOprObj.getSelStyle(false,{},me.projectGljSheetData[orow].bgColour);
+            me.projectGljSheet.setStyle(orow, -1, tstyle);
             me.projectGljRowChang();
+        }else{
+          me.projectGljSheet.repaint();
         }
-        me.projectGljSheet.repaint();
+        me.projectGljSheet.resumeEvent();
+        me.projectGljSheet.resumePaint();
     },
     projectGljRowChang:function(row){
         let me = projectGljObject;
@@ -748,7 +758,6 @@ projectGljObject={
             }
         }
         if(gljUtil.isConcreteType(glj.type)) data.bgColour = "#E0E0E0";//混凝土、砂浆、配合比的底色显示为 灰色#E0E0E0,灰色底色提醒用户不可修改。
-
         return data;
     },
     refreshProjectGljRow:function (row) {
@@ -1077,7 +1086,6 @@ projectGljObject={
     changeFileCallback:function(){
         projectGljObject.unitPriceFileInit();
         projectGljObject.refreshDataSheet();
-        gljOprObj.refreshView();
         projectGljObject.initVvTax();
         materialCalcObj.showDatas();
         projectObj.project.calcProgram.calcAllNodesAndSave(calcAllType.catAll,function () {
@@ -1093,6 +1101,7 @@ projectGljObject={
                 socketObject.roomInfo.unitFile = socketObject.getUnitFileRoomID();
             }
         });
+        gljOprObj.refreshView();
 
     },
     calcPartASupplyFeeByProjectGLJs: function (projectGLJsArr) {

+ 3 - 3
web/building_saas/main/js/views/project_view.js

@@ -1502,9 +1502,6 @@ var projectObj = {
                     name: '删除',
                     icon: 'fa-remove',
                     disabled: function () {
-                        if (projectReadOnly) {
-                            return true;
-                        }
                         return !ifCanDelete();
                     },
                     callback: function () {
@@ -2723,6 +2720,9 @@ function isSingleSelect() {//是否选中造价书中的单行
     return false;
 }
 function ifCanDelete() {
+    if (projectReadOnly) {
+      return false;
+    }
     let selections = projectObj.mainSpread.getActiveSheet().getSelections();
     let tree = projectObj.project.mainTree;
     let selected = projectObj.project.mainTree.selected;