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
45d8210331
33 muutettua tiedostoa jossa 284 lisäystä ja 138 poistoa
  1. 2 0
      .gitignore
  2. 1 1
      modules/glj/models/glj_list_model.js
  3. 6 8
      modules/glj/models/unit_price_model.js
  4. 1 1
      modules/main/controllers/ration_controller.js
  5. 4 2
      modules/reports/rpt_component/jpc_flow_tab.js
  6. BIN
      modules/reports/util/pdf_base_files/simhei.ttf
  7. BIN
      modules/reports/util/pdf_base_files/simhei_bold.ttf
  8. BIN
      modules/reports/util/pdf_base_files/simhei_bold_italic.ttf
  9. BIN
      modules/reports/util/pdf_base_files/simhei_italic.ttf
  10. BIN
      modules/reports/util/pdf_base_files/simkai.ttf
  11. BIN
      modules/reports/util/pdf_base_files/simkai_bold.ttf
  12. BIN
      modules/reports/util/pdf_base_files/simkai_bold_italic.ttf
  13. BIN
      modules/reports/util/pdf_base_files/simkai_italic.ttf
  14. BIN
      modules/reports/util/pdf_base_files/simsun_1.ttf
  15. BIN
      modules/reports/util/pdf_base_files/simsun_1_bold.ttf
  16. BIN
      modules/reports/util/pdf_base_files/simsun_1_bold_italic.ttf
  17. BIN
      modules/reports/util/pdf_base_files/simsun_1_italic.ttf
  18. 16 7
      modules/reports/util/rpt_font_util.js
  19. 10 12
      modules/reports/util/rpt_pdf_util.js
  20. 2 1
      public/web/socket/connection.js
  21. 1 1
      public/web/tree_sheet/tree_sheet_helper.js
  22. 17 1
      web/building_saas/css/main.css
  23. 1 1
      web/building_saas/fee_rates/fee_rate.html
  24. 27 2
      web/building_saas/main/js/models/calc_base.js
  25. 27 4
      web/building_saas/main/js/models/calc_program.js
  26. 3 2
      web/building_saas/main/js/models/project_glj.js
  27. 50 9
      web/building_saas/main/js/models/ration.js
  28. 1 3
      web/building_saas/main/js/models/ration_glj.js
  29. 4 9
      web/building_saas/main/js/views/fee_rate_view.js
  30. 10 10
      web/building_saas/main/js/views/glj_col.js
  31. 86 53
      web/building_saas/main/js/views/glj_view.js
  32. 2 2
      web/building_saas/main/js/views/project_glj_view.js
  33. 13 9
      web/building_saas/main/js/views/project_view.js

+ 2 - 0
.gitignore

@@ -7,3 +7,5 @@ tmp/*.pdf
 tmp/*.jsp
 test/unit/logs
 *.log
+modules/reports/util/pdf_base_files/*.ttf
+modules/reports/util/pdf_base_files/*.ttc

+ 1 - 1
modules/glj/models/glj_list_model.js

@@ -770,7 +770,7 @@ class GLJListModel extends BaseModel {
         // 整理数据
         let unitPriceData = {};
         for(let tmp of unitPriceList) {
-            let u_index = this.getIndex(tmp,['code','name','specs','unit','type'])
+            let u_index = this.getIndex(tmp,['code','name','specs','unit','type']);
             unitPriceData[u_index] = tmp;
         }
         return [gljData,mixRatioData,unitPriceData];

+ 6 - 8
modules/glj/models/unit_price_model.js

@@ -178,20 +178,18 @@ class UnitPriceModel extends BaseModel {
     }
 
     isPropertyInclude(data,pops,obj){
-        let condition={};
+        let condition={},me = this;
         if (data.length <= 0) {
             return null;
         }
         if(pops instanceof  Array){
-            for(let p of pops){
-                if(obj[p]!==undefined && obj[p]!==undefined!=null){
-                    condition[p]=obj[p]
-                }
-            }
+            return _.find(data,function (d) {
+                return me.getIndex(d,pops) == me.getIndex(obj,pops)
+            });
         }else {
-            condition[pops]=obj[pops]
+            condition[pops]=obj[pops];
+            return _.find(data,condition);
         }
-        return _.find(data,condition);
     }
     /**
      * 更新市场单价

+ 1 - 1
modules/main/controllers/ration_controller.js

@@ -92,7 +92,7 @@ async function addMultiRation(req,res) {
 async function replaceRations(req,res) {
     let result={
         error:0
-    }
+    };
     try {
         let data = req.body.data;
         data = JSON.parse(data);

+ 4 - 2
modules/reports/rpt_component/jpc_flow_tab.js

@@ -10,6 +10,7 @@ let JpcTextHelper = require('./helper/jpc_helper_text');
 let JpcCommonOutputHelper = require('./helper/jpc_helper_common_output');
 let JpcAreaHelper = require('./helper/jpc_helper_area');
 let PDFKit = require('pdfkit');
+let fontUtil = require('../util/rpt_font_util');
 
 let JpcFlowTabSrv = function(){};
 JpcFlowTabSrv.prototype.createNew = function(){
@@ -316,10 +317,11 @@ JpcFlowTabSrv.prototype.createNew = function(){
                         if (values.length > rst) rst = values.length;
                         let font = private_get_font(tab_field[JV.PROP_FONT]);
                         if (font) {
-                            doc.font(__dirname.slice(0, __dirname.length - 14) + '/util/pdf_base_files/simsun_1.ttf');
+                            let fontFile = __dirname.slice(0, __dirname.length - 14) + '/util/pdf_base_files/' + fontUtil.getActualFont(font[JV.FONT_PROPS[0]], (font[JV.FONT_PROPS[3]] === 'T'), (font[JV.FONT_PROPS[4]] === 'T')) + '.ttf';
+                            doc.font(fontFile);
                             doc.fontSize(parseInt(font[JV.FONT_PROPS[JV.FONT_PROP_IDX_HEIGHT]]));
                         } else {
-                            doc.font(__dirname.slice(0, __dirname.length - 14) + '/util/pdf_base_files/simsun_1.ttf');
+                            doc.font(__dirname.slice(0, __dirname.length - 14) + '/util/pdf_base_files/Smart.ttf');
                             doc.fontSize(12);
                         }
                         let hasSplitStr = false, splitStrArr = [];

BIN
modules/reports/util/pdf_base_files/simhei.ttf


BIN
modules/reports/util/pdf_base_files/simhei_bold.ttf


BIN
modules/reports/util/pdf_base_files/simhei_bold_italic.ttf


BIN
modules/reports/util/pdf_base_files/simhei_italic.ttf


BIN
modules/reports/util/pdf_base_files/simkai.ttf


BIN
modules/reports/util/pdf_base_files/simkai_bold.ttf


BIN
modules/reports/util/pdf_base_files/simkai_bold_italic.ttf


BIN
modules/reports/util/pdf_base_files/simkai_italic.ttf


BIN
modules/reports/util/pdf_base_files/simsun_1.ttf


BIN
modules/reports/util/pdf_base_files/simsun_1_bold.ttf


BIN
modules/reports/util/pdf_base_files/simsun_1_bold_italic.ttf


BIN
modules/reports/util/pdf_base_files/simsun_1_italic.ttf


+ 16 - 7
modules/reports/util/rpt_font_util.js

@@ -3,20 +3,29 @@
  */
 
 let fontMapObj = {
-    "宋体": "simsun_1"
+    "宋体": "Smart"
     ,"楷体": "simkai"
     ,"黑体": "simhei"
-    // ,"Arial": "arial"
+    // ,"华文中宋": "STZHONGS"
+    // ,"华文宋体": "STSONG"
+    //"宋体": "Smart"
 };
-// 目前不支持下划线
+//下划线在option中支持
+//另注意:
 
 module.exports = {
     getActualFont: getActualFont
 }
 
 function getActualFont(mapName, isBold, isItalic) {
-    let rst = "simsun_1";
-    if (fontMapObj[mapName]) rst = fontMapObj[mapName];
-    rst = rst + (isBold?"_bold":"") + (isItalic?"_italic":"");
-    return rst;
+    let rst = ["Smart"];
+    if (fontMapObj[mapName]) rst[0] = fontMapObj[mapName];
+    // rst = rst + (isBold?"_bold":"") + (isItalic?"_italic":"");
+    if (isBold) {
+        rst.push("_bold");
+    }
+    if (isItalic) {
+        rst.push("_italic");
+    }
+    return rst.join("");
 }

+ 10 - 12
modules/reports/util/rpt_pdf_util.js

@@ -147,11 +147,10 @@ function export_pdf_file (pageData, paperSize, fName, callback) {
         let fontFile = __dirname + '/pdf_base_files/simkai.ttf';
         if (font) {
             dftFontHeight = 1 * font[JV.FONT_PROPS[1]];
-            let dftFontBold = font[JV.FONT_PROPS[3]];
-            let dftFontItalic = font[JV.FONT_PROPS[4]];
-            fontFile = __dirname + '/pdf_base_files/' + fontUtil.getActualFont(font[JV.FONT_PROPS[0]], (dftFontBold === 'T'), (dftFontItalic === 'T')) + '.ttf';
+            fontFile = __dirname + '/pdf_base_files/' + fontUtil.getActualFont(font[JV.FONT_PROPS[0]], (font[JV.FONT_PROPS[3]] === 'T'), (font[JV.FONT_PROPS[4]] === 'T')) + '.ttf';
             doc.fontSize(dftFontHeight);
         }
+        doc.font(fontFile);
         let options={};
         if (control) {
             private_setupAreaH(area, control.Horizon, font.FontAngle, dftFontHeight, output,options);
@@ -164,23 +163,22 @@ function export_pdf_file (pageData, paperSize, fName, callback) {
         if (parseInt(font.FontAngle) !== 0) {
             w = area[JV.IDX_BOTTOM] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM] - area[JV.IDX_TOP] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP];
         }
-        doc.save();
+        // doc.save();
         //doc.translate(output[0], output[1]);
         if (w >= doc.widthOfString(val)) {
-            options.width=w;
-            options.height=dftFontHeight;
+            options.width = w;
+            options.height = dftFontHeight;
         } else {
             while (true) {
                 dftFontHeight--;
                 doc.fontSize(dftFontHeight);
                 if (w >= doc.widthOfString(val) || dftFontHeight < 6) {
-                    options.width=w;
-                    options.height=dftFontHeight;
+                    options.width = w;
+                    options.height = dftFontHeight;
                     break;
                 }
             }
         }
-
         function private_drawUnderline() {
             //A. 暂不支持角度; B. PDF输出时,坐标没有translate
             let ctx = doc;
@@ -232,9 +230,9 @@ function export_pdf_file (pageData, paperSize, fName, callback) {
             }
             doc.rotate(font.FontAngle,rotateOptions);
         }
-        // doc.text(val,output[0], output[1],options);
-        doc.font(fontFile).text(val,output[0], output[1],options);
-        doc.restore();
+        doc.text(val,output[0], output[1], options);
+        doc.font(__dirname + '/pdf_base_files/Smart.ttf');
+        // doc.restore();
     }
 
     function private_setupAreaH(area, type, fontAngle, dftFontHeight, outputPoint,options) {

+ 2 - 1
public/web/socket/connection.js

@@ -7,7 +7,8 @@ socketObject={
       // 连接socket服务器
       var hostName = window.location.hostname;
       let me = this;
-      socket = io('http://'+hostName+':3300');
+      let port = window.location.protocol ==='http:'?3300:3301
+      socket = io(window.location.protocol+'//'+hostName+':'+port);
       socket.on('connect', function () {
           me.roomInfo={
               feeRate:me.getFeeRateRoomID(),

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

@@ -433,7 +433,7 @@ var TREE_SHEET_HELPER = {
             TREE_SHEET_HELPER.showTipsDiv(text,setting,hitinfo);
         };
         TipCellType.prototype.processMouseLeave = function (hitinfo) {
-            let me = this;
+            let me = TREE_SHEET_HELPER;
             TREE_SHEET_HELPER.tipDiv = 'hide';
             if (me._toolTipElement) {
                 $(me._toolTipElement).hide();

+ 17 - 1
web/building_saas/css/main.css

@@ -395,4 +395,20 @@ a{
 }
 .custom-file-input:lang(zh) ~ .custom-file-label::after {
     content: "浏览";
-}
+}
+/*.popover{position:absolute;
+    top:0;left:0;
+    z-index:1060;
+    display:block;
+    max-width:276px;
+    font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-style:normal;font-weight:400;line-height:1.5;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;letter-spacing:normal;word-break:normal;word-spacing:normal;white-space:normal;line-break:auto;font-size:.875rem;word-wrap:break-word;
+    background-color:black;
+    background-clip:padding-box;
+    border:1px solid black;
+    border-radius:.3rem}*/
+
+/*
+.arrow{
+    background-color:black;
+}
+*/

+ 1 - 1
web/building_saas/fee_rates/fee_rate.html

@@ -3,7 +3,7 @@
 <div >
 <div class="toolsbar_feeRate px-1 ">
     <div class="form-inline py-1">
-        <label class="mx-2" >当前使用:<span id="feeRateFileName">费率1</span>(<label class="a_color" id="pop-lv"><span id="projectCount">3</span> 个单位工程使用</label>)
+        <label  class="mx-2" >当前使用:<span id="feeRateFileName">费率1</span>(<label class="a_color" id="pop-lv"><span id="projectCount">3</span> 个单位工程使用</label>)
             <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#change-lv" id="changFeeRateFile"><i class="fa fa-exchange"></i> 选择其他</a>
             <a class="btn btn-sm ml-1" href="#" data-toggle="modal" id="saveAs" data-target="#copy-lv"><i class="fa fa-files-o"></i> 另存单独用</a></label>
     </div>

+ 27 - 2
web/building_saas/main/js/models/calc_base.js

@@ -71,11 +71,36 @@ let cbTools = {
         return rst;
     },
     //根据公式获取相关的节点
-    getNodesByExp: function (exp) {
+    getNodesByExp: function (exp, formulaNodesArr) {
         let rst = [], ids = [];
         if(this.isUnDef(exp) || exp === ''){
             return rst;
         }
+        if(exp.includes('{税前工程造价}')){
+            let findChildNodes = [];
+            let subEngingeering = this.findBill(fixedFlag.SUB_ENGINERRING) ? this.getNodeByID(this.findBill(fixedFlag.SUB_ENGINERRING).ID) : null,
+                measure = this.findBill(fixedFlag.MEASURE) ? this.getNodeByID(this.findBill(fixedFlag.MEASURE).ID) : null,
+                other = this.findBill(fixedFlag.OTHER) ? this.getNodeByID(this.findBill(fixedFlag.OTHER).ID) : null,
+                charge = this.findBill(fixedFlag.CHARGE) ? this.getNodeByID(this.findBill(fixedFlag.CHARGE).ID) : null;
+            if(subEngingeering){
+                findChildNodes.push(subEngingeering);
+            }
+            if(measure){
+                findChildNodes.push(measure);
+            }
+            if(other){
+                findChildNodes.push(other);
+            }
+            if(charge){
+                findChildNodes.push(charge);
+            }
+            //
+            let childrenNodes = calcTools.getChildrenFormulaNodes(formulaNodesArr, findChildNodes);
+            for(let cNode of childrenNodes){
+                ids.push(cNode.data.ID);
+            }
+            rst = rst.concat(childrenNodes);
+        }
         //获取表达式中的基数和行引用
         let figureF = cbParser.getFigureF(cbParser.getFigure(exp), cbParser.getUID(cbParser.getFIDArr(exp)));
         for(let i = 0, len = figureF.length; i < len; i++){
@@ -309,7 +334,7 @@ let cbTools = {
                 for (let node of nodes){
                     if (orderArr.includes(node)) continue;    // 已排过序的节点则跳过
                     if (node.data.calcBase){
-                        let subNodes = cbTools.getNodesByExp(node.data.calcBase);
+                        let subNodes = cbTools.getNodesByExp(node.data.calcBase, nodesArr);
                         recursionNode(subNodes);
                     };
                     if (nodesArr.includes(node) && !orderArr.includes(node)) orderArr.push(node);

+ 27 - 4
web/building_saas/main/js/models/calc_program.js

@@ -168,6 +168,22 @@ let calcTools = {
 
         return flagsArr.includes(flag);
     },
+    getChildrenFormulaNodes: function (allFormulaNodesArr, parentNodes){       // 获取结点parentNodes下有公式的子结点
+        let nodes = [];
+        for (let pn of parentNodes){
+            for (let node of allFormulaNodesArr){
+                let cur = node;
+                while (cur.parent) {
+                    cur = cur.parent;
+                    if (cur == pn){
+                        nodes.push(node);
+                        break;
+                    }
+                };
+            };
+        };
+        return nodes;
+    },
     getGLJList: function (treeNode, needOneBill) {
         delete treeNode.data.gljList;
         if (this.isRationCategory(treeNode)) {
@@ -234,6 +250,12 @@ let calcTools = {
             treeNode.changed = true;
         };
 
+        // 不知在何种情况下,tenderUnitFee、tenderTotalFee的值会变成NaN,这里提前处理一下
+        if (isNaN(treeNode.data.feesIndex[feeObj.fieldName].tenderUnitFee))
+            treeNode.data.feesIndex[feeObj.fieldName].tenderUnitFee = undefined;
+        if (isNaN(treeNode.data.feesIndex[feeObj.fieldName].tenderTotalFee))
+            treeNode.data.feesIndex[feeObj.fieldName].tenderTotalFee = undefined;
+
         if (treeNode.data.feesIndex[feeObj.fieldName].tenderUnitFee != feeObj.tenderUnitFee){
             treeNode.data.feesIndex[feeObj.fieldName].tenderUnitFee = feeObj.tenderUnitFee;
             treeNode.changed = true;
@@ -314,8 +336,10 @@ let calcTools = {
         };
 
         if (priceType == priceTypes.ptDiffPrice){
-            result = (temp.toDecimal(decimalObj.ration.unitPrice) - temp2.toDecimal(decimalObj.ration.unitPrice)).toDecimal(decimalObj.ration.unitPrice);
-            // result = (temp - temp2).toDecimal(decimalObj.ration.unitPrice);
+            if (gljTypes == baseMaterialTypes)
+                result = (temp - temp2).toDecimal(decimalObj.ration.unitPrice)
+            else
+                result = (temp.toDecimal(decimalObj.ration.unitPrice) - temp2.toDecimal(decimalObj.ration.unitPrice)).toDecimal(decimalObj.ration.unitPrice);
         }
         else{
             result = result.toDecimal(decimalObj.ration.unitPrice);
@@ -1931,8 +1955,7 @@ class CalcProgram {
     calcFormulaNodes(changedArr, tender){
         let me = this;
         let formulaNodes = cbTools.getFormulaNodes(true);
-        for(let n of formulaNodes){
-        }
+
         if (formulaNodes.length == 0) return;
         for (let formulaNode of formulaNodes){
             formulaNode.data.userCalcBase = formulaNode.data.calcBase;    // 这句不该出现,projectObj.project.calcBase中要改进。

+ 3 - 2
web/building_saas/main/js/models/project_glj.js

@@ -690,10 +690,11 @@ ProjectGLJ.prototype.getByConKey = function (conkey) {//根据5个连接属性
 
 ProjectGLJ.prototype.refreshTreeNodePriceIfNeed = function (data) {
     if ((data.unit_price.type == gljType.MAIN_MATERIAL || data.unit_price.type == gljType.EQUIPMENT) && projectInfoObj.projectInfo.property.displaySetting.disPlayMainMaterial == true) {
+        let me = this;
         var nodes = _.filter(projectObj.project.mainTree.items, function (tem) {
             if (tem.sourceType == ModuleNames.ration_glj && tem.data.projectGLJID == data.id) {
-                tem.data.marketUnitFee = this.getMarketPrice(data);//data.unit_price.market_price;
-                tem.data.marketPrice = this.getMarketPrice(data);//data.unit_price.market_price;
+                tem.data.marketUnitFee = me.getMarketPrice(data);//data.unit_price.market_price;
+                tem.data.marketPrice = me.getMarketPrice(data);//data.unit_price.market_price;
                 return true;
             }
         })

+ 50 - 9
web/building_saas/main/js/models/ration.js

@@ -432,8 +432,8 @@ var Ration = {
                     $.bootstrapLoading.end();
                 });
 
-                if(data.length<recodes.length&&recodes[data.length].value!=null){//说明有部分定额编号没找到记录
-                    alert('当前库中找不到定额"' + recodes[data.length].value + '"');
+                if(data.length < nodeInfo.length && nodeInfo[data.length].newCode!=null){//说明有部分定额编号没找到记录
+                    alert('当前库中找不到定额"' + nodeInfo[data.length].newCode + '"');
                 }
                 updateBillsOprRation();
             })
@@ -593,9 +593,6 @@ var Ration = {
                     needInstall = project.Bills.isFBFX(billsNode);//在分部分项插入的定额才需要定额安装增加费
                 }
                 $.bootstrapLoading.start();
-                newNode = project.mainTree.insert(billItemID, nextID, newID);
-                newNode.sourceType = project.Ration.getSourceType();
-                newNode.data = newData;
                 CommonAjax.post("/ration/addNewRation",{itemQuery:itemQuery,newData:newData,firstLibID: rationLibObj.getFirstStdRationLibID(),calQuantity:calQuantity,brUpdate:brUpdate,needInstall:needInstall},function (data) {
                     //更新缓存
                     me.datas.push(data.ration);
@@ -605,12 +602,12 @@ var Ration = {
 
                     //插入树节点
                     newSource = data.ration;
-                    // newNode = project.mainTree.insert(billItemID, nextID, newSource.ID);  上移到post方法外部。批量粘贴时,先插入空行,前端等不了,先生成树结点,效果同清单处理方式。
+                    newNode = project.mainTree.insert(billItemID, nextID, newSource.ID);
                     newNode.source = newSource;
-                    // newNode.sourceType = project.Ration.getSourceType();
+                    newNode.sourceType = project.Ration.getSourceType();
                     newNode.data = newSource;
                     project.projectGLJ.loadData(function () {
-                        // ProjectController.syncDisplayNewNode(sheetController, newNode);
+                        ProjectController.syncDisplayNewNode(sheetController, newNode);
                         project.ration_glj.addToMainTree(data.ration_gljs);
                         projectObj.mainController.refreshTreeNode([newNode], false);
                         project.calcProgram.calcAndSave(newNode,function () {
@@ -626,11 +623,55 @@ var Ration = {
                         $.bootstrapLoading.end();
                     });
                 })
+                return newNode;
+            }
+            else return null;
+        };
+        ration.prototype.addNewRationForPaste = function (rationType) {
+            let me = this;
+            let project = projectObj.project, sheetController = projectObj.mainController;
+            let engineering = projectInfoObj.projectInfo.property.engineering;
+            let selected = project.mainTree.selected, newSource = null, newNode = null,pre=null,br=null;
+            let billItemID = null,serialNo=1,nextID=null;
+            if (selected === null) { return null; }
+            if (selected.sourceType === project.Ration.getSourceType()) {
+                billItemID = selected.getParentID();
+                br = this.getBillsSortRation(billItemID);
+                serialNo = selected.data.serialNo+1;
+                nextID = selected.getNextSiblingID();
+                pre = selected.source;
+            };
+            if(billItemID){
+                let newID = me.getNewRationID();
+                let newData =  me.getTempRationData(newID, billItemID, serialNo, rationType);
+                let brUpdate = [];
+                //更新兄弟节点的序列号
+                if (pre) {
+                    let preIndex = br.indexOf(pre), i;
+                    for (i = preIndex + 1; i < br.length; i++) {
+                        br[i].serialNo = i < br.length - 1 ? br [i + 1].serialNo : br[i].serialNo + 1;
+                        brUpdate.push({projectID:newData.projectID,ID:br[i].ID,serialNo:br[i].serialNo});
+                    }
+                }
+                if(engineering==engineeringType.BUILD_IN) {//如果是安装工程,要看需不需要生成安装增加费
+                    let billsNode = project.mainTree.getNodeByID(billItemID);
+                }
+                $.bootstrapLoading.start();
+                newNode = project.mainTree.insert(billItemID, nextID, newID);
+                newNode.sourceType = project.Ration.getSourceType();
+                newNode.data = newData;
+                CommonAjax.post("/ration/addNewRation",{itemQuery:null,newData:newData,firstLibID: rationLibObj.getFirstStdRationLibID(),calQuantity:false,brUpdate:brUpdate,needInstall:false},function (data) {
+                    //更新缓存
+                    me.datas.push(data.ration);
+                    //插入树节点
+                    newSource = data.ration;
+                    newNode.source = newSource;
+                    newNode.data = newSource;
+                })
                 ProjectController.syncDisplayNewNode(sheetController, newNode);
                 return newNode;
             }
             else return null;
-
         };
         ration.prototype.deleteSubListOfRation = function(ration){
             projectObj.project.ration_glj.deleteByRation(ration);

+ 1 - 3
web/building_saas/main/js/models/ration_glj.js

@@ -189,9 +189,7 @@ var ration_glj = {
                 if (this.needShowToTree(data)) {
                     gljOprObj.setGLJPrice(data);
                     this.transferToNodeData(data);
-                    let parentNode = _.find(projectObj.project.mainTree.items, function (n) {//找父节点
-                        return n.sourceType == ModuleNames.ration && n.data.ID == data.rationID;
-                    });
+                    let parentNode = projectObj.project.mainTree.findNode(data.rationID);
                     if (parentNode) {
                         let nextNodeID = null;
                         if (parentNode.children.length > 0) {

+ 4 - 9
web/building_saas/main/js/views/fee_rate_view.js

@@ -917,22 +917,17 @@ var feeRateObject={
 function getPopoverContent() {
     var feeRateFile = projectObj.project.FeeRate.getActivateFeeRate();
     var usageProjects = feeRateFile.usageProjects;
-    var popover_content = "";
-    _.forEach(usageProjects,function (p,index) {
-        if(index>0){
-            popover_content+='<br>';
-        }
-        popover_content+=p.name;
-    })
+    let names = _.map(usageProjects,'name');
+    let popover_content = names.join('<br>');
     return popover_content;
 }
 
 $(function(){
-    $('#pop-lv').popover({
+    $('#pop-lv').tooltip({
             placement:"bottom",
             html:true,
             trigger:"hover | focus",
-            content:getPopoverContent
+            title:getPopoverContent
         }
     );
 

+ 10 - 10
web/building_saas/main/js/views/glj_col.js

@@ -36,13 +36,13 @@ let gljCol = {
             {headerName: "总消耗量", headerWidth: 90, dataCode: "quantity", hAlign: "right", dataType: "Number",decimalField:'glj.quantity'},
             {headerName: "暂估", headerWidth: 45, dataCode: "is_evaluate", hAlign: "center", dataType: "String",cellType:'checkBox'},
             {headerName: "主要\n材料", headerWidth: 45, dataCode: "is_main_material", hAlign: "center", dataType: "String",cellType:'checkBox'},
+            {headerName: "不调价", headerWidth: 55, dataCode: "is_adjust_price", dataType: "String",cellType: "checkBox"},
             {headerName: "供货方式", headerWidth: 70, dataCode: "supply", hAlign: "center", dataType: "String",cellType:'comboBox',editorValueType:true,options:supplyComboMap},
             {headerName: "甲供数量", headerWidth: 90, dataCode: "supply_quantity", hAlign: "right", dataType: "Number",validator:"number",decimalField:'glj.quantity'},
             {headerName: "三材类别", headerWidth: 70, dataCode: "materialType", hAlign: "center", dataType: "String",cellType:'comboBox',editorValueType:true,options:materialComboMap},
             {headerName: "三材系数", headerWidth: 70, dataCode: "materialCoe", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:'material'
             {headerName: "交货方式", headerWidth: 70, dataCode: "delivery", hAlign: "left", dataType: "String"},
             {headerName: "送达地点", headerWidth: 70, dataCode: "delivery_address", hAlign: "left", dataType: "String"},
-            {headerName: "不调价", headerWidth: 55, dataCode: "is_adjust_price", dataType: "String",cellType: "checkBox"},
             {headerName: "备注", headerWidth: 100, dataCode: "remark", hAlign: "left", dataType: "String"}
         ],
         view: {
@@ -52,15 +52,15 @@ let gljCol = {
     },
     mixRatio_Setting:{
         header:[
-            {headerName: "编码", headerWidth: 120, dataCode: "code", dataType: "String"},
-            {headerName: "名称", headerWidth: 120, dataCode: "name", dataType: "String"},
-            {headerName: "规格型号", headerWidth: 120, dataCode: "specs", dataType: "String"},
-            {headerName: "单位", headerWidth: 120, dataCode: "unit", hAlign: "center", dataType: "String"},
-            {headerName: "类型", headerWidth: 120, dataCode: "short_name", hAlign: "center", dataType: "String"},
-            {headerName: "定额价", headerWidth: 120, dataCode: "basePrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:'glj.unitPrice'
-            {headerName: "调整价", headerWidth: 120, dataCode: "adjustPrice", hAlign: "right", dataType: "Number"},//,decimalField:"glj.unitPrice"
-            {headerName: "市场价", headerWidth: 120, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
-            {headerName: "消耗量", headerWidth: 120, dataCode: "consumption", hAlign: "right", dataType: "Number",decimalField:"glj.quantity",validator:"number"}
+            {headerName: "编码", headerWidth: 80, dataCode: "code", dataType: "String"},
+            {headerName: "名称", headerWidth: 240, dataCode: "name", dataType: "String"},
+            {headerName: "规格型号", headerWidth: 190, dataCode: "specs", dataType: "String"},
+            {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
+            {headerName: "类型", headerWidth: 45, dataCode: "short_name", hAlign: "center", dataType: "String"},
+            {headerName: "定额价", headerWidth: 80, dataCode: "basePrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:'glj.unitPrice'
+            {headerName: "调整价", headerWidth: 80, dataCode: "adjustPrice", hAlign: "right", dataType: "Number"},//,decimalField:"glj.unitPrice"
+            {headerName: "市场价", headerWidth: 80, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
+            {headerName: "消耗量", headerWidth: 80, dataCode: "consumption", hAlign: "right", dataType: "Number",decimalField:"glj.quantity",validator:"number"}
         ],
         view: {
             lockColumns: [0,1,2,3,4,5,6,7]

+ 86 - 53
web/building_saas/main/js/views/glj_view.js

@@ -106,12 +106,29 @@ var gljOprObj = {
         subSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, me.onButtonClick);
         if(!projectReadOnly){
             gljContextMenu.loadGLJSpreadContextMenu();
+            //me.bindGLJEnterKey(subSpread,sheet);
         }
         sheet.bind(GC.Spread.Sheets.Events.SelectionChanged,function (sender,args) {
             let selected = args.newSelections[0] ? args.newSelections[0] : {row: 0, col: 0};
             me.sheetInitSelection(selected);
         });
     },
+
+    bindGLJEnterKey:function (spread,sheet) {
+        let me = this;
+        subSpread.commandManager().register('myEnter', enterKeyAction);
+        subSpread.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.enter, false, false, false, false);
+        subSpread.commandManager().setShortcutKey('myEnter', GC.Spread.Commands.Key.enter, false, false, false, false);
+
+        function enterKeyAction(spd,sheeName) {
+            let editRow = sheet.getActiveRowIndex(),orgCol = sheet.getActiveColumnIndex();
+            if(sheet.isEditing()) sheet.endEdit();
+             //GC.Spread.Sheets.Commands.commitInputNavigationDown.execute(spd,sheeName);
+            //sheet.setSelection(editRow,orgCol+1,1,1);
+            GC.Spread.Sheets.Commands.navigationRight.execute(spd,sheeName);
+            //sheet.setActiveCell(editRow, orgCol+1)
+        }
+    },
     sheetInitSelection: function (selected) {
         let me = gljOprObj;
         if(selected.row < me.sheetData.length){
@@ -553,12 +570,15 @@ var gljOprObj = {
         if(priceMap){
             for(let connectKey in priceMap){
                 let code = priceMap[connectKey].code;
+                let name = priceMap[connectKey].name;
+                let specs = priceMap[connectKey].specs;
                 if(code){
+                    let displayText = code +" "+name +" "+specs;
                    let preCode = code.split("-")[0];
                    if(codeMap[preCode]) {
-                       codeMap[preCode].push({text:code,value:connectKey});
+                       codeMap[preCode].push({text:displayText,value:connectKey});
                    }else {
-                       codeMap[preCode]=[{text:code ,value:connectKey}];
+                       codeMap[preCode]=[{text:displayText ,value:connectKey}];
                    }
                 }
             }
@@ -571,7 +591,8 @@ var gljOprObj = {
         this.sheet.suspendEvent();
         this.sheet.setRowCount(this.sheetData.length >30?this.sheetData.length:30);
         for (var i = 0; i < this.sheetData.length; i++) {
-            this.sheet.setCellType(i, 0,this.getTreeNodeCellType(this.sheetData,i,codeMap),GC.Spread.Sheets.SheetArea.viewport);
+            let options = this.getCodeOptions(this.sheetData[i],codeMap);
+            this.sheet.setCellType(i, 0,this.getTreeNodeCellType(this.sheetData,options),GC.Spread.Sheets.SheetArea.viewport);
             if (this.sheetData[i].hasOwnProperty('subList')) {
                 var collapsed = this.sheetData[i].collapsed == undefined ? true : this.sheetData[i].collapsed;
                 if (collapsed == true) {
@@ -582,6 +603,19 @@ var gljOprObj = {
         this.sheet.resumeEvent();
         this.sheet.resumePaint();
     },
+    getCodeOptions:function (recode,codeMap) {
+        let options = [];
+          if(recode.isMixRatio ===true){
+              return null;
+          }
+        let code = recode.code;
+        if(code) {
+            let preCode = code.split("-")[0];
+            if( codeMap[preCode]) options = codeMap[preCode];
+            if(options.length>0) _.remove(options,{'value':gljOprObj.getIndex(recode, gljKeyArray)})//去掉本身
+        }
+        return options;
+    },
     filterGljByRation: function (ration, datas) {
         var gljList = [];
         if (datas && datas.length > 0) {
@@ -669,11 +703,13 @@ var gljOprObj = {
         let decimalObj = projectInfoObj.projectInfo.property.decimal;
         let labourCoeDatas =  projectObj.project.labourCoe.datas;
         glj = glj?glj:_.find(proGLJ.datas.gljList, {'id': data.projectGLJID});
-        let result = gljUtil.getGLJPrice(glj,proGLJ.datas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
-        data.marketPrice = result.marketPrice;
-        data.basePrice =  result.basePrice;
-        data.adjustPrice = result.adjustPrice;
-        data.marketUnitFee = data.marketPrice;//更新树节点市场单价列的值
+        if(glj){
+            let result = gljUtil.getGLJPrice(glj,proGLJ.datas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
+            data.marketPrice = result.marketPrice;
+            data.basePrice =  result.basePrice;
+            data.adjustPrice = result.adjustPrice;
+            data.marketUnitFee = data.marketPrice;//更新树节点市场单价列的值
+        }
         return data;
 
     },
@@ -716,36 +752,36 @@ var gljOprObj = {
     getMixRationShowDatas: function (mixRatioList, projectGljs) {
         var temRationGLJs = [];
         for (var i = 0; i < mixRatioList.length; i++) {
-            var pg = _.find(projectGljs, {
-                'code': mixRatioList[i].code,
-                'name': mixRatioList[i].name,
-                'specs': mixRatioList[i].specs,
-                'type': mixRatioList[i].type,
-                'unit': mixRatioList[i].unit
+            let mIndex = gljOprObj.getIndex(mixRatioList[i],gljKeyArray);
+            var pg = _.find(projectGljs, function (item) {
+                return gljOprObj.getIndex(item,gljKeyArray) == mIndex
             });//改关联关系
-            var tem = {
-                projectGLJID: pg.id,
-                code: pg.code,
-                name: pg.name,
-                specs: pg.specs,
-                unit: pg.unit,
-                type:mixRatioList[i].type,
-                shortName: projectObj.project.projectGLJ.getShortNameByID(mixRatioList[i].type),
-                consumption:mixRatioList[i].consumption,
-                rationItemQuantity: mixRatioList[i].consumption,
-                // quantity:mixRatioList[i].consumption,
-              /*  basePrice: pg.unit_price.base_price,
-                marketPrice: pg.unit_price.market_price,
-                adjustPrice: pg.adjust_price,*/
-                //isEstimate: pg.is_evaluate,
-                isMixRatio: true,
-                isAdd: pg.unit_price.is_add,
-                GLJID: pg.glj_id
-            };
-            if(projectObj.project.projectGLJ.isEstimateType(pg.type)){
-                tem.isEstimate =  pg.is_evaluate;
+            if(pg){
+                var tem = {
+                    projectGLJID: pg.id,
+                    code: pg.code,
+                    name: pg.name,
+                    specs: pg.specs,
+                    unit: pg.unit,
+                    type:mixRatioList[i].type,
+                    shortName: projectObj.project.projectGLJ.getShortNameByID(mixRatioList[i].type),
+                    consumption:mixRatioList[i].consumption,
+                    rationItemQuantity: mixRatioList[i].consumption,
+                    // quantity:mixRatioList[i].consumption,
+                    /*  basePrice: pg.unit_price.base_price,
+                     marketPrice: pg.unit_price.market_price,
+                     adjustPrice: pg.adjust_price,*/
+                    //isEstimate: pg.is_evaluate,
+                    isMixRatio: true,
+                    isAdd: pg.unit_price.is_add,
+                    GLJID: pg.glj_id
+                };
+                if(projectObj.project.projectGLJ.isEstimateType(pg.type)){
+                    tem.isEstimate =  pg.is_evaluate;
+                }
+                this.setGLJPrice(tem,pg);
             }
-            this.setGLJPrice(tem,pg);
+
             temRationGLJs.push(tem);
         }
         temRationGLJs = _.sortBy(temRationGLJs, 'code');
@@ -1196,7 +1232,7 @@ var gljOprObj = {
         }
         return node;
     },
-    getTreeNodeCellType: function (data,index,codeMap) {
+    getTreeNodeCellType: function (data,comboboxOptions) {
         var ns = GC.Spread.Sheets;
         var rectW = 10;
         var rectH = 10;
@@ -1258,12 +1294,17 @@ var gljOprObj = {
             return offset;
         }
 
-        if(isDef(index) && data[index] && data[index].isMixRatio !==true){
-            TreeNodeCellType.prototype =  sheetCommonObj.getDynamicCombo();
-        }else {
-            TreeNodeCellType.prototype =  new ns.CellTypes.Text();
-        }
+        TreeNodeCellType.prototype =  comboboxOptions?sheetCommonObj.getDynamicCombo():new ns.CellTypes.Text();
+
         TreeNodeCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
+            if (style.backColor) {//先画背景色
+                ctx.save();
+                ctx.fillStyle = style.backColor;
+                ctx.fillRect(x, y, w, h);
+                ctx.restore();
+            } else {
+                ctx.clearRect(x, y, w, h);
+            }
             if (value != null) {
                 var offset = margin + rectW + 6;
                 var recode = data[options.row];
@@ -1283,7 +1324,7 @@ var gljOprObj = {
             }
         };
         TreeNodeCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
-            if(x < cellRect.x+cellRect.width -15){
+            if(x < cellRect.x+cellRect.width -15){//这里要判断点击的位置来决定return的内容,不能直接用combobox的方法
                 return {
                     x: x,
                     y: y,
@@ -1317,17 +1358,9 @@ var gljOprObj = {
            // GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
         };
         let cellType = new TreeNodeCellType();
-        let options = [];
-        if(isDef(index) && data[index] && data[index].isMixRatio !==true){
-            let code = data[index].code;
-            if(code) {
-                let preCode = code.split("-")[0];
-                if( codeMap[preCode]) options = codeMap[preCode];
-                if(options.length>0) _.remove(options,{'value':gljOprObj.getIndex(data[index], gljKeyArray)})//去掉本身
-
-            }
+        if(comboboxOptions){
             cellType.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
-            cellType.itemHeight(options.length).items(options);
+            cellType.itemHeight(comboboxOptions.length).items(comboboxOptions);
         }
         return cellType;
     },

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

@@ -1134,11 +1134,11 @@ $(function () {
      me.showProjectGljData();
      me.initMixRatio();
      });*/
-    $('#pop-used-list').popover({
+    $('#pop-used-list').tooltip({
             placement: "bottom",
             html: true,
             trigger: "hover | focus",
-            content: projectGljObject.getUsedTenderInfo
+            title: projectGljObject.getUsedTenderInfo
         }
     );
     // 单价文件切换弹框

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

@@ -584,17 +584,18 @@ var projectObj = {
         }
     },
     onClipboardPasting: function (sender, info){
-        info.cancel = true;
-
         let rIdx = info.sheet.getActiveRowIndex();
         let node = projectObj.project.mainTree.items[rIdx];
         if (!node.parent){
+            info.cancel = true;
             hintBox.infoBox('系统提示','大项费用不允许粘贴!', 1);
             return false;
         };
 
         let colName = projectObj.project.projSetting.main_tree_col.cols[info.cellRange.col].data.field;
         if (colName == 'code'){
+            info.cancel = true;
+
             function getNodeType(node) {
                 let t = null;
                 if (calcTools.isRationItem(node))
@@ -621,7 +622,7 @@ var projectObj = {
                 }
                 return rstArr;
             };
-            function getPasteNodes(count, nodeType) {
+            function getPasteNodes(node, nodeType, count) {
                 let nodesArr = [];
                 let curNode = null;
                 for (let i = rIdx; i < rIdx + count; i++) {
@@ -643,7 +644,7 @@ var projectObj = {
                     for (let i = 0; i < add; i++) {
                         switch (nodeType) {
                             case 1:
-                                curNode = projectObj.project.Ration.addNewRation(null,rationType.ration,null,true);
+                                curNode = projectObj.project.Ration.addNewRationForPaste(rationType.ration);
                                 break;
                             case 2:
                                 curNode = ProjectController.addFB(projectObj.project, projectObj.mainController);
@@ -670,12 +671,16 @@ var projectObj = {
 
                 return nodesArr;
             };
-            function doPaste(datas, nodes, nodeType) {
+            function doPaste(nodes, nodeType, datas) {
                 if (nodeType == 1){  // 批量粘贴定额有严重的异步问题,这里要和清单分开处理
                     let updateRationCodes = [];
                     for (let i = 0; i < datas.length; i++) {
                         let ptNode = nodes[i];
                         let code = datas[i][0];
+                        // 编号去掉“换、借、补”等多余的字
+                        code = code.replace(new RegExp(rationPrefix.complementary), '');
+                        code = code.replace(new RegExp(rationPrefix.borrow), '');
+                        code = code.replace(new RegExp(rationPrefix.replace), '');
                         updateRationCodes.push({'node':ptNode, value:code});
                     }
                     projectObj.project.Ration.updateRationCodes(updateRationCodes);
@@ -697,11 +702,10 @@ var projectObj = {
                 hintBox.infoBox('系统提示', '该树结点类型不支持从项目编码列粘贴!', 1);
                 return false;
             };
-
             let datas = getPasteTextArr(info);
             if (!datas) return;
-            let pasteNodes = getPasteNodes(datas.length, tagType);
-            doPaste(datas, pasteNodes, tagType);
+            let pasteNodes = getPasteNodes(node, tagType, datas.length);
+            doPaste(pasteNodes, tagType, datas);
         };
     },
     mainSpreadEditEnded: function (sender, info) {
@@ -2856,4 +2860,4 @@ $('#calcBaseFeeRateConf').click(function () {
     else if(!validateFeeRate && needToSave) {
         projectObj.project.calcProgram.calcAndSave(selected);
     }
-});
+});