Browse Source

变更主材

zhongzewei 7 years ago
parent
commit
9575865db5

+ 2 - 1
web/building_saas/complementary_glj_lib/js/components.js

@@ -78,7 +78,8 @@ let componentOprObj = {
         let that = repositoryGljObj, me = componentOprObj;
             for(let i = 0; i < gljList.length; i++){
                 if(that.currentGlj.gljType === 301 && machineArr.indexOf(gljList[i].gljType) !== -1 ||
-                    materialArr.indexOf(that.currentGlj.gljType) !== -1 && gljList[i].gljType === 201){
+                    materialArr.indexOf(that.currentGlj.gljType) !== -1 && gljList[i].gljType === 201 ||
+                    that.currentGlj.gljType === 4 && gljList[i].gljType === 4 && (!gljList[i].component || gljList[i].component.length === 0) && gljList[i].ID !== that.currentGlj.ID){
                     //去除与已添加的组成物重复的条目
                     let isExist = false;
                     for(let j = 0; j < that.currentComponent.length; j++){

+ 22 - 3
web/building_saas/complementary_glj_lib/js/glj.js

@@ -35,8 +35,8 @@ let repositoryGljObj = {
     gljList: [],
     stdGljList:[],
     complementaryGljList: [],
-    allowComponent: [202, 203, 204, 301],//可带组成物类型:混凝土、砂浆、配合比、机械台班
-    componentGljType: [201, 302, 303],//可成为组成物的工料机类型: 普通材料、 机械组成物、 机上人工
+    allowComponent: [202, 203, 204, 301, 4],//可带组成物类型:混凝土、砂浆、配合比、机械台班、主材
+    componentGljType: [201, 302, 303, 4],//可成为组成物的工料机类型: 普通材料、 机械组成物、 机上人工、主材
     distTypeTree: null,//add
     setting: {
 
@@ -165,6 +165,25 @@ let repositoryGljObj = {
         me.workBook.bind(GC.Spread.Sheets.Events.ButtonClicked, me.onButtonClicked);//复选框点击事件
     },
 
+    isDef: function (v) {
+        return v !== undefined && v !== null;
+    },
+
+    //成为了组成物,暂时只需要判断主材的
+    isComponent: function (gljId, gljList) {
+        for(let i = 0, len = gljList.length; i < len; i++){
+            let gljComponent = gljList[i].component;
+            if(gljList[i].gljType === 4 && this.isDef(gljComponent) && gljComponent.length > 0){
+                for(let j = 0, jLen = gljComponent.length; j < jLen; j++){
+                    if(gljComponent[j].ID === gljId){
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    },
+
     getCurrentComponent: function (gljComponent) {
         let me = repositoryGljObj, rst = [];
         for(let i = 0; i < gljComponent.length; i++){
@@ -359,7 +378,7 @@ let repositoryGljObj = {
         me.orgCode = me.workBook.getSheet(0).getValue(args.row, 0);
         if(args.row < me.currentCache.length){
             me.currentGlj = me.currentCache[args.row];
-            if(args.col === 0 || (args.col === 4 && me.allowComponent.indexOf(me.currentGlj.gljType) !== -1)
+            if(args.col === 0 || (args.col === 4 && me.allowComponent.indexOf(me.currentGlj.gljType) !== -1 && me.currentGlj.component.length > 0)
                 || args.col === 6){
                 args.cancel = true;
             }

+ 4 - 3
web/building_saas/complementary_glj_lib/js/gljComponent.js

@@ -69,7 +69,7 @@ let gljComponentOprObj = {
                     //控制按钮是否可用
                     let insertDis = false,
                         delDis = false;
-                    if(!(that.currentGlj && that.allowComponent.indexOf(that.currentGlj.gljType) !== -1)){
+                    if(!(that.currentGlj && that.allowComponent.indexOf(that.currentGlj.gljType) !== -1) || (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.stdGljList.concat(that.complementaryGljList)))){
                         insertDis = true;
                     }
                     if(!that.currentGlj || typeof that.currentComponent === 'undefined' || (typeof that.currentComponent !== 'undefined' && target.row >= that.currentComponent.length)){//右键定位在有组成物的行,删除键才显示可用
@@ -210,6 +210,7 @@ let gljComponentOprObj = {
         if(thatRow < that.currentCache.length){
             that.currentGlj = that.currentCache[thatRow];
             if(me.setting.view.lockedCols.indexOf(args.col) !== -1 || that.allowComponent.indexOf(that.currentGlj.gljType) === -1 ||
+                (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.stdGljList.concat(that.complementaryGljList))) ||
                 (args.col === 4 && (!that.currentComponent|| args.row >= that.currentComponent.length))){
                 args.cancel = true;
             }
@@ -345,10 +346,10 @@ let gljComponentOprObj = {
         }
     },
     onClipboardPasting: function (sender, info) {
-        let me = gljComponentOprObj;
+        let me = gljComponentOprObj, that = repositoryGljObj;
         let maxCol = info.cellRange.col + info.cellRange.colCount - 1;
         //复制的列数超过正确的列数,不可复制
-        if(info.cellRange.col !== 4 && info.cellRange.colCount > 1){
+        if(info.cellRange.col !== 4 && info.cellRange.colCount > 1 || (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.stdGljList.concat(that.complementaryGljList)))){
             args.cancel = true;
         }
     },

+ 29 - 26
web/building_saas/main/js/models/calc_base.js

@@ -188,52 +188,52 @@ let baseFigureTemplate = {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SUB_ENGINERRING]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.common.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common.totalFee) ? bill.feesIndex.common.totalFee : 0;
     },
     'FBFXDEJJRGF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SUB_ENGINERRING]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.labour.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.labour) && cbTools.isDef(bill.feesIndex.labour.totalFee) ? bill.feesIndex.labour.totalFee : 0;
     },
     'FBFXDEJJCLF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SUB_ENGINERRING]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.material.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.material) && cbTools.isDef(bill.feesIndex.material.totalFee) ? bill.feesIndex.material.totalFee : 0;
     },
     'FBFXDEJJJXF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SUB_ENGINERRING]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.machine.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.machine) && cbTools.isDef(bill.feesIndex.machine.totalFee) ? bill.feesIndex.machine.totalFee : 0;
     },
     'FBFXTZRGF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SUB_ENGINERRING]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.adjustLabour.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.adjustLabour) && cbTools.isDef(bill.feesIndex.adjustLabour.totalFee) ? bill.feesIndex.adjustLabour.totalFee : 0;
     },
     'FBFXTZJSRGF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SUB_ENGINERRING]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.adjustMachineLabour.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.adjustMachineLabour) && cbTools.isDef(bill.feesIndex.adjustMachineLabour.totalFee) ? bill.feesIndex.adjustMachineLabour.totalFee : 0;
     },
     'FBFXZCF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SUB_ENGINERRING]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.mainMaterial.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.mainMaterial) && cbTools.isDef(bill.feesIndex.mainMaterial.totalFee) ? bill.feesIndex.mainMaterial.totalFee : 0;
     },
     'FBFXSBF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SUB_ENGINERRING]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.mainMaterial.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.equipment) && cbTools.isDef(bill.feesIndex.equipment.totalFee) ? bill.feesIndex.equipment.totalFee : 0;
     },
     'FBFXWJJCLF': function () {
-        return 0;
+        return (this['FBFXZCF']() + this['FBFXSBF']()).toDecimal(decimalObj.bills.totalPrice);
     },
     'FBFXRGGR': function () {
         return 0;
@@ -245,13 +245,13 @@ let baseFigureTemplate = {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.MEASURE]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.common.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common.totalFee) ? bill.feesIndex.common.totalFee : 0;
     },
     'ZZCSXMF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_ORGANIZATION]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.common.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common.totalFee) ? bill.feesIndex.common.totalFee : 0;
     },
     'ZZCSXMDEJJZJGCF': function () {
         return (this['ZZCSXMDEJJRGF']() + this['ZZCSXMDEJJCLF']() + this['ZZCSXMDEJJJXF']()).toDecimal(decimalObj.bills.totalPrice);
@@ -260,67 +260,70 @@ let baseFigureTemplate = {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_ORGANIZATION]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.labour.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.labour) && cbTools.isDef(bill.feesIndex.labour.totalFee) ? bill.feesIndex.labour.totalFee : 0;
     },
     'ZZCSXMDEJJCLF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_ORGANIZATION]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.material.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.material) && cbTools.isDef(bill.feesIndex.material.totalFee) ? bill.feesIndex.material.totalFee : 0;
     },
     'ZZCSXMDEJJJXF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_ORGANIZATION]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.machine.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.machine) && cbTools.isDef(bill.feesIndex.machine.totalFee) ? bill.feesIndex.machine.totalFee : 0;
     },
     'JSCSXMF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_TECH]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.common.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common.totalFee) ? bill.feesIndex.common.totalFee : 0;
     },
     'JSCSXMDEJJRGF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_TECH]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.labour.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.labour) && cbTools.isDef(bill.feesIndex.labour.totalFee) ? bill.feesIndex.labour.totalFee : 0;
     },
     'JSCSXMDEJJCLF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_TECH]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.material.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.material) && cbTools.isDef(bill.feesIndex.material.totalFee) ? bill.feesIndex.material.totalFee : 0;
     },
     'JSCSXMDEJJJXF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_TECH]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.machine.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.machine) && cbTools.isDef(bill.feesIndex.machine.totalFee) ? bill.feesIndex.machine.totalFee : 0;
     },
     'JSCSXMTZRGF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_TECH]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.adjustLabour.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.adjustLabour) && cbTools.isDef(bill.feesIndex.adjustLabour.totalFee) ? bill.feesIndex.adjustLabour.totalFee : 0;
     },
     'JSCSXMTZJSRGF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_TECH]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.adjustMachineLabour.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.adjustMachineLabour) && cbTools.isDef(bill.feesIndex.adjustMachineLabour.totalFee) ? bill.feesIndex.adjustMachineLabour.totalFee : 0;
     },
     'JSCSXMZCF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_TECH]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.mainMaterial.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.mainMaterial) && cbTools.isDef(bill.feesIndex.mainMaterial.totalFee) ? bill.feesIndex.mainMaterial.totalFee : 0;
     },
     'JSCSXMSBF': function () {
-        return 0;
+        let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_TECH]['bill'];
+        if(cbTools.isUnDef(bill)) return 0;
+        if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
+        return cbTools.isDef(bill.feesIndex.equipment) && cbTools.isDef(bill.feesIndex.equipment.totalFee) ? bill.feesIndex.equipment.totalFee : 0;
     },
     'JSCSXMWJJCLF': function () {
-        return 0;
+        return (this['JSCSXMZCF']() + this['JSCSXMSBF']()).toDecimal(decimalObj.bills.totalPrice);
     },
     'JSCSXMRGGR': function () {
         return 0;
@@ -332,19 +335,19 @@ let baseFigureTemplate = {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.OTHER]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.common.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common.totalFee) ? bill.feesIndex.common.totalFee : 0;
     },
     'GF': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CHARGE]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.common.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common.totalFee) ? bill.feesIndex.common.totalFee : 0;
     },
     'SJ': function () {
         let bill = calcBase.fixedBills[calcBase.fixedFlag.TAX]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return bill.feesIndex.common.totalFee || 0;
+        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common.totalFee) ? bill.feesIndex.common.totalFee : 0;
     }
 };