瀏覽代碼

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

zhongzewei 6 年之前
父節點
當前提交
1b19d80021

+ 0 - 1
modules/glj/models/unit_price_model.js

@@ -146,7 +146,6 @@ class UnitPriceModel extends BaseModel {
             }
         }
         return last;
-
      }
     /**
      * 新增记录

+ 1 - 1
modules/main/facade/ration_facade.js

@@ -491,7 +491,7 @@ async function CalculateQuantity (ration,billsItemID,projectID) {
     let decimalObject =await decimal_facade.getProjectDecimal(projectID,project);
     let quantity_decimal = (decimalObject&&decimalObject.ration&&decimalObject.ration.quantity)?decimalObject.ration.quantity:3;
     let pbill = await bill_model.model.findOne({projectID:projectID,ID:billsItemID});
-    let  t_unit = ration.unit.replace(/^\d+/,"");
+    let  t_unit = ration.unit?ration.unit.replace(/^\d+/,""):"";
     if(t_unit!=pbill.unit){//如果定额工程量的单位去除前面的数字后不等于清单单位,定额工程量保持不变
         return ;
     }

+ 1 - 1
modules/ration_glj/routes/ration_glj_route.js

@@ -13,7 +13,7 @@ module.exports = function (app) {
     rgRouter.post('/replaceGLJ',rgController.replaceGLJ);
     rgRouter.post('/mReplaceGLJ',rgController.mReplaceGLJ);
     rgRouter.post('/updateRationGLJByEdit',rgController.updateRationGLJByEdit);
-    rgRouter.post('/getGLJClass', rgController.getGLJClass);
+    rgRouter.post('/getGLJClass/:engineerID', rgController.getGLJClass);
     app.use('/rationGlj',rgRouter);
 }
 

+ 20 - 2
modules/reports/rpt_component/helper/jpc_helper_common.js

@@ -1,4 +1,5 @@
 let JV = require('../jpc_value_define');
+let stringUtil = require('../../../../public/stringUtil');
 
 let JpcCommonHelper = {
     commonConstant: {},
@@ -134,7 +135,15 @@ let JpcCommonHelper = {
     },
     getStringLinesInArea: function(area, strVal, pdfDoc) {
         let areaWidth = area[JV.PROP_RIGHT] - area[JV.PROP_LEFT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT] - 2;
-        let txtWidth = pdfDoc.widthOfString(strVal);
+        // let re = /[\u4E00-\u9FA5]/g;
+        let re = /[^\x00-\xff]/ig; //普通ASCII以外的字符
+        let cStr = strVal.match(re);
+        let chnAmt = (cStr)?cStr.length:0;
+        let chnW = pdfDoc.widthOfString('一'), otherW = pdfDoc.widthOfString('_');
+        //备注: 因后台的pdfDoc判断字符串长度与前端的不一样,需要做些调整,不一次性地判断字符串长度。
+        //      分2种字符:中文与非中文,按照各种字符的数量分别乘以相关一个字符的宽度再累计。
+        // let txtWidth = pdfDoc.widthOfString(strVal);
+        let txtWidth = chnAmt * chnW + (strVal.length - chnAmt) * otherW;
         let rst = parseInt(txtWidth / areaWidth);
         if (txtWidth % areaWidth > 0) {
             rst++;
@@ -145,10 +154,19 @@ let JpcCommonHelper = {
     },
     splitString: function (area, strVal, pdfDoc) {
         let rst = [];
+        // let re = /[\u4E00-\u9FA5]/g;
+        let re = /[^\x00-\xff]/ig; //普通ASCII以外的字符
+        let chnW = pdfDoc.widthOfString('一'), otherW = pdfDoc.widthOfString('_');
         let areaWidth = area[JV.PROP_RIGHT] - area[JV.PROP_LEFT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT] - 2;
         let preSIdx = 0, txtWidth = 0;
+
         for (let sIdx = 1; sIdx <= strVal.length; sIdx++) {
-            txtWidth = pdfDoc.widthOfString(strVal.substr(preSIdx, sIdx - preSIdx));
+            let tmpStr = strVal.substr(preSIdx, sIdx - preSIdx);
+            let cStr = tmpStr.match(re);
+            let chnAmt = (cStr)?cStr.length:0;
+            // let chnAmt = tmpStr.match(re).length;
+            // txtWidth = pdfDoc.widthOfString(strVal.substr(preSIdx, sIdx - preSIdx));
+            txtWidth = chnAmt * chnW + (tmpStr.length - chnAmt) * otherW;
             if (txtWidth > areaWidth) {
                 rst.push(strVal.substr(preSIdx, sIdx - preSIdx - 1));
                 preSIdx = sIdx - 1;

+ 1 - 0
modules/reports/rpt_component/jpc_flow_tab.js

@@ -324,6 +324,7 @@ JpcFlowTabSrv.prototype.createNew = function(){
                         let value = JpcFieldHelper.getValue(data_field, theRecIdx);
                         let area = JpcAreaHelper.outputArea(tab_field[JV.PROP_AREA], band, 1, 1, 0, 1, 0, 1, 0, false, false);
                         if (value !== null && value !== undefined) {
+                            value = value.replace('\t', '');
                             value = value.replace(reg1, '|').replace(reg2, '|').replace(reg3, '|').replace(reg4, '|');
                         } else {
                             value = '';

+ 4 - 6
public/web/tree_sheet/tree_sheet_helper.js

@@ -164,21 +164,19 @@ var TREE_SHEET_HELPER = {
                         sheet.setTag(iRow, iCol,tag);
                     }*/
                     if(colSetting.data.field=="code"){
-                        let tag ="";
+                        let tag =null;
                         if(node.sourceType == ModuleNames.ration){//定额的时候换算子目
                             tag = node.data.adjustState?node.data.adjustState:'';
                         }/*else if(node.sourceType == ModuleNames.bills &&projectObj.ifItemCharHiden(setting)){//清单、并且项目特征列隐藏的时候悬浮提示  这里改成在 计量单位那里提示
                             tag = node.data.itemCharacterText?node.data.itemCharacterText:'';
                         }*/
-                        sheet.setTag(iRow, iCol,tag);
+                        if(tag!=null&&tag!="") sheet.setTag(iRow, iCol,tag);
                     }
                     /*if(colSetting.data.field=="name"){ 2018-08-06 改成在编号列悬浮提示
                         let tag = node.data.itemCharacterText?node.data.itemCharacterText:'';
                         sheet.setTag(iRow, iCol,tag);
                     }*/
-
                 }
-
                 if(colSetting.visible == false) return;//隐藏列不做其它操作
                 var cell = sheet.getCell(iRow, iCol, GC.Spread.Sheets.SheetArea.viewport);
                 if (colSetting.data.getText && Object.prototype.toString.apply(colSetting.data.getText) === "[object Function]") {
@@ -211,7 +209,7 @@ var TREE_SHEET_HELPER = {
                 }
             });
             if(setting.setAutoFitRow){
-                setting.setAutoFitRow(sheet,node)
+                setting.setAutoFitRow(sheet,node)//自动行高功能比较费时,400行,启用和不启用相差2秒左右
             }
             if (recursive) {
                 TREE_SHEET_HELPER.refreshTreeNodeData(setting, sheet, node.children, recursive);
@@ -618,7 +616,7 @@ var TREE_SHEET_HELPER = {
                     let left =  setting.pos.x + hitinfo.cellRect.x;
                     $(this._toolTipElement).css("top", top).css("left", left);*/
                     //显示在下方,三角形指
-                    let top = setting.pos.y  + hitinfo.cellRect.y+26;
+                    let top = setting.pos.y  +hitinfo.cellRect.y+ hitinfo.cellRect.height+10;
                     let left =  setting.pos.x + hitinfo.cellRect.x;
                     $(this._toolTipElement).css("top", top).css("left", left);
 

+ 3 - 2
test/unit/reports/test_tpl_09_1.js

@@ -26,7 +26,8 @@ let fsUtil = require("../../../public/fsUtil");
 
 let demoPrjId = - 1;
 // let demoRptId = 226;
-let demoRptId = 453; //copied
+// let demoRptId = 453; //copied
+let demoRptId = 612; //copied
 let pagesize = "A4";
 
 // let userId_Leng = "59cdf14a0034a1000ba52b97"; //小冷User Id 换成_id了 QQ号
@@ -62,7 +63,7 @@ test('测试 - 测试模板啦: ', function (t) {
         rptTplDataFacade.prepareProjectData(userId_Dft, demoPrjId, filter, function (err, msg, rawDataObj) {
             if (!err) {
                 try {
-                    fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/ConstructionCost/tmp/rptTplRawDataObject_建筑09-1表.jsp");
+                    // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/ConstructionCost/tmp/rptTplRawDataObject_建筑09-1表.jsp");
                     let tplData = rptDataUtil.assembleData(rawDataObj);
                     // fsUtil.writeObjToFile(rawDataObj, "D:/GitHome/ConstructionCost/tmp/rptTplRawDataAfterCacl_建筑09-1表.jsp");
                     // fsUtil.writeObjToFile(tplData, "D:/GitHome/ConstructionCost/tmp/rptTplAssembledData_建筑09-1表.jsp");

+ 6 - 2
web/building_saas/main/js/controllers/block_controller.js

@@ -242,7 +242,7 @@ let BlockController = {
             for(let d of blockData.datas){
                 d.billsItemID = parentID;
                 let billsQuantity = scMathUtil.roundForObj(parent.data.quantity,getDecimal("quantity",parent));
-                this.calcRationQuantityAndContain(billsQuantity,d);
+                this.calcRationQuantityAndContain(billsQuantity,d,parent.data.unit);
                 //如果粘贴位置不属于分部分项工程,或者不是安装工程,则把安装增加费内容置空
                 if(!Bills.isFBFX(parent)|| !project.isInstall()){
                     d.ration_installations = [];
@@ -552,10 +552,14 @@ let BlockController = {
             firstSerialNo += 1;
         }
     },
-    calcRationQuantityAndContain : function (billsQuantity,ration) {//计算定额工程量和含量
+    calcRationQuantityAndContain : function (billsQuantity,ration,billsUnit) {//计算定额工程量和含量
         let EXPString = ration.quantityEXP+"";
         if(EXPString.indexOf("QDL") != -1){
             if(EXPString=="QDL"){//定额的工程量是直接通过清单量填进来的;
+                let  t_unit = ration.unit?ration.unit.replace(/^\d+/,""):"";
+                if(t_unit!=billsUnit){//如果定额的单位去除前面的数字后不等于清单单位,定额工程量保持不变
+                    return ;
+                }
                 let times = parseInt(ration.unit);
                 if(isNaN(times)){
                     times = 1;

+ 2 - 1
web/building_saas/main/js/views/glj_view_contextMenu.js

@@ -398,7 +398,8 @@ function getGLJData(actionType) {
 }
 
 function showGLJClassTree(record) {
-    CommonAjax.post('/rationGlj/getGLJClass',record, function (data) {
+    let engineerID = projectInfoObj.projectInfo.property.engineering_id;
+    CommonAjax.post('/rationGlj/getGLJClass/'+engineerID,record, function (data) {
         if(data.exist==true){
             alert("当前人材机已存在。");
         }else {