浏览代码

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost

zhangweicheng 7 年之前
父节点
当前提交
2c36635d84

+ 0 - 38
modules/main/models/proj_counter.js

@@ -1,38 +0,0 @@
-/**
- * Created by Mai on 2017/6/13.
- */
-
-let mongoose = require('mongoose');
-let baseModel = require('./base_model');
-
-class projCounter extends baseModel {
-    constructor (name) {
-        let db = require("../db/project_db");
-        let Schema = require("mongoose").Schema;
-        let projCounterSchema = new Schema({
-            projectID: Number,
-            bills: Number,
-            ration: Number,
-            volume_price: Number
-        });
-        let projCounterModel = db.model(name, projCounterSchema);
-        super(projCounterModel);
-        this.collectionName = name;
-    };
-
-    getData (projectID, callback) {
-        this.model.findOne({"projectID": projectID}, '-_id', function (err, result) {
-            if (!err) {
-                callback(0, '', result);
-            } else {
-                callback(1, '查询数据失败。', null);
-            }
-        });
-    };
-
-    save (user_id, data, callback) {
-        this.model.update({"projectID": data.projectID}, data, callback);
-    }
-};
-
-module.exports = new projCounter('projCounter');

+ 29 - 0
modules/main/models/proj_counter_model.js

@@ -0,0 +1,29 @@
+/**
+ * Created by Mai on 2017/6/13.
+ */
+
+let baseModel = require('./base_model');
+import {default as projCounterSchema, collectionName as collectionName} from "./schemas/proj_counter";
+
+class projCounter extends baseModel {
+    constructor() {
+        super(projCounterSchema);
+        this.collectionName = collectionName;
+    }
+
+    getData (projectID, callback) {
+        this.model.findOne({"projectID": projectID}, '-_id', function (err, result) {
+            if (!err) {
+                callback(0, collectionName, result);
+            } else {
+                callback(1, '查询数据失败。', null);
+            }
+        });
+    };
+
+    save (user_id, data, callback) {
+        this.model.update({"projectID": data.projectID}, data, callback);
+    }
+};
+
+module.exports = new projCounter();

+ 1 - 1
modules/main/models/proj_setting_model.js

@@ -15,7 +15,7 @@ class projSettingModel extends baseModel {
     getData (projectID, callback) {
         this.model.findOne({"projectID": projectID}, '-_id', function (err, result) {
             if (!err) {
-                callback(0, '', result);
+                callback(0, collectionName, result);
             } else {
                 callback(1, '查询数据失败。', null);
             }

+ 3 - 1
modules/main/models/project.js

@@ -9,7 +9,8 @@ var ration_coe_data = require('../../ration_glj/facade/ration_coe_facade');
 var ration_ass_data = require('../../ration_glj/facade/ration_ass_facade');
 var quantity_detail_data = require('../../ration_glj/facade/quantity_detail_facade');
 var fee_rate_data = require('../../fee_rates/facade/fee_rates_facade');
-let projCounter = require('./proj_counter');
+let projCounter = require('./proj_counter_model');
+let projSetting = require('./proj_setting_model');
 let volumePriceData = require('../../volume_price/models/volume_price_model');
 var consts = require('./project_consts');
 var projectConsts = consts.projectConst;
@@ -25,6 +26,7 @@ moduleMap[projectConsts.RATION_COE] = ration_coe_data;
 moduleMap[projectConsts.RATION_ASS] = ration_ass_data;
 moduleMap[projectConsts.QUANTITY_DETAIL] = quantity_detail_data;
 moduleMap[projCounter.collectionName] = projCounter;
+moduleMap[projSetting.collectionName] = projSetting;
 moduleMap[volumePriceData.collectionName] = volumePriceData;
 moduleMap[projectConsts.FEERATE] = fee_rate_data;
 

+ 15 - 0
modules/main/models/schemas/proj_counter.js

@@ -0,0 +1,15 @@
+/**
+ * Created by Mai on 2017/9/15.
+ */
+
+let mongoose = require("mongoose");
+let Schema = mongoose.Schema;
+let collectionName = 'projCounter';
+let projSettingSchema = {
+    projectID: Number,
+    bills: Number,
+    ration: Number,
+    volume_price: Number
+};
+let model = mongoose.model(collectionName, new Schema(projSettingSchema, {versionKey: false, collection: collectionName}));
+export {model as default, collectionName as collectionName};

+ 3 - 1
modules/pm/controllers/copy_proj_controller.js

@@ -4,7 +4,8 @@
 
 let billsData = require('../../main/models/bills');
 let rationData = require('../../main/models/ration');
-let projCounter = require('../../main/models/proj_counter');
+let projCounter = require('../../main/models/proj_counter_model');
+let projSetting = require('../../main/models/proj_setting_model');
 let volumePriceData = require('../../volume_price/models/volume_price_model');
 let async = require('async');
 
@@ -30,6 +31,7 @@ module.exports = {
         fun.push(copyData(billsData));
         fun.push(copyData(rationData));
         fun.push(copyData(projCounter));
+        fun.push(copyData(projSetting));
         fun.push(copyData(volumePriceData));
         async.parallel(fun, (err) => callback(err));
     }

+ 1 - 2
modules/pm/controllers/new_proj_controller.js

@@ -3,7 +3,7 @@
  */
 
 let billsData = require('../../main/models/bills');
-let projCounter = require('../../main/models/proj_counter');
+let projCounter = require('../../main/models/proj_counter_model');
 let projSetting = require('../../main/models/proj_setting_model');
 let async = require('async');
 
@@ -24,7 +24,6 @@ module.exports = {
                 billsData.insertData(billsDatas, callback);
             },
             function (cb) {
-                console.log(projCounter);
                 projCounter.insertData({"projectID": newProjID}, cb);
             },
             async function (cb) {

+ 6 - 0
public/web/sheet/sheet_data_helper.js

@@ -81,6 +81,7 @@ var SheetDataHelper = {
                     iRow += col.head.spanRows[i];
                 };
                 sheet.setColumnWidth(index, col.width);
+                sheet.setColumnVisible(index, col.visible);
             });
         }
     },
@@ -196,6 +197,11 @@ var SheetDataHelper = {
         sheet.resumeEvent();
         sheet.resumePaint();
     },
+    refreshColumnVisible: function (setting, sheet) {
+        setting.cols.forEach(function (col, index) {
+            sheet.setColumnVisible(index, col.visible);
+        });
+    },
     bindSheetData: function (setting, sheet, datas) {     
         var getBindColInfo = function (setting) {
             var colInfo = {};

+ 1 - 0
public/web/tree_sheet/tree_sheet_helper.js

@@ -68,6 +68,7 @@ var TREE_SHEET_HELPER = {
                 iRow += col.head.spanRows[i];
             };
             sheet.setColumnWidth(index, col.width);
+            sheet.setColumnVisible(index, col.visible && true);
         });
     },
     protectdSheet: function (sheet) {

+ 21 - 0
web/building_saas/main/html/main.html

@@ -112,6 +112,9 @@
                     <a href="javascript:void(0)" class="btn btn-sm" id="downMove"><i class="fa fa-arrow-down" aria-hidden="true"></i> 下移</a>
                     <a href="javascript:void(0)" class="btn btn-sm" id="upMove"><i class="fa fa-arrow-up" aria-hidden="true"></i> 上移</a>
                   </div>
+                  <div>
+                      <a href="javacript:void(0);" data-toggle="modal" data-target="#column" class="btn btn-sm"><i class="fa fa-table" aria-hidden="true"></i> 列设置</a>
+                  </div>
                   <div class="side-tabs">
                       <ul class="nav nav-tabs" role="tablist">
                           <li class="nav-item">
@@ -406,6 +409,24 @@
 
         </div>
     </div>
+    <!--弹出列设置-->
+    <div class="modal fade" id="column" data-backdrop="static">
+        <div class="modal-dialog modal-lg" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title"><i class="fa fa-table"></i> 列设置</h5>
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">&times;</span>
+                    </button>
+                </div>
+                <div class="modal-body modal-auto-height" id="col_setting_spread" style="height: 130px; overflow: hidden;">
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
+                </div>
+            </div>
+        </div>
+    </div>
     <!-- JS. -->
     <script type="text/javascript">
         autoFlashHeight();

+ 6 - 2
web/building_saas/main/js/models/project.js

@@ -12,7 +12,8 @@ var PROJECT = {
             updateData: [],
             operation: '',
             modules: {},
-            projCounter: 'projCounter'
+            projCounter: 'projCounter',
+            projSetting: 'proj_setting'
         };
 
         var me = tools;
@@ -35,6 +36,9 @@ var PROJECT = {
                     me.modules[item.moduleName].loadData(item.data);
                 } else if (item.moduleName === me.projCounter) {
                     counter = item.data;
+                } else if (item.moduleName === me.projSetting) {
+                    me._project.projSetting = item.data;
+                    me._project.projSetting.moduleName = me.projSetting;
                 }
             });
             for (module in counter) {
@@ -274,7 +278,7 @@ var PROJECT = {
                 this.push(moduleName, data);
             }
             this.endUpdate();
-        }
+        };
 
         project.prototype.registerModule = function(moduleName, obj){
             if (!tools.modules.hasOwnProperty(moduleName)){

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

@@ -86,3 +86,54 @@ let MainTreeCol = {
         }
     }
 };
+
+let colSettingObj = {
+    settingSpread: null,
+    checkBox: new GC.Spread.Sheets.CellTypes.CheckBox(),
+    loadSetting: function (sheet, setting) {
+        sheet.setColumnCount(setting.cols.length);
+        sheet.setRowCount(setting.headRows, GC.Spread.Sheets.SheetArea.colHeader);
+        sheet.setRowCount(1);
+        sheet.getRange(0, -1, 1, -1).cellType(this.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
+
+        setting.headRowHeight.forEach(function (rowHeight, index) {
+            sheet.setRowHeight(index, rowHeight, GC.Spread.Sheets.SheetArea.colHeader);
+        });
+        setting.cols.forEach(function (col, index) {
+            let i, iRow = 0, cell;
+            for (i = 0; i < col.head.spanCols.length; i++) {
+                if (col.head.spanCols[i] !== 0) {
+                    cell = sheet.getCell(iRow, index, GC.Spread.Sheets.SheetArea.colHeader);
+                    cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]).wordWrap(true);
+                }
+                if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
+                    sheet.addSpan(iRow, index, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.colHeader);
+                }
+                iRow += col.head.spanRows[i];
+            };
+            sheet.setColumnWidth(index, col.width);
+            cell = sheet.getCell(0, index).value(col.visible);
+        });
+    },
+    initSettingSpread: function () {
+        this.settingSpread = SheetDataHelper.createNewSpread($('#col_setting_spread')[0], {sheetCount: 1});
+        this.settingSpread.options.showScrollTip = GC.Spread.Sheets.ShowScrollTip.horizontal;
+        this.loadSetting(this.settingSpread.getActiveSheet(), projectObj.project.projSetting.main_tree_col);
+    }
+};
+
+$('#column').on('shown.bs.modal', function () {
+    if (!colSettingObj.settingSpread) {
+        colSettingObj.initSettingSpread();
+    }
+});
+
+$('#column').on('hide.bs.modal', function () {
+    let sheet = colSettingObj.settingSpread.getActiveSheet();
+    for (let iCol = 0; iCol < sheet.getColumnCount(); iCol ++) {
+        projectObj.project.projSetting.main_tree_col.cols[iCol].visible = sheet.getValue(0, iCol);
+        projectObj.project.projSetting.mainGridSetting.cols[iCol].visible = sheet.getValue(0, iCol);
+    }
+    SheetDataHelper.refreshColumnVisible(projectObj.project.projSetting.mainGridSetting, projectObj.mainSpread.getActiveSheet());
+    projectObj.project.pushNow('editColSetting', projectObj.project.projSetting.moduleName, {projectID: projectObj.project.ID(), main_tree_col: projectObj.project.projSetting.main_tree_col});
+})

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

@@ -91,8 +91,10 @@ var projectObj = {
         this.project = PROJECT.createNew(scUrlUtil.GetQueryString('project'), userID);
         this.project.loadDatas(function (err) {
             if (!err) {
-                TREE_SHEET_HELPER.initSetting($('#billsSpread')[0], BillsGridSetting);
-                BillsGridSetting.cols.forEach(function (col) {
+                let str = JSON.stringify(that.project.projSetting.main_tree_col);
+                that.project.projSetting.mainGridSetting = JSON.parse(str);
+                TREE_SHEET_HELPER.initSetting($('#billsSpread')[0], that.project.projSetting.mainGridSetting);
+                that.project.projSetting.mainGridSetting.cols.forEach(function (col) {
                     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);
@@ -109,7 +111,7 @@ var projectObj = {
                         col.data.formatter = MainTreeCol.getNumberFormatter(col.data.decimal);
                     }
                 });
-                that.mainController = TREE_SHEET_CONTROLLER.createNew(that.project.mainTree, that.mainSpread.getActiveSheet(), BillsGridSetting);
+                that.mainController = TREE_SHEET_CONTROLLER.createNew(that.project.mainTree, that.mainSpread.getActiveSheet(), that.project.projSetting.mainGridSetting);
                 that.mainController.showTreeData();
                 that.mainController.bind('refreshBaseActn', function (tree) {
                     var setButtonValid = function (valid, btn) {
@@ -403,3 +405,4 @@ $('#downMove').click(function () {
         controller.downMove();
     }
 });
+

+ 3 - 0
web/building_saas/pm/js/pm_main.js

@@ -550,6 +550,9 @@ $(document).ready(function() {
  * @return {void}
  */
 function init() {
+    billValuation = billValuation.replace(/\n/g, '\\n');
+    rationValuation = rationValuation.replace(/\n/g, '\\n');
+
     let table = $('#ProjTree');
     $('thead', table).remove();
     $('tbody', table).remove();