瀏覽代碼

清单界面取费专业:
①从标准清单库获取计算程序ID。
②ID转换显示工程类别名称到取费专业。
③取费专业字段提供工程类别下拉选择列表。
④切换取费专业实时计算当前结点,并转换计算程序ID入库存储。

Chenshilong 7 年之前
父節點
當前提交
e8cfe20eb8

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

@@ -290,21 +290,24 @@ let executeObj = {
                     }
                 };
             }else{
-                for (let glj of me.treeNode.data.gljList) {
-                    if (base.gljTypes.indexOf(glj.type) >= 0) {
-                        if (base.calcType == baseCalc){ price = glj["basePrice"];}
-                        else if (base.calcType == adjustCalc){price = glj["adjustPrice"];}
-                        else if (base.calcType == budgetCalc){price = glj["marketPrice"];}
-                        else if (base.calcType == diffCalc){
-                            aprice = glj["adjustPrice"];
-                            if (!aprice) aprice = 0;
-                            mprice = glj["marketPrice"];
-                            if (!mprice) mprice = 0;
-                            price = mprice - aprice;
+                if (!me.treeNode.data.gljList) tmpSum = 0
+                else{
+                    for (let glj of me.treeNode.data.gljList) {
+                        if (base.gljTypes.indexOf(glj.type) >= 0) {
+                            if (base.calcType == baseCalc){ price = glj["basePrice"];}
+                            else if (base.calcType == adjustCalc){price = glj["adjustPrice"];}
+                            else if (base.calcType == budgetCalc){price = glj["marketPrice"];}
+                            else if (base.calcType == diffCalc){
+                                aprice = glj["adjustPrice"];
+                                if (!aprice) aprice = 0;
+                                mprice = glj["marketPrice"];
+                                if (!mprice) mprice = 0;
+                                price = mprice - aprice;
+                            };
+                            if (!price) price = 0;
+                            tmpSum = tmpSum + (glj["quantity"] * price).toDecimal(me.digitDefault);
+                            tmpSum = (tmpSum).toDecimal(me.digitDefault);
                         };
-                        if (!price) price = 0;
-                        tmpSum = tmpSum + (glj["quantity"] * price).toDecimal(me.digitDefault);
-                        tmpSum = (tmpSum).toDecimal(me.digitDefault);
                     };
                 };
             };
@@ -351,7 +354,9 @@ class CalcProgram {
         me.compiledFeeRates = {};
         me.compiledLabourCoes = {};
         me.compiledTemplates = {};
-        me.compiledFeeTypes = {};
+        me.compiledTemplateMaps = {};
+        me.compiledTemplateNames = [];
+        me.compiledFeeTypeMaps = {};
         me.compiledFeeTypeNames = [];
         me.compiledCalcBases = {};
         me.saveForReports = [];
@@ -391,8 +396,8 @@ class CalcProgram {
         }
 
         for (let ft of me.feeTypes) {
-            me.compiledFeeTypes[ft.type] = ft.name;
-            me.compiledFeeTypes[ft.name] = ft.type;    // 中文预编译,可靠性有待验证
+            me.compiledFeeTypeMaps[ft.type] = ft.name;
+            me.compiledFeeTypeMaps[ft.name] = ft.type;    // 中文预编译,可靠性有待验证
             me.compiledFeeTypeNames.push(ft.name);
         }
 
@@ -404,6 +409,9 @@ class CalcProgram {
     compileTemplate(template){
         let me = this;
         me.compiledTemplates[template.ID] = template;
+        me.compiledTemplateMaps[template.ID] = template.name;
+        me.compiledTemplateMaps[template.name] = template.ID;
+        me.compiledTemplateNames.push(template.name);
         template.hasCompiled = false;
         template.errs = [];
 
@@ -487,7 +495,7 @@ class CalcProgram {
                 };
 
                 // 字段名映射
-                item.displayFieldName = me.compiledFeeTypes[item.fieldName];
+                item.displayFieldName = me.compiledFeeTypeMaps[item.fieldName];
             }
         };
 
@@ -709,6 +717,7 @@ class CalcProgram {
                     ID: node.data.ID,
                     projectID: me.project.ID(),
                     quantity: node.data.quantity,
+                    programID: node.data.programID,
                     fees: node.data.fees
                 };
                 let newData = {'updateType': 'ut_update', 'updateData': data};

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

@@ -33,7 +33,7 @@ let rationPM = {
         ],
         view:{
             comboBox:[],
-            lockColumns:[0,1,2,4,5,6],
+            lockColumns:[0,1,2,5,6],
             colHeaderHeight: CP_Col_Width.colHeader,
             rowHeaderWidth: CP_Col_Width.rowHeader
         }

+ 9 - 3
web/building_saas/main/js/views/main_tree_col.js

@@ -17,9 +17,9 @@ let MainTreeCol = {
         },
 
         calcProgramName: function (node) {
-            let prgmID = node.data.programID;
-            if (!prgmID) return;
-            return projectObj.project.calcProgram.compiledTemplates[prgmID].name;
+            let programID = node.data.programID;
+            if (!programID) return
+            else return projectObj.project.calcProgram.compiledTemplateMaps[programID];
         }
     },
     readOnly: {
@@ -75,6 +75,12 @@ let MainTreeCol = {
 
         feeRate: function () {
             return feeRateObject.getFeeRateEditCellType();
+        },
+
+        calcProgramName: function () {
+            var names = new GC.Spread.Sheets.CellTypes.ComboBox();
+            names.items(projectObj.project.calcProgram.compiledTemplateNames);
+            return names;
         }
      },
     getEvent: function (eventName) {

+ 17 - 6
web/building_saas/main/js/views/project_view.js

@@ -125,7 +125,11 @@ var projectObj = {
     checkSpreadEditingText: function (editingText, colSetting) {
         if (colSetting.data.field === 'quantity' || colSetting.data.field === 'feesIndex.common.unitFee') {
             return this.checkFormulaValidField(editingText, colSetting);
-        } else {
+        }
+        else if (colSetting.data.field === 'programID') {
+            return this.project.calcProgram.compiledTemplateMaps[editingText];
+        }
+        else {
             return this.checkCommonField(editingText, colSetting);
         }
     },
@@ -275,6 +279,10 @@ var projectObj = {
                 project.calcProgram.calculate(node);
                 project.calcProgram.saveNode(node);
                 // projectObj.updateAndReCalculate(node, fieldName, value);
+            } else if (fieldName === 'programID') {
+                node.data.programID = value;
+                project.calcProgram.calculate(node);
+                project.calcProgram.saveNode(node);
             } else if(fieldName ==='feeRate'){
                 project.FeeRate.updateFeeRateFromBills(value,node,fieldName);
             }else {
@@ -339,14 +347,17 @@ var projectObj = {
                 that.project.calcFields = JSON.parse(JSON.stringify(feeType));
                 that.project.initCalcFields();
                 let str = JSON.stringify(that.project.projSetting.main_tree_col);
-                let strObj = JSON.parse(str);
-                // for test.  后端没有绑定,暂时写死用于测试。
-                strObj.cols[14].data.field = 'programID';
-                strObj.cols[14].data.getText = 'getText.calcProgramName';
-                that.project.projSetting.mainGridSetting = strObj;
+                that.project.projSetting.mainGridSetting = JSON.parse(str);
                 that.project.projSetting.mainGridSetting.frozenCols = 4;
                 TREE_SHEET_HELPER.initSetting($('#billsSpread')[0], that.project.projSetting.mainGridSetting);
                 that.project.projSetting.mainGridSetting.cols.forEach(function (col) {
+                    // for test.  后端没有绑定,暂时写死用于测试。
+                    if (col.data.field == '' && col.head.titleNames[0] == "取费专业") {
+                        col.data.field = 'programID';
+                        col.data.getText = 'getText.calcProgramName';
+                        col.data.cellType = 'cellType.calcProgramName';
+                    };
+
                     col.data.splitFields = col.data.field.split('.');
                     if (col.data.getText && Object.prototype.toString.apply(col.data.getText) === "[object String]") {
                         col.data.getText = MainTreeCol.getEvent(col.data.getText);