Browse Source

修复列设置问题,更新列设置客制化属性

MaiXinRong 7 years ago
parent
commit
6a394b6999

+ 7 - 1
modules/users/models/engineering_lib_model.js

@@ -59,7 +59,13 @@ class EngineeringLibModel extends BaseModel {
         if (data.main_tree_col) {
             data.main_tree_col = JSON.parse(data.main_tree_col);
         } else {
-            delete data['main_tree_col'];
+            data.main_tree_col = {
+                emptyRows: 3,
+                headRows: 0,
+                treeCol: 0,
+                headRowHeight: [],
+                cols:[]
+            }
         }
 
         let result = false;

+ 8 - 2
web/users/js/col_setting.js

@@ -12,7 +12,7 @@ let ColSettingObj = {
         readOnly: null,
         checkBox: null
     },
-    Rows: {data: 0, filedName: 0, getText: 1, wordWrap: 2, cellType: 3, width: 4, readOnly: 5, showHint: 6, visible: 7},
+    Rows: {data: 0, filedName: 0, getText: 1, wordWrap: 2, cellType: 3, width: 4, readOnly: 5, showHint: 6, visible: 7, customize: 8},
     columnValueChanged: function (e, info) {
         let that = ColSettingObj;
         info.colList.forEach(function (iCol) {
@@ -67,7 +67,7 @@ let ColSettingObj = {
         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.visible + 1);
+        sheet.setRowCount(setting.headRows + this.Rows.customize + 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);
@@ -82,6 +82,7 @@ let ColSettingObj = {
         initColProperty(this.Rows.showHint, 'ShowHint');
         initColProperty(this.Rows.visible, 'Visible');
         initColProperty(this.Rows.cellType, 'CellType');
+        initColProperty(this.Rows.customize, 'Customize');
     },
     initColSetting: function (setting) {
         this.DEFAULT_TITLE_STYLE = this.getCellStyle('Arial', GC.Spread.Sheets.HorizontalAlign.center, GC.Spread.Sheets.VerticalAlign.center);
@@ -159,6 +160,9 @@ let ColSettingObj = {
                 // 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);
+                // customize
+                cell = sheet.getCell(this.colSetting.headRows + this.Rows.customize, iCol, GC.Spread.Sheets.SheetArea.viewport);
+                cell.cellType(this.cellType.checkBox).value(col.customize).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
             }
         }
 
@@ -185,6 +189,7 @@ let ColSettingObj = {
             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);
+            sheet.getCell(this.colSetting.headRows + this.Rows.customize, iCol).cellType(this.cellType.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center).value(false);
         }
     },
     setHeaderRowCount: function (count) {
@@ -244,6 +249,7 @@ let ColSettingObj = {
                 col.showHint = sheet.getValue(setting.headRows + this.Rows.showHint, iCol) || false;
             }
             col.visible = sheet.getValue(setting.headRows + this.Rows.visible, iCol) || false;
+            col.customize = sheet.getValue(setting.headRows + this.Rows.customize, iCol) || false;
 
             col.head = {};
             col.head.titleNames = [];

+ 6 - 4
web/users/js/compilation.js

@@ -234,19 +234,21 @@ function initCompilation() {
     let rationLibData = rationList === undefined ? [] : JSON.parse(rationList);
     let gljLibData = gljList === undefined ? [] : JSON.parse(gljList);
     let feeLibData = feeRateList === undefined ? [] : JSON.parse(feeRateList);
-    mainTreeCol = mainTreeCol !== '' ? mainTreeCol.replace(/\n/g, '\\n') : mainTreeCol;
-    mainTreeCol = mainTreeCol === '' ? '' : JSON.parse(mainTreeCol);
     let artificialCoefficientData = artificialCoefficientList === undefined ? [] : JSON.parse(artificialCoefficientList);
+
+    mainTreeCol = mainTreeCol !== '' ? mainTreeCol.replace(/\n/g, '\\n') : mainTreeCol;
     billsTemplateData = billsTemplateData.replace(/\n/g, '\\n');
 
+    let mainTreeColObj = mainTreeCol === '' ? {} : JSON.parse(mainTreeCol);
+
     // 初始化 造价书列设置
     colSpread = TREE_SHEET_HELPER.createNewSpread($('#main-tree-col')[0]);
     let billsTemplateTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1});
 
     billsTemplateTree.loadDatas(JSON.parse(billsTemplateData));
     if (mainTreeCol !== '') {
-        TREE_SHEET_HELPER.loadSheetHeader(mainTreeCol, colSpread.getActiveSheet());
-        TREE_SHEET_HELPER.showTreeData(mainTreeCol, colSpread.getActiveSheet(), billsTemplateTree);
+        TREE_SHEET_HELPER.loadSheetHeader(mainTreeColObj, colSpread.getActiveSheet());
+        TREE_SHEET_HELPER.showTreeData(mainTreeColObj, colSpread.getActiveSheet(), billsTemplateTree);
     }
 
     if (billListData.length <= 0 || rationLibData.length <= 0 || gljLibData.length <= 0) {