Selaa lähdekoodia

Merge branch '1.0.0_online' of http://192.168.1.12:3000/SmartCost/ConstructionCost into 1.0.0_online

TonyKang 6 vuotta sitten
vanhempi
commit
d41c4fec1b

+ 1 - 1
modules/pm/models/project_property_template.js

@@ -7,7 +7,7 @@ const defaultDecimal = {
     bills: {unitPrice: 2, totalPrice: 2},
     ration: {quantity: 4, unitPrice: 2, totalPrice: 2},
     glj: {quantity: 4, unitPriceHasMix: 2, unitPrice: 3},
-    feeRate: 2,
+    feeRate: 3,
     quantity_detail: 4,
     material:5,//三材系数
     process: 6

+ 2 - 2
modules/users/models/user_model.js

@@ -123,7 +123,7 @@ class UserModel extends BaseModel {
      * @param {string} scene
      */
     setScene(scene = '') {
-        switch (scene) {
+       /* switch (scene) {
             case 'saveInfo':
                 this.model.schema.path('real_name').required(true);
                 this.model.schema.path('company').required(true);
@@ -135,7 +135,7 @@ class UserModel extends BaseModel {
                 this.model.schema.path('company').required(false);
                 this.model.schema.path('province').required(false);
                 this.model.schema.path('version').required(false);
-        }
+        }*/
     }
 
     /**

+ 53 - 0
public/web/sheet/sheet_common.js

@@ -146,6 +146,9 @@ 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.style){
+                sheet.setStyle(row, -1, setting.style);
+            }
         }
         this.lockCells(sheet,setting);
         sheet.resumeEvent();
@@ -281,7 +284,57 @@ var sheetCommonObj = {
             sheet.setStyle(row, -1, style);
         }
     },
+    getCustomerCoeCellType: function (htmlGenerator,setEditorValue,updateCallback) {
+        let me = this;
+        function CustomerCoeCellType() {
+            this.isEscKey=false;
+            this.displayText='';
+        }
+        CustomerCoeCellType.prototype = new GC.Spread.Sheets.CellTypes.Base();
+
+        CustomerCoeCellType.prototype.createEditorElement = function (context) {
+            console.log("create editor")
+            let element = document.createElement("div");//这里创建的,会自动销毁
+            return element
+        };
+        CustomerCoeCellType.prototype.activateEditor = function (editorContext, cellStyle, cellRect, context) {
+            if (editorContext) {
+                $editor = $(editorContext);
+                $editor.css("position", "fixed");
+                $editor.css("background", "white");
+                $editor.css("width", cellRect.width);
+                $editor.attr("gcUIElement", "gcEditingInput");
+                if(htmlGenerator) $editor.html(htmlGenerator(context,cellRect));
+            }
+        }
+        CustomerCoeCellType.prototype.deactivateEditor = function (editorContext, context) {
 
+        };
+        CustomerCoeCellType.prototype.setEditorValue = function (editor, value, context) {
+            console.log("set editor value");
+            this.displayText = value;
+        };
+        CustomerCoeCellType.prototype.getEditorValue = function (editor, context) {
+            console.log("get value");
+            if(this.isEscKey !=true&& updateCallback){
+                updateCallback();
+            }
+            this.isEscKey = false;
+            return this.displayText;
+        };
+        CustomerCoeCellType.prototype.updateEditor = function (editorContext, cellStyle, cellRect, context) {
+            console.log(" update editor");
+            if( setEditorValue){//不是esc时才更新
+                setEditorValue(context);
+            }
+        };
+        CustomerCoeCellType.prototype.isReservedKey = function (e, context) {
+            //cell type handle tab key by itself
+            this.isEscKey = e.keyCode === GC.Spread.Commands.Key.esc;
+            return false;
+        };
+        return new CustomerCoeCellType();
+    },
     setSelectButton(row,col,sheet,header){
         let getSelectButton = function (cellWidth=100) {
             function moreButton() {

+ 1 - 7
public/web/sheet/sheet_data_helper.js

@@ -58,6 +58,7 @@ var SheetDataHelper = {
         spread.options.allowUserEditFormula = false;
         spread.options.showDragFillSmartTag = false;
         spread.options.defaultDragFillType = GC.Spread.Sheets.Fill.AutoFillType.fillWithoutFormatting;
+        spread.getActiveSheet().options.clipBoardOptions = GC.Spread.Sheets.ClipboardPasteOptions.values;//设置粘贴时只粘贴值,不粘贴样式和公式等
         spread.getActiveSheet().setRowCount(3);
         return spread;
     },
@@ -125,16 +126,9 @@ var SheetDataHelper = {
         style.wordWrap = setting.data.wordWrap;
         return style;
     },
-    getTipWidth: function(text){
-        const fontSize = 14.4;
-        let widthArr = text.split('<br>');
-        console.log(widthArr);
-    },
     loadSheetData: function (setting, sheet, datas) {
         let me = this;
         SheetDataHelper.protectdSheet(sheet);
-
-
         let TipCellType = function () {};
         TipCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
         TipCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {

+ 28 - 21
public/web/tree_sheet/tree_sheet_helper.js

@@ -159,18 +159,23 @@ var TREE_SHEET_HELPER = {
                     return data;
                 };
                 if(sheet.name()=="mainSheet"){
-                    if(colSetting.data.field=="quantity"){
+                 /*   if(colSetting.data.field=="quantity"){  2018-08-06 去掉工程量列表达式
                         let tag = node.data.quantityEXP?node.data.quantityEXP:'';
                         sheet.setTag(iRow, iCol,tag);
-                    }
+                    }*/
                     if(colSetting.data.field=="code"){
-                        let tag = node.data.adjustState?node.data.adjustState:'';
+                        let tag ="";
+                        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(colSetting.data.field=="name"){
+                    /*if(colSetting.data.field=="name"){ 2018-08-06 改成在编号列悬浮提示
                         let tag = node.data.itemCharacterText?node.data.itemCharacterText:'';
                         sheet.setTag(iRow, iCol,tag);
-                    }
+                    }*/
 
                 }
 
@@ -375,12 +380,12 @@ var TREE_SHEET_HELPER = {
         TreeNodeCellType.prototype.processMouseEnter = function(hitinfo){
             let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
             let tag = hitinfo.sheet.getTag(hitinfo.row, hitinfo.col);
-            if(tag){
+            if(tag&&tag!=''){
                 TREE_SHEET_HELPER.showTipsDiv(tag,setting,hitinfo);
             }
         };
         TreeNodeCellType.prototype.processMouseLeave = function (hitinfo) {
-            let me = this;
+            let me = TREE_SHEET_HELPER;
             TREE_SHEET_HELPER.tipDiv = 'hide';
             if (me._toolTipElement) {
                 $(me._toolTipElement).hide();
@@ -413,10 +418,10 @@ var TREE_SHEET_HELPER = {
             let cellWidth = hitinfo.sheet.getCell(-1, hitinfo.col).width();
             let dataField = setting.cols[hitinfo.col].data.field;
 
-            if(tag==''&&hitinfo.sheet.getCell(hitinfo.row,hitinfo.col).wordWrap()==true){//显示其它列的标记为空并且设置了自动换行
+            if((tag==undefined||tag=='')&&hitinfo.sheet.getCell(hitinfo.row,hitinfo.col).wordWrap()==true){//显示其它列的标记为空并且设置了自动换行
                 return;
             }
-            if(dataField === 'itemCharacterText' || dataField === 'jobContentText' || dataField === 'adjustState'){
+            if(dataField === 'itemCharacterText' || dataField === 'jobContentText' || dataField === 'adjustState'||dataField=="name"){
                 if((hitinfo.sheet.getParent() === projectObj.mainSpread||hitinfo.sheet.getParent() === tender_obj.tenderSpread) && textLength <= cellWidth)
                  return;
             }
@@ -424,13 +429,13 @@ var TREE_SHEET_HELPER = {
             if(hitinfo.sheet.name()=="mainSheet"){
                 if(dataField=="quantity"){//显示工程量明细
                     text = tag;
-                }if(dataField=="name"){//项目特征及内容隐藏时,显示特征及内容
-                    if(projectObj.ifItemCharHiden(setting)&&tag!=''){
-                        text = tag;
-                    }else if(textLength <= cellWidth){
-                        return;
-                    }
-                }
+                }/*if(dataField=="name"){//项目特征及内容隐藏时,显示特征及内容
+                 if(projectObj.ifItemCharHiden(setting)&&tag!=''){
+                 text = tag;
+                 }else if(textLength <= cellWidth){
+                 return;
+                 }
+                 }*/
                 else if(tag !== undefined && tag) {
                     text = tag;
                 }
@@ -478,10 +483,11 @@ var TREE_SHEET_HELPER = {
                 if (!div) {
                     div = document.createElement("div");
                     $(div).css("position", "absolute")
-                        .css("border", "1px #C0C0C0 solid")
-                        .css("box-shadow", "1px 2px 5px rgba(0,0,0,0.4)")
+                        .css("border", "1px #000000 solid")
+                        .css("box-shadow", "1px 2px 5px rgba(0,0,0,0)")
                         .css("font", "0.9rem Calibri")
-                        .css("background", "White")
+                        .css("background", "#000000")
+  						.css("color",'#FFFFFF')
                         .css("padding", 5)
                         .attr("id", 'autoTip');
                     $(div).hide();
@@ -492,7 +498,8 @@ var TREE_SHEET_HELPER = {
                 if(hitinfo.sheet && hitinfo.sheet.getParent().qo){
                     setting.pos = SheetDataHelper.getObjPos(hitinfo.sheet.getParent().qo);
                 }
-                $(this._toolTipElement).text(text);
+                if(text) text = replaceAll(/[\n]/,'<br>',text);
+                $(this._toolTipElement).html(text);
                 //清单指引、清单库做特殊处理
                 if($(hitinfo.sheet.getParent().qo).attr('id') === 'stdBillsSpread' || $(hitinfo.sheet.getParent().qo).attr('id') === 'billsGuidance_bills'){
                     $(this._toolTipElement).css('top', '').css('left', '').css('width', '');
@@ -503,7 +510,7 @@ var TREE_SHEET_HELPER = {
                     $(this._toolTipElement).css("top", setting.pos.y + hitinfo.y + 15).css("left", marginLeftMouse ? setting.pos.x + marginLeftMouse : setting.pos.x);
                 }
                 else {
-                    $(this._toolTipElement).css("top", setting.pos.y + hitinfo.y + 15).css("left", setting.pos.x + hitinfo.x + 15);
+                    $(this._toolTipElement).css("top", setting.pos.y + hitinfo.cellRect.y -$(this._toolTipElement).height()-10 ).css("left", setting.pos.x + hitinfo.cellRect.x + hitinfo.cellRect.width);
                 }
                 $(this._toolTipElement).show("fast");
                 TREE_SHEET_HELPER.tipDiv = 'show';//做个标记

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

@@ -178,7 +178,6 @@ a{
     background:#F1F1F1;
     bottom:30px;
     left:2px;
-    z-index: 999
 }
 .side-tabs .nav-tabs .nav-item {
     z-index: 999

+ 15 - 17
web/building_saas/main/html/main.html

@@ -158,7 +158,7 @@
                               <!-- Tab panes -->
                               <div class="tab-content" id="tabCon">
                                   <div class="tab-pane active" id="subItems" role="tabpanel">
-                                      <div class="main-data-bottom ovf-hidden" id="subSpread" style="display: none">
+                                      <div class="main-data-bottom ovf-hidden" id="subSpread" style="display: none" tabindex="0">
                                       </div>
                                       <div class="main-data-bottom ovf-hidden" id="tabZMHS" style="display: none">
                                           <div class=" main-data-bottom ovf-hidden" style="width: 50%; float: left; margin: 0; padding:0;" id="coeSpread"></div>
@@ -498,7 +498,7 @@
                     <div class="row">
                         <div class="col-3">
                             <ul class="nav flex-column nav-pills" role="tablist">
-                                <li class="nav-item"><a class="nav-link active" data-toggle="pill" href="#poj-settings-basicInfo" role="tab" id="tab_poj-settings-basicInfo">基本信息</a></li>
+                                <li class="nav-item"><a class="nav-link active" data-toggle="pill" href="#poj-settings-basicInfo" role="tab" id="tab_poj-settings-basicInfo">建设项目基本信息</a></li>
                                 <li class="nav-item"><a class="nav-link" data-toggle="pill" href="#poj-settings-projFeature" id="tab_poj-settings-projFeature" role="tab">工程特征</a></li>
                                 <li class="nav-item"><a class="nav-link" data-toggle="pill" href="#poj-settings-indicativeInfo" id="tab_poj-settings-indicativeInfo" role="tab">指标信息</a></li>
                                 <li class="nav-item"><a class="nav-link" data-toggle="pill" href="#poj-settings-4" id="about-calc" role="tab">关于计算</a></li>
@@ -865,24 +865,22 @@
                             </div>
                         </div>
                         <div style="width:75%; padding-left: 3px; float: left;">
-                            <div class="row">
-                                <div class="col-12" id="gljRadios">
-                                    <div class="row">
-                                        <div class="col-7" style="margin-top: 5px;">
-                                            <input type="radio" class="glj-radio" name="glj" value="allGljs" checked>所有&nbsp;&nbsp;
-                                            <input type="radio" class="glj-radio" name="glj" value="stdGLJ">标准&nbsp;&nbsp;
-                                            <input type="radio" class="glj-radio" name="glj" value="complementaryGLJs">补充&nbsp;&nbsp;
-                                        </div>
-                                        <div class="input-group col-5" style="margin-bottom: 5px;">
-                                            <input type="text" class="form-control form-control-sm" placeholder="请输入筛选编码或名称" value="" id="gljSearchKeyword">
-                                            <!--  <span class="input-group-btn"><button class="btn btn-secondary btn-sm" type="button" id="gljSearch"><i class="fa fa-search" aria-hidden="true"></i></button></span>-->
-                                        </div>
+                            <div id="gljRadios">
+                                <div class="row">
+                                    <div class="col-7" style="margin-top: 5px;">
+                                        <input type="radio" class="glj-radio" name="glj" value="allGljs" checked>所有&nbsp;&nbsp;
+                                        <input type="radio" class="glj-radio" name="glj" value="stdGLJ">标准&nbsp;&nbsp;
+                                        <input type="radio" class="glj-radio" name="glj" value="complementaryGLJs">补充&nbsp;&nbsp;
+                                    </div>
+                                    <div class="input-group col-5" style="margin-bottom: 5px;">
+                                        <input type="text" class="form-control form-control-sm" placeholder="请输入筛选编码或名称" value="" id="gljSearchKeyword">
+                                        <!--  <span class="input-group-btn"><button class="btn btn-secondary btn-sm" type="button" id="gljSearch"><i class="fa fa-search" aria-hidden="true"></i></button></span>-->
                                     </div>
-                                    <!-- <div class="form-group"><input id="searchGlj" type="text" class="form-control-sm" placeholder="查询工料机"></div>-->
                                 </div>
-                                <div class="modal-auto-height col-12" style="overflow: hidden" id="gljLibSheet">
+                                <!-- <div class="form-group"><input id="searchGlj" type="text" class="form-control-sm" placeholder="查询工料机"></div>-->
+                            </div>
+                            <div class="modal-auto-height" style="overflow: hidden" id="gljLibSheet">
 
-                                </div>
                             </div>
                         </div>
                 </div>

+ 11 - 6
web/building_saas/main/js/models/calc_base.js

@@ -71,7 +71,8 @@ let cbTools = {
         return rst;
     },
     //根据公式获取相关的节点
-    getNodesByExp: function (exp, formulaNodesArr) {
+    getNodesByExp: function (node, formulaNodesArr) {
+        let exp = node.data.calcBase;
         let rst = [], ids = [];
         if(this.isUnDef(exp) || exp === ''){
             return rst;
@@ -95,7 +96,7 @@ let cbTools = {
                 findChildNodes.push(charge);
             }
             //
-            let childrenNodes = calcTools.getChildrenFormulaNodes(formulaNodesArr, findChildNodes);
+            let childrenNodes = calcTools.getChildrenFormulaNodes(node, formulaNodesArr, findChildNodes);
             for(let cNode of childrenNodes){
                 ids.push(cNode.data.ID);
             }
@@ -162,11 +163,15 @@ let cbTools = {
         mapObj['ENGINEERINGCOST'] = Object.create(null);
         let filter = ['CSXMF', 'ZZCSXMF', 'ZZCSXMDEJJZJGCF', 'ZZCSXMDEJJRGF', 'ZZCSXMDEJJCLF', 'ZZCSXMDEJJJXF', 'QTXMF', 'GF', 'SJ', 'SQGCZJ', 'AQWMSGZXF'];
         let needFixedBillsClass = ['FBFX', 'CXSM', 'QTXM', 'GF', 'SJ'];
+        //不需要关联节点的、但是下挂在固定清单分类下的基数
+        let noneFixedBillsFigures = ['JZMJ'];
         //安全文明施工专项费用只有税金和工程造价能用
         for(let figure in baseFigures){
-            //过滤相关清单固定行不存在的
-            if(needFixedBillsClass.includes(baseFigures[figure]['class']) && !baseFigures[figure]['fixedBill']){
-                continue;
+            if(!noneFixedBillsFigures.includes(baseFigures[figure]['base'])){
+                //过滤相关清单固定行不存在的
+                if(needFixedBillsClass.includes(baseFigures[figure]['class']) && !baseFigures[figure]['fixedBill']){
+                    continue;
+                }
             }
             if(filter.indexOf(baseFigures[figure]['base']) === -1){
                 mapObj['CONSTRUCTION_ORGANIZATION'][figure] = baseFigures[figure];
@@ -334,7 +339,7 @@ let cbTools = {
                 for (let node of nodes){
                     if (orderArr.includes(node)) continue;    // 已排过序的节点则跳过
                     if (node.data.calcBase){
-                        let subNodes = cbTools.getNodesByExp(node.data.calcBase, nodesArr);
+                        let subNodes = cbTools.getNodesByExp(node, nodesArr);
                         recursionNode(subNodes);
                     };
                     if (nodesArr.includes(node) && !orderArr.includes(node)) orderArr.push(node);

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

@@ -168,14 +168,14 @@ let calcTools = {
 
         return flagsArr.includes(flag);
     },
-    getChildrenFormulaNodes: function (allFormulaNodesArr, parentNodes){       // 获取结点parentNodes下有公式的子结点
+    getChildrenFormulaNodes: function (self, 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){
+                    if (cur == pn && node != self){
                         nodes.push(node);
                         break;
                     }

+ 22 - 15
web/building_saas/main/js/models/fee_rate.js

@@ -381,22 +381,29 @@ var FeeRate = {
         FeeRate.prototype.updateFeeRateFromBills=function(value,node){
             var me =this;
             if(node.sourceType === project.Bills.getSourceType()){
-                var fee_value= number_util.checkNumberValue(value,getDecimal("feeRate"));
-                if(fee_value!=null){
-                    var bill = node.data;
-                    var rate =me.getFeeRateByID(bill.feeRateID);
-                    var data=me.getfbUpdateData(rate,bill,fee_value,value);
-                    if(data==null){//只更改清单的值的情况下,由计算程序更新
-                        project.calcProgram.calcAndSave(node);
-                    }
-                    this.setFeeRateToBill(data,function (result) {
-                        if(data.hasOwnProperty('feeRate')){
-                            rate.rate=fee_value;
-                            me.onFeeRateChange(rate.ID,fee_value);
-                        }
-                    });
+                if(value === ''||value ===null ||value === undefined){//费费为空或空字符串时,请空对应的费率值和ID
+                    node.data.feeRateID = null;
+                    node.data.feeRate = null;
+                    node.changed = true;
+                    project.calcProgram.calcAndSave(node);
                 }else {
-                    projectObj.mainController.refreshTreeNode([node]);
+                    var fee_value= number_util.checkNumberValue(value,getDecimal("feeRate"));
+                    if(fee_value!=null){
+                        var bill = node.data;
+                        var rate =me.getFeeRateByID(bill.feeRateID);
+                        var data=me.getfbUpdateData(rate,bill,fee_value,value);
+                        if(data==null){//只更改清单的值的情况下,由计算程序更新
+                            project.calcProgram.calcAndSave(node);
+                        }
+                        this.setFeeRateToBill(data,function (result) {
+                            if(data.hasOwnProperty('feeRate')){
+                                rate.rate=fee_value;
+                                me.onFeeRateChange(rate.ID,fee_value);
+                            }
+                        });
+                    }else {
+                        projectObj.mainController.refreshTreeNode([node]);
+                    }
                 }
             }
         };

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

@@ -304,7 +304,7 @@ var installation_fee = {
             }
 
             for(let tem_bx of BXs){//过滤要删除的 自动生成的补项
-                if(tem_bx.code.startsWith('BAZF')&& usedBXMap[tem_bx.ParentID]==undefined){
+                if(tem_bx.code&&tem_bx.code.startsWith('BAZF')&& usedBXMap[tem_bx.ParentID]==undefined){
                     updateData.bills.delete.push(tem_bx);
                     let b_node =  project.mainTree.getNodeByID(tem_bx.ID);
                     if(b_node){

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

@@ -770,13 +770,9 @@ ProjectGLJ.prototype.getProjectGLJs = function (data,refreshPrice=true) {
     let indexList = gljKeyArray;
     for (let d of data) {
         if (d) {
-            let condition = {};
-            for (let index of indexList) {
-                if (d[index] != null && d[index] != undefined && d[index] != '') {
-                    condition[index] = d[index]
-                }
-            }
-            let glj = _.find(projectGljs, condition);
+            let glj = _.find(projectGljs, function (item) {
+                return gljOprObj.getIndex(item,indexList) == gljOprObj.getIndex(d,indexList);
+            });
             if (glj) {
                 if(refreshPrice==true){
                     d.base_price?glj.unit_price.base_price = d.base_price:'';

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

@@ -792,9 +792,9 @@ var quantity_detail = {
         };
         quantity_detail.prototype.updateRationQuantity=function(value,node,quantityEXP,editingText){
             node.data.quantityEXP = quantityEXP?quantityEXP:editingText;
-            value = scMathUtil.roundForObj(value,getDecimal("ration.quantity"));
-            value = project.quantity_detail.autoTransformQuantity(value,node);
-            value = scMathUtil.roundForObj(value,decimalObj.decimal("quantity",node))
+            //value = scMathUtil.roundForObj(value,getDecimal("ration.quantity"));
+            value = project.quantity_detail.autoTransformQuantity(value,node);//先转换再4舍5入
+            value = scMathUtil.roundForObj(value,decimalObj.decimal("quantity",node));
             node.data.quantity=value;
             if(node.parent.data.quantity&&node.parent.data.quantity!=0&&node.parent.data.quantity!=""){
                 var billQuantity = scMathUtil.roundForObj(node.parent.data.quantity,getDecimal("quantity",node.parent));

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

@@ -417,10 +417,26 @@ var ration_glj = {
             return updateData;
         };
         ration_glj.prototype.updateRationGLJByEdit = function (recode, updateField, newval, node) {
-            var me = this;
-            $.bootstrapLoading.start();
-            var callback = function (data) {
-                let initShow = false;//是否需要表格初始化显示
+            let me = this,doc = {};
+            doc[updateField] = newval;
+            me.submitChange(recode,doc,updateField,node);
+        };
+
+        ration_glj.prototype.submitChange = function(recode,updateData,updateField,node){
+            let me = this;
+            let query = {
+                'ID': recode.ID,
+                'projectID': recode.projectID,
+                'rationID': recode.rationID
+            };
+            let priceInfo = {
+                base_price: recode.basePrice,
+                market_price: recode.marketPrice
+            };
+            if(updateData['type'] != undefined || updateData['type'] != null){
+                updateData.shortName = projectObj.project.projectGLJ.getShortNameByID(updateData['type']);
+            }
+            let callback = function (data) {
                 if (updateField == 'customQuantity') {
                     me.refreshAfterQuantityUpdate(data, node);
                 } else {
@@ -429,50 +445,32 @@ var ration_glj = {
                         recode[key] = doc[key];
                     }
                     me.refreshRationAfterEdit(data,recode.rationID, node);//更新名称和定额调整状态
-                    if (recode.subList && recode.subList.length > 0) {
-                        initShow = true;
-                    }
                     if (node) {//如果不是在造价书页面直接编辑,则不用刷新
-                        if (updateField == "type" && !(newval == gljType.MAIN_MATERIAL || newval == gljType.EQUIPMENT)) {//如果改变类型后不是主材或设备,则在造价书树中移除
+                        if (updateField == "type" && !(updateData['type'] == gljType.MAIN_MATERIAL || updateData['type'] == gljType.EQUIPMENT)) {//如果改变类型后不是主材或设备,则在造价书树中移除
                             projectObj.mainController.deleteNode(node, true);
                         }
                     }
                 }
-                if (initShow == false) {//不需要初始化,只需耍新当前显示就可以了
-                    gljOprObj.showRationGLJSheetData();
-                }
                 projectObj.project.projectGLJ.loadData(function () {//等项目工料机加载完成后再给用户编辑
+                    gljOprObj.refreshView();
                     me.refreshTreeNodeIfNeeded(recode);//刷新造价书上的树节点(如果需要)
                     me.reCalcWhenGLJChange(recode);//触发计算定额以及父节点
-                    if (initShow == true) {
-                        gljOprObj.refreshView();
-                    }
                     $.bootstrapLoading.end();
                     installationFeeObj.calcInstallationFee();
                 });
-            }
-            var query = {
-                'ID': recode.ID,
-                'projectID': recode.projectID,
-                'rationID': recode.rationID
             };
-            var priceInfo = {
-                base_price: recode.basePrice,
-                market_price: recode.marketPrice
-            }
-            var doc = {};
-            doc[updateField] = newval;
-            if (updateField == "type") {
-                doc.shortName = projectObj.project.projectGLJ.getShortNameByID(newval);
-            }
+            $.bootstrapLoading.start();
             CommonAjax.post("/rationGlj/updateRationGLJByEdit", {
                 query: query,
-                doc: doc,
+                doc: updateData,
                 priceInfo: priceInfo
             }, callback, function (err) {
                 $.bootstrapLoading.end();
             });
-        }
+        };
+
+
+
         ration_glj.prototype.refreshAfterQuantityUpdate = function (data, node) {
             var me = this;
             data.glj_result.forEach(function (item) {

+ 3 - 1
web/building_saas/main/js/views/glj_col.js

@@ -18,8 +18,10 @@ let gljCol = {
             {headerName: "暂估", headerWidth: 45, dataCode: "isEstimate", dataType: "String", hAlign: "center", vAlign: "center", cellType: "checkBox"}
         ],
         view: {
-            lockColumns: [ 5, 7, 9, 10, 11]
+            lockColumns: [ 5, 7, 9, 10, 11]//这里以后改成dataCode好一点
         },
+        style:{foreColor:"#4D7BFF"},
+        navigationRightCol:['name','specs','unit'],//选中这几列时,按enter键跳到右边一列
         // 工料机类型是混凝土、砂浆、配合比、机械台班时,价格不可编辑。
         editedTyep:[GLJTypeConst.MAIN_MATERIAL,GLJTypeConst.EQUIPMENT]//主材设备
     },

+ 88 - 17
web/building_saas/main/js/views/glj_view.js

@@ -8,6 +8,8 @@ var gljOprObj = {
     ration: null,
     sheetData: [],
     checkb: null,
+    rationGljEditObj:null,//编辑定额工料机还没提交的缓存数据
+    cancelUpdate:true,
     mainTreeSelectedChange:false,
     detailSheet: null,
     detailData: [],
@@ -106,13 +108,44 @@ var gljOprObj = {
         subSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, me.onButtonClick);
         if(!projectReadOnly){
             gljContextMenu.loadGLJSpreadContextMenu();
-            //me.bindGLJEnterKey(subSpread,sheet);
+            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);
+        sheet.bind(GC.Spread.Sheets.Events.SelectionChanged,me.onRationGLJSelectionChange);
+        sheet.bind(GC.Spread.Sheets.Events.CellClick,function () {
+            //这里主要记录是否点击了sheet以外的地方,如果点击了sheet里的单元格,则将cancelUpdate设置为true不触发提交更新操作
+            me.cancelUpdate = true;//取消延时任务由selection change 事件处理
         });
     },
+    onRationGLJSelectionChange:function(sender,args){
+        let me = gljOprObj;
+        let selected = args.newSelections[0] ? args.newSelections[0] : {row: 0, col: 0};
+        console.log("selected changed-------");
+        //这主要记录是否点击了sheet以外的地方,如果点击了sheet里的单元格,则将cancelUpdate设置为true不触发提交更新操作
+        me.cancelUpdate = true;//取消延时任务由这里进行判断处理
+        console.log("change to true");
+        me.sheetInitSelection(selected,me.setting.style);
+        if(me.rationGljEditObj){
+            if(ifNeedUpdate(selected)){
+                me.updateGljFromCache();
+            }
+        }
+
+        function ifNeedUpdate(selected) {
+            let navigationRightCol = me.setting.navigationRightCol , fieldID = me.setting.header[selected.col].dataCode;
+            if(me.rationGljEditObj.row == selected.row && navigationRightCol.indexOf(fieldID)!= -1){//如果换行或者超出了三个编辑列,则提交更新
+                return false;
+            }
+            return true;
+        }
+    },
+
+    updateGljFromCache:function () {
+        let me = this;
+        if(me.rationGljEditObj){
+            projectObj.project.ration_glj.submitChange(me.rationGljEditObj.recode, me.rationGljEditObj.doc);
+        }
+        me.rationGljEditObj = null;
+    },
 
     bindGLJEnterKey:function (spread,sheet) {
         let me = this;
@@ -122,21 +155,24 @@ var gljOprObj = {
 
         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)
+            let fieldID = me.setting.header[orgCol].dataCode;
+            if(me.setting.navigationRightCol.indexOf(fieldID) != -1){
+                if(sheet.isEditing()) sheet.endEdit();
+                GC.Spread.Sheets.Commands.navigationRight.execute(spd,sheeName);
+            }else {
+                GC.Spread.Sheets.Commands.commitInputNavigationDown.execute(spd,sheeName);
+            }
+
         }
     },
-    sheetInitSelection: function (selected) {
+    sheetInitSelection: function (selected,style) {
         let me = gljOprObj;
         if(selected.row < me.sheetData.length){
-            me.sheet.setStyle(selected.row, -1, me.getSelStyle(true));
+            me.sheet.setStyle(selected.row, -1, me.getSelStyle(true,style));
         }
         me.sheet.repaint();
         if(me.preGljSelection && me.preGljSelection.row !== selected.row){
-            me.sheet.setStyle(me.preGljSelection.row, -1, me.getSelStyle(false));
+            me.sheet.setStyle(me.preGljSelection.row, -1, me.getSelStyle(false,style));
         }
         me.preGljSelection = selected;
     },
@@ -266,8 +302,13 @@ var gljOprObj = {
         let me = gljOprObj;
         me.initSelection(args.newSelections.length > 0 ? {row: args.newSelections[0].row} : {row: 0});
     },
-    getSelStyle: function (selected) {
+    getSelStyle: function (selected,settingStyle) {
         let style = new GC.Spread.Sheets.Style();
+        if(settingStyle){
+            for(let key in settingStyle){
+                style[key] = settingStyle[key];
+            }
+        }
         style.borderLeft = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
         style.borderTop = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
         style.borderRight = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
@@ -453,7 +494,7 @@ var gljOprObj = {
     showDataIfRationSelect: function (node,selectedNodeId) {
         var isShow = false;
         //恢复底色
-        this.sheet.setStyle(this.sheet.getActiveRowIndex(), -1, this.getSelStyle(false));
+        this.sheet.setStyle(this.sheet.getActiveRowIndex(), -1, this.getSelStyle(false,this.setting.style));
         if(projectReadOnly && this.setting.view.lockColumns){
             this.setting.view.lockColumns = null;
         }
@@ -524,7 +565,7 @@ var gljOprObj = {
         sheetCommonObj.showData(this.sheet, this.setting, this.sheetData);
         //初始选择
         this.preGljSelection = null;
-        this.sheetInitSelection({row: this.sheet.getActiveRowIndex(), col: 0});
+        this.sheetInitSelection({row: this.sheet.getActiveRowIndex(), col: 0},this.setting.style);
         this.sheet.getRange(-1, 0, -1, this.setting.header.length).locked(true);//锁住定额工料机的所有列
         this.detailSheet.getRange(-1, 0, -1, this.detailSetting.header.length).locked(true);//锁住工程量明细的所有列
     },
@@ -561,7 +602,7 @@ var gljOprObj = {
         }
         //初始选择
         this.preGljSelection = null;
-        this.sheetInitSelection({row: this.sheet.getActiveRowIndex(), col: this.sheet.getActiveColumnIndex()});
+        this.sheetInitSelection({row: this.sheet.getActiveRowIndex(), col: this.sheet.getActiveColumnIndex()},this.setting.style);
 
     },
     getUnitPriceCodeMap : function () {//取单价文件中,编码前缀一样的映射表
@@ -781,7 +822,6 @@ var gljOprObj = {
                 }
                 this.setGLJPrice(tem,pg);
             }
-
             temRationGLJs.push(tem);
         }
         temRationGLJs = _.sortBy(temRationGLJs, 'code');
@@ -854,10 +894,27 @@ var gljOprObj = {
             projectObj.project.projectGLJ.updatePriceFromRG(recode, updateField, newval);
         }else if(updateField == 'code'){//替换单价文件中已经有的工料机
             projectObj.project.ration_glj.updateRationGLJByChangeCode(recode, updateField, newval);
+        }else if(me.setting.navigationRightCol.indexOf(updateField) != -1){//对于名称、规格、单位先跳到下一列,保存至缓存
+            me.setToEditCache(recode,updateField, newval,args);
         } else {
             projectObj.project.ration_glj.updateRationGLJByEdit(recode, updateField, newval);
         }
     },
+    setToEditCache:function(recode,updateField,value,args){
+        let me = this;
+        if(me.rationGljEditObj == null){
+            me.rationGljEditObj = {
+                recode:recode,
+                doc:{},
+                row:args.row
+            }
+            me.rationGljEditObj.doc[updateField] = value;
+        }else {
+            if(me.rationGljEditObj.recode.ID == recode.ID){//确保编辑的是同一条数据
+                me.rationGljEditObj.doc[updateField] = value;
+            }
+        }
+    },
     isRationGLJExit:function (connectKey) {
         for(let rg of gljOprObj.sheetData){
             if(rg.isMixRatio == true){
@@ -1539,6 +1596,20 @@ $(function () {
         $('#selected_class').val("");
     })
 
+
+    $("#subSpread").focusout(function(e){//当本身或子元素失去焦点时这个事件都会发生,而且不好判断点击的是哪里。
+        if(gljOprObj.rationGljEditObj){
+            gljOprObj.cancelUpdate = false;
+            gljOprObj.timeStamp = e.timeStamp;//设置时间戳,有可能用户在表格上乱点,这个事件被触发多次
+            setTimeout(function () {//延时执行提交操作,如果点击的是spread里的地方,会把cancelUpdate改成true,这样的话就不执行提交操作
+                if(gljOprObj.timeStamp == e.timeStamp && gljOprObj.cancelUpdate  !== true){//时间戳要相同
+                    gljOprObj.updateGljFromCache();
+                }
+            },200)
+        }
+    });
+
+
     function getcmpUpdateData(items) {
         var data = {
             "updateItems": [],

+ 36 - 65
web/building_saas/main/js/views/importBills.js

@@ -23,6 +23,10 @@ const importBills = (function(){
         return _isDef(data) ? data.toString().replace(/[\r,\n,\s,\t]/g, '') : data;
     }
 
+    function _deNR(data) {
+        return _isDef(data) ? data.toString().replace(/\r\r/g, '\r') : data;
+    }
+
     //列名对应中文字符
     const colText = {
         serialNo: ['序号'],
@@ -150,39 +154,39 @@ const importBills = (function(){
                 continue;
             }
             //序号
-            if(colMapping.serialNo === undefined && cellData === colText.serialNo[0]){
+            if(colMapping.serialNo === undefined && _deESC(cellData) === colText.serialNo[0]){
                 colMapping.serialNo = colIdx;
             }
             //编码
-            else if(colMapping.code === undefined && (cellData === colText.code[0] || cellData === colText.code[1])){
+            else if(colMapping.code === undefined && (_deESC(cellData) === colText.code[0] || _deESC(cellData) === colText.code[1])){
                 colMapping.code = colIdx;
             }
             //名称
-            else if(colMapping.name === undefined && (cellData === colText.name[0] || cellData === colText.name[1])){
+            else if(colMapping.name === undefined && (_deESC(cellData) === colText.name[0] || _deESC(cellData) === colText.name[1])){
                 colMapping.name = colIdx;
             }
             //项目特征
-            else if(colMapping.itemCharacterText === undefined && (cellData === colText.itemCharacterText[0] || cellData === colText.itemCharacterText[1])){
+            else if(colMapping.itemCharacterText === undefined && (_deESC(cellData) === colText.itemCharacterText[0] || _deESC(cellData) === colText.itemCharacterText[1])){
                 colMapping.itemCharacterText = colIdx;
             }
             //单位
-            else if(colMapping.unit === undefined && (cellData === colText.unit[0] || cellData === colText.unit[1])){
+            else if(colMapping.unit === undefined && (_deESC(cellData) === colText.unit[0] || _deESC(cellData) === colText.unit[1])){
                 colMapping.unit = colIdx;
             }
             //工程量
-            else if(colMapping.quantity === undefined && (cellData === colText.quantity[0] || cellData === colText.quantity[1])){
+            else if(colMapping.quantity === undefined && (_deESC(cellData) === colText.quantity[0] || _deESC(cellData) === colText.quantity[1])){
                 colMapping.quantity = colIdx;
             }
             //金额
-            else if(colMapping.money === undefined && cellData.includes(colText.money[0])){
+            else if(colMapping.money === undefined && _deESC(cellData).includes(colText.money[0])){
                 colMapping.money = colIdx;
             }
             //工程量明细
-            else if(colMapping.quantityDetail === undefined && cellData === colText.quantityDetail[0]){
+            else if(colMapping.quantityDetail === undefined && _deESC(cellData) === colText.quantityDetail[0]){
                 colMapping.quantityDetail = colIdx;
             }
             //费用明细
-            else if(colMapping.feeDetail === undefined && cellData === colText.feeDetail[0]){
+            else if(colMapping.feeDetail === undefined && _deESC(cellData) === colText.feeDetail[0]){
                 colMapping.feeDetail = colIdx;
             }
         }
@@ -330,50 +334,9 @@ const importBills = (function(){
             }
             return null;
         }
-        //excel数据与标准库数据匹配,根据清单前九位编码匹配,匹配成功则获取标准清单对应的工程专业、特征及内容
-        /*function matchStdBill(excelBill, stdData){
-            let isMatch = false;
-            let regExp = /^\d{12}$/g;
-            if(regExp.test(excelBill.code)){
-                let nineCode = excelBill.code.substr(0, 9);
-                for(let stdBill of stdData.stdBills){
-                    //set programID
-                    if(nineCode == stdBill.code){
-                        isMatch = true;
-                        excelBill.programID = stdBill.engineering ? stdBill.engineering : null;
-                        excelBill.billsLibId = stdBill.billsLibId ? stdBill.billsLibId : null;
-                        //set jobContent and itemCharacter
-                        let tempJob = [], tempCharacter = [];
-                        for(let billJob of stdBill.jobs){
-                            for(let stdJob of stdData.stdJobs) {
-                                if (billJob.id == stdJob.id) {
-                                    tempJob.push({isChecked: false, serialNo: billJob.serialNo, content: stdJob.content});
-                                }
-                            }
-                        }
-                        for(let billCharacter of stdBill.items){
-                            for(let stdCharacter of stdData.stdCharacters){
-                                if(billCharacter.id == stdCharacter.id){
-                                    let eigenvalue = [];
-                                    for(let eValue of stdCharacter.itemValue){
-                                        eigenvalue.push({isSelected: false, value: eValue.value});
-                                    }
-                                    tempCharacter.push({isChecked: false, serialNo: billCharacter.serialNo, character: stdCharacter.content, eigenvalue: eigenvalue});
-                                }
-                            }
-                        }
-                        excelBill.jobContent = tempJob;
-                        excelBill.itemCharacter = tempCharacter;
-                    }
-                }
-            }
-            if(!isMatch && excelBill.type === billType.FX){//分项不为空,同时在标准清单中不匹配,则识别为补项
-                excelBill.type = billType.BX;
-            }
-        }*/
+        let preData = null;
         for(let r = 0; r < validData.length; r++){
-            let preData = validData[r-1],
-                rData = validData[r];
+            let rData = validData[r];
             if(flag == fixedFlag.CONSTRUCTION_TECH && rData[colMapping.name] && rData[colMapping.name]['value'] === '施工技术措施项目'
                 || flag == fixedFlag.CONSTRUCTION_ORGANIZATION && rData[colMapping.name] && rData[colMapping.name]['value'] === '施工组织措施项目'){
                 continue;
@@ -386,27 +349,32 @@ const importBills = (function(){
                 let preBill = billIdx[preID];
                 if(preBill){
                     //合并续数据
-                    preBill.code += rData[colMapping.code] && rData[colMapping.code]['value'] ? rData[colMapping.code]['value'] : '';
-                    preBill.name += rData[colMapping.name] && rData[colMapping.name]['value'] ? rData[colMapping.name]['value'] : '';
-                    preBill.itemCharacterText += rData[colMapping.itemCharacterText] && rData[colMapping.itemCharacterText]['value'] ? rData[colMapping.itemCharacterText]['value'] : '';
-                    preBill.unit += rData[colMapping.unit] && rData[colMapping.unit]['value'] ? rData[colMapping.unit]['value'] : '';
-                    preBill.quantity += rData[colMapping.quantity] && rData[colMapping.quantity]['value'] ? rData[colMapping.quantity]['value'] : '';
+                    preBill.code += rData[colMapping.code] && rData[colMapping.code]['value'] && _isDef(_deESC(rData[colMapping.code]['value'])) ? rData[colMapping.code]['value'] : '';
+                    preBill.name += rData[colMapping.name] && rData[colMapping.name]['value'] && _isDef(_deESC(rData[colMapping.name]['value'])) ? rData[colMapping.name]['value'] : '';
+                    preBill.itemCharacterText += rData[colMapping.itemCharacterText] && rData[colMapping.itemCharacterText]['value'] && _isDef(_deESC(rData[colMapping.itemCharacterText]['value']))
+                        ? '\n' + _deNR(rData[colMapping.itemCharacterText]['value']) : '';
+                    preBill.unit += rData[colMapping.unit] && rData[colMapping.unit]['value'] && _isDef(_deESC(rData[colMapping.unit]['value'])) ? rData[colMapping.unit]['value'] : '';
+                    preBill.quantity += rData[colMapping.quantity] && rData[colMapping.quantity]['value'] && _isDef(_deESC(rData[colMapping.quantity]['value'])) ? rData[colMapping.quantity]['value'] : '';
                 }
             }
             else {
                 let newID = uuid.v1();
                 let pID = -1;
                 let preBill = null;
+                let preRoot = null,
+                    preLeaf = null;
                 let nodeType = 'root';//后端以此标记来设置ParentID
+                let preSerialBill = billIdx[preID];
                 if(isRoot(rData)){
-
                     //pID = 'fixedBillID';
                     preBill = billIdx[preRootID];
+                    preRoot = billIdx[preRootID];
                 }
                 else if(isLeaf(rData)){
                     nodeType = 'leaf';
                     //pID = preRootID !== -1 ? preRootID : fixedBill.ID;
                     preBill = billIdx[preLeafID];
+                    preLeaf = billIdx[preLeafID];
                 }
                 //set bill data
                 billIdx[newID] = {
@@ -414,7 +382,7 @@ const importBills = (function(){
                     ID: newID, ParentID: pID, NextSiblingID: -1,
                     code: rData[colMapping.code] && rData[colMapping.code]['value'] ? _deESC(rData[colMapping.code]['value']) : '',
                     name: rData[colMapping.name] && rData[colMapping.name]['value'] ? _deESC(rData[colMapping.name]['value']) : '',
-                    itemCharacterText: rData[colMapping.itemCharacterText] && rData[colMapping.itemCharacterText]['value'] ? rData[colMapping.itemCharacterText]['value'] : '',
+                    itemCharacterText: rData[colMapping.itemCharacterText] && rData[colMapping.itemCharacterText]['value'] ? _deNR(rData[colMapping.itemCharacterText]['value']) : '',
                     itemCharacter: [],
                     jobContentText: '',
                     jobContent: [],
@@ -427,17 +395,22 @@ const importBills = (function(){
                     fees: [],
                     projectID: projectID,
                     type: getBillType(rData, flag)};
-                //match stdBill and reset programID、jobContent、itemCharacter
-                //matchStdBill(billIdx[newID], stdData);
                 //update preBill NextSibling
-                if(preBill){
-                    preBill.NextSiblingID = newID;
+                if(nodeType === 'root' && preRoot){
+                    preRoot.NextSiblingID = newID;
                 }
+                else if(nodeType === 'leaf' && preLeaf && preSerialBill && preSerialBill.nodeType === preLeaf.nodeType){
+                    preLeaf.NextSiblingID = newID;
+                }
+               /* if(preBill){
+                    preBill.NextSiblingID = newID;
+                }*/
                 //set new preID
                 preID = newID;
                 preRootID = isRoot(rData) ? newID : preRootID;
                 preLeafID = isLeaf(rData) ? newID : preLeafID;
             }
+            preData = rData;
         }
         for(let i in billIdx){
             rst.push(billIdx[i]);
@@ -457,13 +430,11 @@ const importBills = (function(){
                 validSheetsDatas.push({position: uploadPosition, colMapping: validSheets[uploadPosition][0].colMapping, validExcelData: validExcelData});
             }
         }
-        console.log(validSheetsDatas);
         for(let validSheetData of validSheetsDatas){
             if(validSheetData.validExcelData.length > 0){
                 rst[validSheetData.position] = parseToBillData(validSheetData.validExcelData, validSheetData.colMapping, positionFlag[validSheetData.position], projectID);
             }
         }
-        console.log(rst);
         return rst;
     }
 

+ 2 - 0
web/building_saas/main/js/views/main_tree_col.js

@@ -548,6 +548,8 @@ $('#switchTznr').click(function () {
         me.setVisible('itemCharacterText', false);
         me.updateColSetting(true);
     }
+    let mainSheet = projectObj.mainSpread.getActiveSheet();
+    mainSheet.showRow(mainSheet.getActiveRowIndex(), GC.Spread.Sheets.VerticalPosition.center);
 });
 
 $('#poj-set').on('shown.bs.modal', function (e) {

+ 1 - 1
web/building_saas/main/js/views/project_property_decimal_view.js

@@ -10,7 +10,7 @@ let defaultDecimal = {
         ration: {editable: true, data: {quantity: 4, unitPrice: 2, totalPrice: 2}},
         glj: {editable: true, data: {quantity: 4, unitPriceHasMix: 2, unitPrice: 3}},
         material: {editable: false, data: 5},
-        feeRate: {editable: true, data: 2},
+        feeRate: {editable: true, data: 3},
         quantity_detail: {editable: false, data: 4},
         process: {editable: false, data: 6}
     }

+ 48 - 19
web/building_saas/main/js/views/project_view.js

@@ -35,7 +35,7 @@ var projectObj = {
         if($('#linkComments').hasClass('active')){
             subViewObj.loadComments(node);
         }
-        gljOprObj.mainTreeSelectedChange = true;
+        gljOprObj.mainTreeSelectedChange = gljOprObj.selectedNodeId != node.getID();
         gljOprObj.showDataIfRationSelect(node);
         if (activeSubSheetIsCalcProgram())
             calcProgramObj.refreshCalcProgram(node, 3);
@@ -284,21 +284,45 @@ var projectObj = {
                 let libId = projectInfoObj.projectInfo.engineeringInfo.bill_lib[0].id;
                 CommonAjax.post('/stdBillsEditor/getStdBillsByCode', {userId: userID, billsLibId: libId, code: stdCode}, function (data) {
                     if (data) {
-                        //data.itemCharacter = pageCCOprObj.safeItemCharater(data.itemCharacter);
-                        node.data.name = data.name;
-                        if(node.data.type == billType.BX){//从清单库中找到标准清单的话,要把补项改成分项
-                            node.data.type = billType.FX;
+                        function sortItems(serialItems, items){
+                            for(let item of items){
+                                for(let serialItem of serialItems){
+                                    if(item.id === serialItem.id){
+                                        item.serialNo = serialItem.serialNo;
+                                    }
+                                }
+                            }
+                            items.sort(function (a, b) {
+                                let rst = 0;
+                                if(a.serialNo > b.serialNo){
+                                    rst = 1;
+                                }
+                                else if(a.serialNo < b.serialNo){
+                                    rst = -1;
+                                }
+                                return rst;
+                            });
+                        }
+                        function updateBeforeInsert(node, data) {
+                            node.data.name = data.name;
+                            if(node.data.type == billType.BX){//从清单库中找到标准清单的话,要把补项改成分项
+                                node.data.type = billType.FX;
+                            }
+                            sortItems(data.items, data.itemCharacter);
+                            sortItems(data.jobs, data.jobContent);
+                            pageCCOprObj.setItemContentNode(node, data.jobContent, data.itemCharacter, node.data.name);
+                            pageCCOprObj.setCacheAndShow(node);
                         }
-                        pageCCOprObj.setItemContentNode(node, data.jobContent, data.itemCharacter, node.data.name);
                         if (/\//.test(data.unit)) {
                             let existB = projectObj.project.Bills.sameStdCodeBillsData(data.code);
                             if (existB) {
+                                updateBeforeInsert(node, data);
                                 data.unit = existB.unit;
-                                //
                                 project.Bills.replaceBills(node.source, data, formatCode);
                                 projectObj.mainController.refreshTreeNode([node], false);
                             } else {
                                 ConfirmModal.stdBillsUnit.check(data, function (std) {
+                                    updateBeforeInsert(node, data);
                                     project.Bills.replaceBills(node.source, std, formatCode);
                                     projectObj.mainController.refreshTreeNode([node], false);
                                 }, function () {
@@ -306,6 +330,7 @@ var projectObj = {
                                 });
                             }
                         } else {
+                            updateBeforeInsert(node, data);
                             project.Bills.replaceBills(node.source, data, formatCode);
                             projectObj.mainController.refreshTreeNode([node], false);
                         }
@@ -540,18 +565,19 @@ var projectObj = {
     },
     onCellDoubleClick: function (sender, info){
         let project = projectObj.project;
-        let node = project.mainTree.items[info.row];
-        let fieldName = projectObj.mainController.setting.cols[info.col].data.field;
-        if(fieldName == 'marketUnitFee'){
-            if(gljOprObj.hasComposition(node.data,true)){
-                alert("当前人材机的市场价由组成物计算得出,不可直接修改。");
-                return;
+        if(info.row && info.col){
+            let node = project.mainTree.items[info.row];
+            let fieldName = projectObj.mainController.setting.cols[info.col].data.field;
+            if(fieldName == 'marketUnitFee'){
+                if(gljOprObj.hasComposition(node.data,true)){
+                    alert("当前人材机的市场价由组成物计算得出,不可直接修改。");
+                    return;
+                }
+            }
+            if(fieldName == 'code' && node){
+                projectObj.showBillOrRationLib(node)
             }
         }
-        if(fieldName == 'code' && node){
-            projectObj.showBillOrRationLib(node)
-        }
-
     },
     showBillOrRationLib(node){
         let BILLS = projectObj.project.Bills;
@@ -2483,6 +2509,7 @@ $('#customFile').change(function () {
        let sDate = +new Date();
        excelIo.open(excelFile, function (json) {
            importJson = json;
+           console.log(json);
            //读取各个表及表名
            importBills.setImportSheetsInfo(importJson.sheets);
            console.log(`解析Excel文件时间:${+new Date() - sDate}`);
@@ -2666,7 +2693,6 @@ function doAfterImport(resData){
         }
         //如果清单未锁定,导入后锁定清单
         if(!projectInfoObj.projectInfo.property.lockBills){
-            console.log('enterLockBillsClick');
             $("a[name='lockBills']").click();
         }
         $.bootstrapLoading.end();
@@ -2698,13 +2724,16 @@ $(function () {
         $('#uploadSheetsHead').hide();
     });
 
-    $("#billsSpread").mouseover(function(){
+   /* $("#billsSpread").mouseover(function(){
         spreadAutoFocus(projectObj.mainSpread,subSpread);
     });
 
     $("#subSpread").mouseover(function(){
         spreadAutoFocus(subSpread,projectObj.mainSpread);
     });
+*/
+
+
 
     $("#paste_confirm").click(function (){
         let selected = projectObj.project.mainTree.selected;

+ 37 - 104
web/building_saas/main/js/views/zmhs_view.js

@@ -13,7 +13,7 @@ let zmhs_obj = {
             {headerName: "内容", headerWidth: 350, dataCode: "content", dataType: "String", hAlign: "left"}
         ],
         view: {
-            lockColumns: [0,1,2]
+            lockColumns:[0,1,2]
         }
     },
     assSpread:null,
@@ -62,14 +62,13 @@ let zmhs_obj = {
             coeList = ration_coe.getCoeByRationID(ration.ID);
         }
         sheetCommonObj.showData(this.coeSheet, this.coeSetting,coeList);
-        this.coeSheet.floatingObjects.remove("customerCoe");
         if (coeList.length > 0) {
             var cus_index = _.findIndex(coeList, function (item) {
                 return item.coeID == -1;
             })
             if (cus_index != -1) {
-                this.addDropDownList();
-                this.addCusButton(cus_index, 1, coeList[cus_index].name);
+                this.coeSheet.getCell(cus_index, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
+                this.coeSheet.setCellType(cus_index, 1, sheetCommonObj.getCustomerCoeCellType(this.generateHtmlString,this.bindCusEditorValue,this.updateCusCoeAfterEditor), GC.Spread.Sheets.SheetArea.viewport);
             }
         }
         this.coeSheetData = coeList;
@@ -96,77 +95,41 @@ let zmhs_obj = {
         if(this.coeSpread&& this.assSpread && $('#linkZMHS').hasClass('active')){
             this.showCoeData(node);
             this.showAssData(node);
-            //hide floatingObject
-            var floatingObject = this.coeSheet.floatingObjects.get('customerCoe');
-            if (floatingObject) {
-                floatingObject.isVisible(false);
-            }
         }
     },
     onCoeCellClick: function (sender, args) {
         let me = zmhs_obj;
-        let floatingObject = me.coeSheet.floatingObjects.get('customerCoe');
-        if(floatingObject){
-            let isVisable = floatingObject.isVisible();
-            if (isVisable) {
-                let result = me.checkIfNeedUpdate();
-                if (result.isNeed) {
-                    projectObj.project.ration_coe.updateCustomerCoe(result);
-                }
-                floatingObject.isVisible(false);
-            }
+        let sheet = args.sheet, row = args.row, col = args.col;
+        if(sheet.getCell(row, col).locked() !=true){
+            if(!sheet.isEditing()) sheet.startEdit();
         }
-
     },
     onButtonClick:function (sender, args) {
         let me = zmhs_obj;
         let sheet = args.sheet, row = args.row, col = args.col;
         let cellType = sheet.getCellType(row, col);
-        if(args.sheet.isEditing()){
-            args.sheet.endEdit();
-        }
-        if (cellType instanceof GC.Spread.Sheets.CellTypes.Button) {
-            if(args.sheetName == 'ration_coe'){
-                me.onCusButtonClick(sender, args);
-            }
-        } else {
+        if (args.sheetName == 'ration_coe' && cellType instanceof GC.Spread.Sheets.CellTypes.CheckBox) {
             me.onCoeCheckBoxClick(sender, args)
         }
     },
-    onCusButtonClick: function (sender, args) {
-        var me = zmhs_obj;
-        var floatingObject = me.coeSheet.floatingObjects.get('customerCoe');
-        var isVisable = floatingObject.isVisible();
-        if (!isVisable) {
-            me.coeSheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).locked(false);
-            me.showFloationObject(floatingObject, me.coeSheetData[args.row]);
-        } else {
-            var result = me.checkIfNeedUpdate();
-            if (result.isNeed) {
-                projectObj.project.ration_coe.updateCustomerCoe(result);
-            }
-            floatingObject.isVisible(false);
+    bindCusEditorValue:function(context){
+        let me = zmhs_obj;
+        if(me.coeSheetData[context.row]){
+            let data = me.coeSheetData[context.row];
+            $('#coe_ration').val(data.coes[0].amount);
+            $('#manual').val(data.coes[1].amount);
+            $('#material').val(data.coes[2].amount);
+            $('#manchine').val(data.coes[3].amount);
+            $('#mainM').val(data.coes[4].amount);
+            $('#equipment').val(data.coes[5].amount);
         }
     },
-    showFloationObject(floatingObject, data){
-        floatingObject.isVisible(true);
-        var sheet = this.coeSheet;
-        var startRow = this.coeSheetData.length;
-        var endRow = startRow + 7;
-        floatingObject.startRow(startRow);
-        floatingObject.startColumn(1);
-        floatingObject.endColumn(2);
-        floatingObject.endRow(endRow);
-        this.bindFloadingObjectValue(data);
-        sheet.repaint();
-    },
-    bindFloadingObjectValue(data){
-        $('#coe_ration').val(data.coes[0].amount);
-        $('#manual').val(data.coes[1].amount);
-        $('#material').val(data.coes[2].amount);
-        $('#manchine').val(data.coes[3].amount);
-        $('#mainM').val(data.coes[4].amount);
-        $('#equipment').val(data.coes[5].amount);
+    updateCusCoeAfterEditor:function(){
+        let me = zmhs_obj;
+        let result = me.checkIfNeedUpdate();
+        if (result.isNeed) {
+            projectObj.project.ration_coe.updateCustomerCoe(result);
+        }
     },
     onInputChange(id, name){
         var coe = _.find(zmhs_obj.coeSheetData, function (c) {
@@ -266,50 +229,23 @@ let zmhs_obj = {
         let recode = me.coeSheetData[args.row];
         projectObj.project.ration_coe.adjustCoeClick(recode, newval);
     },
-    addCusButton: function (row, col, text) {
-        zmhs_obj.coeSheet.suspendPaint();
-        var cus_button = new GC.Spread.Sheets.CellTypes.Button();
-        zmhs_obj.coeSheet.setCellType(row, col, cus_button, GC.Spread.Sheets.SheetArea.viewport);
-        cus_button.marginLeft(0);
-        cus_button.marginTop(0);
-        cus_button.marginRight(-2);
-        cus_button.marginBottom(-2);
-        cus_button.text(text);
-        cus_button.buttonBackColor('white');
-        zmhs_obj.coeSheet.resumePaint();
-        //zmhs_obj.coeSheet.repaint();
-    },
-    addDropDownList: function () {
-        var sheet = this.coeSheet;
-        sheet.suspendPaint();
-        var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("customerCoe");
-        var div = document.createElement('div');
-        div.innerHTML = this.generateHtmlString();
-        customFloatingObject.startRow(1);
-        customFloatingObject.startColumn(1);
-        customFloatingObject.endColumn(2);
-        customFloatingObject.endRow(2);
-        $(div).css('background', 'white');
-        customFloatingObject.content(div);
-        sheet.floatingObjects.add(customFloatingObject);
-        customFloatingObject.isVisible(false);
-        sheet.resumePaint();
-    },
-    generateHtmlString: function () {
-        var newString = "<form ><table border='1px' bordercolor='#CCCCCC' cellspacing='0px' style='border-collapse:collapse;font-size: 10px;>";
-        newString += this.getOneRow('定额', 0, 'coe_ration');
-        newString += this.getOneRow('人工', 1, 'manual');
-        newString += this.getOneRow('材料', 2, 'material');
-        newString += this.getOneRow('机械', 3, 'manchine');
-        newString += this.getOneRow('主材', 4, 'mainM');
-        newString += this.getOneRow('设备', 5, 'equipment');
+    generateHtmlString: function (context,cellRect) {
+        let me = zmhs_obj;
+        let height = cellRect.height;
+        let newString = "<div style='height:"+ height+"px'><div onclick='zmhs_obj.coeSheet.endEdit()' style='margin:-1px 1px 0px'>自定义系数</div></div><form style='margin-top:1px' ><table  width='100%'  cellpadding='0'  border='1px' bordercolor='#CCCCCC' cellspacing='0px' style='border-collapse:collapse;font-size: 10px;'>";
+        newString += me.getOneRow('定额', 0, 'coe_ration',height);
+        newString += me.getOneRow('人工', 1, 'manual',height);
+        newString += me.getOneRow('材料', 2, 'material',height);
+        newString += me.getOneRow('机械', 3, 'manchine',height);
+        newString += me.getOneRow('主材', 4, 'mainM',height);
+        newString += me.getOneRow('设备', 5, 'equipment',height);
         newString += "</table></form>";
         return newString;
     },
-    getOneRow: function (text, name, id) {
-        var rowstr = "<tr style='height:10px'><td style='width: 50px'>" + text
-            + ":</td><td style='width: 70px' align='right'><input type='text'value='1' name=" + name
-            + " style='width:30px;border:0;height:14px' align='right' id=" + id + " onchange='zmhs_obj.onInputChange(this.id,this.name)'onfocus = 'zmhs_obj.coeStartEdit()' autocomplete='off'></td></tr>";
+    getOneRow: function (text, name, id,inputHeight) {
+        var rowstr = "<tr ><td style='width: 40%'>" + text
+            + ":</td><td style='width: 60%' align='right'><input type='text' value='1' name=" + name
+            + " style='width:40px;border:0;height:"+ inputHeight+"px;' align='right' id=" + id + " onchange='zmhs_obj.onInputChange(this.id,this.name)' autocomplete='off'></td></tr>";
         return rowstr;
 
     },
@@ -319,7 +255,6 @@ let zmhs_obj = {
         }else {
             zmhs_obj.coeSheet.startEdit();
         }
-
     },
     onAssEditEnded:function (e,args) {
         var me = zmhs_obj;
@@ -341,7 +276,6 @@ let zmhs_obj = {
         if (args.sheetName == 'ration_ass') {
             me.updateRationAss(args);
         }
-
     },
     updateRationAss: function (args) {
         var me = zmhs_obj;
@@ -389,5 +323,4 @@ let zmhs_obj = {
         }
         return true;
     }
-
 };