ソースを参照

台账分解、计量台账,计量单元,表达式框相关问题

maixinrong 5 年 前
コミット
8360a9f126
2 ファイル変更29 行追加14 行削除
  1. 25 14
      app/public/js/ledger.js
  2. 4 0
      app/public/js/stage.js

+ 25 - 14
app/public/js/ledger.js

@@ -923,6 +923,8 @@ $(document).ready(function() {
         });
 
         $('#bills-expr').bind('change mouseleave', function () {
+            if (document.activeElement.id !== "bills-expr") return;
+
             const expr = $(this);
             const sheet = ledgerSpread.getActiveSheet();
             const select = SpreadJsObj.getSelectObject(sheet);
@@ -1338,6 +1340,24 @@ $(document).ready(function() {
         editStarting: function (e, info) {
             posOperationObj.ledgerTreeNode = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
         },
+        loadExprToInput: function () {
+            const sheet = posSpread.getActiveSheet();
+            const sel = sheet.getSelections()[0];
+            if (!sel) return;
+
+            const col = sheet.zh_setting.cols[sel.col], cell = sheet.getCell(sel.row, sel.col);
+            if (col && col.type === 'Number') {
+                const data = SpreadJsObj.getSelectObject(sheet);
+                if (data) {
+                    $('#pos-expr').val(data[col.field]).attr('field', col.field).attr('org', data[col.field])
+                        .attr('row', sel.row).attr('readOnly', readOnly || cell.locked());
+                } else {
+                    $('#pos-expr').val('').attr('readOnly', true);
+                }
+            } else {
+                $('#pos-expr').val('').attr('readOnly', true);
+            }
+        },
         /**
          * 加载计量单元 根据当前台账选择节点
          */
@@ -1350,6 +1370,7 @@ $(document).ready(function() {
             } else {
                 SpreadJsObj.loadSheetData(posSpread.getActiveSheet(), 'data', []);
             }
+            posOperationObj.loadExprToInput();
         },
         /**
          * 编辑单元格响应事件
@@ -1603,19 +1624,7 @@ $(document).ready(function() {
             }
         },
         selectionChanged: function (e, info) {
-            const col = info.sheet.zh_setting.cols[info.newSelections[0].col];
-            const cell = info.sheet.getCell(info.newSelections[0].row, info.newSelections[0].col);
-            if (col && col.type === 'Number') {
-                const data = SpreadJsObj.getSelectObject(info.sheet);
-                if (data) {
-                    $('#pos-expr').val(data[col.field]).attr('field', col.field).attr('org', data[col.field])
-                        .attr('row', info.newSelections[0].row).attr('readOnly', readOnly || cell.locked());
-                } else {
-                    $('#pos-expr').val('').attr('readOnly', true);
-                }
-            } else {
-                $('#pos-expr').val('').attr('readOnly', true);
-            }
+            posOperationObj.loadExprToInput();
         },
         addPegs: function (pegs) {
             if (!pegs || pegs.length <= 0) return;
@@ -1637,10 +1646,12 @@ $(document).ready(function() {
     posSpread.bind(spreadNS.Events.SelectionChanged, posOperationObj.selectionChanged);
     if (!posSpreadSetting.readOnly) {
         $('#pos-expr').bind('change mouseleave', function () {
+            if (document.activeElement.id !== "pos-expr") return;
+
             const expr = $(this);
             const posSheet = posSpread.getActiveSheet();
             const select = SpreadJsObj.getSelectObject(posSheet);
-            if (select) return;
+            if (!select) return;
 
             const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = expr.val(), row = trimInvalidChar(expr.attr('row'));
             if (orgValue === newValue || (!orgValue && newValue == '')) { return; }

+ 4 - 0
app/public/js/stage.js

@@ -985,6 +985,8 @@ $(document).ready(() => {
     const stagePosSpreadObj = {
         loadExprToInput(sheet) {
             const sel = sheet.getSelections()[0];
+            if (!sel) return;
+
             const col = sheet.zh_setting.cols[sel.col], cell = sheet.getCell(sel.row, sel.col);
             if (col && col.type === 'Number') {
                 const data = SpreadJsObj.getSelectObject(sheet);
@@ -1014,6 +1016,7 @@ $(document).ready(() => {
             } else {
                 SpreadJsObj.loadSheetData(spSpread.getActiveSheet(), 'data', []);
             }
+            SpreadJsObj.loadExprToInput(spSpread.getActiveSheet());
         },
         editEnded: function (e, info) {
             if (info.sheet.zh_setting) {
@@ -1379,6 +1382,7 @@ $(document).ready(() => {
     if (!readOnly) {
         $('#pos-expr').bind('change mouseleave', function () {
             if (this.readOnly) return;
+            if (document.activeElement.id !== "pos-expr") return;
 
             const expr = $(this);
             const posSheet = spSpread.getActiveSheet();