Browse Source

remove smartMenu / tuning ration edit mode

TonyKang 8 years ago
parent
commit
74fe06a9c7

File diff suppressed because it is too large
+ 0 - 1
lib/smartMenu/jquery-smartMenu-min.js


+ 12 - 0
modules/rationRepository/controllers/rationController.js

@@ -29,5 +29,17 @@ module.exports = {
                 callback(req, res, err, message, rst);
                 callback(req, res, err, message, rst);
             }
             }
         });
         });
+    },
+    removeRationItems: function(req, res){
+        var rIds = JSON.parse(req.body.updateItems);
+        if (rIds && rIds.length > 0) {
+            rationItem.removeRationItems(rIds, function(err, message, rst){
+                if (err) {
+                    callback(req, res, err, message, null);
+                } else {
+                    callback(req, res, err, message, rst);
+                }
+            });
+        }
     }
     }
 }
 }

+ 10 - 0
modules/rationRepository/models/gljRepository.js

@@ -88,6 +88,16 @@ gljItemDAO.prototype.mixUpdateGljItems = function(repId, updateItems, addItems,
     }
     }
 };
 };
 
 
+gljItemDAO.prototype.removeGljItems = function(removeIds, callback) {
+    //gljItemModel.collection.remove({}, null, function(err, docs){
+    //    if (err) {
+    //        callback(true, "保存定额错误!", false);
+    //    } else {
+    //        callback(false, "保存定额成功!", docs);
+    //    }
+    //})
+};
+
 gljItemDAO.prototype.addGljItems = function(repId, items, callback) {
 gljItemDAO.prototype.addGljItems = function(repId, items, callback) {
     if (items && items.length > 0) {
     if (items && items.length > 0) {
         counter.counterDAO.getIDAfterCount(counter.moduleName.GLJ, items.length, function(err, result){
         counter.counterDAO.getIDAfterCount(counter.moduleName.GLJ, items.length, function(err, result){

+ 10 - 0
modules/rationRepository/models/rationItem.js

@@ -54,6 +54,16 @@ rationItemDAO.prototype.mixUpdateRationItems = function(sectionId, updateItems,
     }
     }
 };
 };
 
 
+rationItemDAO.prototype.removeRationItems = function(rIds,callback){
+    rationItemModel.collection.remove({ID: {$in: rIds}}, null, function(err, docs){
+        if (err) {
+            callback(true, "删除定额错误!", false);
+        } else {
+            callback(false, "删除定额成功!", docs);
+        }
+    })
+};
+
 rationItemDAO.prototype.getRationItemsByCode = function(code,callback){
 rationItemDAO.prototype.getRationItemsByCode = function(code,callback){
     //
     //
 };
 };

+ 1 - 0
modules/rationRepository/routes/rationRepRoutes.js

@@ -23,6 +23,7 @@ apiRouter.post("/deleteNodes",rationChapterTreeController.deleteNodes);
 
 
 apiRouter.post("/getRationItems",rationController.getRationItemsBySection);
 apiRouter.post("/getRationItems",rationController.getRationItemsBySection);
 apiRouter.post("/mixUpdateRationItems",rationController.mixUpdateRationItems);
 apiRouter.post("/mixUpdateRationItems",rationController.mixUpdateRationItems);
+apiRouter.post("/removeRationItems",rationController.removeRationItems);
 
 
 apiRouter.post("/getGljTree",repositoryGljController.getGljTree);
 apiRouter.post("/getGljTree",repositoryGljController.getGljTree);
 apiRouter.post("/getGljItems",repositoryGljController.getGljItems);
 apiRouter.post("/getGljItems",repositoryGljController.getGljItems);

+ 0 - 14
web/css/smartMenu/smartMenu.css

@@ -1,14 +0,0 @@
-@charset "utf-8";
-/* smartMenu.css	by zhangxinxu */
-.smart_menu_box{display:none; width:140px; position:absolute; z-index:201105;}
-.smart_menu_body{padding:1px; border:1px solid #B8CBCB; background-color:#fff; -moz-box-shadow:2px 2px 5px #666; -webkit-box-shadow:2px 2px 5px #666; box-shadow:2px 2px 5px #666;}
-.smart_menu_ul{margin:0; padding:0; list-style-type:none;}
-.smart_menu_li{position:relative;}
-.smart_menu_a{display:block; height:25px; line-height:24px; padding:0 5px 0 25px; color:#000; font-size:12px; text-decoration:none; overflow:hidden;}
-.smart_menu_a:hover, .smart_menu_a_hover{background-color:#348CCC; color:#fff; text-decoration:none;}
-.smart_menu_li_separate{line-height:0; margin:3px; border-bottom:1px solid #B8CBCB; font-size:0;}
-.smart_menu_triangle{width:0; height:0; border:5px dashed transparent; border-left:5px solid #666; overflow:hidden; position:absolute; top:7px; right:5px;}
-.smart_menu_a:hover .smart_menu_triangle, .smart_menu_a_hover .smart_menu_triangle{border-left-color:#fff;}
-.smart_menu_li_hover .smart_menu_box{top:-1px; left:130px;}
-
-

+ 0 - 3
web/rationLibEditor/dinge.html

@@ -869,7 +869,6 @@
     <script type="text/javascript" src="/web/rationLibEditor/js/sheetCommon.js"></script>
     <script type="text/javascript" src="/web/rationLibEditor/js/sheetCommon.js"></script>
     <script type="text/javascript" src="/web/rationLibEditor/js/ration.js"></script>
     <script type="text/javascript" src="/web/rationLibEditor/js/ration.js"></script>
     <script type="text/javascript" src="/web/rationLibEditor/js/rationGLJ.js"></script>
     <script type="text/javascript" src="/web/rationLibEditor/js/rationGLJ.js"></script>
-    <script type="text/javascript" src="/web/rationLibEditor/js/rightKeyMenu.js"></script>
     <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>
     <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>
     <script type="text/javascript" src="/public/QueryParam.js"></script>
     <script type="text/javascript" src="/public/QueryParam.js"></script>
     <script type="text/javascript">
     <script type="text/javascript">
@@ -918,8 +917,6 @@
         pageOprObj.initPage();
         pageOprObj.initPage();
         rationOprObj.buildSheet($("#rationItemsSheet")[0]);
         rationOprObj.buildSheet($("#rationItemsSheet")[0]);
         rationGLJOprObj.buildSheet($("#rationGLJSheet")[0]);
         rationGLJOprObj.buildSheet($("#rationGLJSheet")[0]);
-        //$("#rct_right_key")[0].smartMenu(ration_chapter_tree_data);
-        $("rationItemsSheetvp_vp").smartMenu(ration_chapter_tree_data);
     });
     });
 </script>
 </script>
 
 

+ 3 - 0
web/rationLibEditor/js/chapterTree.js

@@ -196,6 +196,9 @@ var zTreeOprObj = {
         var sectionID = treeNode.ID;
         var sectionID = treeNode.ID;
         if (!(treeNode.items) || treeNode.items.length == 0) {
         if (!(treeNode.items) || treeNode.items.length == 0) {
             rationOprObj.getRationItems(sectionID);
             rationOprObj.getRationItems(sectionID);
+        } else {
+            sheetCommonObj.cleanSheet(rationOprObj.workBook.getSheet(0), rationOprObj.setting, -1);
+            sheetCommonObj.shieldAllCells(rationOprObj.workBook.getSheet(0), rationOprObj.setting);
         }
         }
     }
     }
 
 

+ 98 - 29
web/rationLibEditor/js/ration.js

@@ -9,6 +9,7 @@ $("#gongliao").click(function(){
 var rationOprObj = {
 var rationOprObj = {
     workBook: null,
     workBook: null,
     currentRations: {},
     currentRations: {},
+    currentEditingRation: null,
     currentSectionId: -1,
     currentSectionId: -1,
     setting: {
     setting: {
         header:[
         header:[
@@ -33,6 +34,58 @@ var rationOprObj = {
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
         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.RangeChanged, me.onRangeChanged);
+    },
+    onRangeChanged: function(sender, args) {
+        if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {
+            var me = rationOprObj, updateArr = [], addArr = [];
+            var cacheSection = me.currentRations["_SEC_ID_" + me.currentSectionId];
+            if (cacheSection) {
+                for (var i = 0; i < args.rowCount; i++) {
+                    var hasUpdate = false, rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row + i);
+                    for (var j = 0; j < cacheSection.length; j++) {
+                        if (cacheSection[j][me.setting.header[0].dataCode] == rObj[me.setting.header[0].dataCode]) {
+                            rObj["ID"] = cacheSection[j]["ID"];
+                            hasUpdate = true;
+                            break;
+                        }
+                    }
+                    if (hasUpdate) {
+                        updateArr.push(rObj);
+                    }
+                }
+                //me.mixUpdateRequest(updateArr, addArr);
+                //removeRationItems
+            }
+        }
+    },
+    onCellEditStart: function(sender, args) {
+        var me = rationOprObj;
+        var rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row);
+        me.currentEditingRation = rObj;
+        var cacheSection = me.currentRations["_SEC_ID_" + me.currentSectionId];
+        if (cacheSection) {
+            for (var j = 0; j < cacheSection.length; j++) {
+                if (cacheSection[j][me.setting.header[0].dataCode] == rObj[me.setting.header[0].dataCode]) {
+                    rObj["ID"] = cacheSection[j]["ID"];
+                    break;
+                }
+            }
+        }
+    },
+    onCellEditEnd: function(sender, args) {
+        var me = rationOprObj, rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row),
+            updateArr = [], addArr = [];
+        if (me.currentEditingRation["ID"]) {
+            rObj["ID"] = me.currentEditingRation["ID"];
+            updateArr.push(rObj);
+        } else {
+            addArr.push(rObj);
+        }
+        me.currentEditingRation = null;
+        me.mixUpdateRequest(updateArr, addArr);
     },
     },
     onClipboardPasting: function(sender, args) {
     onClipboardPasting: function(sender, args) {
         var me = rationOprObj;
         var me = rationOprObj;
@@ -65,40 +118,54 @@ var rationOprObj = {
             }
             }
         };
         };
         if (updateArr.length > 0 || addArr.length > 0) {
         if (updateArr.length > 0 || addArr.length > 0) {
-            $.ajax({
-                type:"POST",
-                url:"api/mixUpdateRationItems",
-                data:{"sectionID": me.currentSectionId, "updateItems": JSON.stringify(updateArr), "addItems": JSON.stringify(addArr)},
-                dataType:"json",
-                cache:false,
-                timeout:5000,
-                success:function(result){
-                    if (result.err) {
-                        alert(err);
-                        me.getRationItems(me.currentSectionId);
-                    } else {
-                        if (!(me.currentRations["_SEC_ID_" + me.currentSectionId])) {
-                            me.currentRations["_SEC_ID_" + me.currentSectionId] = [];
-                            cacheSection = me.currentRations["_SEC_ID_" + me.currentSectionId];
-                        }
-                        if (addArr.length > 0) {
-                            me.currentRations["_SEC_ID_" + me.currentSectionId] = cacheSection.concat(addArr);
-                            cacheSection = me.currentRations["_SEC_ID_" + me.currentSectionId];
-                        }
-                        for (var i = 0; i < updateArr.length; i++) {
+            me.mixUpdateRequest(updateArr, addArr);
+        }
+    },
+    mixUpdateRequest: function(updateArr, addArr) {
+        var me = rationOprObj;
+        $.ajax({
+            type:"POST",
+            url:"api/mixUpdateRationItems",
+            data:{"sectionID": me.currentSectionId, "updateItems": JSON.stringify(updateArr), "addItems": JSON.stringify(addArr)},
+            dataType:"json",
+            cache:false,
+            timeout:5000,
+            success:function(result){
+                if (result.err) {
+                    alert(err);
+                    me.getRationItems(me.currentSectionId);
+                } else {
+                    var cacheSection = me.currentRations["_SEC_ID_" + me.currentSectionId];
+                    if (!(me.currentRations["_SEC_ID_" + me.currentSectionId])) {
+                        me.currentRations["_SEC_ID_" + me.currentSectionId] = [];
+                        cacheSection = me.currentRations["_SEC_ID_" + me.currentSectionId];
+                    }
+                    if (addArr.length > 0) {
+                        me.currentRations["_SEC_ID_" + me.currentSectionId] = cacheSection.concat(addArr);
+                        cacheSection = me.currentRations["_SEC_ID_" + me.currentSectionId];
+                    }
+                    if (result.data.ops && result.data.ops.length > 0) {
+                        for (var i = 0; i < result.data.ops.length; i++) {
                             for (var j = 0; j < cacheSection.length; j++) {
                             for (var j = 0; j < cacheSection.length; j++) {
-                                if (cacheSection[j][me.setting.header[0].dataCode] == updateArr[i][me.setting.header[0].dataCode]) {
-                                    cacheSection[j] = updateArr[i];
+                                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"];
                                 }
                                 }
                             }
                             }
                         }
                         }
-                        me.showRationItems(me.currentSectionId);
                     }
                     }
-                },
-                error:function(){
+                    for (var i = 0; i < updateArr.length; i++) {
+                        for (var j = 0; j < cacheSection.length; j++) {
+                            if (cacheSection[j][me.setting.header[0].dataCode] == updateArr[i][me.setting.header[0].dataCode]) {
+                                cacheSection[j] = updateArr[i];
+                            }
+                        }
+                    }
+                    me.showRationItems(me.currentSectionId);
                 }
                 }
-            })
-        }
+            },
+            error:function(){
+            }
+        });
     },
     },
     getRationItems: function(sectionID){
     getRationItems: function(sectionID){
         if (sectionID != -1) {
         if (sectionID != -1) {
@@ -118,8 +185,10 @@ var rationOprObj = {
                         if (result) {
                         if (result) {
                             me.currentRations["_SEC_ID_" + sectionID] = result.data;
                             me.currentRations["_SEC_ID_" + sectionID] = result.data;
                             me.showRationItems(sectionID);
                             me.showRationItems(sectionID);
+                            sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
+                        } else {
+                            sheetCommonObj.shieldAllCells(me.workBook.getSheet(0), me.setting);
                         }
                         }
-
                     },
                     },
                     error:function(err){
                     error:function(err){
                         alert(err);
                         alert(err);

+ 10 - 0
web/rationLibEditor/js/sheetCommon.js

@@ -114,7 +114,17 @@ var sheetCommonObj = {
         }
         }
         return rst;
         return rst;
     },
     },
+    combineRowData: function(sheet, setting, row) {
+        var rst = {};
+        for (var col = 0; col < setting.header.length; col++) {
+            rst[setting.header[col].dataCode] = sheet.getValue(row, col);
+        }
+        return rst;
+    },
     shieldAllCells: function(sheet, setting) {
     shieldAllCells: function(sheet, setting) {
         sheet.options.isProtected = true;
         sheet.options.isProtected = true;
+    },
+    unShieldAllCells: function(sheet) {
+        sheet.options.isProtected = false;
     }
     }
 }
 }