Browse Source

自动调用变更令提示

MaiXinRong 3 weeks ago
parent
commit
0ee6d8cf86
3 changed files with 60 additions and 26 deletions
  1. 29 25
      app/public/js/stage.js
  2. 29 0
      app/view/shares/check_modal.ejs
  3. 2 1
      app/view/stage/modal.ejs

+ 29 - 25
app/public/js/stage.js

@@ -4586,30 +4586,32 @@ $(document).ready(() => {
                         name: '自动调用',
                         icon: 'fa-play',
                         callback: function (key, opt) {
-                            const curChange = SpreadJsObj.getSelectObject(self.changeSheet);
-                            const changeBills = self.changeBillsSheet.zh_data;
-                            const data = { bills: [], autoType: 'bills' };
-                            for (const cb of changeBills) {
-                                const billsPos = self.findBillsPos(curChange, cb);
-                                if (billsPos) data.bills.push({ ...billsPos, cid: cb.cid, cbid: cb.id })
-                            }
-                            if (data.bills.length === 0) {
-                                toastr.warning('无可调用的清单或计量单元');
-                                return;
-                            }
-                            postData(window.location.pathname + '/auto-use-change', data, function(result) {
-                                if (result.pos) {
-                                    stagePos.loadCurStageData(result.pos.curStageData);
+                            checkAgainHint(function(){
+                                const curChange = SpreadJsObj.getSelectObject(self.changeSheet);
+                                const changeBills = self.changeBillsSheet.zh_data;
+                                const data = { bills: [], autoType: 'bills' };
+                                for (const cb of changeBills) {
+                                    const billsPos = self.findBillsPos(curChange, cb);
+                                    if (billsPos) data.bills.push({ ...billsPos, cid: cb.cid, cbid: cb.id })
                                 }
-                                const nodes = stageTree.loadPostStageData(result.bills);
-                                stageTreeSpreadObj.refreshTreeNodes(slSpread.getActiveSheet(), nodes);
-                                stagePosSpreadObj.loadCurPosData();
-                                if (detail) {
-                                    detail.loadStageChangeUpdateData(result, nodes);
-                                } else {
-                                    stageIm.loadUpdateChangeData(result, nodes)
+                                if (data.bills.length === 0) {
+                                    toastr.warning('无可调用的清单或计量单元');
+                                    return;
                                 }
-                            });
+                                postData(window.location.pathname + '/auto-use-change', data, function(result) {
+                                    if (result.pos) {
+                                        stagePos.loadCurStageData(result.pos.curStageData);
+                                    }
+                                    const nodes = stageTree.loadPostStageData(result.bills);
+                                    stageTreeSpreadObj.refreshTreeNodes(slSpread.getActiveSheet(), nodes);
+                                    stagePosSpreadObj.loadCurPosData();
+                                    if (detail) {
+                                        detail.loadStageChangeUpdateData(result, nodes);
+                                    } else {
+                                        stageIm.loadUpdateChangeData(result, nodes)
+                                    }
+                                });
+                            }, ['自动调用后,已调用变更令无法批量取消,请谨慎操作。', '去顶自动调用变更令?']);
                         },
                         disabled: function (key, opt) {
                             const curChange = SpreadJsObj.getSelectObject(self.changeSheet);
@@ -4624,9 +4626,11 @@ $(document).ready(() => {
                         name: '自动调用(全部变更令)',
                         icon: 'fa-play',
                         callback: function (key, opt) {
-                            postData(window.location.pathname + '/auto-use-change', { autoType: 'all' }, function(result) {
-                                window.location.reload();
-                            });
+                            checkAgainHint(function(){
+                                postData(window.location.pathname + '/auto-use-change', { autoType: 'all' }, function(result) {
+                                    window.location.reload();
+                                });
+                            }, ['自动调用后,已调用变更令无法批量取消,请谨慎操作。', '去顶自动调用变更令?']);
                         },
                         disabled: function (key, opt) {
                             const curChange = SpreadJsObj.getSelectObject(self.changeSheet);

+ 29 - 0
app/view/shares/check_modal.ejs

@@ -0,0 +1,29 @@
+<!--确认-->
+<div class="modal fade" id="check-again-modal" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title" id="cam-caption">确认</h5>
+            </div>
+            <div class="modal-body" id="cam-hint">
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
+                <button type="button" class="btn btn-sm btn-primary" id="cam-ok" data-dismiss="modal">确定</button>
+            </div>
+        </div>
+    </div>
+</div>
+<script>
+    const checkAgainHint = function (fun, hint, caption = '确认') {
+        $('#cam-cation').html(caption);
+        const hints = hint instanceof Array ? hint : [hint];
+        const hintHtml = hints.map(h => { return `<h6>${h || ''}</h6>`});
+        if (hintHtml) $('#cam-hint').html(hintHtml);
+        $('#check-again-modal').bind('hidden.bs.modal', function () {
+            $('#cam-ok').unbind('click');
+        });
+        $('#cam-ok').bind('click', fun);
+        $('#check-again-modal').modal('show');
+    }
+</script>

+ 2 - 1
app/view/stage/modal.ejs

@@ -711,4 +711,5 @@
 <% include ../shares/delete_hint_modal.ejs%>
 <% include ../shares/batch_import_modal.ejs%>
 <% include ../shares/import_file_modal.ejs%>
-<% include ../spss/spss_select_modal.ejs %>
+<% include ../spss/spss_select_modal.ejs %>
+<% include ../shares/check_modal.ejs %>