Browse Source

造价书回车键控制,小数位数:人材机单价(有组成物)

zhongzewei 7 years ago
parent
commit
ca18980875

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

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

+ 11 - 5
web/building_saas/main/html/main.html

@@ -621,15 +621,21 @@
                                             </div>
                                             </div>
                                             <h5 class="mt-3">人材机</h5>
                                             <h5 class="mt-3">人材机</h5>
                                             <div class="row m-0">
                                             <div class="row m-0">
-                                                <div class="col-sm-3">
-                                                    <div class="input-group input-group-sm mb-2">
+                                                <div style="width: 23.3%;">
+                                                    <div style="width:120px;" class="input-group input-group-sm mb-2">
                                                         <div class="input-group-addon">消耗量</div>
                                                         <div class="input-group-addon">消耗量</div>
                                                         <input type="number" name="glj-quantity" class="form-control" value="2" step="1" max="6" min="0">
                                                         <input type="number" name="glj-quantity" class="form-control" value="2" step="1" max="6" min="0">
                                                     </div>
                                                     </div>
                                                 </div>
                                                 </div>
-                                                <div class="col-sm-3">
-                                                    <div class="input-group input-group-sm mb-2">
-                                                        <div class="input-group-addon">单价</div>
+                                                <div  style="width: 38.3%;">
+                                                    <div style="width:190px;" class="input-group input-group-sm mb-2">
+                                                        <div class="input-group-addon">单价(有组成物)</div>
+                                                        <input type="number" name="glj-unitPriceHasMix" class="form-control" value="2" step="1" max="6" min="0">
+                                                    </div>
+                                                </div>
+                                                <div style="width: 38.3%;">
+                                                    <div  style="width:190px;" class="input-group input-group-sm mb-2">
+                                                        <div class="input-group-addon">单价(无组成物)</div>
                                                         <input type="number" name="glj-unitPrice" class="form-control" value="2" step="1" max="6" min="0">
                                                         <input type="number" name="glj-unitPrice" class="form-control" value="2" step="1" max="6" min="0">
                                                     </div>
                                                     </div>
                                                 </div>
                                                 </div>

+ 1 - 0
web/building_saas/main/js/controllers/project_controller.js

@@ -145,6 +145,7 @@ ProjectController = {
     addFX:function(project, sheetController) {//添加分项
     addFX:function(project, sheetController) {//添加分项
         if (!project || !sheetController) { return null; }
         if (!project || !sheetController) { return null; }
         let selected = project.mainTree.selected;
         let selected = project.mainTree.selected;
+        console.log(selected);
         if(selected.data.type==billType.FB||(selected.parent==null&&isFlag(selected.data)&&selected.data.flagsIndex.fixed.flag==fixedFlag.SUB_ENGINERRING)){//选中的是分部或者是分部分项工程,则插入做为最后一个子项
         if(selected.data.type==billType.FB||(selected.parent==null&&isFlag(selected.data)&&selected.data.flagsIndex.fixed.flag==fixedFlag.SUB_ENGINERRING)){//选中的是分部或者是分部分项工程,则插入做为最后一个子项
             this.addSpecialBill(project, sheetController,selected, null,true,billType.FX);
             this.addSpecialBill(project, sheetController,selected, null,true,billType.FX);
         }
         }

+ 24 - 0
web/building_saas/main/js/models/calc_base.js

@@ -239,6 +239,30 @@ let cbTools = {
             //根据基数和行引用获取清单ID
             //根据基数和行引用获取清单ID
             for(let i = 0, len = bases.length; i < len; i++){
             for(let i = 0, len = bases.length; i < len; i++){
                 //基数是跟清单直接关联的
                 //基数是跟清单直接关联的
+                /*if(bases[i]['type'] === 'base' && cbTools.isDef(calcBase.baseFigures[bases[i]['value']])){
+                    //税前工程造价算法用了分部分项、项目措施、其他项目、规费里的底层价格,相当于引用了4条固定清单,特殊处理
+                    if(bases[i]['value'] === '税前工程造价'){
+                        let subEngineering = cbTools.findBill(calcBase.fixedFlag.SUB_ENGINERRING),
+                            measure = cbTools.findBill(calcBase.fixedFlag.MEASURE),
+                            other = cbTools.findBill(calcBase.fixedFlag.OTHER),
+                            charge = cbTools.findBill(calcBase.fixedFlag.CHARGE);
+                        if(subEngineering){
+                            block.push(subEngineering.ID);
+                        }
+                        if(measure){
+                            block.push(measure.ID);
+                        }
+                        if(other){
+                            block.push(other.ID);
+                        }
+                        if(charge){
+                            block.push(charge.ID);
+                        }
+                    }
+                    else if(cbTools.isDef(calcBase.baseFigures[bases[i]['value']]['fixedBill'])){
+                        block.push(calcBase.baseFigures[bases[i]['value']]['fixedBill']['bill']['ID']);
+                    }
+                }*/
                 if(bases[i]['type'] === 'base' && cbTools.isDef(calcBase.baseFigures[bases[i]['value']])
                 if(bases[i]['type'] === 'base' && cbTools.isDef(calcBase.baseFigures[bases[i]['value']])
                     && cbTools.isDef(calcBase.baseFigures[bases[i]['value']]['fixedBill'])){
                     && cbTools.isDef(calcBase.baseFigures[bases[i]['value']]['fixedBill'])){
                     block.push(calcBase.baseFigures[bases[i]['value']]['fixedBill']['bill']['ID']);
                     block.push(calcBase.baseFigures[bases[i]['value']]['fixedBill']['bill']['ID']);

+ 0 - 1
web/building_saas/main/js/models/project.js

@@ -361,7 +361,6 @@ var PROJECT = {
         };
         };
         //清单是否属于锁定范围(分部分项、措施项目)
         //清单是否属于锁定范围(分部分项、措施项目)
         project.prototype.withinBillsLocked = function (node) {
         project.prototype.withinBillsLocked = function (node) {
-            console.log(node);
             const lockedFixFlag = [fixedFlag.SUB_ENGINERRING, fixedFlag.MEASURE];
             const lockedFixFlag = [fixedFlag.SUB_ENGINERRING, fixedFlag.MEASURE];
             while(node){
             while(node){
                 if(!node.parent){
                 if(!node.parent){

+ 34 - 2
web/building_saas/main/js/views/project_property_decimal_view.js

@@ -8,7 +8,7 @@ let defaultDecimal = {
     _def: {//editable: 开放给用户编辑的
     _def: {//editable: 开放给用户编辑的
         bills: {editable: true, data: {unitPrice: 2, totalPrice: 2}},
         bills: {editable: true, data: {unitPrice: 2, totalPrice: 2}},
         ration: {editable: true, data: {quantity: 4, unitPrice: 2, totalPrice: 2}},
         ration: {editable: true, data: {quantity: 4, unitPrice: 2, totalPrice: 2}},
-        glj: {editable: true, data: {quantity: 4, unitPrice: 3}},
+        glj: {editable: true, data: {quantity: 4, unitPriceHasMix: 2, unitPrice: 3}},
         material: {editable: false, data: 5},
         material: {editable: false, data: 5},
         feeRate: {editable: true, data: 2},
         feeRate: {editable: true, data: 2},
         quantity_detail: {editable: false, data: 4},
         quantity_detail: {editable: false, data: 4},
@@ -19,6 +19,36 @@ let defaultDecimal = {
 let decimalObj = Object.create(null);
 let decimalObj = Object.create(null);
 
 
 decimalObj.decimal = function (field, node) {
 decimalObj.decimal = function (field, node) {
+    if(field.sameText('unitFee')){
+        field = 'unitPrice';
+    }
+    else if(field.sameText('totalFee')){
+        field = 'totalPrice';
+    }
+    if(!isDef(node) && isDef(field)){
+        let fields = field.split('.');
+        let fieldDecimal = fields.length === 2 ? this[fields[0]][fields[1]] : this[fields[0]];
+        return  fieldDecimal ? fieldDecimal : this.process;
+    }
+    else {
+        if(node.sourceType === projectObj.project.Bills.getSourceType()){
+            if(field === 'quantity'){
+                return billsQuanDecimal.decimal(node.data.unit);
+            }
+            else {
+                return returnV(this['bills'][field], this.process);
+            }
+        }
+        else if(node.sourceType === projectObj.project.Ration.getSourceType()){
+            return returnV(this['ration'][field], this.process);
+        }
+        else if(node.sourceType === projectObj.project.ration_glj.getSourceType()){
+            return returnV(this['glj'][field], this.process);
+        }
+    }
+};
+
+/*decimalObj.decimal = function (field, node) {
     if(isDef(field)){
     if(isDef(field)){
         if(field === 'feeRate'||field==="quantity_detail"){
         if(field === 'feeRate'||field==="quantity_detail"){
             return this[field];
             return this[field];
@@ -44,7 +74,7 @@ decimalObj.decimal = function (field, node) {
         }
         }
     }
     }
     return  this[field]?this[field]:this.process;
     return  this[field]?this[field]:this.process;
-};
+};*/
 
 
 function returnV(v, r){
 function returnV(v, r){
     if(isDef(v)){
     if(isDef(v)){
@@ -104,6 +134,8 @@ function toUpdateDecimal(orgV, newV){
 }
 }
 
 
 function setDecimal(_digits, data){
 function setDecimal(_digits, data){
+    console.log(_digits);
+    console.log(data)
     if(isDef(data)){
     if(isDef(data)){
         for(let attr in data){
         for(let attr in data){
             _digits[attr] = returnV(data[attr], defaultDecimal['_def'][attr]['data']);
             _digits[attr] = returnV(data[attr], defaultDecimal['_def'][attr]['data']);

+ 81 - 14
web/building_saas/main/js/views/project_view.js

@@ -695,15 +695,16 @@ var projectObj = {
                 that.mainController.bind('refreshBaseActn', that.refreshBaseActn);
                 that.mainController.bind('refreshBaseActn', that.refreshBaseActn);
                 that.mainController.bind(TREE_SHEET_CONTROLLER.eventName.beforeTreeSelectedChange, that.beforeMainTreeSelectedChange);
                 that.mainController.bind(TREE_SHEET_CONTROLLER.eventName.beforeTreeSelectedChange, that.beforeMainTreeSelectedChange);
                 that.mainController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, that.treeSelectedChanged);
                 that.mainController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, that.treeSelectedChanged);
-
-                //that.bindEnterKey(that.mainSpread, 'mainEnterKey', that.mainSpreadEnterKey);
+                if(!projectReadOnly){
+                    that.bindEnterKey(that.mainSpread, 'mainEnterKey', that.mainSpreadEnterKey);
+                }
                 setTimeout(function () {
                 setTimeout(function () {
                     that.mainSpread.getActiveSheet().startEdit();//这两句需要挺多时间,而又需要在editend 事件前触发,而这些又不影响计算,所以这里用异步的方法
                     that.mainSpread.getActiveSheet().startEdit();//这两句需要挺多时间,而又需要在editend 事件前触发,而这些又不影响计算,所以这里用异步的方法
                     that.mainSpread.getActiveSheet().endEdit();
                     that.mainSpread.getActiveSheet().endEdit();
 
 
                     that.mainSpread.bind(GC.Spread.Sheets.Events.EditEnded, that.mainSpreadEditEnded);
                     that.mainSpread.bind(GC.Spread.Sheets.Events.EditEnded, that.mainSpreadEditEnded);
                 },100);
                 },100);
-                that.mainSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, that.amountAreaNumber);
+                that.mainSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, that.amountAreaNumber);//选中统计专用,节点相关操作在treeSelectedChanged里些
                 that.mainSpread.bind(GC.Spread.Sheets.Events.LeaveCell, that.mainSpreadLeaveCell);
                 that.mainSpread.bind(GC.Spread.Sheets.Events.LeaveCell, that.mainSpreadLeaveCell);
                 that.mainSpread.bind(GC.Spread.Sheets.Events.EnterCell, that.mainSpreadEnterCell);
                 that.mainSpread.bind(GC.Spread.Sheets.Events.EnterCell, that.mainSpreadEnterCell);
                 that.mainSpread.bind(GC.Spread.Sheets.Events.EditStarting, that.mainSpreadEditStarting);
                 that.mainSpread.bind(GC.Spread.Sheets.Events.EditStarting, that.mainSpreadEditStarting);
@@ -754,28 +755,92 @@ var projectObj = {
         }
         }
         //正常情况,焦点应该是在下一行的同一列
         //正常情况,焦点应该是在下一行的同一列
         let newRow = orgRow + 1, newCol = orgCol;
         let newRow = orgRow + 1, newCol = orgCol;
+        //getColByField getVisible都不提出来,减少调用次数
         if(selected){
         if(selected){
             //在分项/补项的编码单元格回车,焦点应跳动至本行的工程量单元格
             //在分项/补项的编码单元格回车,焦点应跳动至本行的工程量单元格
             if(orgField && orgField === 'code' && selected.sourceType === me.project.Bills.getSourceType() && [billType.FX, billType.BX].includes(selected.data.type)){
             if(orgField && orgField === 'code' && selected.sourceType === me.project.Bills.getSourceType() && [billType.FX, billType.BX].includes(selected.data.type)){
                 let quantityCol = colSettingObj.getColByField('quantity');
                 let quantityCol = colSettingObj.getColByField('quantity');
                 let quantityVisible = colSettingObj.getVisible('quantity');
                 let quantityVisible = colSettingObj.getVisible('quantity');
-                if(quantityCol && quantityVisible){
+                if(quantityCol !== null && quantityVisible !== false){
                     newRow = orgRow;
                     newRow = orgRow;
                     newCol = quantityCol;
                     newCol = quantityCol;
                 }
                 }
             }
             }
-            //在分项/补项的工程量单元格回车,如果其下有定额/量价/人材机,焦点应跳动至其下第一条定额/量价/人材机的工程量;
-            //如果其下没有定额/量价/人材机,则自动在其下插入一条定额空行,在其后自动插入一条分项空行,焦点跳动至定额空行的编码单元格。
-            if(orgField && orgField === 'quantity' && selected.sourceType === me.project.Bills.getSourceType() && [billType.FX, billType.BX].includes(selected.data.type)
-                && selected.children.length === 0){
-                me.project.Ration.addNewRation(null,rationType.ration, function () {
-                    newRow = sheet.getActiveRowIndex();
-                    newCol = sheet.getActiveColumnIndex();
-                });
+            else if(orgField && orgField === 'quantity' && selected.sourceType === me.project.Bills.getSourceType() && [billType.FX, billType.BX].includes(selected.data.type)){
+                //在分项/补项的工程量单元格回车,如果其下有定额/量价/人材机,焦点应跳动至其下第一条定额/量价/人材机的工程量,如果是空行,则跳到至第一条定额xx的编码;
+                if(selected.children.length !== 0 && !(isDef(selected.children[0].data.code) && selected.children[0].data.code.toString().trim() !== '')){
+                    let codeCol = colSettingObj.getColByField('code');
+                    let codeVisible = colSettingObj.getVisible('code');
+                    newRow = orgRow + 1;
+                    if(codeCol !== null && codeVisible !== false){
+                        newCol = codeCol;
+                    }
+                }
+                //如果其下没有定额/量价/人材机,则自动在其下插入一条定额空行,在其后自动插入一条分项空行,焦点跳动至定额空行的编码单元格。
+                else if(selected.children.length === 0){
+                    //在其后插入分项
+                    if(!(projectInfoObj.projectInfo.property.lockBills && projectObj.project.withinBillsLocked(projectObj.project.mainTree.selected))){
+                        ProjectController.addFX(me.project, me.mainController);
+                        //将焦点行设置成原本的行,以插入定额
+                        me.mainController.setTreeSelected(me.project.mainTree.items[orgRow]);
+                    }
+                    //插入定额
+                    me.project.Ration.addNewRation(null, rationType.ration, function () {
+                        newRow = sheet.getActiveRowIndex();
+                        let codeCol = colSettingObj.getColByField('code');
+                        let codeVisible = colSettingObj.getVisible('code');
+                        if(codeCol !== null && codeVisible !== false){
+                            newCol = codeCol;
+                        }
+                        sheet.setActiveCell(newRow, newCol);
+                    });
+                }
             }
             }
             //在定额/量价/人材机的编码单元格回车,焦点应跳动至本行的工程量单元格
             //在定额/量价/人材机的编码单元格回车,焦点应跳动至本行的工程量单元格
-            if(orgField && orgField === 'code' && selected.sourceType === me.project.Ration.getSourceType() && []){
-
+            else if(orgField && orgField === 'code' && selected.sourceType === me.project.Ration.getSourceType()){
+                let quantityCol = colSettingObj.getColByField('quantity');
+                let quantityVisible = colSettingObj.getVisible('quantity');
+                if(quantityCol !== null && quantityVisible !== false){
+                    newRow = orgRow;
+                    newCol = quantityCol;
+                }
+            }
+            //在定额/量价/人材机的工程量单元格回车
+            else if(orgField && orgField === 'quantity' && selected.sourceType === me.project.Ration.getSourceType()){
+                let nextSibling = selected.nextSibling;
+                //如果其后有定额/量价/人材机(空行:编码为空不算),焦点应跳动至下一行定额/量价/人材机的工程量,不需处理
+
+                //如果其后没有定额/量价/人材机(空行也没有),则自动在其后插入一行定额空行,焦点跳动至定额空行的编码单元格
+                if(!nextSibling){
+                    let codeCol = colSettingObj.getColByField('code');
+                    let codeVisible = colSettingObj.getVisible('code');
+                    me.project.Ration.addNewRation(null, rationType.ration, function () {
+                        newRow = sheet.getActiveRowIndex();
+                        if(codeCol !== null && codeVisible !== false){
+                            newCol = codeCol;
+                        }
+                        sheet.setActiveCell(newRow, newCol);
+                    });
+                }
+                //如果其后有定额空行,焦点跳动至定额空行的编码单元格
+                else if(nextSibling && !(isDef(nextSibling.data.code) && nextSibling.data.code.toString().trim() !== '')) {
+                    let codeCol = colSettingObj.getColByField('code');
+                    let codeVisible = colSettingObj.getVisible('code');
+                    if(codeCol !== null && codeVisible !== false){
+                        newRow = orgRow + 1;
+                        newCol = codeCol;
+                    }
+                }
+            }
+            //在清单的编码单元格回车,如果清单是叶子节点,焦点跳动至本行的工程量单元格
+            else if(orgField && orgField === 'code' && selected.sourceType === me.project.Bills.getSourceType()
+                && selected.data.type === billType.BILL && selected.source.children.length === 0){
+                let quantityCol = colSettingObj.getColByField('quantity');
+                let quantityVisible = colSettingObj.getVisible('quantity');
+                if(quantityCol && quantityVisible){
+                    newRow = orgRow;
+                    newCol = quantityCol;
+                }
             }
             }
 
 
 
 
@@ -784,6 +849,8 @@ var projectObj = {
         sheet.setActiveCell(newRow, newCol);
         sheet.setActiveCell(newRow, newCol);
         //触发表格事件
         //触发表格事件
         me.mainController.setTreeSelected(me.project.mainTree.items[newRow]);//SelectionChanged
         me.mainController.setTreeSelected(me.project.mainTree.items[newRow]);//SelectionChanged
+        me.mainSpreadLeaveCell({type: 'LeaveCell'}, {sheet: sheet, sheetName: sheet.name(), cancel: false, row: orgRow, col: orgCol});
+        me.mainSpreadEnterCell({type: 'EnterCell'}, {sheet: sheet, sheetName: sheet.name(), cancel: false, row: newRow, col: newCol});
 
 
     },
     },
     //注册自定义回车键事件
     //注册自定义回车键事件