瀏覽代碼

Merge branch 'master' into olym

olym 7 年之前
父節點
當前提交
38e12df286

+ 1 - 1
public/web/sheet/sheet_data_helper.js

@@ -73,7 +73,7 @@ var SheetDataHelper = {
                 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]);
+                        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);

+ 3 - 4
public/web/tree_sheet/tree_sheet_helper.js

@@ -60,7 +60,7 @@ var TREE_SHEET_HELPER = {
             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(col.head.wordWrap);
+                    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);
@@ -130,12 +130,12 @@ var TREE_SHEET_HELPER = {
                     }
                     return data;
                 };
-                if (colSetting.data.getText) {
+                if (colSetting.data.getText && Object.prototype.toString.apply(colSetting.data.getText) === "[object Function]") {
                     cell.value(colSetting.data.getText(node));
                 } else {
                     cell.value(getFieldText2());
                 }
-                if (colSetting.data.cellType) {
+                if (colSetting.data.cellType && Object.prototype.toString.apply(colSetting.data.cellType) !== "[object String]") {
                     cell.cellType(colSetting.data.cellType);
                 }
                 if (colSetting.readOnly) {
@@ -163,7 +163,6 @@ var TREE_SHEET_HELPER = {
         };
         TreeNodeCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
         TreeNodeCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
-            console.log(style);
             if (style.backColor) {
                 ctx.save();
                 ctx.fillStyle = style.backColor;

+ 37 - 11
web/users/js/col_setting.js

@@ -8,10 +8,11 @@ let ColSettingObj = {
     DEFAULT_DATA_STYLE: null,
     cellType: {
         getText: null,
+        cellType: null,
         readOnly: null,
         checkBox: null
     },
-    Rows: {data: 0, filedName: 0, getText: 1, wordWrap: 2, width: 3, readOnly: 4, showHint: 5},
+    Rows: {data: 0, filedName: 0, getText: 1, wordWrap: 2, cellType: 3, width: 4, readOnly: 5, showHint: 6, visible: 7},
     columnValueChanged: function (e, info) {
         let that = ColSettingObj;
         info.colList.forEach(function (iCol) {
@@ -52,13 +53,21 @@ let ColSettingObj = {
         this.cellType.getText = new GC.Spread.Sheets.CellTypes.ComboBox();
         this.cellType.getText.items(['getText.type']);
 
+        this.cellType.cellType = new GC.Spread.Sheets.CellTypes.ComboBox();
+        this.cellType.cellType.items(['cellType.units']);
+
         this.cellType.checkBox = new GC.Spread.Sheets.CellTypes.CheckBox();
     },
     initSheet: function (sheet, setting) {
+        let initColProperty = function (iRow, title) {
+            sheet.setText(setting.headRows + iRow, 0, title, GC.Spread.Sheets.SheetArea.rowHeader);
+            sheet.addSpan(setting.headRows + iRow, 0, 1, 2, GC.Spread.Sheets.SheetArea.rowHeader);
+        };
+
         sheet.setColumnCount(2, GC.Spread.Sheets.SheetArea.rowHeader);
         sheet.setColumnWidth(0, 80, GC.Spread.Sheets.SheetArea.rowHeader);
         sheet.setColumnWidth(1, 70, GC.Spread.Sheets.SheetArea.rowHeader);
-        sheet.setRowCount(setting.headRows + this.Rows.showHint + 1);
+        sheet.setRowCount(setting.headRows + this.Rows.visible + 1);
 
         sheet.setText(setting.headRows + this.Rows.data, 0, 'Data', GC.Spread.Sheets.SheetArea.rowHeader);
         sheet.setStyle(setting.headRows + this.Rows.data, -1, this.DEFAULT_DATA_STYLE);
@@ -68,14 +77,11 @@ let ColSettingObj = {
         sheet.setText(setting.headRows + this.Rows.getText, 1, 'getText', GC.Spread.Sheets.SheetArea.rowHeader);
         sheet.setText(setting.headRows + this.Rows.wordWrap, 1, 'wordWrap', GC.Spread.Sheets.SheetArea.rowHeader);
 
-        sheet.setText(setting.headRows + this.Rows.width, 0, 'width', GC.Spread.Sheets.SheetArea.rowHeader);
-        sheet.addSpan(setting.headRows + this.Rows.width, 0, 1, 2, GC.Spread.Sheets.SheetArea.rowHeader);
-
-        sheet.setText(setting.headRows + this.Rows.readOnly, 0, 'ReadOnly', GC.Spread.Sheets.SheetArea.rowHeader);
-        sheet.addSpan(setting.headRows + this.Rows.readOnly, 0, 1, 2, GC.Spread.Sheets.SheetArea.rowHeader);
-
-        sheet.setText(setting.headRows + this.Rows.showHint, 0, 'ShowHint', GC.Spread.Sheets.SheetArea.rowHeader);
-        sheet.addSpan(setting.headRows + this.Rows.showHint, 0, 1, 2, GC.Spread.Sheets.SheetArea.rowHeader);
+        initColProperty(this.Rows.width, 'Width');
+        initColProperty(this.Rows.readOnly, 'ReadOnly');
+        initColProperty(this.Rows.showHint, 'ShowHint');
+        initColProperty(this.Rows.visible, 'Visible');
+        initColProperty(this.Rows.cellType, 'CellType');
     },
     initColSetting: function (setting) {
         this.DEFAULT_TITLE_STYLE = this.getCellStyle('Arial', GC.Spread.Sheets.HorizontalAlign.center, GC.Spread.Sheets.VerticalAlign.center);
@@ -87,11 +93,15 @@ let ColSettingObj = {
         $('#header-row-count').val(setting.headRows);
 
         colEditSpread = new GC.Spread.Sheets.Workbook($('#colEditSpread')[0], {sheetCount: 1});
+        colEditSpread.getActiveSheet().setRowCount(0);
+        colEditSpread.getActiveSheet().setColumnCount(0);
         colEditSpread.options.tabStripVisible = false;
         colEditSpread.bind(GC.Spread.Sheets.Events.ColumnWidthChanged, this.columnValueChanged);
         colEditSpread.bind(GC.Spread.Sheets.Events.ValueChanged, this.valueChanged);
         colEditSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, this.selectionChanged);
 
+        colEditSpread.getActiveSheet().suspendPaint();
+
         this.initSheet(colEditSpread.getActiveSheet(), setting);
         this.setColCount(this.colSetting.cols.length);
         this.setHeaderRowCount(this.colSetting.headRows);
@@ -134,6 +144,9 @@ let ColSettingObj = {
                 // wordWrap
                 cell = sheet.getCell(this.colSetting.headRows + this.Rows.wordWrap, iCol, GC.Spread.Sheets.SheetArea.viewport);
                 cell.cellType(this.cellType.checkBox).value(col.data.wordWrap).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
+                // cellType
+                cell = sheet.getCell(this.colSetting.headRows + this.Rows.cellType, iCol, GC.Spread.Sheets.SheetArea.viewport);
+                cell.cellType(this.cellType.cellType).value(col.data.cellType).hAlign(GC.Spread.Sheets.HorizontalAlign.right);
                 // 列宽
                 sheet.setColumnWidth(iCol, col.width);
                 sheet.setValue(this.colSetting.headRows + this.Rows.width, iCol, sheet.getColumnWidth(iCol), GC.Spread.Sheets.SheetArea.viewport);
@@ -143,8 +156,14 @@ let ColSettingObj = {
                 // showHint
                 cell = sheet.getCell(this.colSetting.headRows + this.Rows.showHint, iCol, GC.Spread.Sheets.SheetArea.viewport);
                 cell.cellType(this.cellType.checkBox).value(col.showHint).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
+                // visible
+                cell = sheet.getCell(this.colSetting.headRows + this.Rows.visible, iCol, GC.Spread.Sheets.SheetArea.viewport);
+                cell.cellType(this.cellType.checkBox).value(col.visible).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
             }
         }
+
+        colEditSpread.getActiveSheet().resumePaint();
+
         let cell = colEditSpread.getActiveSheet().getCell(0, 0, GC.Spread.Sheets.SheetArea.viewport);
         if (cell) {
             $('#font').val(cell.font());
@@ -152,14 +171,20 @@ let ColSettingObj = {
     },
     setColCount: function (count) {
         let sheet = colEditSpread.getActiveSheet();
+        let orgCount = sheet.getColumnCount();
         sheet.setColumnCount(count);
-        for (let iCol = 0; iCol < sheet.getColumnCount(); iCol++) {
+        for (let iCol = orgCount; iCol < count; iCol++) {
+            for (let iRow = 0; iRow < this.colSetting.headRows; iRow ++) {
+                sheet.setStyle(iRow, iCol, this.DEFAULT_TITLE_STYLE);
+            }
             sheet.getCell(this.colSetting.headRows + this.Rows.getText, iCol).cellType(this.cellType.getText).hAlign(GC.Spread.Sheets.HorizontalAlign.right);
             sheet.getCell(this.colSetting.headRows + this.Rows.wordWrap, iCol).cellType(this.cellType.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
+            sheet.getCell(this.colSetting.headRows + this.Rows.cellType, iCol).cellType(this.cellType.cellType).hAlign(GC.Spread.Sheets.HorizontalAlign.right);
             sheet.setValue(this.colSetting.headRows + this.Rows.width, iCol, sheet.getColumnWidth(iCol), GC.Spread.Sheets.SheetArea.viewport);
             sheet.getCell(this.colSetting.headRows + this.Rows.readOnly, iCol).cellType(this.cellType.readOnly).hAlign(GC.Spread.Sheets.HorizontalAlign.right);
             sheet.setValue(this.colSetting.headRows + this.Rows.readOnly, iCol, false, GC.Spread.Sheets.SheetArea.viewport);
             sheet.getCell(this.colSetting.headRows + this.Rows.showHint, iCol).cellType(this.cellType.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
+            sheet.getCell(this.colSetting.headRows + this.Rows.visible, iCol).cellType(this.cellType.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center).value(true);
         }
     },
     setHeaderRowCount: function (count) {
@@ -218,6 +243,7 @@ let ColSettingObj = {
             if (sheet.getValue(setting.headRows + this.Rows.showHint, iCol)) {
                 col.showHint = sheet.getValue(setting.headRows + this.Rows.showHint, iCol) || false;
             }
+            col.visible = sheet.getValue(setting.headRows + this.Rows.visible, iCol) || false;
 
             col.head = {};
             col.head.titleNames = [];

+ 2 - 0
web/users/js/compilation.js

@@ -237,6 +237,8 @@ function initCompilation() {
     mainTreeCol = mainTreeCol === '' ? '' : JSON.parse(mainTreeCol);
 
     let artificialCoefficientData = artificialCoefficientList === undefined ? [] : JSON.parse(artificialCoefficientList);
+    mainTreeCol = mainTreeCol.replace(/\n/g, '\\n');
+    billsTemplateData = billsTemplateData.replace(/\n/g, '\\n');
 
     // 初始化 造价书列设置
     colSpread = TREE_SHEET_HELPER.createNewSpread($('#main-tree-col')[0]);

+ 88 - 0
web/users/js/main_tree_col.js

@@ -0,0 +1,88 @@
+/**
+ * Created by Mai on 2017/7/25.
+ */
+
+let MainTreeCol = {
+    getText: {
+        type: function (node) {
+            if (node.sourceType === projectObj.project.Bills.getSourceType()) {
+                return '';
+            } else if (node.sourceType === projectObj.project.Ration.getSourceType()) {
+                return '定';
+            } else if (node.sourceType === projectObj.project.VolumePrice.getSourceType()) {
+                return '量';
+            } else if (node.sourceType === projectObj.project.ration_glj.getSourceType()) {
+                return '主';
+            }
+        }
+    },
+    readOnly: {
+        bills: function (node) {
+            return node.sourceType === projectObj.project.Bills.getSourceType();
+        },
+        ration: function (node) {
+            return node.sourceType === projectObj.project.Ration.getSourceType();
+        },
+        volumePrice: function (node) {
+            return node.sourceType === projectObj.project.VolumePrice.getSourceType();
+        },
+        non_bills: function (node) {
+            return node.sourceType !== projectObj.project.Bills.getSourceType();
+        },
+        non_ration: function (node) {
+            return node.sourceType !== projectObj.project.Ration.getSourceType();
+        },
+        non_volumePrice: function (node) {
+            return node.sourceType !== projectObj.project.Ration.getSourceType();
+        },
+        billsParent: function (node) {
+            return node.sourceType === projectObj.project.Bills.getSourceType() && node.source.children.length > 0;
+        },
+        forCalcBase: function (node) {
+            // to do according to billsParentType
+            return MainTreeCol.readOnly.billsParent && MainTreeCol.readOnly.non_bills;
+        }
+    },
+    cellType: {
+        unit: function () {
+            let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
+            combo.itemHeight(10).items(['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
+                '根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']);
+            return combo;
+        }
+    },
+    getEvent: function (eventName) {
+        let names = eventName.split('.');
+        let event = this;
+        for (let name of names) {
+            if (event[name]) {
+                event = event[name];
+            } else {
+                return null;
+            }
+        }
+        if (event && Object.prototype.toString.apply(event) !== "[object Function]") {
+            return null;
+        } else {
+            return event;
+        }
+    },
+    getNumberFormatter: function (digit) {
+        switch (digit) {
+            case 1:
+                return '0.#';
+            case 2:
+                return '0.##';
+            case 3:
+                return '0.###';
+            case 4:
+                return '0.####';
+            case 5:
+                return '0.#####';
+            case 6:
+                return '0.######';
+            default:
+                return '0.##';
+        }
+    }
+};

+ 1 - 0
web/users/js/template.js

@@ -183,6 +183,7 @@ $(document).ready(function () {
         }
     }
 
+    billsTemplateData = billsTemplateData.replace('\n', '\\n');
     let templateData = JSON.parse(billsTemplateData);
     for (let data of templateData) {
         if (data.flags) {

+ 1 - 1
web/users/views/compilation/modal.html

@@ -163,7 +163,7 @@
                         </div>
                     </div>
                 </div>
-                <div id="colEditSpread">
+                <div id="colEditSpread" style="height: 300px">
                 </div>
             </div>
             <div class="modal-footer">