Browse Source

1. mainTree, column, readOnly
2. volumePrice, Modify & Calculate & Update

MaiXinRong 8 years ago
parent
commit
5f73da358d

+ 2 - 0
modules/volume_price/models/volume_price_schema.js

@@ -18,6 +18,8 @@ let volumePriceSchema = new Schema({
     billsItemID: Number,
     billsItemID: Number,
     // 排序
     // 排序
     serialNo: Number,
     serialNo: Number,
+    // 编号
+    code: String,
     // 名称
     // 名称
     name: String,
     name: String,
     // 单位
     // 单位

+ 10 - 10
test/tmp_data/bills_grid_setting.js

@@ -136,7 +136,7 @@ var BillsGridSetting ={
         },
         },
         {
         {
             "width":180,
             "width":180,
-            "readOnly":false,
+            "readOnly":'readOnly.volumePrice',
             "head":{
             "head":{
                 "titleNames":[
                 "titleNames":[
                     "项目特征"
                     "项目特征"
@@ -166,7 +166,7 @@ var BillsGridSetting ={
         },
         },
         {
         {
             "width":80,
             "width":80,
-            "readOnly":false,
+            "readOnly":'readOnly.volumePrice',
             "head":{
             "head":{
                 "titleNames":[
                 "titleNames":[
                     "工作内容"
                     "工作内容"
@@ -196,7 +196,7 @@ var BillsGridSetting ={
         },
         },
         {
         {
             "width":80,
             "width":80,
-            "readOnly":false,
+            "readOnly":'readOnly.volumePrice',
             "head":{
             "head":{
                 "titleNames":[
                 "titleNames":[
                     "工程专业"
                     "工程专业"
@@ -226,7 +226,7 @@ var BillsGridSetting ={
         },
         },
         {
         {
             "width":80,
             "width":80,
-            "readOnly":false,
+            "readOnly":'readOnly.volumePrice',
             "head":{
             "head":{
                 "titleNames":[
                 "titleNames":[
                     "取费专业"
                     "取费专业"
@@ -286,7 +286,7 @@ var BillsGridSetting ={
         },
         },
         {
         {
             "width":120,
             "width":120,
-            "readOnly":false,
+            "readOnly":true,
             "head":{
             "head":{
                 "titleNames":[
                 "titleNames":[
                     "定额调整状态"
                     "定额调整状态"
@@ -346,7 +346,7 @@ var BillsGridSetting ={
         },
         },
         {
         {
             "width":80,
             "width":80,
-            "readOnly":false,
+            "readOnly":'readOnly.volumePrice',
             "head":{
             "head":{
                 "titleNames":[
                 "titleNames":[
                     "含量"
                     "含量"
@@ -376,7 +376,7 @@ var BillsGridSetting ={
         },
         },
         {
         {
             "width":120,
             "width":120,
-            "readOnly":false,
+            "readOnly":'readOnly.volumePrice',
             "head":{
             "head":{
                 "titleNames":[
                 "titleNames":[
                     "计算基数"
                     "计算基数"
@@ -406,7 +406,7 @@ var BillsGridSetting ={
         },
         },
         {
         {
             "width":80,
             "width":80,
-            "readOnly":false,
+            "readOnly":'readOnly.volumePrice',
             "head":{
             "head":{
                 "titleNames":[
                 "titleNames":[
                     "费率(%)"
                     "费率(%)"
@@ -496,7 +496,7 @@ var BillsGridSetting ={
         },
         },
         {
         {
             "width":80,
             "width":80,
-            "readOnly":false,
+            "readOnly":'readOnly.volumePrice',
             "head":{
             "head":{
                 "titleNames":[
                 "titleNames":[
                     "暂估单价"
                     "暂估单价"
@@ -526,7 +526,7 @@ var BillsGridSetting ={
         },
         },
         {
         {
             "width":80,
             "width":80,
-            "readOnly":false,
+            "readOnly":'readOnly.volumePrice',
             "head":{
             "head":{
                 "titleNames":[
                 "titleNames":[
                     "暂估合价"
                     "暂估合价"

+ 21 - 2
web/building_saas/main/js/calc/calc_fees.js

@@ -19,6 +19,7 @@ let calcFees = {
     findFee: function (data, fieldName) {
     findFee: function (data, fieldName) {
         if (!data.fees) {
         if (!data.fees) {
             data.fees = [];
             data.fees = [];
+            data.feesIndex = {};
         }
         }
         for (let fee of data.fees) {
         for (let fee of data.fees) {
             if (fee.fieldName === fieldName) {
             if (fee.fieldName === fieldName) {
@@ -27,7 +28,7 @@ let calcFees = {
         }
         }
         return null;
         return null;
     },
     },
-    AddFee: function (data, fieldName) {
+    addFee: function (data, fieldName) {
         let fee = {
         let fee = {
             'fieldName': fieldName,
             'fieldName': fieldName,
             'unitFee': 0,
             'unitFee': 0,
@@ -45,7 +46,7 @@ let calcFees = {
         }
         }
         for (let field of fields) {
         for (let field of fields) {
             if (!this.findFee(data, field.type)) {
             if (!this.findFee(data, field.type)) {
-                this.AddFee(data, field.type);
+                this.addFee(data, field.type);
             }
             }
         }
         }
     },
     },
@@ -70,5 +71,23 @@ let calcFees = {
             }
             }
         }
         }
         return value;
         return value;
+    },
+    setFee: function (data, fullField, value) {
+        let fields = fullField.split('.'), valueField = data;
+        for (let i in fields) {
+            if (valueField[fields[i]]) {
+                if (i == fields.length - 1) {
+                    valueField[fields[i]] = value;
+                } else {
+                    valueField = valueField[fields[i]];
+                }
+            } else {
+                if (i == fields.length - 1) {
+                    valueField[fields[i]] = {};
+                } else {
+                    valueField[fields[i]] = value;
+                };
+            }
+        }
     }
     }
 }
 }

+ 30 - 0
web/building_saas/main/js/models/volume_price.js

@@ -35,7 +35,12 @@ var VolumePrice = {
 
 
             loadData (datas) {
             loadData (datas) {
                 this.datas = datas;
                 this.datas = datas;
+                // generate Fees & Flags Index,For View & Calculate
                 for (let data of datas) {
                 for (let data of datas) {
+                    data.feesIndex = {};
+                    data.fees.forEach(function (fee) {
+                        data.feesIndex[fee.fieldName] = fee;
+                    });
                     this.maxID(data.ID);
                     this.maxID(data.ID);
                 }
                 }
             };
             };
@@ -135,6 +140,31 @@ var VolumePrice = {
                     }
                     }
                 }
                 }
             };
             };
+
+            calculate (volumePrice) {
+                if (!calcFees.findFee(volumePrice, 'common')) {
+                    calcFees.addFee(volumePrice, 'common');
+                }
+                volumePrice.feesIndex.common.totalFee = (volumePrice.feesIndex.common.unitFee * volumePrice.quantity).toDecimal(2);
+                volumePrice.needRefresh = true;
+            }
+            updateField(volumePrice, field, newValue) {
+                calcFees.setFee(volumePrice, field, newValue);
+                let updateData = [];
+                if (field === 'quantity' || field === 'feesIndex.common.unitFee') {
+                    let data = {'ID': volumePrice.ID, 'projectID': this.getProject().ID()};
+                    data[field] = newValue;
+                    this.calculate(volumePrice);
+                    data.fees = volumePrice.fees;
+                    updateData.push({'updateType': 'ut_update', 'updateData': data});
+                    tools.owner.pushNow('updateVolumePrice', this.getSourceType(), updateData);
+                } else {
+                    let data = {'ID': volumePrice.ID, 'projectID': this.getProject().ID()};
+                    data[field] = newValue;
+                    updateData.push({'updateType': 'ut_update', 'updateData': data});
+                    tools.owner.pushNow('updateVolumePrice', this.getSourceType(), updateData);
+                }
+            }
         }
         }
 
 
         return new volumePrice();
         return new volumePrice();

+ 22 - 0
web/building_saas/main/js/views/project_view.js

@@ -7,6 +7,26 @@ var projectObj = {
     mainSpread: null,
     mainSpread: null,
     mainController: null,
     mainController: null,
     gljSpreed:null,
     gljSpreed:null,
+    mainSpreadEditEnded: function (sender, info) {
+        let project = projectObj.project;
+        let node = project.mainTree.items[info.row];
+        let colSetting = projectObj.mainController.setting.cols[info.col];
+        let fieldName = projectObj.mainController.setting.cols[info.col].data.field;
+        if (colSetting.data.wordWrap) {
+            info.sheet.autoFitRow(info.row);
+        }
+        if (node.sourceType === project.Bills.getSourceType()) {
+
+        } else if (node.sourceType === project.Ration.getSourceType()) {
+
+        } else if (node.sourceType === project.VolumePrice.getSourceType()) {
+            project.VolumePrice.updateField(node.source, fieldName, info.editingText);
+            if (node.source.needRefresh) {
+                projectObj.mainController.refreshTreeNode([node]);
+                node.source.needRefresh = false;
+            }
+        };
+    },
     checkMainSpread: function () {
     checkMainSpread: function () {
         if (!this.mainSpread) {
         if (!this.mainSpread) {
             this.mainSpread = SheetDataHelper.createNewSpread($('#billsSpread')[0]);
             this.mainSpread = SheetDataHelper.createNewSpread($('#billsSpread')[0]);
@@ -93,6 +113,8 @@ var projectObj = {
                     }
                     }
                 });
                 });
 
 
+                that.mainSpread.bind(GC.Spread.Sheets.Events.EditEnded, that.mainSpreadEditEnded);
+
                 that.loadMainSpreadContextMenu();
                 that.loadMainSpreadContextMenu();
             }
             }
             else {
             else {