Browse Source

debug & 优化

zhongzewei 7 years ago
parent
commit
ecf1b4f8fb

+ 4 - 4
web/maintain/ration_repository/dinge.html

@@ -507,18 +507,18 @@
             $(document).ready(function(){
                 pageOprObj.initPage();
                 rationOprObj.buildSheet($("#rationItemsSheet")[0]);
-                sheetCommonObj.shieldAllCells(rationOprObj.workBook.getSheet(0), rationOprObj.setting);
+               // sheetCommonObj.shieldAllCells(rationOprObj.workBook.getSheet(0), rationOprObj.setting);
 
                // tabPanel 下有多个Spread时,相互之间不能正确显示。改成一个Spread下多个Sheet。
                 var rdSpread = sheetCommonObj.createSpread($("#rdSpread")[0], 3);
                 rationGLJOprObj.buildSheet(rdSpread.getSheet(0));
-                sheetCommonObj.shieldAllCells(rdSpread.getSheet(0), rationGLJOprObj.setting);
+               // sheetCommonObj.shieldAllCells(rdSpread.getSheet(0), rationGLJOprObj.setting);
 
                 rationAssistOprObj.buildSheet(rdSpread.getSheet(1));
-                sheetCommonObj.shieldAllCells(rdSpread.getSheet(1), rationAssistOprObj.setting);
+             //   sheetCommonObj.shieldAllCells(rdSpread.getSheet(1), rationAssistOprObj.setting);
 
                 rationCoeOprObj.buildSheet(rdSpread.getSheet(2));
-                sheetCommonObj.shieldAllCells(rdSpread.getSheet(2), rationCoeOprObj.setting);
+              //  sheetCommonObj.shieldAllCells(rdSpread.getSheet(2), rationCoeOprObj.setting);
 
                 $("#linkGLJ").click(function(){
                     rationGLJOprObj.bindRationGljDelOpr();

+ 20 - 47
web/maintain/ration_repository/js/ration.js

@@ -57,7 +57,6 @@ let rationOprObj = {
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.SelectionChanged, me.onSelectionChanged);
     },
-
     onSelectionChanged: function (sender, info) {
         if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
             let row = info.newSelections[0].row;
@@ -66,11 +65,8 @@ let rationOprObj = {
                 sheetCoe = rationCoeOprObj.sheet, settingCoe = rationCoeOprObj.setting,
                 sheetAss = rationAssistOprObj.sheet, settingAss = rationAssistOprObj.setting;
             sheetCommonObj.cleanSheet(sheetGLJ, settingGLJ, -1);
-            sheetCommonObj.shieldAllCells(sheetGLJ);
             sheetCommonObj.cleanSheet(sheetCoe, settingCoe, -1);
-            sheetCommonObj.shieldAllCells(sheetCoe);
             sheetCommonObj.cleanSheet(sheetAss, settingAss, -1);
-            sheetCommonObj.shieldAllCells(sheetAss);
             let cacheSection = me.getCache();
             if (cacheSection && row < cacheSection.length) {
                 rationGLJOprObj.getGljItems(cacheSection[row], function () {
@@ -118,6 +114,8 @@ let rationOprObj = {
                     if (cacheSection[j][me.setting.header[0].dataCode] == result.data.ops[i][me.setting.header[0].dataCode]) {
                         cacheSection[j]["ID"] = result.data.ops[i]["ID"];
                         cacheSection[j]["rationGljList"] = result.data.ops[i]["rationGljList"];
+                        cacheSection[j]["rationCoeList"] = result.data.ops[i]["rationCoeList"];
+                        cacheSection[j]["rationAssList"] = result.data.ops[i]["rationAssList"];
                     }
                 }
             }
@@ -159,12 +157,9 @@ let rationOprObj = {
                         if(sels[sel].col === 0){
                             $('#alertText').text("编号不能为空,修改失败!");
                             $('#alertModalBtn').click();
-                            rationSheet.options.isProtected = true;
                             $('#alertModalCls').click(function () {
-                                rationSheet.options.isProtected = false;
                             });
                             $('#alertModalCof').click(function () {
-                                rationSheet.options.isProtected = false;
                             })
                         }
                         else if(sels[sel].col !== 0 && !(sels[sel].col === 3 && sels.col + sels[sel].colCount -1 === 6)){
@@ -214,20 +209,16 @@ let rationOprObj = {
                 let focusToCol = !me.addRationItem.code ? 0 : -1;
                 if(focusToCol !== -1){
                     $('#rationAlertBtn').click();
-                    me.workBook.getSheet(0).options.isProtected = true;
                     $('#rationAlertCac').click(function () {
-                        me.workBook.getSheet(0).options.isProtected = false;
                         me.addRationItem = null;
                         for(let col=0; col<me.setting.header.length; col++){
                             me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value('');
                         }
                     });
                     $('#rationAlertCls').click(function () {
-                        me.workBook.getSheet(0).options.isProtected = false;
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
                     });
                     $('#rationAlertCof').click(function () {
-                        me.workBook.getSheet(0).options.isProtected = false;
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
                     });
                 }
@@ -236,7 +227,7 @@ let rationOprObj = {
     },
     onCellEditStart: function(sender, args) {
         let me = rationOprObj;
-        if(!me.canRations){
+        if(!me.canRations || me.setting.view.lockColumns.indexOf(args.col) !== -1){
             args.cancel = true;
         }
         else{
@@ -315,22 +306,6 @@ let rationOprObj = {
                         alert('编码已存在!');
                         me.workBook.getSheet(0).setValue(args.row, args.col, '');
                     }
-                    /*else if(!rObj.code && rObj.code === ''){
-                        $('#alertModalBtn').click();
-                        me.workBook.getSheet(0).options.isProtected = true;
-                        $('#alertModalCls').click(function () {
-                            me.workBook.getSheet(0).options.isProtected = false;
-                            me.addRationItem.code = '';
-                            me.workBook.getSheet(0).setValue(args.row, args.col, '');
-                            me.workBook.getSheet(0).setActiveCell(args.row, args.col);
-                        });
-                        $('#alertModalCof').click(function () {
-                            me.workBook.getSheet(0).options.isProtected = false;
-                            me.addRationItem.code = '';
-                            me.workBook.getSheet(0).setValue(args.row, args.col, '');
-                            me.workBook.getSheet(0).setActiveCell(args.row, args.col);
-                        });
-                    }*/
                 }
                 else if(rObj.code && rObj.code.toString.trim().length === 0){
                     me.workBook.getSheet(0).setValue(args.row, args.col, '');
@@ -343,9 +318,17 @@ let rationOprObj = {
             me.mixUpdateRequest(updateArr, addArr, []);
         }
     },
+    canPasted: function (beginCol, maxCol) {
+        let rst = false;
+        if(maxCol < 3 || beginCol > 6){
+            rst = true;
+        }
+        return rst;
+    },
     onClipboardPasting: function(sender, args) {
         let me = rationOprObj;
-        if(!me.canRations){
+        let maxCol = args.cellRange.col + args.cellRange.colCount -1;
+        if(!me.canRations || !me.canPasted(args.cellRange.col, maxCol) || maxCol > me.setting.header.length - 1){
             args.cancel = true;
         }
     },
@@ -461,7 +444,6 @@ let rationOprObj = {
     },
     mixUpdateRequest: function(updateArr, addArr, removeIds, callback) {
         let me = rationOprObj;
-        sheetCommonObj.setLockCol(me.workBook.getSheet(0), 0, true);
         $.ajax({
             type:"POST",
             url:"api/mixUpdateRationItems",
@@ -507,7 +489,6 @@ let rationOprObj = {
                     me.mixUpdate = 0;
                     me.mixDel = 0;
                 }
-                sheetCommonObj.setLockCol(me.workBook.getSheet(0), 0, false);
                 if(callback) callback();
             },
             error:function(){
@@ -526,11 +507,6 @@ let rationOprObj = {
                 //annotation
                 annotationOprObj.rationAnnotationOpr(me.currentRations["_SEC_ID_" + sectionID]);
                 me.showRationItems(sectionID);
-                ///sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
-                sheetCommonObj.lockCells(rationGLJOprObj.sheet, rationGLJOprObj.setting);
-                sheetCommonObj.lockCells(rationCoeOprObj.sheet, rationCoeOprObj.setting);
-                sheetCommonObj.lockCells(me.workBook.getSheet(0), rationOprObj.setting);
-                sheetCommonObj.unShieldAllCells(rationAssistOprObj.sheet);
             } else {
                 $.ajax({
                     type:"POST",
@@ -549,16 +525,6 @@ let rationOprObj = {
                             //annotation
                             annotationOprObj.rationAnnotationOpr(me.currentRations["_SEC_ID_" + sectionID]);
                             me.showRationItems(sectionID);
-                            //sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
-                            sheetCommonObj.lockCells(me.workBook.getSheet(0), rationOprObj.setting);
-                            sheetCommonObj.lockCells(rationGLJOprObj.sheet, rationGLJOprObj.setting);
-                            sheetCommonObj.lockCells(rationCoeOprObj.sheet, rationCoeOprObj.setting);
-                            sheetCommonObj.unShieldAllCells(rationAssistOprObj.sheet);
-                        } else {
-                            sheetCommonObj.shieldAllCells(me.workBook.getSheet(0));
-                            sheetCommonObj.shieldAllCells(rationGLJOprObj.sheet);
-                            sheetCommonObj.shieldAllCells(rationCoeOprObj.sheet);
-                            sheetCommonObj.shieldAllCells(rationAssistOprObj.sheet);
                         }
                     },
                     error:function(err){
@@ -578,23 +544,30 @@ let rationOprObj = {
                 let cacheSection = me.currentRations["_SEC_ID_" + sectionID];
                 sheetCommonObj.cleanData(me.workBook.getSheet(0), me.setting, -1);
                 sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, cacheSection);
-                sheetCommonObj.setLockCol(me.workBook.getSheet(0), 4, true);
                 //combo
                 sheetCommonObj.setStaticCombo(me.workBook.getActiveSheet(), 0, 2, cacheSection.length, rationUnits, 10, false);
                 sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), cacheSection.length, 2, me.workBook.getActiveSheet().getRowCount() - cacheSection.length, rationUnits, 10, false);
                 if(me.mixDel === 1){
                     let row = me.workBook.getSheet(0).getSelections()[0].row;
                     if (cacheSection && row < cacheSection.length) {
+                        sheetCommonObj.cleanData(sheetGLJ, settingGLJ, -1);
+                        sheetCommonObj.cleanData(sheetCoe, settingCoe, -1);
+                        sheetCommonObj.cleanData(sheetAss, settingAss, -1);
                         rationGLJOprObj.getGljItems(cacheSection[row]);
                         rationCoeOprObj.getCoeItems(cacheSection[row]);
                         rationAssistOprObj.getAssItems(cacheSection[row]);
                     }
                     else {
                         rationGLJOprObj.currentRationItem = null;
+                        sheetCommonObj.cleanData(sheetGLJ, settingGLJ, -1);
+                        sheetCommonObj.cleanData(sheetCoe, settingCoe, -1);
+                        sheetCommonObj.cleanData(sheetAss, settingAss, -1);
+                        sheetCommonObj.setDynamicCombo(sheetAss, 0, 5, sheetAss.getRowCount(), rationAssistOprObj.setting.comboItems, false, false);
                     }
                 }
 
             } else {
+                sheetCommonObj.setDynamicCombo(sheetAss, 0, 5, sheetAss.getRowCount(), rationAssistOprObj.setting.comboItems, false, false);
                 sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 2, me.workBook.getActiveSheet().getRowCount(), rationUnits, 10, false);
                 //清除ration数据及工料机数据
                 rationGLJOprObj.currentRationItem = null;

+ 25 - 10
web/maintain/ration_repository/js/ration_assist.js

@@ -28,23 +28,28 @@ var rationAssistOprObj = {
 
         sheetCommonObj.initSheet(me.sheet, me.setting, 30);
 
-        /*var carryBit = new GC.Spread.Sheets.CellTypes.ComboBox();
-        carryBit.items(["四舍五入","进一"]);
-        me.sheet.getRange(-1, 5, -1, 1).cellType(carryBit);*/
-
         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.EditStarting, me.onEditStarting);
         me.sheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onEditEnded);
         me.sheet.bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
-        //me.sheet.bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
     },
 
     onEnterCell: function (sender, args) {
+        let me = rationAssistOprObj;
         args.sheet.repaint();
+        let cellType = args.sheet.getCellType(args.row, 5);
+        if(cellType.typeName !== 'undefined' && cellType.typeName === '1'){
+            sheetCommonObj.setStaticCombo(args.sheet, 0, 5, 0, me.setting.comboItems, false);
+            sheetCommonObj.setDynamicCombo(args.sheet, 0, 5, me.sheet.getRowCount(), me.setting.comboItems, false, false);
+        }
     },
 
     onClipboardPasting: function(sender, args) {
-        var me = rationAssistOprObj;
+        let me = rationAssistOprObj;
+        let rationSection = rationOprObj.getCache();
+        let rationRow = rationOprObj.workBook.getSheet(0).getSelections()[0].row;
+        me.ration = rationRow < rationSection.length ? rationSection[rationRow] : null;
         if (!me.ration) {
             args.cancel = true;
         }
@@ -71,12 +76,23 @@ var rationAssistOprObj = {
         sheetCommonObj.showData(me.sheet, me.setting, me.ration.rationAssList);
     },
 
+    onEditStarting: function (sender, args) {
+        let me = rationAssistOprObj;
+        let rationSection = rationOprObj.getCache();
+        let rationRow = rationOprObj.workBook.getSheet(0).getSelections()[0].row;
+        me.ration = rationRow < rationSection.length ? rationSection[rationRow] : null;
+        if(!me.ration){
+            args.cancel = true;
+        }
+    },
+
     onEditEnded: function(sender, args){
         var me = rationAssistOprObj;
         if (!me.ration) {return;};
+        if(typeof me.ration.rationAssList === 'undefined'){
+            me.ration.rationAssList = [];
+        }
         var assList = me.ration.rationAssList;
-        if(assList == undefined) assList = [];
-        //var assObj = sheetCommonObj.combineRowData(me.sheet, me.setting, args.row);
         var assObj = sheetsOprObj.combineRationRowData(me.sheet, me.setting, args.row);
         let dataCode = me.setting.header[args.col].dataCode;
         if((args.col === 2 || args.col === 3 || args.col === 6 || args.col === 7)
@@ -92,14 +108,13 @@ var rationAssistOprObj = {
             return;
         }
         // 新增
-        if ((assList == undefined) || (assList && args.row >= assList.length)) {
+        if (args.row >= assList.length) {
             if (assObj.decimal == undefined || assObj.decimal == null){assObj.decimal = '0';};
             if (assObj.carryBit == undefined || assObj.carryBit == null){assObj.carryBit = '四舍五入';};
             assList.push(assObj);
         }
         // 修改
         else{ assList[args.row] = assObj; };
-
         rationOprObj.mixUpdateRequest([me.ration], [], [], function () {
             me.sheet.getParent().focus(true);
         });

+ 18 - 5
web/maintain/ration_repository/js/ration_coe.js

@@ -28,12 +28,16 @@ var rationCoeOprObj = {
         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.EditStarting, me.onEditStarting);
         me.sheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onEditEnded);
        // me.sheet.bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
     },
 
     onClipboardPasting: function(sender, args) {
         var me = rationCoeOprObj;
+        let rationSection = rationOprObj.getCache();
+        let rationRow = rationOprObj.workBook.getSheet(0).getSelections()[0].row;
+        me.curRation = rationRow < rationSection.length ? rationSection[rationRow] : null;
         if (args.cellRange.colCount != 1 || args.cellRange.col != 0 || !(me.curRation)) {
             args.cancel = true;
         }
@@ -94,7 +98,16 @@ var rationCoeOprObj = {
             }
         }
     },
+    onEditStarting: function (sender, args) {
+        let me = rationCoeOprObj;
+        let rationSection = rationOprObj.getCache();
+        let rationRow = rationOprObj.workBook.getSheet(0).getSelections()[0].row;
+        me.curRation = rationRow < rationSection.length ? rationSection[rationRow] : null;
+        if(!me.curRation || args.col !== 0){
+            args.cancel = true;
+        }
 
+    },
     onEditEnded: function(sender, args){
         var me = rationCoeOprObj;
         if (args.col == 0 && args.editingText && args.editingText.toString().trim().length > 0 && !isNaN(args.editingText)) {   // 编号列
@@ -195,7 +208,7 @@ var rationCoeOprObj = {
 
         if(temp.length == 0){
             me.showCoeItems(me.curRation.ID);
-            sheetCommonObj.lockCells(me.sheet, me.setting);
+            //sheetCommonObj.lockCells(me.sheet, me.setting);
         }else{
             $.ajax({
                 type:"POST",
@@ -223,7 +236,7 @@ var rationCoeOprObj = {
                         });
                         me.showCoeItems(me.curRation.ID);
                     };
-                    sheetCommonObj.lockCells(me.sheet, me.setting);
+                    //sheetCommonObj.lockCells(me.sheet, me.setting);
                 },
                 error:function(err){
                     alert(err);
@@ -243,8 +256,8 @@ var rationCoeOprObj = {
         var curCache = me.cache["_Coe_" + ration.ID];
         if (curCache) {
             me.showCoeItems(ration.ID);
-            sheetCommonObj.lockCells(me.sheet, me.setting);
-        } else {
+            //sheetCommonObj.lockCells(me.sheet, me.setting);
+        } else if(!curCache && typeof coeList !== 'undefined' && coeList.length > 0) {
             var data = {"libID": me.libID, "coeIDs": coeList};
             $.ajax({
                 type:"POST",
@@ -265,7 +278,7 @@ var rationCoeOprObj = {
 
                         me.showCoeItems(ration.ID);
                     }
-                    sheetCommonObj.lockCells(me.sheet, me.setting);
+                    //sheetCommonObj.lockCells(me.sheet, me.setting);
                     if(callback) callback();
                 },
                 error:function(err){

+ 60 - 70
web/maintain/ration_repository/js/ration_glj.js

@@ -83,19 +83,14 @@ var rationGLJOprObj = {
             me.bindRationGljDelOpr();
             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.EditStarting, me.onEditStarting);
             me.sheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
-            //me.sheet.bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
         });
     },
-    unBindDel: function () {
-        let me = rationGLJOprObj, spreadBook = me.sheet.getParent();
-        spreadBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
-        spreadBook.commandManager().setShortcutKey('clear', GC.Spread.Commands.Key.del, false, false, false, false);
-    },
     bindRationGljDelOpr: function () {
         let me = rationGLJOprObj, spreadBook = me.sheet.getParent();
         spreadBook.commandManager().register('rationGljDelete', function () {
-            let sels = me.sheet.getSelections(), updateArr = [], removeArr = [], lockCols = me.setting.view.lockColumns;
+            let sels = me.sheet.getSelections(), lockCols = me.setting.view.lockColumns;
             let cacheSection = me.cache["_GLJ_" + me.currentRationItem.ID], isUpdate = false;
             if(sels.length > 0){
                 for(let sel = 0; sel < sels.length; sel++){
@@ -131,16 +126,18 @@ var rationGLJOprObj = {
                 sheetCommonObj.cleanData(me.sheet, me.setting, -1);
                 me.showGljItems(me.currentRationItem.ID);
             }
-           /* if(updateArr.length > 0 || removeArr.length > 0){
-                me.mixUpdateRequest(updateArr, [], removeArr);
-            }*/
-
         });
         spreadBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
         spreadBook.commandManager().setShortcutKey('rationGljDelete', GC.Spread.Commands.Key.del, false, false, false, false);
     },
     onClipboardPasting: function(sender, args) {
         var me = rationGLJOprObj;
+        let rationSection = rationOprObj.getCache();
+        let rationRow = rationOprObj.workBook.getSheet(0).getSelections()[0].row;
+        me.currentRationItem = rationRow < rationSection.length ? rationSection[rationRow] : null;
+        if(me.currentRationItem && typeof me.cache["_GLJ_" + me.currentRationItem.ID] === 'undefined'){
+            me.cache["_GLJ_" + me.currentRationItem.ID] = [];
+        }
         if (!(args.cellRange.col === 0 || args.cellRange.col === 5) || !(me.currentRationItem)) {
             args.cancel = true;
         }
@@ -196,6 +193,23 @@ var rationGLJOprObj = {
             }
         }
     },
+    onEditStarting: function (sender, args) {
+        let me = rationGLJOprObj;
+        let rationSection = rationOprObj.getCache();
+        let rationRow = rationOprObj.workBook.getSheet(0).getSelections()[0].row;
+        me.currentRationItem = rationRow < rationSection.length ? rationSection[rationRow] : null;
+        if(me.currentRationItem && typeof me.cache["_GLJ_" + me.currentRationItem.ID] === 'undefined'){
+            me.cache["_GLJ_" + me.currentRationItem.ID] = [];
+        }
+        if(!me.currentRationItem){
+            args.cancel = true;
+        }
+        else {
+            if(args.col !== 0 && args.col !== 5 || args.col === 5 && args.row >= me.cache["_GLJ_" + me.currentRationItem.ID].length){
+                args.cancel = true;
+            }
+        }
+    },
     onCellEditEnd: function(sender, args){
         var me = rationGLJOprObj;
         if(me.currentRationItem) {
@@ -209,13 +223,10 @@ var rationGLJOprObj = {
                         if (isNaN(parseFloat(args.editingText))) {
                             $('#alertModalBtn').click();
                             $('#alertText').text("定额消耗只能输入数值!");
-                            args.sheet.options.isProtected = true;
                             $('#alertModalCls').click(function () {
-                                args.sheet.options.isProtected = false;
                                 args.sheet.setValue(args.row, args.col, editGlj['consumeAmt']);
                             });
                             $('#alertModalCof').click(function () {
-                                args.sheet.options.isProtected = false;
                                 args.sheet.setValue(args.row, args.col, editGlj['consumeAmt']);
                             })
                         }
@@ -296,8 +307,6 @@ var rationGLJOprObj = {
                         callback: function(key, options) {
                         },
                         items: {
-                            /*"insert": {name: "插入", callback: function (key, opt) {
-                            }},*/
                             "delete": {name: "删除", icon: 'fa-remove', disabled: delDis, callback: function (key, opt) {
                                 cacheSection.splice(target.row, 1);
                                 me.updateRationItem(function () {
@@ -333,7 +342,6 @@ var rationGLJOprObj = {
     },
     addGljItems: function(codes, repId, args) {
         var me = this;
-        sheetCommonObj.setLockCol(me.sheet, 0, true);
         $.ajax({
             type:"POST",
             url:"api/getGljItemsByCodes",
@@ -342,10 +350,8 @@ var rationGLJOprObj = {
             cache:false,
             timeout:5000,
             success:function(result){
-                //sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
                 if (result) {
                     if(result.data.length > 0){
-                        //sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
                         sheetCommonObj.cleanData(me.sheet, me.setting, -1);
                         var rstArr = [], dummyR = {gljId: 0, consumeAmt:0}, newAddArr = [];
                         for (var i = 0; i < result.data.length; i++) {
@@ -391,7 +397,6 @@ var rationGLJOprObj = {
                         if(recoveryArr.length > 0){
                             me.cache["_GLJ_" + me.currentRationItem.ID] = cacheArr.concat(recoveryArr);
                         }
-                        //me.cache["_GLJ_" + me.currentRationItem.ID] = cacheArr.concat(me.tempCacheArr);
                         //更新的工料机不存在
                         me.cache["_GLJ_" + me.currentRationItem.ID].sort(function(a, b) {
                             var rst = 0;
@@ -401,19 +406,14 @@ var rationGLJOprObj = {
                         });
                         $('#alertModalBtn').click();
                         $('#alertText').text("工料机"+ codes + "不存在,请查找你所需要的工料机,或新增工料机");
-                        me.sheet.options.isProtected = true;
                         $('#alertModalCls').click(function () {
-                            sheetCommonObj.lockCells(me.sheet, me.setting);
                             me.showGljItems(me.currentRationItem.ID);
                         });
                         $('#alertModalCof').click(function () {
-                            sheetCommonObj.lockCells(me.sheet, me.setting);
                             me.showGljItems(me.currentRationItem.ID);
                         })
                     }
                 }
-                sheetCommonObj.lockCells(me.sheet, me.setting);
-                sheetCommonObj.setLockCol(me.sheet, 0, false);
             },
             error:function(err){
                 alert(err);
@@ -518,54 +518,52 @@ var rationGLJOprObj = {
         me.currentRationItem = rationItem;
         if (me.cache["_GLJ_" + rationID]) {
             me.showGljItems(rationID);
-            sheetCommonObj.lockCells(me.sheet, me.setting);
         } else {
             var gljIds = [];
             for (var i = 0; i < rationGljList.length; i++) {
                 gljIds.push(rationGljList[i].gljId);
             }
-            $.ajax({
-                type:"POST",
-                url:"api/getGljItemsByIds",
-                data:{"gljIds": JSON.stringify(gljIds)},
-                dataType:"json",
-                cache:false,
-                timeout:5000,
-                success:function(result){
-                    sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
-                    if (result) {
-                        var cacheArr = [];
-                        for (var i = 0; i < result.data.length; i++) {
-                            for (var j = 0; j < rationGljList.length; j++) {
-                                if (rationGljList[j].gljId == result.data[i].ID) {
-                                    cacheArr.push(me.createRationGljDisplayItem(rationGljList[j], result.data[i]));
-                                    break;
+                $.ajax({
+                    type:"POST",
+                    url:"api/getGljItemsByIds",
+                    data:{"gljIds": JSON.stringify(gljIds)},
+                    dataType:"json",
+                    cache:false,
+                    timeout:5000,
+                    success:function(result){
+                        sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
+                        if (result) {
+                            var cacheArr = [];
+                            for (var i = 0; i < result.data.length; i++) {
+                                for (var j = 0; j < rationGljList.length; j++) {
+                                    if (rationGljList[j].gljId == result.data[i].ID) {
+                                        cacheArr.push(me.createRationGljDisplayItem(rationGljList[j], result.data[i]));
+                                        break;
+                                    }
                                 }
                             }
-                        }
-                        function compare(){
-                            return function (a, b) {
-                                let rst = 0;
-                                if (a.code > b.code) {
-                                    rst = 1;
-                                }
-                                else if (a.code < b.code) {
-                                    rst = -1;
+                            function compare(){
+                                return function (a, b) {
+                                    let rst = 0;
+                                    if (a.code > b.code) {
+                                        rst = 1;
+                                    }
+                                    else if (a.code < b.code) {
+                                        rst = -1;
+                                    }
+                                    return rst;
                                 }
-                                return rst;
                             }
+                            cacheArr.sort(compare());
+                            me.cache["_GLJ_" + rationID] = cacheArr;
+                            me.showGljItems(rationID);
                         }
-                        cacheArr.sort(compare());
-                        me.cache["_GLJ_" + rationID] = cacheArr;
-                        me.showGljItems(rationID);
+                        if(callback) callback();
+                    },
+                    error:function(err){
+                        alert(err);
                     }
-                    sheetCommonObj.lockCells(me.sheet, me.setting);
-                    if(callback) callback();
-                },
-                error:function(err){
-                    alert(err);
-                }
-            })
+                })
         }
     },
     showGljItems: function(rationID) {
@@ -573,14 +571,6 @@ var rationGLJOprObj = {
         if (me.cache["_GLJ_" + rationID]) {
             sheetCommonObj.cleanData(me.sheet, me.setting, -1);
             sheetsOprObj.showData(me.sheet, me.setting, me.cache["_GLJ_" + rationID], me.distTypeTree);
-            //lock
-            me.sheet.suspendPaint();
-            me.sheet.suspendEvent();
-            for(let i = 0, len = me.sheet.getRowCount(); i < len; i++){
-                me.sheet.getCell(i, 4).locked(true);
-            }
-            me.sheet.resumePaint();
-            me.sheet.resumeEvent();
         }
     }
 }

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

@@ -355,16 +355,16 @@ var zTreeOprObj = {
         } else {
             rationOprObj.canRations = false;
             rationOprObj.currentSectionId = sectionID;
-            sheetCommonObj.unsetCombo(rationOprObj.workBook.getActiveSheet(), 0, 2, rationOprObj.workBook.getActiveSheet().getRowCount());
+           // sheetCommonObj.unsetCombo(rationOprObj.workBook.getActiveSheet(), 0, 2, rationOprObj.workBook.getActiveSheet().getRowCount());
             jobContentOprObj.setRadiosDisabled(true, jobContentOprObj.radios);
             jobContentOprObj.hideTable($('#tableAll'), $('#tablePartial'));
             annotationOprObj.setRadiosDisabled(true, annotationOprObj.radios);
             annotationOprObj.hideTable($('#fzTableAll'), $('#fzTablePartial'));
             sheetCommonObj.cleanSheet(rationOprObj.workBook.getSheet(0), rationOprObj.setting, -1);
-            sheetCommonObj.shieldAllCells(rationOprObj.workBook.getSheet(0));
+            //sheetCommonObj.shieldAllCells(rationOprObj.workBook.getSheet(0));
         }
         sheetCommonObj.cleanSheet(rationGLJOprObj.sheet, rationGLJOprObj.setting, -1);
-        sheetCommonObj.shieldAllCells(rationGLJOprObj.sheet);
+        //sheetCommonObj.shieldAllCells(rationGLJOprObj.sheet);
         rationGLJOprObj.sheet.getParent().focus(false);
     }
 };

+ 13 - 13
web/maintain/ration_repository/js/sheetsOpr.js

@@ -32,11 +32,11 @@ let sheetsOprObj = {
         else{
             sheet.setRowCount(typeof repositoryGljObj !== 'undefined' && repositoryGljObj.currentOprParent === 1 ? data.length : data.length + 10);
         }
-        if(data.length === 0){
+        /*if(data.length === 0){
             for(let i = 0; i < sheet.getRowCount(); i++){
                 sheet.getCell(i, 4, GC.Spread.Sheets.SheetArea.viewport).locked(false);
             }
-        }
+        }*/
         for (var col = 0; col < setting.header.length; col++) {
             var hAlign = "left", vAlign = "center";
             if (setting.header[col].hAlign) {
@@ -55,26 +55,26 @@ let sheetsOprObj = {
             for (var row = 0; row < data.length; row++) {
                 //var cell = sheet.getCell(row, col, GC.Spread.Sheets.SheetArea.viewport);
                 if(setting.header[col].dataCode === 'gljType' && data[row].gljType){
-                    if(typeof repositoryGljObj !== 'undefined' && typeof repositoryGljObj.allowComponent !== 'undefined' && repositoryGljObj.allowComponent.indexOf(data[row].gljType) !== -1){
+                   /* if(typeof repositoryGljObj !== 'undefined' && typeof repositoryGljObj.allowComponent !== 'undefined' && repositoryGljObj.allowComponent.indexOf(data[row].gljType) !== -1){
                         sheet.getCell(row, 4, GC.Spread.Sheets.SheetArea.viewport).locked(true);
                     }
                     else if(typeof repositoryGljObj !== 'undefined' && typeof repositoryGljObj.allowComponent !== 'undefined' && repositoryGljObj.allowComponent.indexOf(data[row].gljType) === -1){
                         sheet.getCell(row, 4, GC.Spread.Sheets.SheetArea.viewport).locked(false);
-                    }
+                    }*/
                     let distTypeVal =  distTypeTree.distTypes[distTypeTree.prefix + data[row].gljType].data.fullName;
                     sheet.setValue(row, col, distTypeVal, ch);
                 }
                 else {
                     sheet.setValue(row, col, data[row][setting.header[col].dataCode], ch);
                     sheet.setTag(row, 0, data[row].ID, ch);
-                    if(typeof setting.owner !== 'undefined' && setting.owner !== 'gljComponent'){
+                    /*if(typeof setting.owner !== 'undefined' && setting.owner !== 'gljComponent'){
                         sheet.getCell(row, 0, GC.Spread.Sheets.SheetArea.viewport).locked(true);
-                    }
+                    }*/
                 }
             }
-            for(let i = data.length; i < sheet.getRowCount(); i++){
+          /*  for(let i = data.length; i < sheet.getRowCount(); i++){
                 sheet.getCell(i, 4, GC.Spread.Sheets.SheetArea.viewport).locked(false);
-            }
+            }*/
         }
         sheet.resumeEvent();
         sheet.resumePaint();
@@ -103,21 +103,21 @@ let sheetsOprObj = {
                         isExist = false;
                     for(let i=0; i< gljList.length; i++){
                         if(gljList[i].code === sheet.getValue(row, col) && sheet.getValue(row, col)!== orgCode){
-                            sheetCommonObj.lockAllCells(sheet);
+                           // sheetCommonObj.lockAllCells(sheet);
                             $('#alertText').text("输入的编号已存在,请重新输入!");
                             $('#codeAlertBtn').click();
                             $('#codAleConfBtn').click(function () {
                                 // me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
-                                sheetCommonObj.unLockAllCells(sheet);
-                                me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
+                               // sheetCommonObj.unLockAllCells(sheet);
+                                //me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
                                 sheet.setValue(row, 0, orgCode);
                                 sheet.getCell(row, 0).formatter("@");
                                 sheet.setActiveCell(row, 0);
                             });
                             $('#codAleClose').click(function () {
                                 //me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
-                                sheetCommonObj.unLockAllCells(sheet);
-                                me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
+                                //sheetCommonObj.unLockAllCells(sheet);
+                                //me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
                                 sheet.setValue(row, 0, orgCode);
                                 sheet.getCell(row, 0).formatter("@");
                                 sheet.setActiveCell(row, 0);

+ 125 - 137
web/maintain/std_glj_lib/js/glj.js

@@ -17,7 +17,6 @@ let pageOprObj = {
                 repositoryGljObj.getGljTree(gljLibId, function () {
                     repositoryGljObj.getGljItems(gljLibId);
                 });
-                sheetCommonObj.shieldAllCells(repositoryGljObj.workBook.getSheet(0), repositoryGljObj.setting);
             });
         });
     }
@@ -79,10 +78,6 @@ let repositoryGljObj = {
             }
         });
         distTypeTree.distTypesArr.forEach(function (distTypeObj) {
-           /* if(distTypeObj.children.length === 0 && distTypeObj.data.fullName !== '普通机械' &&distTypeObj.data.fullName !== '机械组成物'
-                && distTypeObj.data.fullName !== '机上人工'){
-                distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
-            }*/
             if(distTypeObj.data.fullName !== '材料' && distTypeObj.data.fullName !== '机械'){
                 distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
             }
@@ -99,9 +94,6 @@ let repositoryGljObj = {
                 if(!result.error && callback){
                     me.distTypeTree = me.getComboData(result.data);
                     console.log(me.distTypeTree);
-                    /*let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
-                    combo.items(me.distTypeTree.comboDatas).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
-                    me.workBook.getSheet(0).getCell(-1, 5, GC.Spread.Sheets.SheetArea.viewport).cellType(combo);*/
                     callback();
                 }
             }
@@ -289,10 +281,6 @@ let repositoryGljObj = {
         //混凝土202、砂浆203、配合比204、机械3
         if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
             let row = info.newSelections[0].row;
-            sheetCommonObj.lockCells(that.workBook.getSheet(0), that.setting);
-            that.workBook.getSheet(0).getRange(-1, 0 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
-            that.workBook.getSheet(0).getRange(-1, 4 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
-            //that.workBook.getSheet(0).options.isProtected = true;
             sheetCommonObj.cleanSheet(that.workBook.getSheet(0), that.setting, -1);
             me.workBook.focus(true);
             me.currentComponent = [];
@@ -301,10 +289,6 @@ let repositoryGljObj = {
                 //标记当前工料机
                 me.currentGlj = me.currentCache[row];
                 if(me.allowComponent.indexOf(me.currentCache[row].gljType) !== -1){
-                    that.workBook.getSheet(0).getRange(-1, 0 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
-                    that.workBook.getSheet(0).getRange(-1, 4 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
-                    //that.workBook.getSheet(0).options.isProtected = false;
-                    //sheetCommonObj.lockCells(that.workBook.getSheet(0), that.setting);
                     //展示数据
                     if(me.currentGlj.component.length > 0){
                         me.currentComponent = me.getCurrentComponent(me.currentGlj.component);
@@ -359,24 +343,13 @@ let repositoryGljObj = {
                 }
                 else {
                     $('#gljAlertBtn').click();
-                    //me.workBook.getSheet(0).options.isProtected = true;
-                    sheetCommonObj.lockAllCells(args.sheet);
                     $('#aleConfBtn').click(function () {
-                        // me.workBook.getSheet(0).options.isProtected = false;
-                        sheetCommonObj.unLockAllCells(args.sheet);
-                        sheetsOprObj.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
                     });
                     $('#gljAleClose').click(function () {
-                        // me.workBook.getSheet(0).options.isProtected = false;
-                        sheetCommonObj.unLockAllCells(args.sheet);
-                        sheetsOprObj.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
                     });
                     $('#aleCanceBtn').click(function () {
-                        // me.workBook.getSheet(0).options.isProtected = false;
-                        sheetCommonObj.unLockAllCells(args.sheet);
-                        sheetsOprObj.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
                         me.addGljObj = null;
                         for(let col=0; col<me.setting.header.length; col++){
                             if(col === 0){
@@ -395,18 +368,19 @@ let repositoryGljObj = {
         let rObj = sheetsOprObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row);
         me.currentEditingGlj = rObj;
         me.orgCode = me.workBook.getSheet(0).getValue(args.row, 0);
-        let cacheSection = me.gljList;
-        if (cacheSection) {
-            for (let j = 0; j < cacheSection.length; j++) {
-                if (cacheSection[j][me.setting.header[0].dataCode] && cacheSection[j][me.setting.header[0].dataCode] == rObj[me.setting.header[0].dataCode]) {
-                    rObj["ID"] = cacheSection[j]["ID"];
-                    rObj.gljClass = cacheSection[j].gljClass;
-                    break;
-                }
+        if(args.row < me.currentCache.length){
+            me.currentGlj = me.currentCache[args.row];
+            if(args.col === 0 || (args.col === 4 && me.allowComponent.indexOf(me.currentGlj.gljType) !== -1)
+                || (args.col === 6 && me.currentGlj.gljType !== 1 && me.currentGlj.gljType !== 303)){
+                args.cancel = true;
+            }
+            else {
+                rObj.ID = me.currentGlj.ID;
+                rObj.gljClass = me.currentGlj.gljClass;
             }
         }
-        if(me.currentEditingGlj.gljType !== 1 && me.currentEditingGlj.gljType !== 303 && me.setting.header[args.col].dataCode === 'adjCoe'){
-            args.cancel = true;
+        else {
+            me.currentGlj = null;
         }
     },
     onCellEditEnd: function(sender, args) {
@@ -537,7 +511,6 @@ let repositoryGljObj = {
         }
         if(updateArr.length >0 || addArr.length >0){
             me.currentEditingGlj = null;
-            //me.workBook.getSheet(0).setValue(11, 5, "人工");
             me.mixUpdateRequest(updateArr, addArr, []);
         }
     },
@@ -611,12 +584,9 @@ let repositoryGljObj = {
                                 }
                                 $('#alertText').text(text + "不可为空!");
                                 $('#codeAlertBtn').click();
-                                sheet.options.isProtected = true;
                                 $('#codAleConfBtn').click(function () {
-                                    sheetsOprObj.lockSomeCodes(sheet, 0, cacheSection.length);
                                 });
                                 $('#codAleClose').click(function () {
-                                    sheetsOprObj.lockSomeCodes(sheet, 0, cacheSection.length);
                                 });
                             }
                         }
@@ -794,127 +764,153 @@ let repositoryGljObj = {
         pasteObj.gljClass = me.gljCurTypeId;
         return true;
     },
-    onClipboardPasting: function(sender, args) {
+    canPasted: function (info) {
+        let rst = true;
         let me = repositoryGljObj;
-        if (me.gljCurTypeId < 0 ) {
-            args.cancel = true;
+        if(me.gljCurTypeId < 0){
+            return false;
+        }
+        if(info.cellRange.col + info.cellRange.colCount - 1 > me.setting.header.length - 1){
+            return false;
+        }
+        if(info.cellRange.row < me.currentCache.length){
+            if(info.cellRange.col === 0){
+                return false;
+            }
+            else if(info.cellRange.col <= 4 && info.cellRange.col + info.cellRange.colCount - 1 >= 4){
+                for(let i = 0, len = info.cellRange.rowCount; i < len; i++){
+                    let row = i + info.cellRange.row;
+                    if(row < me.currentCache.length){
+                        if(me.allowComponent.indexOf(me.currentCache[row].gljType) !== -1){
+                            rst = false;
+                        }
+                    }
+                    else {
+                        break;
+                    }
+                }
+            }
         }
-        let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
+        return rst;
+    },
+    onClipboardPasting: function(sender, args) {
+        let me = repositoryGljObj;
         //复制的列数超过正确的列数,不可复制
-        if(maxCol >= me.setting.header.length){
+        if(!me.canPasted(args)){
             args.cancel = true;
         }
     },
     onClipboardPasted: function(e, info) {
         let me = repositoryGljObj;
-            let updateArr = [], addArr = [];
-            let items = sheetCommonObj.analyzePasteData(me.setting, info);
-            let beginRow = info.cellRange.row, endRow = info.cellRange.row + info.cellRange.rowCount - 1,
-                maxRow = me.currentCache.length - 1,
-                updateBasePrcArr = [] ,
-                updateCount, resumeArr = [];
-            if(endRow <= maxRow){
-                //updateItems = items;
-                for(let i = 0; i < items.length; i++){
-                    let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
-                    if(updateObj && typeof updateObj.updateGlj !== 'undefined' && updateObj.updateGlj.length > 0){
-                        //updateArr = updateObj.updateGlj;
-                        updateArr = updateArr.concat(updateObj.updateGlj);
-                        if(typeof updateObj.updateBasePrc !== 'undefined'){
-                            //updateBasePrcArr = updateObj.updateBasePrc;
-                            updateBasePrcArr = updateBasePrcArr.concat(updateObj.updateBasePrc);
-                        }
+        let updateArr = [], addArr = [];
+        let items = sheetCommonObj.analyzePasteData(me.setting, info);
+        let beginRow = info.cellRange.row, endRow = info.cellRange.row + info.cellRange.rowCount - 1,
+            maxRow = me.currentCache.length - 1,
+            updateBasePrcArr = [] ,
+            updateCount, resumeArr = [];
+        if(endRow <= maxRow){
+            //updateItems = items;
+            for(let i = 0; i < items.length; i++){
+                let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
+                if(updateObj && typeof updateObj.updateGlj !== 'undefined' && updateObj.updateGlj.length > 0){
+                    //updateArr = updateObj.updateGlj;
+                    updateArr = updateArr.concat(updateObj.updateGlj);
+                    if(typeof updateObj.updateBasePrc !== 'undefined'){
+                        //updateBasePrcArr = updateObj.updateBasePrc;
+                        updateBasePrcArr = updateBasePrcArr.concat(updateObj.updateBasePrc);
                     }
-                    else{
-                        resumeArr.push(info.cellRange.row + i);
+                }
+                else{
+                    resumeArr.push(info.cellRange.row + i);
+                }
+            }
+        }
+        else if(beginRow <= maxRow && endRow > maxRow){
+            updateCount = maxRow - beginRow + 1;
+            for(let i = 0; i < updateCount; i++){
+                let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
+                if(updateObj && typeof updateObj.updateGlj !== 'undefined'){
+                    updateArr = updateArr.concat(updateObj.updateGlj);
+                    if(typeof updateObj.updateBasePrc !== 'undefined'){
+                        updateBasePrcArr = updateBasePrcArr.concat(updateObj.updateBasePrc);
                     }
                 }
+                else{
+                    resumeArr.push(info.cellRange.row + i);
+                }
             }
-            else if(beginRow <= maxRow && endRow > maxRow){
-                updateCount = maxRow - beginRow + 1;
-                for(let i = 0; i < updateCount; i++){
-                    let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
-                    if(updateObj && typeof updateObj.updateGlj !== 'undefined'){
-                        updateArr = updateArr.concat(updateObj.updateGlj);
-                        if(typeof updateObj.updateBasePrc !== 'undefined'){
-                            updateBasePrcArr = updateBasePrcArr.concat(updateObj.updateBasePrc);
+            if(info.cellRange.colCount === me.setting.header.length){
+                for(let i = updateCount ; i < items.length; i++){
+                    if(me.isValidObj(items[i])){
+                        items[i].component = [];
+                        //类型为混凝土、砂浆、配合比、机械时,基价只能组成物计算
+                        if(me.allowComponent.indexOf(items[i].gljType) !== -1){
+                            items[i].basePrice = 0;
                         }
+                        addArr.push(items[i]);
                     }
                     else{
                         resumeArr.push(info.cellRange.row + i);
                     }
                 }
-                if(info.cellRange.colCount === me.setting.header.length){
-                    for(let i = updateCount ; i < items.length; i++){
-                        if(me.isValidObj(items[i])){
-                            items[i].component = [];
-                            //类型为混凝土、砂浆、配合比、机械时,基价只能组成物计算
-                            if(me.allowComponent.indexOf(items[i].gljType) !== -1){
-                                items[i].basePrice = 0;
-                            }
-                            addArr.push(items[i]);
-                        }
-                        else{
-                            resumeArr.push(info.cellRange.row + i);
+            }
+            else{
+                for(let i = updateCount ; i < items.length; i++){
+                    resumeArr.push(info.cellRange.row + i);
+                }
+            }
+        }
+        else{
+            if(info.cellRange.colCount === me.setting.header.length - 1 && info.cellRange.col + info.cellRange.colCount - 1 >= 5){
+                for(let i = 0; i < items.length; i++){
+                    if(me.isValidObj(items[i])){
+                        items[i].component = [];
+                        if(me.allowComponent.indexOf(items[i].gljType) !== -1){
+                            items[i].basePrice = 0;
                         }
+                        addArr.push(items[i]);
                     }
-                }
-                else{
-                    for(let i = updateCount ; i < items.length; i++){
+                    else{
                         resumeArr.push(info.cellRange.row + i);
                     }
                 }
             }
             else{
-                if(info.cellRange.colCount === me.setting.header.length){
-                    for(let i = 0; i < items.length; i++){
-                        if(me.isValidObj(items[i])){
-                            items[i].component = [];
-                            if(me.allowComponent.indexOf(items[i].gljType) !== -1){
-                                items[i].basePrice = 0;
-                            }
-                            addArr.push(items[i]);
+                for(let i = 0; i < items.length; i++){
+                    resumeArr.push(info.cellRange.row + i);
+                }
+            }
+        }
+        //repaint
+        if(resumeArr.length > 0){
+            info.sheet.suspendPaint();
+            for(let i = 0; i < resumeArr.length ; i++){
+                if(resumeArr[i] < me.currentCache.length){
+                    for(let col = 0; col < me.setting.header.length; col++){
+                        if(me.setting.header[col].dataCode === 'gljType'){
+                            let gljType = me.currentCache[resumeArr[i]][me.setting.header[col].dataCode];
+                            info.sheet.setValue(resumeArr[i], col, me.distTypeTree.distTypes["gljType" + gljType].data.fullName);
                         }
                         else{
-                            resumeArr.push(info.cellRange.row + i);
+                            info.sheet.setValue(resumeArr[i], col, me.currentCache[resumeArr[i]][me.setting.header[col].dataCode]);
                         }
                     }
                 }
                 else{
-                    for(let i = 0; i < items.length; i++){
-                        resumeArr.push(info.cellRange.row + i);
+                    for(let col = 0; col < me.setting.header.length; col++){
+                        info.sheet.setValue(resumeArr[i], col, '');
                     }
                 }
             }
-            //repaint
-            if(resumeArr.length > 0){
-                info.sheet.suspendPaint();
-                for(let i = 0; i < resumeArr.length ; i++){
-                    if(resumeArr[i] < me.currentCache.length){
-                        for(let col = 0; col < me.setting.header.length; col++){
-                            if(me.setting.header[col].dataCode === 'gljType'){
-                                let gljType = me.currentCache[resumeArr[i]][me.setting.header[col].dataCode];
-                                info.sheet.setValue(resumeArr[i], col, me.distTypeTree.distTypes["gljType" + gljType].data.fullName);
-                            }
-                            else{
-                                info.sheet.setValue(resumeArr[i], col, me.currentCache[resumeArr[i]][me.setting.header[col].dataCode]);
-                            }
-                        }
-                    }
-                    else{
-                        for(let col = 0; col < me.setting.header.length; col++){
-                            info.sheet.setValue(resumeArr[i], col, '');
-                        }
-                    }
-                }
-                info.sheet.resumePaint();
-            }
-            if (updateArr.length > 0 || addArr.length > 0) {
-                me.mixUpdateRequest(updateArr, addArr, []);
-            }
-            if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
-                me.updateRationBasePrcRq(updateBasePrcArr);
-            }
+            info.sheet.resumePaint();
+        }
+        if (updateArr.length > 0 || addArr.length > 0) {
+            console.log(addArr);
+            me.mixUpdateRequest(updateArr, addArr, []);
+        }
+        if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
+            me.updateRationBasePrcRq(updateBasePrcArr);
+        }
     },
     updateRationBasePrcRq: function (basePrcArr) {
         $.ajax({
@@ -963,14 +959,12 @@ let repositoryGljObj = {
                     }
                     else{
                         me.currentCache = me.getCache();
-                        //sheetCommonObj.unLockAllCells(me.workBook.getSheet(0));
-                        sheetsOprObj.reLockSomeCodes(me.workBook.getSheet(0), 0, me.currentCache.length);
-                        //sheetCommonObj.lockSomeCodes(me.workBook.getSheet(0), 0, me.currentCache.length);
                     }
                     me.showGljItems(me.gljList, me.gljCurTypeId);
                 }
             },
             error:function(err){
+                console.log(err);
                 alert("保存失败");
             }
         })
@@ -1053,20 +1047,14 @@ let gljTypeTreeOprObj = {
             gljTypeId = treeNode.ID;
         me.gljCurTypeId = treeNode.ID;
         me.addGljObj = null;
-        //me.currentCache = me.getCache();
         sheetCommonObj.cleanSheet(that.workBook.getSheet(0), that.setting, 5);
-        that.workBook.getSheet(0).getRange(-1, 0 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
-        that.workBook.getSheet(0).getRange(-1, 4 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
         if (me.parentNodeIds["_pNodeId_" + treeNode.ID]) {
             me.currentOprParent = 1;
             me.currentCache = me.getParentCache(me.parentNodeIds["_pNodeId_" + treeNode.ID]);
-            sheetsOprObj.lockCodeCells(me.workBook.getSheet(0), me.currentCache.length);
             me.workBook.getSheet(0).setRowCount(me.currentCache.length);
         } else {
             me.currentOprParent = 0;
             me.currentCache = me.getCache();
-            sheetCommonObj.unLockAllCells(me.workBook.getSheet(0));
-            sheetsOprObj.reLockSomeCodes(me.workBook.getSheet(0), 0, me.currentCache.length);
         }
         me.showGljItems(me.gljList, gljTypeId);
     },

+ 14 - 11
web/maintain/std_glj_lib/js/gljComponent.js

@@ -9,12 +9,12 @@ let gljComponentOprObj = {
         header:[
             {headerName:"编码",headerWidth:50,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
             {headerName:"名称",headerWidth:60,dataCode:"name", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
-            {headerName:"计量单位",headerWidth:60,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"单位",headerWidth:60,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
             {headerName:"单价",headerWidth:50,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
             {headerName:"消耗量",headerWidth:55,dataCode:"consumeAmt", dataType: "Number", formatter: "0.000", hAlign: "right", vAlign: "center"}
         ],
         view: {
-            lockedCells:[1, 2, 3]
+            lockedCols:[1, 2, 3]
         }
     },
     buildSheet: function(container) {
@@ -22,7 +22,6 @@ let gljComponentOprObj = {
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30, me);
         me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
         me.workBook.getSheet(0).setFormatter(-1, 0, "@", GC.Spread.Sheets.SheetArea.viewport);
-        me.workBook.getSheet(0).options.isProtected = true;
         sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
 
         me.gljComponentDelOpr();
@@ -30,12 +29,6 @@ let gljComponentOprObj = {
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
-       /* me.repositoryGljDelOpr();
-        me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
-        me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);*/
     },
     getRowData: function (sheet, row, setting) {
         let rst = {};
@@ -139,6 +132,17 @@ let gljComponentOprObj = {
         let me = gljComponentOprObj, that = repositoryGljObj;
         let rObj = me.getRowData(args.sheet, args.row, me.setting);
         me.currentEditingComponent = rObj;
+        let thatRow = that.workBook.getSheet(0).getSelections()[0].row;
+        if(thatRow < that.currentCache.length){
+            that.currentGlj = that.currentCache[thatRow];
+            if(me.setting.view.lockedCols.indexOf(args.col) !== -1 || that.allowComponent.indexOf(that.currentGlj.gljType) === -1 ||
+                (args.col === 4 && (!that.currentComponent|| args.row >= that.currentComponent.length))){
+                args.cancel = true;
+            }
+        }
+        else {
+            args.cancel = true;
+        }
     },
     onCellEditEnd: function (sender, args) {
         let me = gljComponentOprObj, that = repositoryGljObj, updateBasePrc = [];
@@ -270,7 +274,7 @@ let gljComponentOprObj = {
         let me = gljComponentOprObj;
         let maxCol = info.cellRange.col + info.cellRange.colCount - 1;
         //复制的列数超过正确的列数,不可复制
-        if(maxCol >= me.setting.header.length){
+        if(info.cellRange.col !== 0 || info.cellRange.col !== 4 || info.cellRange.colCount > 1){
             args.cancel = true;
         }
     },
@@ -398,7 +402,6 @@ let gljComponentOprObj = {
                     if(result.data[0]){
                         that.currentComponent =  that.getCurrentComponent(result.data[0].component);
                         me.workBook.getSheet(0).getSelections()[0]
-                        //sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
                         sheetCommonObj.cleanData(me.workBook.getSheet(0), me.setting, -1);
                         sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, that.currentComponent);
                     }

+ 85 - 71
web/maintain/std_glj_lib/js/main.js

@@ -3,78 +3,90 @@
  */
 $(function () {
     let dispNameArr;
-    getAllGljLib(function (dispNames, compilationsUsedArr) {
-        dispNameArr = dispNames;
-        //添加
-        $('#addBtn').click(function () {
-            let compilationName = $('#compilationSels option:selected').text();
-            let compilationId = $('#compilationSels option:selected').val();
-            let libName = $('#libNameTxt').val();
-            if(libName.trim().length === 0){
-                alert('名称不可为空!');
-                $('#libNameTxt').val('')
-            }
-            else if(compilationsUsedArr.indexOf(compilationId) !== -1){// compilationsUsedArr;//在该编办下已建库,限制一个编办只能有一个库
-                alert('该编办已被绑定!');
-                $('#libNameTxt').val('')
-            }
-            else if(dispNames.indexOf(libName) !== -1){
-                alert('此工料机库已存在!');
-                $('#libNameTxt').val('')
-            }
-            else if(compilationName.trim().length === 0){
-                alert('编办不可为空!');
-            }
-            else{
-                let newGljLib = {};
-                newGljLib.dispName = libName;
-                newGljLib.compilationId = compilationId;
-                newGljLib.compilationName = compilationName;
-                newGljLib.creator = oprtor;
-                newGljLib.appType = "建筑";
-                $('#libNameTxt').val('');
-                createGljLib(newGljLib, dispNameArr);
-            }
-        });
-        //重命名
-        $("#showArea").on("click", "[data-target = '#edit']", function(){
-            let renameId = $(this).parent().parent().attr("id");
-            let compilationName = $(this).parent().parent().children()[1].textContent;
-            $('#compilationEdit option').text(compilationName);
-            $("#renameA").attr("renameId", renameId);
-        });
-        $("#renameA").click(function(){
-            let newName = $("#renameText").val();
-            let libId = $(this).attr("renameId");
-            let jqSel = "#" + libId + " td:first" + " a";
-            let orgName = $(jqSel).text();
-            if(newName.trim().length === 0){
-                alert("名称不可为空!");
-                $("#renameText").val('');
-            }
-            else if(dispNameArr.indexOf(newName) !== -1){
-                alert("该工料机库已存在!");
-                $("#renameText").val('');
-            }
-           else{
-               renameGljLib({ID: libId, newName: newName, orgName: orgName}, dispNameArr);
-            }
-        });
-        //删除
-        $("#showArea").on("click", "[data-target = '#del']", function(){
-            let deleteId = $(this).parent().parent().attr("id");
-            $("#deleteA").attr("deleteId", deleteId);
-        });
-        $("#deleteA").click(function(){
-            let deleteId = $(this).attr("deleteId");
-            let jqSel = "#" + deleteId + " td:first" + " a";
-            let libName = $(jqSel).text();
-            removeGljLib({libId: deleteId, libName: libName}, dispNameArr);
-        });
+    let compilationsArr;
+    let usedCom;
+    getCompilationList(function (datas) {
+        compilationsArr = datas;
+        getAllGljLib(function (dispNames, compilationsUsedArr) {
+            usedCom = compilationsUsedArr;
+            dispNameArr = dispNames;
+            //添加
+            $('#addBtn').click(function () {
+                let compilationName = $('#compilationSels option:selected').text();
+                let compilationId = $('#compilationSels option:selected').val();
+                let libName = $('#libNameTxt').val();
+                if(libName.trim().length === 0){
+                    alert('名称不可为空!');
+                    $('#libNameTxt').val('')
+                }
+                else if(compilationsUsedArr.indexOf(compilationId) !== -1){// compilationsUsedArr;//在该编办下已建库,限制一个编办只能有一个库
+                    alert('该编办已被绑定!');
+                    $('#libNameTxt').val('')
+                }
+                else if(dispNames.indexOf(libName) !== -1){
+                    alert('此工料机库已存在!');
+                    $('#libNameTxt').val('')
+                }
+                else if(compilationName.trim().length === 0){
+                    alert('编办不可为空!');
+                }
+                else{
+                    let newGljLib = {};
+                    newGljLib.dispName = libName;
+                    newGljLib.compilationId = compilationId;
+                    newGljLib.compilationName = compilationName;
+                    newGljLib.creator = oprtor;
+                    newGljLib.appType = "建筑";
+                    $('#libNameTxt').val('');
+                    createGljLib(newGljLib, dispNameArr, usedCom);
+                }
+            });
+            //重命名
+            $("#showArea").on("click", "[data-target = '#edit']", function(){
+                let renameId = $(this).parent().parent().attr("id");
+                let compilationName = $(this).parent().parent().children()[1].textContent;
+                $('#compilationEdit option').text(compilationName);
+                $("#renameA").attr("renameId", renameId);
+            });
+            $("#renameA").click(function(){
+                let newName = $("#renameText").val();
+                let libId = $(this).attr("renameId");
+                let jqSel = "#" + libId + " td:first" + " a";
+                let orgName = $(jqSel).text();
+                if(newName.trim().length === 0){
+                    alert("名称不可为空!");
+                    $("#renameText").val('');
+                }
+                else if(dispNameArr.indexOf(newName) !== -1){
+                    alert("该工料机库已存在!");
+                    $("#renameText").val('');
+                }
+                else{
+                    renameGljLib({ID: libId, newName: newName, orgName: orgName}, dispNameArr);
+                }
+            });
+            //删除
+            $("#showArea").on("click", "[data-target = '#del']", function(){
+                let deleteId = $(this).parent().parent().attr("id");
+                $("#deleteA").attr("deleteId", deleteId);
+            });
+            $("#deleteA").click(function(){
+                let deleteId = $(this).attr("deleteId");
+                let jqSel = "#" + deleteId + " td:first" + " a";
+                let libName = $(jqSel).text();
+                let compilationName = $("#" + deleteId + " td:eq(1)").text();
+                for(let i = 0, len = compilationsArr.length; i < len; i++){
+                    if(compilationsArr[i].name === compilationName.trim()){
+                        usedCom.splice(usedCom.indexOf(compilationsArr[i]._id), 1);
+                        break;
+                    }
+                }
+                removeGljLib({libId: deleteId, libName: libName}, dispNameArr);
+            });
 
 
+        });
     });
-    getCompilationList();
 });
 
 function getAllGljLib(callback){
@@ -116,7 +128,7 @@ function getAllGljLib(callback){
         }
     });
 }
-function getCompilationList(){
+function getCompilationList(callback){
     $.ajax({
         type: 'post',
         url: 'api/getCompilationList',
@@ -130,10 +142,11 @@ function getCompilationList(){
             }
             $('#compilationSels').on("change", function () {
             });
+            callback(result.data);
         }
     });
 }
-function createGljLib(gljLibObj, dispNamesArr){
+function createGljLib(gljLibObj, dispNamesArr, usedCom){
     $.ajax({
         type: 'post',
         url: 'api/createGljLib',
@@ -146,6 +159,7 @@ function createGljLib(gljLibObj, dispNamesArr){
                 let createDate = result.data.createDate.split(' ')[0];
                 let compilationName = result.data.compilationName;
                 dispNamesArr.push(libName);
+                usedCom.push(gljLibObj.compilationId);
                 $("#showArea").append(
                     "<tr id='tempId'>" +
                     "<td><a href='/stdGljRepository/glj'>"+libName+"</a></td>" +

+ 0 - 29
web/maintain/std_glj_lib/js/sheetsOpr.js

@@ -32,11 +32,6 @@ let sheetsOprObj = {
         else{
             sheet.setRowCount(typeof repositoryGljObj !== 'undefined' && repositoryGljObj.currentOprParent === 1 ? data.length : data.length + 10);
         }
-        if(data.length === 0){
-            for(let i = 0; i < sheet.getRowCount(); i++){
-                sheet.getCell(i, 4, GC.Spread.Sheets.SheetArea.viewport).locked(false);
-            }
-        }
         for (var col = 0; col < setting.header.length; col++) {
             var hAlign = "left", vAlign = "center";
             if (setting.header[col].hAlign) {
@@ -47,38 +42,22 @@ let sheetsOprObj = {
             vAlign = setting.header[col].vAlign?setting.header[col].vAlign:vAlign;
             me.setAreaAlign(sheet.getRange(-1, col, -1, 1), hAlign, vAlign);
             if (setting.header[col].formatter) {
-                //var style = new GC.Spread.Sheets.Style();
-                //style.formatter = setting.header[col].formatter;
-                //sheet.setStyle(row,col,style,GC.Spread.Sheets.SheetArea.viewport);
                 sheet.setFormatter(-1, col, setting.header[col].formatter, GC.Spread.Sheets.SheetArea.viewport);
             }
             for (var row = 0; row < data.length; row++) {
                 //var cell = sheet.getCell(row, col, GC.Spread.Sheets.SheetArea.viewport);
                 if(setting.header[col].dataCode === 'gljType' && data[row].gljType){
-                    if(typeof repositoryGljObj !== 'undefined' && typeof repositoryGljObj.allowComponent !== 'undefined' && repositoryGljObj.allowComponent.indexOf(data[row].gljType) !== -1){
-                        sheet.getCell(row, 4, GC.Spread.Sheets.SheetArea.viewport).locked(true);
-                    }
-                    else if(typeof repositoryGljObj !== 'undefined' && typeof repositoryGljObj.allowComponent !== 'undefined' && repositoryGljObj.allowComponent.indexOf(data[row].gljType) === -1){
-                        sheet.getCell(row, 4, GC.Spread.Sheets.SheetArea.viewport).locked(false);
-                    }
                     let distTypeVal =  distTypeTree.distTypes[distTypeTree.prefix + data[row].gljType].data.fullName;
                     sheet.setValue(row, col, distTypeVal, ch);
                 }
                 else {
                     sheet.setValue(row, col, data[row][setting.header[col].dataCode], ch);
                     sheet.setTag(row, 0, data[row].ID, ch);
-                    if(typeof setting.owner !== 'undefined' && setting.owner !== 'gljComponent'){
-                        sheet.getCell(row, 0, GC.Spread.Sheets.SheetArea.viewport).locked(true);
-                    }
                 }
             }
-            for(let i = data.length; i < sheet.getRowCount(); i++){
-                sheet.getCell(i, 4, GC.Spread.Sheets.SheetArea.viewport).locked(false);
-            }
         }
         sheet.resumeEvent();
         sheet.resumePaint();
-        //me.shieldAllCells(sheet);
     },
     combineRowData: function(sheet, setting, row, repositoryGljObj) {
         let me = this;
@@ -103,26 +82,18 @@ let sheetsOprObj = {
                         isExist = false;
                     for(let i=0; i< gljList.length; i++){
                         if(gljList[i].code === sheet.getValue(row, col) && sheet.getValue(row, col)!== orgCode){
-                            sheetCommonObj.lockAllCells(sheet);
                             $('#alertText').text("输入的编号已存在,请重新输入!");
                             $('#codeAlertBtn').click();
                             $('#codAleConfBtn').click(function () {
-                                // me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
-                                sheetCommonObj.unLockAllCells(sheet);
-                                me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
                                 sheet.setValue(row, 0, orgCode);
                                 sheet.getCell(row, 0).formatter("@");
                                 sheet.setActiveCell(row, 0);
                             });
                             $('#codAleClose').click(function () {
-                                //me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
-                                sheetCommonObj.unLockAllCells(sheet);
-                                me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
                                 sheet.setValue(row, 0, orgCode);
                                 sheet.getCell(row, 0).formatter("@");
                                 sheet.setActiveCell(row, 0);
                             });
-                            // sheet.setValue(row, col, orgCode);
                             isExist = true
                         }
                     }