Prechádzať zdrojové kódy

多Spread结构调整,换成一Spread多Sheet。

Chenshilong 8 rokov pred
rodič
commit
8f84fb5df5

+ 26 - 0
public/web/sheet/sheet_common.js

@@ -2,6 +2,32 @@
  * Created by Tony on 2017/4/28.
  */
 var sheetCommonObj = {
+    // createSpread、initSheet 在一个Spread多个Sheet分别调用时的情况下使用。
+    // buildSheet 在一个Spread、一个Sheet的情况下使用。
+    createSpread: function(container, SheetCount){
+        var me = this;
+        var spreadBook = new GC.Spread.Sheets.Workbook(container, { sheetCount: SheetCount });
+        spreadBook.options.tabStripVisible = false;
+        spreadBook.options.showHorizontalScrollbar = false;
+        return spreadBook;
+    },
+
+    initSheet: function(sheet, setting, rowCount) {
+        var me = this;
+        var spreadNS = GC.Spread.Sheets;
+        sheet.suspendPaint();
+        sheet.suspendEvent();
+        sheet.setRowCount(1, spreadNS.SheetArea.colHeader);
+        sheet.setColumnCount(setting.header.length, spreadNS.SheetArea.viewport);
+        sheet.options.colHeaderAutoTextIndex = 1;
+        sheet.options.colHeaderAutoText = spreadNS.HeaderAutoText.numbers;
+        sheet.showRowOutline(false);
+        me.buildHeader(sheet, setting);
+        if (rowCount > 0) sheet.setRowCount(rowCount);
+        sheet.resumeEvent();
+        sheet.resumePaint();
+    },
+
     buildSheet: function(container, setting, rowCount) {
         var me = this;
         var spreadBook = new GC.Spread.Sheets.Workbook(container, { sheetCount: 1 });

+ 23 - 8
web/maintain/ration_repository/dinge.html

@@ -77,25 +77,28 @@
                                   <!-- 标签 -->
                                   <ul class="nav nav-tabs" role="tablist">
                                       <li class="nav-item">
-                                          <a class="nav-link" data-toggle="tab" href="#bglj" role="tab">工料机</a>
+                                          <a class="nav-link active" id="linkGLJ" data-toggle="tab" href="#bglj" role="tab">工料机</a>
                                       </li>
                                       <li class="nav-item">
                                           <a class="nav-link" data-toggle="tab" href="#bfzd" role="tab">辅助定额调整</a>
                                       </li>
                                       <li class="nav-item">
-                                          <a class="nav-link active" data-toggle="tab" href="#bfzt" role="tab">附注条件调整</a>
+                                          <a class="nav-link" id="linkFZTJ" data-toggle="tab" href="#bfzt" role="tab">附注条件调整</a>
                                       </li>
                                       <li class="nav-item">
                                           <a class="nav-link" data-toggle="tab" href="#baz" role="tab">安装增加费</a>
                                       </li>
                                       <li class="nav-item">
-                                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button>本分项全部适用</button>
+                                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button id="btnGLJ">工料机</button>
+                                      </li>
+                                      <li class="nav-item">
+                                          &nbsp;<button id="btnFZTJ">附注条件</button>
                                       </li>
                                   </ul>
                                   <!-- 内容 -->
                                   <div class="tab-content">
                                       <!--工料机-->
-                                      <div class="tab-pane" id="bglj" role="tabpanel">
+                                      <div class="tab-pane active" id="bglj" role="tabpanel">
                                           <div id="rationGLJSheet" class="main-data-bottom"></div>
                                       </div>
                                       <!--辅助定额调整-->
@@ -123,7 +126,7 @@
                                       </div>
                                       <!--附注条件调整-->
 
-                                      <div class="tab-pane active" id="bfzt" role="tabpanel">
+                                      <div class="tab-pane" id="bfzt" role="tabpanel">
                                           <div id="rationCoeSpread" class="main-data-bottom"></div>
                                           <!--<div class="main-data-bottom">
                                               <table class="table table-sm table-bordered m-0">
@@ -559,10 +562,22 @@
             $(document).ready(function(){
                 pageOprObj.initPage();
                 rationOprObj.buildSheet($("#rationItemsSheet")[0]);
-                rationGLJOprObj.buildSheet($("#rationGLJSheet")[0]);
-                rationCoeOprObj.buildSheet($("#rationCoeSpread")[0]);
                 sheetCommonObj.shieldAllCells(rationOprObj.workBook.getSheet(0), rationOprObj.setting);
-                sheetCommonObj.shieldAllCells(rationGLJOprObj.workBook.getSheet(0), rationGLJOprObj.setting);
+
+               // tabPanel 下有多个Spread时,相互之间不能正确显示。改成一个Spread下多个Sheet。
+                var rdSpread = sheetCommonObj.createSpread($("#rationGLJSheet")[0], 3);
+                rationGLJOprObj.buildSheet(rdSpread.getSheet(0));
+                sheetCommonObj.shieldAllCells(rdSpread.getSheet(0), rationGLJOprObj.setting);
+                rationCoeOprObj.buildSheet(rdSpread.getSheet(1));
+                sheetCommonObj.shieldAllCells(rdSpread.getSheet(1), rationCoeOprObj.setting);
+
+                $("#btnGLJ").click(function(){
+                    rdSpread.setActiveSheetIndex(0);
+                });
+
+                $("#btnFZTJ").click(function(){
+                    rdSpread.setActiveSheetIndex(1);
+                });
             });
         </script>
     </div>

+ 10 - 5
web/maintain/ration_repository/js/ration.js

@@ -44,8 +44,9 @@ var rationOprObj = {
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.CellClick, me.onCellClick);
     },
     onCellClick: function(sender, args) {
-        var me = rationOprObj, sheetGLJ = rationGLJOprObj.workBook.getSheet(0), settingGLJ = rationGLJOprObj.setting,
-            sheetCoe = rationCoeOprObj.workBook.getSheet(0), settingCoe = rationCoeOprObj.setting;
+        var me = rationOprObj,
+            sheetGLJ = rationGLJOprObj.sheet, settingGLJ = rationGLJOprObj.setting,
+            sheetCoe = rationCoeOprObj.sheet, settingCoe = rationCoeOprObj.setting;
         if(args.sheetArea === GC.Spread.Sheets.SheetArea.colHeader || args.sheetArea === GC.Spread.Sheets.SheetArea.corner){
             sheetCommonObj.cleanSheet(sheetGLJ, settingGLJ, -1);
             sheetCommonObj.shieldAllCells(sheetGLJ);
@@ -58,6 +59,7 @@ var rationOprObj = {
             sheetCommonObj.shieldAllCells(sheetCoe);
             var cacheSection = me.getCache();
             if (cacheSection && args.row < cacheSection.length) {
+                //alert('0001'+JSON.stringify(cacheSection[args.row]));
                 rationGLJOprObj.getGljItems(cacheSection[args.row]);
                 rationCoeOprObj.getCoeItems(cacheSection[args.row]);
             }
@@ -240,7 +242,8 @@ var rationOprObj = {
             if (me.currentRations["_SEC_ID_" + sectionID]) {
                 me.showRationItems(sectionID);
                 sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
-                sheetCommonObj.lockCells(rationGLJOprObj.workBook.getSheet(0), rationGLJOprObj.setting);
+                sheetCommonObj.lockCells(rationGLJOprObj.sheet, rationGLJOprObj.setting);
+                sheetCommonObj.lockCells(rationCoeOprObj.sheet, rationCoeOprObj.setting);
             } else {
                 $.ajax({
                     type:"POST",
@@ -254,10 +257,12 @@ var rationOprObj = {
                             me.currentRations["_SEC_ID_" + sectionID] = result.data;
                             me.showRationItems(sectionID);
                             sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
-                            sheetCommonObj.lockCells(rationGLJOprObj.workBook.getSheet(0), rationGLJOprObj.setting);
+                            sheetCommonObj.lockCells(rationGLJOprObj.sheet, rationGLJOprObj.setting);
+                            sheetCommonObj.lockCells(rationCoeOprObj.sheet, rationCoeOprObj.setting);
                         } else {
                             sheetCommonObj.shieldAllCells(me.workBook.getSheet(0));
-                            sheetCommonObj.shieldAllCells(rationGLJOprObj.workBook.getSheet(0));
+                            sheetCommonObj.shieldAllCells(rationGLJOprObj.sheet);
+                            sheetCommonObj.shieldAllCells(rationCoeOprObj.sheet);
                         }
                     },
                     error:function(err){

+ 21 - 15
web/maintain/ration_repository/js/ration_coe.js

@@ -2,7 +2,7 @@
  * Created by CSL on 2017-06-08.
  */
 var rationCoeOprObj = {
-    workBook: null,
+    sheet: null,
     libID: -1,
     currentRationItem: null,
     cache: {},
@@ -17,14 +17,17 @@ var rationCoeOprObj = {
             lockColumns:[1,2]
         }
     },
-    buildSheet: function(container) {
+    buildSheet: function(sheet) {
         var me = this;
+        me.sheet = sheet;
+        //alert('0020 libID:' + JSON.stringify(me.libID));
         me.libID = storageUtil.getSessionCache("RationGrp","repositoryID");
-        me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
+        //alert('0021 libID:' + JSON.stringify(me.libID));
+        sheetCommonObj.initSheet(me.sheet, me.setting, 30);
+        me.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
+        me.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
+        me.sheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
+        me.sheet.bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
     },
     onRangeChanged: function(sender, args) {
         if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {
@@ -38,7 +41,7 @@ var rationCoeOprObj = {
                         }
                     }
                     me.updateRationItem();
-                    sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
+                    sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
                     me.showCoeItems(me.currentRationItem.ID);
                 }
             }
@@ -75,7 +78,7 @@ var rationCoeOprObj = {
                     if (args.row < cacheArr.length) {
                         cacheArr.splice(args.row, 1);
                         me.updateRationItem();
-                        sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
+                        sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
                         me.showCoeItems(me.currentRationItem.ID);
                     }
                 }
@@ -99,7 +102,7 @@ var rationCoeOprObj = {
             cache:false,
             timeout:5000,
             success:function(result){
-                sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
+                sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
                 if (result) {
                     var rstArr = [], newAddArr = [];
                     for (var i = 0; i < result.data.length; i++) {
@@ -132,7 +135,7 @@ var rationCoeOprObj = {
                         me.updateRationItem();
                     }
                 }
-                sheetCommonObj.lockCells(me.workBook.getSheet(0), me.setting);
+                sheetCommonObj.lockCells(me.sheet, me.setting);
             },
             error:function(err){
                 alert(err);
@@ -165,9 +168,12 @@ var rationCoeOprObj = {
         if (rationCoeList == undefined){return;};
 
         me.currentRationItem = rationItem;
+        //alert('0009 ' + JSON.stringify(me.cache));
+        //alert('0010 ' + JSON.stringify(me.cache["_Coe_" + rationID]));
+        //alert('0011 ' + JSON.stringify(me.libID));
         if (me.cache["_Coe_" + rationID]) {
             me.showCoeItems(rationID);
-            sheetCommonObj.lockCells(me.workBook.getSheet(0), me.setting);
+            sheetCommonObj.lockCells(me.sheet, me.setting);
         } else {
             $.ajax({
                 type:"POST",
@@ -177,7 +183,7 @@ var rationCoeOprObj = {
                 cache:false,
                 timeout:5000,
                 success:function(result){
-                    sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
+                    sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
 
                     if (result.data) {
                         var cacheArr = [];
@@ -192,7 +198,7 @@ var rationCoeOprObj = {
                         me.cache["_Coe_" + rationID] = cacheArr;
                         me.showCoeItems(rationID);
                     }
-                    sheetCommonObj.lockCells(me.workBook.getSheet(0), me.setting);
+                    sheetCommonObj.lockCells(me.sheet, me.setting);
                 },
                 error:function(err){
                     alert(err);
@@ -203,7 +209,7 @@ var rationCoeOprObj = {
     showCoeItems: function(rationID) {
         var me = this;
         if (me.cache["_Coe_" + rationID]) {
-            sheetCommonObj.showData(me.workBook.getSheet(0), me.setting, me.cache["_Coe_" + rationID]);
+            sheetCommonObj.showData(me.sheet, me.setting, me.cache["_Coe_" + rationID]);
         }
     }
 }

+ 18 - 16
web/maintain/ration_repository/js/ration_glj.js

@@ -2,12 +2,12 @@
  * Created by Tony on 2017/4/28.
  */
 var rationGLJOprObj = {
-    workBook: null,
+    sheet: null,
     currentRationItem: null,
     cache: {},
     setting: {
         header:[
-            {headerName:"编码",headerWidth:160,dataCode:"code", dataType: "String", formatter: "@"},
+            {headerName:"编码",headerWidth:120,dataCode:"code", dataType: "String", formatter: "@"},
             {headerName:"名称",headerWidth:400,dataCode:"name", dataType: "String"},
             {headerName:"单位",headerWidth:160,dataCode:"unit", dataType: "String"},
             {headerName:"单位基价",headerWidth:160, dataCode:"basePrice", dataType: "Number", precision: 2},
@@ -19,13 +19,15 @@ var rationGLJOprObj = {
             lockColumns:[1,2,3,5,6]
         }
     },
-    buildSheet: function(container) {
+    buildSheet: function(sheet) {
         var me = this;
-        me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
+        me.sheet = sheet;
+        sheetCommonObj.initSheet(me.sheet, me.setting, 30);
+
+        me.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
+        me.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
+        me.sheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
+        me.sheet.bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
     },
     onRangeChanged: function(sender, args) {
         if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {
@@ -39,7 +41,7 @@ var rationGLJOprObj = {
                         }
                     }
                     me.updateRationItem();
-                    sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
+                    sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
                     me.showGljItems(me.currentRationItem.ID);
                 }
             }
@@ -87,7 +89,7 @@ var rationGLJOprObj = {
                     if (args.row < cacheArr.length) {
                         cacheArr.splice(args.row, 1);
                         me.updateRationItem();
-                        sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
+                        sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
                         me.showGljItems(me.currentRationItem.ID);
                     }
                 }
@@ -112,7 +114,7 @@ var rationGLJOprObj = {
             cache:false,
             timeout:5000,
             success:function(result){
-                sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
+                sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
                 if (result) {
                     var rstArr = [], dummyR = {gljId: 0, consumeAmt:0}, newAddArr = [];
                     for (var i = 0; i < result.data.length; i++) {
@@ -146,7 +148,7 @@ var rationGLJOprObj = {
                         me.updateRationItem();
                     }
                 }
-                sheetCommonObj.lockCells(me.workBook.getSheet(0), me.setting);
+                sheetCommonObj.lockCells(me.sheet, me.setting);
             },
             error:function(err){
                 alert(err);
@@ -191,7 +193,7 @@ var rationGLJOprObj = {
         me.currentRationItem = rationItem;
         if (me.cache["_GLJ_" + rationID]) {
             me.showGljItems(rationID);
-            sheetCommonObj.lockCells(me.workBook.getSheet(0), me.setting);
+            sheetCommonObj.lockCells(me.sheet, me.setting);
         } else {
             var gljIds = [];
             for (var i = 0; i < rationGljList.length; i++) {
@@ -205,7 +207,7 @@ var rationGLJOprObj = {
                 cache:false,
                 timeout:5000,
                 success:function(result){
-                    sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
+                    sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
                     if (result) {
                         var cacheArr = [];
                         for (var i = 0; i < result.data.length; i++) {
@@ -219,7 +221,7 @@ var rationGLJOprObj = {
                         me.cache["_GLJ_" + rationID] = cacheArr;
                         me.showGljItems(rationID);
                     }
-                    sheetCommonObj.lockCells(me.workBook.getSheet(0), me.setting);
+                    sheetCommonObj.lockCells(me.sheet, me.setting);
                 },
                 error:function(err){
                     alert(err);
@@ -230,7 +232,7 @@ var rationGLJOprObj = {
     showGljItems: function(rationID) {
         var me = this;
         if (me.cache["_GLJ_" + rationID]) {
-            sheetCommonObj.showData(me.workBook.getSheet(0), me.setting, me.cache["_GLJ_" + rationID]);
+            sheetCommonObj.showData(me.sheet, me.setting, me.cache["_GLJ_" + rationID]);
         }
     }
 }

+ 2 - 2
web/maintain/ration_repository/js/section_tree.js

@@ -201,8 +201,8 @@ var zTreeOprObj = {
             sheetCommonObj.cleanSheet(rationOprObj.workBook.getSheet(0), rationOprObj.setting, -1);
             sheetCommonObj.shieldAllCells(rationOprObj.workBook.getSheet(0));
         }
-        sheetCommonObj.cleanSheet(rationGLJOprObj.workBook.getSheet(0), rationGLJOprObj.setting, -1);
-        sheetCommonObj.shieldAllCells(rationGLJOprObj.workBook.getSheet(0));
+        sheetCommonObj.cleanSheet(rationGLJOprObj.sheet, rationGLJOprObj.setting, -1);
+        sheetCommonObj.shieldAllCells(rationGLJOprObj.sheet);
     }
 
 };