Просмотр исходного кода

1.清单库锁定解锁功能
2.定额锁定解锁功能

zeweizhong 6 лет назад
Родитель
Сommit
370f78e757

+ 16 - 12
modules/ration_repository/controllers/repository_views_controller.js

@@ -34,9 +34,10 @@ class ViewsController extends BaseController{
     }
     async redirectRation(req, res){
         const repId = req.query.repository;
-        const redirectGlj = `/rationRepository/lmm?repository=${repId}`;
-        const redirectCoe = `/rationRepository/coeList?repository=${repId}`;
-        const redirectInstallation = `/rationRepository/installation?repository=${repId}`;
+        const locked = req.query.locked || 'true';
+        const redirectGlj = `/rationRepository/lmm?repository=${repId}&locked=${locked}`;
+        const redirectCoe = `/rationRepository/coeList?repository=${repId}&locked=${locked}`;
+        const redirectInstallation = `/rationRepository/installation?repository=${repId}&locked=${locked}`;
         let overWriteUrl = null;
         let priceProperties = [];
         let stdRationLib = await rationLibModel.findOne({ID: repId});
@@ -60,9 +61,10 @@ class ViewsController extends BaseController{
     }
     async redirectGlj(req, res){
         const repId = req.query.repository;
-        const redirectRation = `/rationRepository/ration?repository=${repId}`;
-        const redirectCoe = `/rationRepository/coeList?repository=${repId}`;
-        const redirectInstallation = `/rationRepository/installation?repository=${repId}`;
+        const locked = req.query.locked || 'true';
+        const redirectRation = `/rationRepository/ration?repository=${repId}&locked=${locked}`;
+        const redirectCoe = `/rationRepository/coeList?repository=${repId}&locked=${locked}`;
+        const redirectInstallation = `/rationRepository/installation?repository=${repId}&locked=${locked}`;
         let overWriteUrl = null;
         let priceProperties = [];
         let stdRationLib = await rationLibModel.findOne({ID: repId});
@@ -86,9 +88,10 @@ class ViewsController extends BaseController{
     }
     redirectCoeList(req, res){
         const repId = req.query.repository;
-        const redirectGlj = `/rationRepository/lmm?repository=${repId}`;
-        const redirectRation = `/rationRepository/ration?repository=${repId}`;
-        const redirectInstallation = `/rationRepository/installation?repository=${repId}`;
+        const locked = req.query.locked || 'true';
+        const redirectGlj = `/rationRepository/lmm?repository=${repId}&locked=${locked}`;
+        const redirectRation = `/rationRepository/ration?repository=${repId}&locked=${locked}`;
+        const redirectInstallation = `/rationRepository/installation?repository=${repId}&locked=${locked}`;
         res.render('maintain/ration_repository/fuzhu.html',
             {
                 userAccount: req.session.managerData.username,
@@ -101,9 +104,10 @@ class ViewsController extends BaseController{
     }
     async redirectInstallation(req, res){
         const repId = req.query.repository;
-        const redirectGlj = `/rationRepository/lmm?repository=${repId}`;
-        const redirectCoe = `/rationRepository/coeList?repository=${repId}`;
-        const redirectRation = `/rationRepository/ration?repository=${repId}`;
+        const locked = req.query.locked || 'true';
+        const redirectGlj = `/rationRepository/lmm?repository=${repId}&locked=${locked}`;
+        const redirectCoe = `/rationRepository/coeList?repository=${repId}&locked=${locked}`;
+        const redirectRation = `/rationRepository/ration?repository=${repId}&locked=${locked}`;
         let stdRationLib = await rationLibModel.findOne({ID: repId});
         res.render('maintain/ration_repository/anzhuang.html',
             {

+ 22 - 1
public/common_util.js

@@ -17,4 +17,25 @@ function deleteEmptyObject(arr) {
             i = i - 1;
         };
     };
-};
+};
+
+((factory) => {
+    if (typeof module !== 'undefined') {
+        module.exports = factory();
+    } else {
+        window._commonUtil = factory();
+    }
+})(() => {
+    function isDef(val) {
+        return typeof val !== 'undefined' && val !== null;
+    }
+
+    function isEmptyVal(val) {
+        return val === null || val === undefined || val === '';
+    }
+
+    return {
+        isDef,
+        isEmptyVal
+    };
+});

+ 93 - 1
public/web/lock_util.js

@@ -9,5 +9,97 @@
  */
 
 const lockUtil = (() => {
-    
+    // 从地址栏获取是否锁定
+    function getLocked() {
+        const search = window.location.search;
+        const reg = /locked=(false|true)/;
+        const match = search.match(reg);
+        return match ? JSON.parse(match[1]) : true;
+    }
+    function lockTools($range, locked) {
+        const $btns = $range.find('.lock-btn-control');
+        const toolList = [];
+        for (const $btn of $btns) {
+            toolList.push({$ref: $($btn), type: 'button'});
+        }
+        const $texts = $range.find('.lock-text-control');
+        for (const $text of $texts) {
+            toolList.push({$ref: $($text), type: 'text'});
+        }
+        toolList.forEach(item => {
+            switch (item.type) {
+                case 'button':
+                    locked ? item.$ref.addClass('disabled') : item.$ref.removeClass('disabled');
+                    break;
+                case 'text':
+                    item.$ref.prop('readOnly', locked);
+                    break;
+            }
+        });
+    }
+    function lockSpread(spread) {
+        spread.unbind(GC.Spread.Sheets.Events.ButtonClicked);
+        const sheetCount = spread.getSheetCount();
+        for(let i = 0; i < sheetCount; i++){
+            const sheet = spread.getSheet(i);
+            sheet.unbind(GC.Spread.Sheets.Events.ButtonClicked);
+            sheet.unbind(GC.Spread.Sheets.Events.EditStarting);
+            sheet.unbind(GC.Spread.Sheets.Events.EditEnded);
+            sheet.unbind(GC.Spread.Sheets.Events.RangeChanged);
+            sheet.unbind(GC.Spread.Sheets.Events.ClipboardChanging);
+            sheet.unbind(GC.Spread.Sheets.Events.ClipboardChanged);
+            sheet.unbind(GC.Spread.Sheets.Events.CellDoubleClick);
+            sheet.unbind(GC.Spread.Sheets.Events.CellClick);
+            sheet.unbind(GC.Spread.Sheets.Events.ValueChanged);
+            sheet.suspendPaint();
+            sheet.suspendEvent();
+            sheet.options.isProtected = true;
+            const rowCount = sheet.getRowCount();
+            const colCount = sheet.getColumnCount();
+            for(let row = 0; row < rowCount; row++){
+                for(let col = 0; col < colCount; col++){
+                    sheet.getCell(row, col).locked(true);
+                }
+            }
+            sheet.resumePaint();
+            sheet.resumeEvent();
+        }
+    }
+    function lockURL(locked, $url) {
+        const originURL = $url.prop('href');
+        const originLocked = !locked;
+        const reg = new RegExp(`locked=${originLocked}`);
+        const curURL = reg.test(originURL) ? originURL.replace(reg, `locked=${locked}`) : `${originURL}&locked=${locked}`;
+        $url.prop('href', curURL);
+    }
+    // 库列表页面,锁定按钮点击操作
+    function handleLockClick($lock) {
+        const curLocked = !$lock.data().locked;
+        $lock.data('locked', curLocked);
+        const innerHtml = curLocked ? '<i class="fa fa-unlock-alt"></i>' : '<i class="fa fa-lock"></i>';
+        $lock.html(innerHtml);
+        const title = curLocked ? '解锁' : '锁定';
+        $lock.prop('title', title);
+        const $url = $lock.parent().parent().children(':first-child').children(':first-child');
+        lockURL(curLocked, $url);
+        const $range = $lock.parent().parent();
+        lockTools($range, curLocked);
+    }
+    function lockSpreadAndTools(spreads, $range) {
+        const locked = lockUtil.getLocked();
+        if (!locked) {
+            return;
+        }
+        spreads.forEach(spread => lockSpread(spread));
+        lockTools($range, locked);
+    }
+
+    return {
+        getLocked,
+        lockTools,
+        lockSpread,
+        lockURL,
+        handleLockClick,
+        lockSpreadAndTools
+    }
 })();

+ 4 - 0
web/maintain/bills_lib/css/main.css

@@ -276,4 +276,8 @@ body {
 .modal-fixed-height {
     height:400px;
     overflow-y:auto;
+}
+.disabled {
+    pointer-events: none;
+    opacity: .65;
 }

+ 2 - 12
web/maintain/bills_lib/html/main.html

@@ -180,6 +180,7 @@
     <script src="/lib/bootstrap/bootstrap.min.js"></script>
     <script src="/public/web/PerfectLoad.js"></script>
     <script src="/public/web/common_ajax.js"></script>
+    <script src="/public/web/lock_util.js"></script>
     <script src="/web/maintain/bills_lib/scripts/global.js"></script>
     <script src="/web/maintain/bills_lib/scripts/bills_lib_ajax.js"></script>
     <script src="/web/maintain/bills_lib/scripts/tools.js"></script>
@@ -249,18 +250,7 @@
        });
 
        $('#showArea').on('click', '.lock', function () {
-           const $lock = $(this);
-           const $url = $lock.parent().parent().children(':first-child').children(':first-child');
-           const locked = $lock.data().locked;
-           const url = $url.prop('href');
-           const curLocked = !locked;
-           const curURL = url.replace(`locked=${locked}`, `locked=${curLocked}`);
-           $(this).data('locked', curLocked);
-           $url.prop('href', curURL);
-           const innerHtml = curLocked ? '<i class="fa fa-unlock-alt"></i>' : '<i class="fa fa-lock"></i>';
-           $lock.html(innerHtml);
-           const title = curLocked ? '解锁' : '锁定';
-           $lock.prop('title', title);
+           lockUtil.handleLockClick($(this));
        });
 
        $('#edit').on('shown.bs.modal', function () {

+ 7 - 2
web/maintain/bills_lib/html/neirong.html

@@ -215,6 +215,7 @@
     <script src="/web/maintain/bills_lib/scripts/global.js"></script>
     <script src="/public/web/PerfectLoad.js"></script>
     <script src="/public/web/common_ajax.js"></script>
+    <script src="/public/web/lock_util.js"></script>
     <script src="/public/web/sheet/sheet_common.js"></script>
     <script src="/web/maintain/bills_lib/scripts/set_sheets.js"></script>
     <script src="/web/maintain/bills_lib/scripts/bills_lib_ajax.js"></script>
@@ -223,6 +224,7 @@
     <script src="/web/maintain/bills_lib/scripts/bills_lib_setting.js"></script>
     <script src="/web/maintain/bills_lib/scripts/db_controller.js"></script>
     <SCRIPT type="text/javascript">
+        const locked = lockUtil.getLocked();
         let billsLibId = getQueryString("billsLibId");
         tools.redirect(billsLibId, 'stdBillsmain');
         let userAccount = '<%= userAccount%>'
@@ -234,13 +236,16 @@
         let sheetJobsDatas;
         $(document).ready(function(){
             $('#aStdBills').attr('href', function(){
-                return 'stdBills?billsLibId=' + billsLibId;
+                return `stdBills?billsLibId=${billsLibId}&locked=${locked}`;
             });
             $('#aStdItems').attr('href', function(){
-                return 'stdItems?billsLibId=' + billsLibId;
+                return `stdItems?billsLibId=${billsLibId}&locked=${locked}`;
             });
             billsAjax.getStdBillsLibName(billsLibId);
             buildAllJobs(spreadAllJobs, totalJobsSetting);
+            if (locked) {
+                lockUtil.lockSpread(spreadAllJobs);
+            }
         });
         function buildAllJobs(spreadAllJobs, setting){
             setSheet.initSheet(spreadAllJobs, setting, true);

+ 22 - 12
web/maintain/bills_lib/html/qingdan.html

@@ -45,22 +45,22 @@
                   <div class="collapse navbar-collapse" id="navbarNav">
                       <ul class="navbar-nav">
                           <li class="nav-item">
-                              <a class="nav-link text-primary" doing="false" fcsOnBills="true" id="insert" href="javascript: void(0);"><i class="fa fa-share" aria-hidden="true"></i>插入</a>
+                              <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" id="insert" href="javascript: void(0);"><i class="fa fa-share" aria-hidden="true"></i>插入</a>
                           </li>
                           <li class="nav-item">
-                              <a class="nav-link text-primary" doing="false" fcsOnBills="true" id ="delete" href="javascript:void (0)"><i class="fa fa-remove" aria-hidden="true"></i>删除</a>
+                              <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" id ="delete" href="javascript:void (0)"><i class="fa fa-remove" aria-hidden="true"></i>删除</a>
                           </li>
                           <li class="nav-item">
-                              <a class="nav-link text-primary" doing="false" fcsOnBills="true" id="upLevel"  href="javascript: void(0);"><i class="fa fa-arrow-left" aria-hidden="true"></i>升级</a>
+                              <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" id="upLevel"  href="javascript: void(0);"><i class="fa fa-arrow-left" aria-hidden="true"></i>升级</a>
                           </li>
                           <li class="nav-item">
-                              <a class="nav-link text-primary" doing="false" fcsOnBills="true" id="downLevel" href="javascript: void(0);"><i class="fa fa-arrow-right" aria-hidden="true"></i>降级</a>
+                              <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" id="downLevel" href="javascript: void(0);"><i class="fa fa-arrow-right" aria-hidden="true"></i>降级</a>
                           </li>
                           <li class="nav-item">
-                              <a class="nav-link text-primary" doing="false" fcsOnBills="true" canMove="false" id="upMove" href="javascript: void(0);"><i class="fa fa-arrow-up" aria-hidden="true"></i>上移</a>
+                              <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" canMove="false" id="upMove" href="javascript: void(0);"><i class="fa fa-arrow-up" aria-hidden="true"></i>上移</a>
                           </li>
                           <li class="nav-item">
-                              <a class="nav-link text-primary" doing="false" fcsOnBills="true" canMove="false" id="downMove" href="javascript: void(0);"><i class="fa fa-arrow-down" aria-hidden="true"></i>下移</a>
+                              <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" canMove="false" id="downMove" href="javascript: void(0);"><i class="fa fa-arrow-down" aria-hidden="true"></i>下移</a>
                           </li>
                       </ul>
                   </div>
@@ -85,7 +85,7 @@
                   </div>-->
                   <div class="form-group">
                       <a class="pull-right" href="javacript:void(0);" data-toggle="modal" data-target="#help" >html怎么写?</a>
-                      <a trigger="billsRecharge" class="pull-right mr-3 uploadImgTrigger" href="javacript:void(0);" data-toggle="modal" data-target="#uploadimg" ><i class="fa fa-image"></i>上传图片</a>
+                      <a trigger="billsRecharge" class="pull-right mr-3 uploadImgTrigger lock-btn-control" href="javacript:void(0);" data-toggle="modal" data-target="#uploadimg" ><i class="fa fa-image"></i>上传图片</a>
                       <label for="exampleTextarea">补注:</label>
                       <textarea class="form-control" id="exampleTextarea" rows="8"></textarea>
                   </div>
@@ -341,6 +341,7 @@
     <script src="/web/maintain/bills_lib/scripts/global.js"></script>
     <script src="/public/web/PerfectLoad.js"></script>
     <script src="/public/web/common_ajax.js"></script>
+    <script src="/public/web/lock_util.js"></script>
     <script src="/public/web/sheet/sheet_common.js"></script>
     <script src="/web/maintain/bills_lib/scripts/set_sheets.js"></script>
     <script src="/web/maintain/bills_lib/scripts/bills_lib_ajax.js"></script>
@@ -357,10 +358,12 @@
     <script src="/web/common/js/uploadImg.js"></script>
 </body>
 <script type="text/javascript">
+    const locked = lockUtil.getLocked();
     var codeEditor = CodeMirror.fromTextArea(document.getElementById("exampleTextarea"), {
         mode: "text/html",
         lineNumbers: true,
-        theme:"material"
+        theme:"material",
+        readOnly: locked
     });
     codeEditor.setSize('auto','350px');
     autoFlashHeight();
@@ -375,25 +378,29 @@
     let sheetItemsDatas;
     let sheetBillsDatas;
     tools.redirect(billsLibId, 'stdBillsmain');
+    let billsSpread;
     let jobsSpread = new GC.Spread.Sheets.Workbook($("#spreadJobs")[0], {sheetCount: 1});
     sheetCommonObj.bindEscKey(jobsSpread, [{sheet: jobsSpread.getSheet(0), editStarting: jobsController.onEditStart, editEnded: jobsController.onEditEnded}]);
     let itemsSpread = new GC.Spread.Sheets.Workbook($("#spreadItems")[0], {sheetCount: 1});
     sheetCommonObj.bindEscKey(itemsSpread, [{sheet: itemsSpread.getSheet(0), editStarting: itemsController.onEditStart, editEnded: itemsController.onEditEnded}]);
     $(document).ready(function(){
         $("#aStdJobs").attr('href', function(){
-            return 'stdJobs?billsLibId=' + billsLibId;
+            return `stdJobs?billsLibId=${billsLibId}&locked=${locked}`;
         });
         $('#aStdItems').attr('href', function(){
-            return 'stdItems?billsLibId=' + billsLibId;
+            return `stdItems?billsLibId=${billsLibId}&locked=${locked}`;
         });
         billsAjax.getStdBillsLibName(billsLibId);
         billsAjax.getBills(billsLibId, function(bills){
             showBillsSheet(bills, jobsSpread.getActiveSheet(), itemsSpread.getActiveSheet(), billsLibSetting)
+            const spreads = [billsSpread, jobsSpread, itemsSpread];
+            const $range = $(document.body);
+            lockUtil.lockSpreadAndTools(spreads, $range);
         });
         buildJobs(jobsSpread, jobsSetting);
         buildItems(itemsSpread, itemsSetting);
     });
-
+    
     function nodeOpration(controller, totalJobs, totalItems){
         let btnInsert = $('#insert');
         let btnDelete = $('#delete');
@@ -460,7 +467,7 @@
 
 
     function showBillsSheet(datas, jobsSheet, itemsSheet, setting) {
-        let billsSpread = new GC.Spread.Sheets.Workbook($('#spreadBills')[0], {sheetCount: 1});
+        billsSpread = new GC.Spread.Sheets.Workbook($('#spreadBills')[0], {sheetCount: 1});
         sheetCommonObj.bindEscKey(billsSpread, [{sheet: billsSpread.getSheet(0), editStarting: dbController.onEditStart, editEnded: dbController.onEditEnded}]);
         billsSpread.focus(true);
         setSheet.initSheet(billsSpread, setting, true);
@@ -615,6 +622,9 @@
     }
 
     function refreshBtn(controller){
+        if (locked) {
+            return;
+        }
         controller.bind('refreshBaseActn', function (tree) {
             let showButton = function (show, btn) {
                 tools.btnAction($('#insert'), 'focusOnBills');

+ 8 - 2
web/maintain/bills_lib/html/tezheng.html

@@ -216,6 +216,7 @@
     <script src="/web/maintain/bills_lib/scripts/global.js"></script>
     <script src="/public/web/PerfectLoad.js"></script>
     <script src="/public/web/common_ajax.js"></script>
+    <script src="/public/web/lock_util.js"></script>
     <script src="/public/web/sheet/sheet_common.js"></script>
     <script src="/web/maintain/bills_lib/scripts/set_sheets.js"></script>
     <script src="/web/maintain/bills_lib/scripts/bills_lib_ajax.js"></script>
@@ -224,6 +225,7 @@
     <script src="/web/maintain/bills_lib/scripts/bills_lib_setting.js"></script>
     <script src="/web/maintain/bills_lib/scripts/db_controller.js"></script>
     <SCRIPT type="text/javascript">
+        const locked = lockUtil.getLocked();
         let spread = new GC.Spread.Sheets.Workbook($('#spreadAllItems')[0], {sheetCount: 1});
         sheetCommonObj.bindEscKey(spread, [{sheet: spread.getSheet(0), editStarting: totalItemsController.onEditStart, editEnded: totalItemsController.onEditEnded}]);
         let spreadVal = new GC.Spread.Sheets.Workbook($('#spreadEigenvalue')[0], {sheetCount: 1});
@@ -239,15 +241,19 @@
         let valueDatas;
   		$(document).ready(function(){
             $('#aStdBills').attr('href', function(){
-                return 'stdBills?billsLibId=' + billsLibId;
+                return `stdBills?billsLibId=${billsLibId}&locked=${locked}`;
             });
             $('#aStdJobs').attr('href', function(){
-                return 'stdJobs?billsLibId=' + billsLibId;
+                return `stdJobs?billsLibId=${billsLibId}&locked=${locked}`;
             });
 
             billsAjax.getStdBillsLibName(billsLibId);
             buildAllItems(spread, totalItemsSetting);
             buildEigenvalue(spreadVal, eigenValueSetting);
+            if (locked) {
+                lockUtil.lockSpread(spread);
+                lockUtil.lockSpread(spreadVal);
+            }
   		});
         function buildAllItems(spread, setting){
             setSheet.initSheet(spread, setting, true);

+ 5 - 5
web/maintain/bills_lib/scripts/bills_lib_ajax.js

@@ -60,15 +60,15 @@ var mainAjax = {
                     <td><a href="/stdBills?billsLibId=${id}&locked=true">${billsLibName}</a></td>
                     <td>${createDateFmt}</td>
                     <td>
-                        <a href="javascript:void(0);" data-toggle="modal" data-target="#edit" title="编辑"><i class="fa fa-pencil-square-o"></i></a>
-                        <a href="javascript:void(0);" class="text-danger" data-toggle="modal" data-target="#del" title="删除"><i class="fa fa-remove"></i></a>
-                        <a href="javascript:void(0);" class="lock" title="解锁" data-locked="true"><i class="fa fa-unlock-alt"></i></a>
+                        <a class="lock-btn-control disabled" data-toggle="modal" data-target="#edit" href="javascript:void(0);" title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+                        <a class="text-danger lock-btn-control disabled" data-toggle="modal" data-target="#del" href="javascript:void(0);" title="删除"><i class="fa fa-remove"></i></a>
+                        <a class="lock" data-locked="true" href="javascript:void(0);" title="解锁"><i class="fa fa-unlock-alt"></i></a>
                     </td>
                     <td>
-                        <a href="javascript:void(0);" class="btn btn-secondary btn-sm import-data" data-id="${id}" title="导入数据"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
+                        <a class="btn btn-secondary btn-sm import-data lock-btn-control disabled" data-id="${id}" href="javascript:void(0);" title="导入数据"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
                     </td>
                     <td>
-                        <a href="javascript:void(0);" class="btn btn-secondary btn-sm copy-data" data-id="${id}" title="复制数据"><i class="fa fa-clone"></i>复制</a>
+                        <a class="btn btn-secondary btn-sm copy-data lock-btn-control disabled" data-id="${id}" href="javascript:void(0);" title="复制数据"><i class="fa fa-clone"></i>复制</a>
                     </td>
                  </tr>`;
             return acc += html;

+ 1 - 0
web/maintain/ration_repository/anzhuang.html

@@ -173,6 +173,7 @@
     <script src="/public/web/uuid.js"></script>
     <script src="/public/web/scMathUtil.js"></script>
     <script src="/public/common_util.js"></script>
+    <script src="/public/web/lock_util.js"></script>
     <script src="/public/web/storageUtil.js"></script>
     <script  src="/public/web/id_tree.js"></script>
     <script src="/public/web/tree_sheet/tree_sheet_controller.js"></script>

+ 4 - 0
web/maintain/ration_repository/css/main.css

@@ -294,3 +294,7 @@ div.resize-x{
     cursor: w-resize;
     float: left;
 }
+.disabled {
+    pointer-events: none;
+    opacity: .65;
+}

+ 22 - 14
web/maintain/ration_repository/dinge.html

@@ -63,15 +63,15 @@
                         <div style="width: 99%; float: left">
                             <div class="tab-bar row">
                                 <div>
-                                    <a href="javascript:void(0);" id="tree_Insert" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="插入"><i class="fa fa-plus" aria-hidden="true"></i></a>
-                                    <a href="javascript:void(0);" id="tree_remove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>
-                                    <a href="javascript:void(0);" id="tree_upLevel" class="btn btn-sm " data-toggle="tooltip" data-placement="bottom" title="" data-original-title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
-                                    <a href="javascript:void(0);" id="tree_downLevel" class="btn btn-sm " data-toggle="tooltip" data-placement="bottom" title="" data-original-title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
-                                    <a href="javascript:void(0);" id="tree_downMove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
-                                    <a href="javascript:void(0);" id="tree_upMove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
+                                    <a class="btn btn-sm lock-btn-control" id="tree_Insert" data-toggle="tooltip" data-placement="bottom" data-original-title="插入" href="javascript:void(0);" title="" ><i class="fa fa-plus" aria-hidden="true"></i></a>
+                                    <a class="btn btn-sm lock-btn-control" id="tree_remove" data-toggle="tooltip" data-placement="bottom" data-original-title="删除" href="javascript:void(0);" title=""><i class="fa fa-remove" aria-hidden="true"></i></a>
+                                    <a class="btn btn-sm lock-btn-control" id="tree_upLevel" data-toggle="tooltip" data-placement="bottom" data-original-title="升级" href="javascript:void(0);" title=""><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
+                                    <a class="btn btn-sm lock-btn-control" id="tree_downLevel" data-toggle="tooltip" data-placement="bottom" data-original-title="降级" href="javascript:void(0);" title=""><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
+                                    <a class="btn btn-sm lock-btn-control" id="tree_downMove" data-toggle="tooltip" data-placement="bottom" data-original-title="下移" href="javascript:void(0);" title=""><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
+                                    <a class="btn btn-sm lock-btn-control" id="tree_upMove" data-toggle="tooltip" data-placement="bottom" data-original-title="上移" href="javascript:void(0);" title=""><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                                 </div>
                                 <div>
-                                    <input type="text" class="form-control form-control-sm" placeholder="搜索定额" value="" id="rationSearch">
+                                    <input class="form-control form-control-sm" id="rationSearch" type="text" value="" placeholder="搜索定额">
                                 </div>
                             </div>
                             <div class="tab-content" id="sectionSpread" style="overflow: hidden">
@@ -136,8 +136,8 @@
                             <div class="tab-pane" id="tsm" role="tabpanel">
                                 <div class="main-data">
                                 <div class="main-content m-2">
-                                    <a trigger="rationExplanation" class="mr-3 uploadImgTrigger" href="javacript:void(0);" data-toggle="modal" data-target="#uploadimg" ><i class="fa fa-image"></i>上传图片</a><a href="javacript:void(0);" data-toggle="modal" data-target="#help" >html怎么写?</a></p>
-                                    <textarea id="explanationShow" name="editor" class="form-control "></textarea>
+                                    <a class="mr-3 uploadImgTrigger lock-btn-control" data-toggle="modal" data-target="#uploadimg" trigger="rationExplanation" href="javacript:void(0);"><i class="fa fa-image"></i>上传图片</a><a href="javacript:void(0);" data-toggle="modal" data-target="#help" >html怎么写?</a></p>
+                                    <textarea id="explanationShow" name="editor" class="form-control"></textarea>
                                     <!--<h5>说明</h5>
                                     <textarea id="explanationShow" class="form-control" style="background: white;"></textarea>-->
                                 </div>
@@ -148,7 +148,7 @@
                                 <div class="main-data">
                                     <!--         <div class="m-2"><a href="javacript:void(0);" data-toggle="modal" data-target="#editTjs" title="编辑">编辑计算规则</a></div>-->
                                     <div class="main-content m-2">
-                                        <a trigger="rationRuleText" class="mr-3 uploadImgTrigger" href="javacript:void(0);" data-toggle="modal" data-target="#uploadimg" ><i class="fa fa-image"></i>上传图片</a><a href="javacript:void(0);" data-toggle="modal" data-target="#help" >html怎么写?</a></p>
+                                        <a class="mr-3 uploadImgTrigger lock-btn-control" data-toggle="modal" data-target="#uploadimg" trigger="rationRuleText" href="javacript:void(0);"><i class="fa fa-image"></i>上传图片</a><a href="javacript:void(0);" data-toggle="modal" data-target="#help" >html怎么写?</a></p>
                                         <textarea id="ruleTextShow" name="editor" class="form-control "></textarea>
                                         <!--<h5>计算规则</h5>
                                         <textarea id="ruleTextShow" class="form-control" style="background: white;"></textarea>-->
@@ -158,11 +158,14 @@
                             <!--工作内容-->
                             <div class="tab-pane" id="tgz" role="tabpanel">
                                 <div class="main-data">
-                                    <div class="form-check m-2"><label class="form-check-label"><input type="radio" class="form-check-input" name="optionsRadios" value="ALL" disabled=""> 适合本项所有定额</label>&nbsp;&nbsp;<label class="form-check-label"><input type="radio" class="form-check-input" name="optionsRadios" value="PARTIAL" disabled> 适合本项部分定额</label></div>
+                                    <div class="form-check m-2">
+                                        <label class="form-check-label lock-btn-control"><input class="form-check-input lock-btn-control" name="optionsRadios" type="radio" value="ALL" disabled=""> 适合本项所有定额</label>&nbsp;&nbsp;
+                                        <label class="form-check-label lock-btn-control"><input class="form-check-input lock-btn-control" name="optionsRadios" type="radio" value="PARTIAL" disabled> 适合本项部分定额</label>
+                                    </div>
                                     <!-- <p class="m-2">适合本项所有定额</p> -->
                                     <table class="table table-sm table-bordered m-0" id="tableAll">
                                         <tr>
-                                            <td><textarea class="form-control" rows="30" id="txtareaAll"></textarea></td>
+                                            <td><textarea class="form-control lock-text-control" rows="30" id="txtareaAll"></textarea></td>
                                         </tr>
                                     </table>
                                     <table class="table table-sm table-bordered m-0" id="tablePartial">
@@ -172,11 +175,14 @@
                             <!--附注-->
                             <div class="tab-pane" id="tfz" role="tabpanel">
                                 <div class="main-data">
-                                    <div class="form-check m-2"><label class="form-check-label"><input type="radio" class="form-check-input" name="fzRadios" value="ALL" disabled=""> 适合本项所有定额</label>&nbsp;&nbsp;<label class="form-check-label"><input type="radio" class="form-check-input" name="fzRadios" value="PARTIAL" disabled> 适合本项部分定额</label></div>
+                                    <div class="form-check m-2">
+                                        <label class="form-check-label lock-btn-control"><input class="form-check-input lock-btn-control" name="fzRadios" type="radio" value="ALL" disabled=""> 适合本项所有定额</label>&nbsp;&nbsp;
+                                        <label class="form-check-label lock-btn-control"><input class="form-check-input lock-btn-control" name="fzRadios" type="radio" value="PARTIAL" disabled> 适合本项部分定额</label>
+                                    </div>
                                     <!-- <p class="m-2">适合本项所有定额</p> -->
                                     <table class="table table-sm table-bordered m-0" id="fzTableAll">
                                         <tr>
-                                            <td><textarea class="form-control" rows="30" id="fzTxtareaAll"></textarea></td>
+                                            <td><textarea class="form-control lock-text-control" rows="30" id="fzTxtareaAll"></textarea></td>
                                         </tr>
                                     </table>
                                     <table class="table table-sm table-bordered m-0" id="fzTablePartial">
@@ -657,6 +663,8 @@
         <script type="text/javascript" src="/web/maintain/ration_repository/js/annotation.js"></script>
         <script type="text/javascript" src="/public/web/scMathUtil.js"></script>
         <script type="text/javascript" src="/public/web/common_ajax.js"></script>
+        <script src="/public/common_util.js"></script>
+        <script src="/public/web/lock_util.js"></script>
         <script type="text/javascript" src="/public/web/id_tree.js"></script>
         <script type="text/javascript" src="/public/web/tree_sheet/tree_sheet_controller.js"></script>
         <script src="/public/web/tree_sheet/tree_sheet_helper.js"></script>

+ 2 - 0
web/maintain/ration_repository/js/coe.js

@@ -173,6 +173,8 @@ var pageObj = {
         gljAdjOprObj.buildSheet($('#contentSpread')[0]);
         coeOprObj.getCoeList();
         gljAdjOprObj.getGljItemsOcc();
+        lockUtil.lockSpread(coeOprObj.workBook);
+        lockUtil.lockSpread(gljAdjOprObj.workBook);
     },
     showData: function(sheet, setting, data) {
         let me = pageObj, ch = GC.Spread.Sheets.SheetArea.viewport;

+ 5 - 2
web/maintain/ration_repository/js/explanatory.js

@@ -11,10 +11,12 @@ let explanatoryOprObj = {
     currentRuleText: null,
     // 初始化说明、计算规则编辑器
     initEditor: function () {
+        const locked = lockUtil.getLocked();
         const exEditor = CodeMirror.fromTextArea(document.getElementById("explanationShow"), {
             mode: "text/html",
             lineNumbers: true,
-            theme:"material"
+            theme:"material",
+            readOnly: locked
         });
         exEditor.setSize('auto','500px');
         $('#explanationLink').click(function () {
@@ -26,7 +28,8 @@ let explanatoryOprObj = {
         const calcEditor = CodeMirror.fromTextArea(document.getElementById("ruleTextShow"), {
             mode: 'text/html',
             lineNumbers: true,
-            theme: 'material'
+            theme: 'material',
+            readOnly: locked
         });
         calcEditor.setSize('auto', '500px');
         $('#ruleTextLink').click(function () {

+ 7 - 0
web/maintain/ration_repository/js/init.js

@@ -43,6 +43,13 @@ const initialization = (() => {
             rationInstObj.initInstallation(rstData.installationList);
             //初始化已使用的定额编码
             rationOprObj.rationsCodes = rstData.rationsCodes;
+            const lockedSpreads = [
+                sectionTreeObj.workBook,
+                rationOprObj.workBook,
+                rdSpread
+            ];
+            const $range = $(document.body);
+            lockUtil.lockSpreadAndTools(lockedSpreads, $range);
 
             $("#linkGLJ").click(function(){
                 rationGLJOprObj.bindRationGljDelOpr();

+ 19 - 8
web/maintain/ration_repository/js/installation.js

@@ -4,6 +4,12 @@
 
 $(document).ready(function () {
     feeItemObj.buildSheet();
+    const lockedSpreads = [
+        feeItemObj.workBook,
+        sectionObj.workBook,
+        feeRuleObj.workBook
+    ];
+    lockedSpreads.forEach(spread => lockUtil.lockSpread(spread));
     $('#sectionTreeModal').on('shown.bs.modal', function (e) {
         batchSectionObj.workBook.refresh();
         //bind confirm btn
@@ -442,6 +448,7 @@ let sectionObj = {
         $.contextMenu({
             selector: '#instSectionSpread',
             build: function($triggerElement, e){
+                const locked = lockUtil.getLocked();
                 //控制允许右键菜单在哪个位置出现
                 let sheet = me.sheet;
                 let offset = $("#instSectionSpread").offset(),
@@ -451,17 +458,21 @@ let sectionObj = {
                 if(target.hitTestType === 3 && me.isDef(target.row) && me.isDef(target.col)){//在表格内
                     sheet.setActiveCell(target.row, target.col);
                     me.initSelection(me.cache[target.row]);
-                    //控制按钮是否可用
-                    let refDis = false;
-                    if(target.row >= me.cache.length){
-                        refDis = true;
-                    }
                     return {
                         callback: function(){},
                         items: {
-                            "ref": {name: "批量关联至定额", disabled: refDis, icon: "fa-arrow-left", callback: function (key, opt) {
-                                $('#sectionTreeModal').modal('show');
-                            }}
+                            "ref": {
+                                name: "批量关联至定额",
+                                disabled: function () {
+                                    const inValidCell = !_commonUtil.isDef(target.row) || !_commonUtil.isDef(target.col);
+                                    const inValidData = target.row >= me.cache.length;
+                                    return locked || inValidCell || inValidData;
+                                },
+                                icon: "fa-arrow-left",
+                                callback: function (key, opt) {
+                                    $('#sectionTreeModal').modal('show');
+                                }
+                            }
                         }
                     };
                 }

+ 4 - 1
web/maintain/ration_repository/js/main.js

@@ -128,7 +128,10 @@ $(function () {
             $('#reCalcConfirm').removeClass('disabled')
         });
     });
-
+    // 锁定、解锁
+    $('#showArea').on('click', '.lock', function () {
+        lockUtil.handleLockClick($(this));
+    });
     getCompilationList(function (data) {
         compilationsArr = data.compilation;
     });

+ 24 - 26
web/maintain/ration_repository/js/ration.js

@@ -249,44 +249,40 @@ let rationOprObj = {
         $.contextMenu({
             selector: '#rationItemsSheet',
             build: function($triggerElement, e){
+                const locked = lockUtil.getLocked();
                 //控制允许右键菜单在哪个位置出现
                 let target = SheetDataHelper.safeRightClickSelection($triggerElement, e, me.workBook);
                 let sheet = me.workBook.getSheet(0);
-                let  delDis = false;
                 let cacheSection = me.getCache();
                 let ration = cacheSection[target.row];
                 if(target.hitTestType === 3){//在表格内&& typeof target.row !== 'undefined' && typeof target.col !== 'undefined'
                     if(typeof target.row !== 'undefined'){
                         //控制按钮是否可用
                         sheet.setActiveCell(target.row, target.col);
-                        if(!cacheSection ||target.row >= cacheSection.length){//右键定位在有数据的行,删除键才显示可用
-                            delDis = true;
-                        }
-                        else{//有数据
-                            if(typeof target.col === 'undefined'){//定位不在表格内
-                                delDis = true;
-                            }
-                        }
-                    }
-                    else{
-                        delDis = true;
                     }
                     return {
                         callback: function(){},
                         items: {
-                            "delete": {name: "删除", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {
-
-                                let removeInfo = `确定要删除定额 “${ration.code}” 及其下的所有数据吗?`;
-                                $('#delRationAlert').find('.modal-body h5').text(removeInfo);
-                                $('#delRationAlert').modal('show');
-                                $('#delRationConfirm').bind('click', function () {
-                                    me.rationsCodes.splice(me.rationsCodes.indexOf(ration.code.toString()), 1);
-                                    me.mixDel = 1;
-                                    me.mixUpdateRequest([], [], [ration.ID]);
-                                    $('#delRationConfirm').unbind('click');
-                                    $('#delRationAlert').modal('hide');
-                                });
-                            }}
+                            "delete": {
+                                name: "删除",
+                                disabled: function () {
+                                    const inValidCell = !_commonUtil.isDef(target.row) || !_commonUtil.isDef(target.col);
+                                    const inValidData = !cacheSection ||target.row >= cacheSection.length;
+                                    return locked || inValidCell || inValidData;
+                                },
+                                icon: "fa-remove",
+                                callback: function (key, opt) {
+                                    let removeInfo = `确定要删除定额 “${ration.code}” 及其下的所有数据吗?`;
+                                    $('#delRationAlert').find('.modal-body h5').text(removeInfo);
+                                    $('#delRationAlert').modal('show');
+                                    $('#delRationConfirm').bind('click', function () {
+                                        me.rationsCodes.splice(me.rationsCodes.indexOf(ration.code.toString()), 1);
+                                        me.mixDel = 1;
+                                        me.mixUpdateRequest([], [], [ration.ID]);
+                                        $('#delRationConfirm').unbind('click');
+                                        $('#delRationAlert').modal('hide');
+                                    });
+                                }}
                         }
                     };
                 }
@@ -721,7 +717,9 @@ let rationOprObj = {
                             annotationOprObj.rationAnnotationOpr(me.currentRations["_SEC_ID_" + sectionID]);
                             me.showRationItems(sectionID);
                         }
-                        sectionTreeObj.removeBtn.removeClass('disabled');
+                        if (!lockUtil.getLocked()) {
+                            sectionTreeObj.removeBtn.removeClass('disabled');
+                        }
                         if(callback) {
                             callback(result.data);
                         }

+ 0 - 74
web/maintain/ration_repository/js/ration_coe.js

@@ -31,86 +31,12 @@ var rationCoeOprObj = {
         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.onContextmenuOpr();
     },
 
     isDef: function (v) {
         return v !== undefined && v !== null;
     },
 
-    onContextmenuOpr: function () {
-        let raCoe = rationCoeOprObj;
-        $.contextMenu({
-            selector: '#rdSpread',
-            build: function($triggerElement, e){
-                //控制允许右键菜单在哪个位置出现
-                let sheet = raCoe.sheet;
-                let offset = $("#rdSpread").offset(),
-                    x = e.pageX - offset.left,
-                    y = e.pageY - offset.top;
-                let target = sheet.hitTest(x, y);
-                if(sheet.getParent().getActiveSheetIndex() === 2 && target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){//在表格内
-                    let currentCache = raCoe.isDef(raCoe.cache["_Coe_" + raCoe.curRation.ID])  ? raCoe.cache["_Coe_" + raCoe.curRation.ID] : [];
-                    sheet.setActiveCell(target.row, target.col);
-                    //控制按钮是否可用
-                    let upDis = false,
-                        downDis = false,
-                        refDis = false;
-                    if(target.row >= currentCache.length){
-                        upDis = true;
-                        downDis = true;
-                        refDis = true;
-                    }
-                    else {
-                        if(!raCoe.isDef(currentCache[target.row - 1])){
-                            upDis = true;
-                        }
-                        if(!raCoe.isDef(currentCache[target.row + 1])){
-                            downDis = true;
-                        }
-                    }
-                    return {
-                        callback: function(){},
-                        items: {
-                            "upMove": {name: "上移", disabled: upDis, icon: "fa-arrow-up", callback: function (key, opt) {
-                                raCoe.upMove(currentCache[target.row], currentCache[target.row - 1], {row: target.row - 1, col: target.col});
-                            }},
-                            "downMove": {name: "下移", disabled: downDis, icon: "fa-arrow-down", callback: function (key, opt) {
-                                raCoe.downMove(currentCache[target.row], currentCache[target.row + 1], {row: target.row + 1, col: target.col});
-                            }},
-                            "ref": {name: "添加到本节其他定额", disabled: refDis, icon: "fa-arrow-left", callback: function (key, opt) {
-                                raCoe.updateSectionRation(rationOprObj.currentRations["_SEC_ID_" + rationOprObj.currentSectionId], currentCache[target.row], function (updateArr) {
-                                    for(let i = 0, len = updateArr.length; i < len; i++){
-                                        let ration = updateArr[i];
-                                        let rationCoeList = updateArr[i].rationCoeList;
-                                        let newNo = 1;
-                                        for(let j = 0, jLen = rationCoeList.length; j < jLen; j++){
-                                            if(rationCoeList[j].no >= newNo){
-                                                newNo = rationCoeList[j].no + 1;
-                                            }
-                                        }
-                                        let theCache = raCoe.cache["_Coe_" + ration.ID];
-                                        if(theCache !== undefined && theCache !== null){
-                                            let newCoe = {};
-                                            for(let attr in currentCache[target.row]){
-                                                newCoe[attr] = currentCache[target.row][attr];
-                                            }
-                                            newCoe.no = newNo;
-                                            theCache.push(newCoe);
-                                        }
-                                    }
-                                });
-                            }}
-                        }
-                    };
-                }
-                else{
-                    return false;
-                }
-            }
-        });
-    },
 
     upMove: function (thisObj, preObj, cell) {
         let me = this;

+ 100 - 88
web/maintain/ration_repository/js/ration_glj.js

@@ -274,63 +274,65 @@ var rationGLJOprObj = {
         $.contextMenu({
             selector: '#rdSpread',
             build: function($triggerElement, e){
+                const locked = lockUtil.getLocked();
                 //控制允许右键菜单在哪个位置出现
                 let target = SheetDataHelper.safeRightClickSelection($triggerElement, e, me.sheet.getParent());
                 let sheet = me.sheet;
-                let addDis = false, delDis = false;
-                let rationGlj = [];
                 if(me.sheet.getParent().getActiveSheetIndex() === 0 && target.hitTestType === 3){//在表格内&& typeof target.row !== 'undefined' && typeof target.col !== 'undefined'
                     //rationGlj表
                     if(typeof target.row !== 'undefined'){
                         //控制按钮是否可用
                         sheet.setActiveCell(target.row, target.col);
-                        console.log(me.currentRationItem);
-                        if(me.currentRationItem){
-                            rationGlj =  me.cache['_GLJ_' + me.currentRationItem.ID];
-                            if(!rationGlj ||target.row >= rationGlj.length){//右键定位在有数据的行,删除键才显示可用
-                                delDis = true;
-                            }
-                            else{//有数据
-                                if(typeof target.col === 'undefined'){//定位不在表格内
-                                    delDis = true;
-                                }
-                            }
-                        }
-                        else{
-                            addDis = true;
-                            delDis = true;
-                        }
-                    }
-                    else{
-                        addDis = true;
-                        delDis = true;
                     }
                     return {
                         callback: function(){},
                         items: {
-                            "add": {name: "添加人材机", disabled: addDis, icon: "fa-plus", callback: function (key, opt) {
-                                //默认radio所有工料机
-                                gljSelOprObj.initRadio();
-                                gljSelOprObj.gljCurTypeId = null;
-                                //默认点击树根节点
-                                if(gljSelOprObj.rootNode){
-                                    gljSelOprObj.treeObj.selectNode(gljSelOprObj.rootNode);
-                                    gljSelTreeOprObj.setting.callback.onClick(null, 'componentTree', gljSelOprObj.rootNode);
-                                }
-                                //弹出窗口
-                                $('#selGlj').modal('show');
-                                if (gljSelOprObj.workBook) {
-                                    gljSelOprObj.workBook.refresh();
-                                }
-                            }},
-                            "delete": {name: "删除人材机", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {
-                                rationGlj.splice(target.row, 1);
-                                me.updateRationItem(function(){
-                                    me.sheet.getParent().focus();
-                                });
-                                sheetCommonObj.cleanData(me.sheet, me.setting, -1);
-                                me.showGljItems(me.currentRationItem.ID);
-                            }},
+                            "add": {
+                                name: "添加人材机",
+                                disabled: function () {
+                                    const inValidCell = !_commonUtil.isDef(target.row) || !_commonUtil.isDef(target.col);
+                                    if (locked || inValidCell || !me.currentRationItem) {
+                                        return true;
+                                    }
+                                    return false;
+                                },
+                                icon: "fa-plus",
+                                callback: function (key, opt) {
+                                    //默认radio所有工料机
+                                    gljSelOprObj.initRadio();
+                                    gljSelOprObj.gljCurTypeId = null;
+                                    //默认点击树根节点
+                                    if(gljSelOprObj.rootNode){
+                                        gljSelOprObj.treeObj.selectNode(gljSelOprObj.rootNode);
+                                        gljSelTreeOprObj.setting.callback.onClick(null, 'componentTree', gljSelOprObj.rootNode);
+                                    }
+                                    //弹出窗口
+                                    $('#selGlj').modal('show');
+                                    if (gljSelOprObj.workBook) {
+                                        gljSelOprObj.workBook.refresh();
+                                    }
+                                }},
+                            "delete": {
+                                name: "删除人材机",
+                                disabled: function () {
+                                    const inValidCell = !_commonUtil.isDef(target.row) || !_commonUtil.isDef(target.col);
+                                    const rationGlj =  me.cache['_GLJ_' + me.currentRationItem.ID];
+                                    const inValidData = !rationGlj || target.row >= rationGlj.length;
+                                    if (locked || inValidCell || !me.currentRationItem || inValidData) {
+                                        return true;
+                                    }
+                                    return false;
+                                },
+                                icon: "fa-remove",
+                                callback: function (key, opt) {
+                                    const rationGlj =  me.cache['_GLJ_' + me.currentRationItem.ID];
+                                    rationGlj.splice(target.row, 1);
+                                    me.updateRationItem(function(){
+                                        me.sheet.getParent().focus();
+                                    });
+                                    sheetCommonObj.cleanData(me.sheet, me.setting, -1);
+                                    me.showGljItems(me.currentRationItem.ID);
+                                }},
                         }
                     };
                 }
@@ -338,55 +340,65 @@ var rationGLJOprObj = {
                 else if(me.sheet.getParent().getActiveSheetIndex() === 2 && target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){
                     let currentCache = raCoe.curRation && raCoe.isDef(raCoe.cache["_Coe_" + raCoe.curRation.ID])  ? raCoe.cache["_Coe_" + raCoe.curRation.ID] : [];
                     sheet.setActiveCell(target.row, target.col);
-                    //控制按钮是否可用
-                    let upDis = false,
-                        downDis = false,
-                        refDis = false;
-                    if(target.row >= currentCache.length){
-                        upDis = true;
-                        downDis = true;
-                        refDis = true;
-                    }
-                    else {
-                        if(!raCoe.isDef(currentCache[target.row - 1])){
-                            upDis = true;
-                        }
-                        if(!raCoe.isDef(currentCache[target.row + 1])){
-                            downDis = true;
-                        }
-                    }
                     return {
                         callback: function(){},
                         items: {
-                            "upMove": {name: "上移", disabled: upDis, icon: "fa-arrow-up", callback: function (key, opt) {
-                                raCoe.upMove(currentCache[target.row], currentCache[target.row - 1], {row: target.row - 1, col: target.col});
-                            }},
-                            "downMove": {name: "下移", disabled: downDis, icon: "fa-arrow-down", callback: function (key, opt) {
-                                raCoe.downMove(currentCache[target.row], currentCache[target.row + 1], {row: target.row + 1, col: target.col});
-                            }},
-                            "ref": {name: "添加到本节其他定额", disabled: refDis, icon: "fa-arrow-left", callback: function (key, opt) {
-                                raCoe.updateSectionRation(rationOprObj.currentRations["_SEC_ID_" + rationOprObj.currentSectionId], currentCache[target.row], function (updateArr) {
-                                    for(let i = 0, len = updateArr.length; i < len; i++){
-                                        let ration = updateArr[i];
-                                        let rationCoeList = updateArr[i].rationCoeList;
-                                        let newNo = 1;
-                                        for(let j = 0, jLen = rationCoeList.length; j < jLen; j++){
-                                            if(rationCoeList[j].no >= newNo){
-                                                newNo = rationCoeList[j].no + 1;
+                            "upMove": {
+                                name: "上移",
+                                disabled: function () {
+                                    const inValidCell = !_commonUtil.isDef(target.row) || !_commonUtil.isDef(target.col);
+                                    const inValidData = target.row >= currentCache.length || !raCoe.isDef(currentCache[target.row - 1]);
+                                    return locked || inValidCell || inValidData
+                                },
+                                icon: "fa-arrow-up",
+                                callback: function (key, opt) {
+                                    raCoe.upMove(currentCache[target.row], currentCache[target.row - 1], {row: target.row - 1, col: target.col});
+                                }
+                            },
+                            "downMove": {
+                                name: "下移",
+                                disabled: function () {
+                                    const inValidCell = !_commonUtil.isDef(target.row) || !_commonUtil.isDef(target.col);
+                                    const inValidData = target.row >= currentCache.length || !raCoe.isDef(currentCache[target.row + 1]);
+                                    return locked || inValidCell || inValidData;
+                                },
+                                icon: "fa-arrow-down",
+                                callback: function (key, opt) {
+                                    raCoe.downMove(currentCache[target.row], currentCache[target.row + 1], {row: target.row + 1, col: target.col});
+                                }
+                            },
+                            "ref": {
+                                name: "添加到本节其他定额",
+                                disabled: function () {
+                                    const inValidCell = !_commonUtil.isDef(target.row) || !_commonUtil.isDef(target.col);
+                                    const inValidData = target.row >= currentCache.length;
+                                    return locked || inValidCell || inValidData;
+                                },
+                                icon: "fa-arrow-left",
+                                callback: function (key, opt) {
+                                    raCoe.updateSectionRation(rationOprObj.currentRations["_SEC_ID_" + rationOprObj.currentSectionId], currentCache[target.row], function (updateArr) {
+                                        for(let i = 0, len = updateArr.length; i < len; i++){
+                                            let ration = updateArr[i];
+                                            let rationCoeList = updateArr[i].rationCoeList;
+                                            let newNo = 1;
+                                            for(let j = 0, jLen = rationCoeList.length; j < jLen; j++){
+                                                if(rationCoeList[j].no >= newNo){
+                                                    newNo = rationCoeList[j].no + 1;
+                                                }
                                             }
-                                        }
-                                        let theCache = raCoe.cache["_Coe_" + ration.ID];
-                                        if(theCache !== undefined && theCache !== null){
-                                            let newCoe = {};
-                                            for(let attr in currentCache[target.row]){
-                                                newCoe[attr] = currentCache[target.row][attr];
+                                            let theCache = raCoe.cache["_Coe_" + ration.ID];
+                                            if(theCache !== undefined && theCache !== null){
+                                                let newCoe = {};
+                                                for(let attr in currentCache[target.row]){
+                                                    newCoe[attr] = currentCache[target.row][attr];
+                                                }
+                                                newCoe.no = newNo;
+                                                theCache.push(newCoe);
                                             }
-                                            newCoe.no = newNo;
-                                            theCache.push(newCoe);
                                         }
-                                    }
-                                });
-                            }}
+                                    });
+                                }
+                            }
                         }
                     };
                 }

+ 4 - 0
web/maintain/ration_repository/js/section_tree.js

@@ -263,6 +263,10 @@ let sectionTreeObj = {
     },
     
     refreshBtn: function (selected) {
+        const locked = lockUtil.getLocked();
+        if (locked) {
+            return;
+        }
         let me = this;
         me.insertBtn.removeClass('disabled');
         me.removeBtn.removeClass('disabled');

+ 11 - 9
web/maintain/ration_repository/main.html

@@ -65,27 +65,28 @@
                         <tbody id="showArea">
                         <% for(let lib of rationLibs){ %>
                         <tr id="<%= lib.ID %>">
-                            <td><a href="/rationRepository/ration?repository=<%= lib.ID%>"><%= lib.dispName%></a></td>
+                            <td><a href="/rationRepository/ration?repository=<%= lib.ID%>&locked=true"><%= lib.dispName%></a></td>
                             <td><%= lib.libCode%></td>
                             <td><%= lib.compilationName%></td>
                             <td><%= moment(lib.createDate).format('YYYY-MM-DD')%></td>
                             <td>
-                                <a href="javacript:void(0);" data-toggle="modal" data-target="#edit" title="编辑"><i class="fa fa-pencil-square-o"></i></a>
-                                <a href="javacript:void(0);" data-toggle="modal" data-target="#del" class="text-danger" title="删除"><i class="fa fa-remove"></i></a>
-                                <a href="javascript:void(0);" data-toggle="modal" data-target="#reCalcAll" title="全部计算"><i class="fa fa-calculator"></i></a>
+                                <a class="lock-btn-control disabled" data-toggle="modal" data-target="#edit" href="javacript:void(0);" title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+                                <a class="text-danger lock-btn-control disabled" data-toggle="modal" data-target="#del" href="javacript:void(0);" title="删除"><i class="fa fa-remove"></i></a>
+                                <a class="lock-btn-control disabled" data-toggle="modal" data-target="#reCalcAll" href="javascript:void(0);" title="全部计算"><i class="fa fa-calculator"></i></a>
+                                <a class="lock" data-locked="true" href="javascript:void(0);" title="解锁"><i class="fa fa-unlock-alt"></i></a>
                             </td>
                             <td>
-                                <a class="btn btn-secondary btn-sm import-source" href="javacript:void(0);" data-id="<%= lib.ID %>" title="导入原始数据"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
+                                <a class="btn btn-secondary btn-sm import-source lock-btn-control disabled" href="javacript:void(0);" data-id="<%= lib.ID %>" title="导入原始数据"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
                             </td>
                             <td>
-                                <a class="btn btn-success btn-sm export" href="javacript:void(0);" data-toggle="modal" data-id="<%= lib.ID %>" data-target="#emport" title="导出内部数据"><i class="fa fa-sign-out fa-rotate-270"></i>导出</a>
-                                <a class="btn btn-secondary btn-sm import-data" href="javacript:void(0);" data-id="<%= lib.ID %>" title="导入内部数据"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
+                                <a class="btn btn-success btn-sm export lock-btn-control disabled" href="javacript:void(0);" data-toggle="modal" data-id="<%= lib.ID %>" data-target="#emport" title="导出内部数据"><i class="fa fa-sign-out fa-rotate-270"></i>导出</a>
+                                <a class="btn btn-secondary btn-sm import-data lock-btn-control disabled" href="javacript:void(0);" data-id="<%= lib.ID %>" title="导入内部数据"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
                             </td>
                             <td>
-                                <a class="btn btn-secondary btn-sm import-section" data-toggle="modal" data-target="#section" href="javacript:void(0);" data-id="<%= lib.ID %>" title="导入章节树"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
+                                <a class="btn btn-secondary btn-sm import-section lock-btn-control disabled" data-toggle="modal" data-target="#section" href="javacript:void(0);" data-id="<%= lib.ID %>" title="导入章节树"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
                             </td>
                             <td>
-                                <a class="btn btn-secondary btn-sm set-comple" href="javacript:void(0);" data-id="<%= lib.ID %>" title="将章节树设为补充模板数据"><i class="fa fa-sign-in fa-rotate-90"></i>设置</a>
+                                <a class="btn btn-secondary btn-sm set-comple lock-btn-control disabled" href="javacript:void(0);" data-id="<%= lib.ID %>" title="将章节树设为补充模板数据"><i class="fa fa-sign-in fa-rotate-90"></i>设置</a>
                             </td>
                         </tr>
                         <% } %>
@@ -353,6 +354,7 @@
     <script src="/public/web/commonAlert.js"></script>
     <script src="/web/maintain/ration_repository/js/global.js"></script>
     <script src="/public/web/common_ajax.js"></script>
+    <script src="/public/web/lock_util.js"></script>
     <!-- zTree -->
     <script type="text/javascript" src="/public/web/date_util.js"></script>
   	<script type="text/javascript" src="/lib/ztree/jquery.ztree.core.js"></script>