瀏覽代碼

Merge branch 'master' into olym

caiaolin 7 年之前
父節點
當前提交
9056bbae42

+ 28 - 16
web/maintain/bills_lib/html/qingdan.html

@@ -332,6 +332,7 @@
 
     function showBillsSheet(datas, jobsSheet, itemsSheet, setting) {
         let billsSpread = new GC.Spread.Sheets.Workbook($('#spreadBills')[0], {sheetCount: 1});
+        billsSpread.focus(true);
         setSheet.initSheet(billsSpread, setting, true);
         myKey.delKey(billsSpread);
         billsTree.loadDatas(datas);
@@ -351,7 +352,7 @@
         //补注内容改变
         rechargeChange(controller);
         //焦点控制
-        switchFcs(controller, controller.sheet, jobsSheet, itemsSheet);
+        switchFcs(controller, controller.sheet, billsSpread, jobsSheet, itemsSheet);
         //jobs
         jobOperation(controller, jobsSheet, function(totalJobs){
             //------关联表粘贴复制
@@ -365,7 +366,7 @@
         });
     }
 
-    function switchFcs(controller, billsSheet, jobsSheet, itemsSheet){
+    function switchFcs(controller, billsSheet, billsSpread, jobsSheet, itemsSheet){
         let btnInsert = $('#insert');
         let btnDelete = $('#delete');
         let btnUpMove = $('#upMove');
@@ -376,13 +377,21 @@
        // billsSheet.options.isProtected = true;
        // controller.setTreeSelected(null);
         billsSheet.bind(GC.Spread.Sheets.Events.CellClick, function (sender, args) {
-            //if(billsSheet.options.isProtected = true){
+           // if(billsSheet.options.isProtected){
+                jobsSheet.clearSelection();
+                itemsSheet.clearSelection();
+                billsSpread.focus(true);
+                jobsSheet.options.isProtected = true;
+                itemsSheet.options.isProtected = true;
+                billsSheet.options.isProtected = false;
+
                 btnInsert.attr('fcsOnBills', 'true');
                 btnDelete.attr('fcsOnBills', 'true');
                 btnUpLevel.attr('fcsOnBills', 'true');
                 btnDownLevel.attr('fcsOnBills', 'true');
                 btnUpMove.attr('fcsOnBills', 'true');
                 btnDownMove.attr('fcsOnBills', 'true');
+          //  }
                // jobsSheet.clearSelection();
                // itemsSheet.clearSelection();
                 //billsSheet.options.isProtected = false;
@@ -397,14 +406,11 @@
         });
         jobsSheet.bind(GC.Spread.Sheets.Events.CellClick, function (sender, args) {
            // if(jobsSheet.options.isProtected){
-               /* itemsSheet.clearSelection();
+                itemsSheet.clearSelection();
+                jobsSpread.focus(true);
                 itemsSheet.options.isProtected = true;
+                billsSheet.options.isProtected = true;
                 jobsSheet.options.isProtected = false;
-                let activeRow = jobsSheet.getActiveRowIndex();
-                let activeCol = jobsSheet.getActiveColumnIndex();
-                jobsSheet.setActiveCell(activeRow === 0 ? 1: 0, 0);
-                jobsSheet.setActiveCell(activeRow, activeCol);*/
-
                 controller.tree.selected.args = args;
                 controller.tree.selected.field = 'job';
                 tools.btnClose(btnInsert);
@@ -420,14 +426,18 @@
                 let selected;
                 if(controller.tree.selected){
                     selected = controller.tree.selected.jobs[args.row];
+                    console.log(`selected`);
+                    console.log(selected);
                 }
                 if(tools.canUpMove(selected, controller.tree.selected.jobs)){
                     tools.btnAction(btnUpMove);
                     btnUpMove.attr('canMove', 'true');
+                    console.log(`canup`);
                 }
                 else{
                     tools.btnClose(btnUpMove);
                     btnUpMove.attr('canMove', 'false');
+                    console.log(`nocan`);
                 }
                 if(tools.canDownMove(selected, controller.tree.selected.jobs)){
                     tools.btnAction(btnDownMove);
@@ -437,14 +447,16 @@
                     tools.btnClose(btnDownMove);
                     btnDownMove.attr('canMove', 'false');
                 }
-          //  }
+            //}
         });
         itemsSheet.bind(GC.Spread.Sheets.Events.CellClick, function (sender, args) {
-            //if(itemsSheet.options.isProtected){
-              /*  jobsSheet.clearSelection();
+           // if(itemsSheet.options.isProtected){
+                jobsSheet.clearSelection();
+                itemsSpread.focus(true);
                 jobsSheet.options.isProtected = true;
+                billsSheet.options.isProtected = true;
                 itemsSheet.options.isProtected = false;
-                let activeRow = itemsSheet.getActiveRowIndex();
+                /*let activeRow = itemsSheet.getActiveRowIndex();
                 let activeCol = itemsSheet.getActiveColumnIndex();
                 itemsSheet.setActiveCell(activeRow === 0 ? 1: 0, 0);
                 itemsSheet.setActiveCell(activeRow, activeCol);*/
@@ -481,7 +493,7 @@
                     tools.btnClose(btnDownMove);
                     btnDownMove.attr('canMove', 'false');
                 }
-           // }
+            //}
         });
     };
 
@@ -780,7 +792,7 @@
     function buildJobs(jobsSpread, setting){
         setSheet.initSheet(jobsSpread, setting, true);
        // setSheet.setMaxRowCount(jobsSpread.getActiveSheet(), 10);
-        //jobsSpread.getActiveSheet().clearSelection();
+        jobsSpread.getActiveSheet().clearSelection();
         myKey.downKey(jobsSpread);
         myKey.enterKey(jobsSpread);
         TREE_SHEET_HELPER.loadSheetHeader(jobsSetting, jobsSpread.getActiveSheet());
@@ -789,7 +801,7 @@
     function buildItems(itemsSpread, setting){
         setSheet.initSheet(itemsSpread, setting, true);
        // setSheet.setMaxRowCount(itemsSpread.getActiveSheet(), 10);
-       // itemsSpread.getActiveSheet().clearSelection();
+        itemsSpread.getActiveSheet().clearSelection();
         myKey.downKey(itemsSpread);
         myKey.enterKey(itemsSpread);
         TREE_SHEET_HELPER.loadSheetHeader(itemsSetting, itemsSpread.getActiveSheet());

+ 41 - 4
web/maintain/bills_lib/scripts/db_controller.js

@@ -1800,6 +1800,14 @@ var jobsController = {
             else{
                 $('#upMove').attr('canMove', 'false');
             }
+            if(tools.canDownMove(controller.tree.selected.jobs[controller.tree.selected.args.row], controller.tree.selected.jobs)){
+                $('#downMove').attr('canMove', true);
+                tools.btnAction($('#downMove'));
+            }
+            else{
+                $('#downMove').attr('canMove', 'false');
+                tools.btnClose($('#downMove'));
+            }
         });
     },
     downMove: function (controller, sheet) {
@@ -1823,6 +1831,14 @@ var jobsController = {
             else{
                 $('#downMove').attr('canMove', 'false');
             }
+            if(tools.canUpMove(controller.tree.selected.jobs[controller.tree.selected.args.row], controller.tree.selected.jobs)){
+                $('#upMove').attr('canMove', 'true');
+                tools.btnAction($('#upMove'));
+            }
+            else{
+                $('#upMove').attr('canMove', 'false');
+                tools.btnClose($('#upMove'));
+            }
         });
     }
 
@@ -1982,6 +1998,14 @@ var itemsController = {
             else{
                 $('#upMove').attr('canMove', 'false');
             }
+            if(tools.canDownMove(controller.tree.selected.items[controller.tree.selected.args.row], controller.tree.selected.items)){
+                $('#downMove').attr('canMove', 'true');
+                tools.btnAction($('#downMove'));
+            }
+            else{
+                $('#downMove').attr('canMove', 'false');
+                tools.btnClose($('#downMove'));
+            }
         });
     },
     downMove: function (controller, sheet) {
@@ -2005,6 +2029,14 @@ var itemsController = {
             else{
                 $('#downMove').attr('canMove', 'false');
             }
+            if(tools.canUpMove(controller.tree.selected.items[controlle.tree.selected.args.row], controller.tree.selected.items)){
+                $('#upMove').attr('canMove', 'true');
+                tools.btnAction($('#upMove'));
+            }
+            else{
+                $('#upMove').attr('canMove', 'false');
+                tools.btnClose($('#upMove'));
+            }
         });
     }
 
@@ -2175,7 +2207,9 @@ var totalJobsController = {
             });
         }
         else {
-            if(typeof newData === 'number'){
+            let parseNum = parseInt(newData);
+            //if(typeof newData === 'number'){
+            if(!isNaN(parseNum)){
                 maxJobsNumber = maxJobsNumber >= newData ? maxJobsNumber : newData;
                 jobsAjax.createJobContent(billsLibId, '', newData, function(newJobId){
                     let newJobData, newJob;
@@ -2196,7 +2230,8 @@ var totalJobsController = {
     },
 
     updateJob: function(totalJobs, id, field, newData, args){
-        if(field === 'code' && typeof newData !== 'number'){
+       // if(field === 'code' && typeof newData !== 'number'){
+        if(field === 'code' && isNaN(parseInt(newData))){
             tools.alertTotalOpr(args, '编号只能为数字,请重新输入!', totalJobs.jobsArr);
         }
         else {
@@ -2205,6 +2240,7 @@ var totalJobsController = {
                     job.data[field] = newData;
                 }
             });
+            tools.reshowData(args.sheet, totalJobs.jobsArr, totalJobsSetting, true);
             jobsAjax.updateJobContent(billsLibId, id, field, newData);
         }
     }
@@ -2251,7 +2287,7 @@ var totalItemsController = {
             });
         }
         else {
-            if(typeof newData === 'number'){
+            if(!isNaN(parseInt(newData))){
                 maxItemsNumber = maxItemsNumber >= newData ? maxItemsNumber : newData;
                 itemsAjax.createItemCharacter(billsLibId, '', newData, function(newItemId){
                     var newItemData, newItem;
@@ -2271,7 +2307,7 @@ var totalItemsController = {
     },
 
     updateItem: function(totalItems, id, field, newData, args){
-        if(field === 'code' && typeof newData !== 'number'){
+        if(field === 'code' && isNaN(parseInt(newData))){
             tools.alertTotalOpr(args, '编号只能为数字,请重新输入!', totalItems.itemsArr);
         }
         else {
@@ -2280,6 +2316,7 @@ var totalItemsController = {
                     item.data[field] = newData;
                 }
             });
+            tools.reshowData(args.sheet, totalItems.itemsArr, totalItemsSetting, true);
             itemsAjax.updateItemCharacter(billsLibId, id, field, newData);
         }
     }

+ 46 - 1
web/maintain/ration_repository/dinge.html

@@ -10,6 +10,7 @@
    <!-- <link rel="stylesheet" href="/lib/css/bootstrap/themes.css">-->
     <link rel="stylesheet" href="/web/maintain/ration_repository/css/main.css">
     <link rel="stylesheet" href="/lib/font-awesome/font-awesome.min.css">
+    <link rel="stylesheet" href="/lib/jquery-contextmenu/jquery.contextMenu.css">
     <!--zTree-->
   	<link rel="stylesheet" href="/lib/ztree/css/zTreeStyle.css" type="text/css">
     <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.excel2013lightGray.10.0.1.css" type="text/css">
@@ -438,11 +439,55 @@
                 </div>
             </div>
         </div>
-
+        <!--弹出警告窗-->
+        <button id="alertModalBtn" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#alertModal" style="display: none"></button>
+        <div class="modal fade" id="alertModal" data-backdrop="static" style="display: none;" aria-hidden="true">
+            <input type="hidden" id="codedid" value="123">
+            <div class="modal-dialog" role="document">
+                <div class="modal-content">
+                    <div class="modal-header">
+                        <h5 class="modal-title">警告</h5>
+                        <button type="button" id="alertModalCls" class="close" data-dismiss="modal" aria-label="Close">
+                            <span aria-hidden="true">×</span>
+                        </button>
+                    </div>
+                    <div class="modal-body">
+                        <h5 class="text-danger" id="alertText">输入的编号已存在,请重新输入!</h5>
+                    </div>
+                    <div class="modal-footer">
+                        <button type="button" class="btn btn-danger" id="alertModalCof" data-dismiss="modal">确认</button>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <button id="ctxmenuBtn" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#ctxmenu" style="display: none"></button>
+        <div class="modal" id="ctxmenu" data-backdrop="static" style="display: none;" aria-hidden="true">
+            <input type="hidden"  value="123">
+            <div class="modal-dialog" role="document">
+                <div class="modal-content">
+                    <div class="modal-body">
+                        <button type="button" class="btn btn-danger" id="ctxAdd" data-dismiss="modal">添加</button>
+                        <button type="button" class="btn btn-danger" id="ctxDel" data-dismiss="modal">删除</button>
+                    </div>
+                    <div class="modal-footer">
+                        <!--<button type="button" class="btn btn-danger" id="alertModalCof" data-dismiss="modal">确认</button>-->
+                    </div>
+                </div>
+            </div>
+        </div>
+        <!--contextMenu-->
+        <div class="contextMenu" id="myMenu">
+            <ul>
+                <li id="insert">添加</li>
+                <li id="delete">删除</li>
+            </ul>
+        </div>
         <!-- JS. -->
         <script src = "/lib/spreadjs/sheets/gc.spread.sheets.all.10.0.1.min.js"></script>
         <script>GC.Spread.Sheets.LicenseKey = "559432293813965#A0y3iTOzEDOzkjMyMDN9UTNiojIklkI1pjIEJCLi4TPB9mM5AFNTd4cvZ7SaJUVy3CWKtWYXx4VVhjMpp7dYNGdx2ia9sEVlZGOTh7NRlTUwkWR9wEV4gmbjBDZ4ElR8N7cGdHVvEWVBtCOwIGW0ZmeYVWVr3mI0IyUiwCMzETN8kzNzYTM0IicfJye&Qf35VfiEzRwEkI0IyQiwiIwEjL6ByUKBCZhVmcwNlI0IiTis7W0ICZyBlIsIyNyMzM5ADI5ADNwcTMwIjI0ICdyNkIsIibj9SbvNmL4N7bjRnch56ciojIz5GRiwiI8+Y9sWY9QmZ0Jyp96uL9v6L0wap9biY9qiq95q197Wr9g+89iojIh94Wiqi";</script>
         <script src="/lib/jquery/jquery.min.js"></script>
+        <script src="/lib/jquery-contextmenu/jquery.contextMenu.min.js"></script>
+        <script src="/lib/jquery-contextmenu/jquery.ui.position.js"></script>
         <script src="/lib/tether/tether.min.js"></script>
         <script src="/lib/bootstrap/bootstrap.min.js"></script>
         <script type="text/javascript" src="/web/maintain/ration_repository/js/global.js"></script>

+ 1 - 1
web/maintain/ration_repository/gongliao.html

@@ -189,7 +189,7 @@
             </div>
         </div>
     </div>
-    <div class="modal fade" id="codeAlert" data-backdrop="static" style="display: none;" aria-hidden="true">
+    <div class="modal" id="codeAlert" data-backdrop="static" style="display: none;" aria-hidden="true">
         <input type="hidden" id="codedid" value="123">
         <div class="modal-dialog" role="document">
             <div class="modal-content">

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

@@ -33,6 +33,9 @@ var rationOprObj = {
             ],
             lockedCells:[
                 {row:-1,col:3,rowCount:-1, colCount:1}
+            ],
+            lockColumns: [
+                3, 4, 5, 6
             ]
         }
     },
@@ -186,15 +189,21 @@ var rationOprObj = {
     },
     onClipboardPasting: function(sender, args) {
         var me = rationOprObj;
-        if (args.cellRange.colCount != me.setting.header.length) {
+        console.log(`args`);
+        console.log(args);
+      /*  if (args.cellRange.colCount != me.setting.header.length) {
             args.cancel = true;
-        }
+        }*/
     },
     onClipboardPasted: function(e, info) {
+        console.log(`info`);
+        console.log(info);
         var me = rationOprObj;
         var cacheSection = me.getCache();
         var updateArr = [], addArr = [];
         var items = sheetCommonObj.analyzePasteData(me.setting, info);
+        console.log(`items`);
+        console.log(items);
         for (var i = 0; i < items.length; i++) {
             if (cacheSection) {
                 var hasCacheItem = false;
@@ -215,7 +224,7 @@ var rationOprObj = {
             }
         };
         if (updateArr.length > 0 || addArr.length > 0) {
-            me.mixUpdateRequest(updateArr, addArr, []);
+            //me.mixUpdateRequest(updateArr, addArr, []);
         }
     },
     mixUpdateRequest: function(updateArr, addArr, removeIds) {
@@ -251,10 +260,13 @@ var rationOprObj = {
             var me = rationOprObj;
             me.currentSectionId = sectionID;
             if (me.currentRations["_SEC_ID_" + sectionID]) {
+                console.log(`currentRations`);
+                console.log(me.currentRations);
                 me.showRationItems(sectionID);
-                sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
+                ///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({
@@ -268,7 +280,8 @@ var rationOprObj = {
                         if (result) {
                             me.currentRations["_SEC_ID_" + sectionID] = result.data;
                             me.showRationItems(sectionID);
-                            sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
+                            //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);
@@ -298,5 +311,15 @@ var rationOprObj = {
                 sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
             }
         }
+    },
+    sortByCode: function(arr){
+        function compare(){
+            return function (a, b) {
+                let valA = a.code,
+                    valB = b.code;
+                return valA - valB;
+            }
+        }
+        arr.sort(compare());
     }
 }

+ 42 - 6
web/maintain/ration_repository/js/ration_glj.js

@@ -79,6 +79,7 @@ var rationGLJOprObj = {
         var me = this;
         me.sheet = sheet;
         me.getGljDistType(function () {
+            me.onContextmenuOpr();
             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);
@@ -133,8 +134,24 @@ var rationGLJOprObj = {
             if (args.row < cacheArr.length) {
                 var editGlj = cacheArr[args.row];
                 if (editGlj["consumeAmt"] != args.editingText) {
-                    editGlj["consumeAmt"] = args.editingText;
-                    me.updateRationItem();
+                    let parseNum = parseFloat(args.editingText);
+                    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']);
+                        })
+                    }
+                    else{
+                        editGlj["consumeAmt"] = parseNum;
+                        me.updateRationItem();
+                    }
                 }
             }
         } else {
@@ -160,6 +177,29 @@ var rationGLJOprObj = {
             }
         }
     },
+    onContextmenuOpr: function () {
+        $.contextMenu({
+            selector: '#rdSpread',
+            callback: function(key, options) {
+                var m = "clicked: " + key;
+                console.log(`maincbkey`);
+                console.log(key);
+                console.log(`maincbOp`);
+                console.log(options);
+                window.console && console.log(m) || alert(m);
+            },
+            items: {
+                "insert": {name: "插入", callback: function (key, opt) {
+                    console.log(`key`);
+                    console.log(key);
+                    console.log(`opt`);
+                    console.log(opt);
+                    console.log(opt.position());
+                }},
+                "delete": {name: "删除"}
+            }
+        });
+    },
 
     addGljItems: function(codes, repId) {
         var me = this;
@@ -266,10 +306,6 @@ var rationGLJOprObj = {
         }
         return rst;
     },
-    getRationUpPrice: function () {
-
-    },
-
     updateRationItem: function() {
         var me = this, updateArr = [];
         if (me.currentRationItem) {