Forráskód Böngészése

1. 台账分解,添加标准项目节,排序问题
2. 单位单元格,离开时,应隐藏下拉按钮

MaiXinRong 6 éve
szülő
commit
3903fa76c3

+ 37 - 2
app/extend/helper.js

@@ -383,10 +383,17 @@ module.exports = {
 
         const path1 = str1.split(symbol);
         const path2 = str2.split(symbol);
+        const reg = /^[0-9]*$/;
         for (let i = 0, iLen = Math.min(path1.length, path2.length); i < iLen; i++) {
-            if (path1 < path2) {
+            if (reg.test(path1[i]) && reg.test(path2[i])) {
+                const num1 = parseInt(path1[i]);
+                const num2 = parseInt(path2[i]);
+                if (num1 !== num2)  {
+                    return num1 - num2;
+                }
+            } else if (path1[i] < path2[i]) {
                 return -1;
-            } else if (path1 > path2) {
+            } else if (path1[i] > path2[i]) {
                 return 1;
             }
         }
@@ -695,5 +702,33 @@ module.exports = {
             result = result + this.ctx.app.mysql.escape(a);
         }
         return result;
+    },
+
+    /**
+     * 合并相关数据
+     * @param {Array} main - 主数据
+     * @param {Array[]}rela - 相关数据 {data, fields, prefix, relaId}
+     */
+    assignRelaData(main, rela) {
+        const index = {}, indexPre = 'id_';
+        const loadFields = function (datas, fields, prefix, relaId) {
+            for (const d of datas) {
+                const key = indexPre + d[relaId];
+                const m = index[key];
+                if (m) {
+                    for (const f of fields) {
+                        if (d[f] !== undefined) {
+                            m[prefix + f] = d[f];
+                        }
+                    }
+                }
+            }
+        };
+        for (const m of main) {
+            index[indexPre + m.id] = m;
+        }
+        for (const r of rela) {
+            loadFields(r.data, r.fields, r.prefix, r.relaId);
+        }
     }
 };

+ 2 - 2
app/public/js/ledger.js

@@ -491,7 +491,7 @@ $(document).ready(function() {
             });
         },
         selectionChanged: function (e, info) {
-            if (info.newSelections[0].row !== info.oldSelections[0].row) {
+            if (!info.oldSelections[0] || info.newSelections[0].row !== info.oldSelections[0].row) {
                 posOperationObj.loadCurPosData();
                 SpreadJsObj.resetTopAndSelect(posSpread.getActiveSheet());
                 posSearch.search($('#pos-keyword').val());
@@ -500,7 +500,7 @@ $(document).ready(function() {
         },
         topRowChanged(e, info) {
             SpreadJsObj.saveTopAndSelect(info.sheet, ckBillsSpread);
-        },
+        }
     };
     // 绑定事件
     ledgerSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, treeOperationObj.selectionChanged);

+ 2 - 5
app/public/js/path_tree.js

@@ -351,14 +351,11 @@ const createNewPathTree = function (type, setting) {
          * @returns {*}
          */
         getPreSiblingNode(node) {
+            if (!node) return null;
             const parent = this.getParent(node);
             const siblings = parent ? parent.children : this.children;
             const index = siblings.indexOf(node);
-            if (index > 0) {
-                return siblings[index - 1];
-            } else {
-                return null;
-            }
+            return (index > 0) ? siblings[index - 1] : null;
         }
         /**
          * 查找node的后兄弟节点

+ 14 - 1
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -382,6 +382,19 @@ const SpreadJsObj = {
         if (colSetting.cellType === 'unit') {
             if (!sheet.extendCellType.unit) {
                 sheet.extendCellType.unit = this.CellType.getUnitCellType();
+                sheet.bind(spreadNS.Events.LeaveCell, function (e, info) {
+                    const cellType = info.sheet.getCell(info.row, info.col).cellType();
+                    if (cellType === sheet.extendCellType.unit) {
+                        info.sheet.leaveCell = {row: info.row, col: info.col};
+                    } else {
+                        delete info.sheet.leaveCell;
+                    }
+                });
+                sheet.bind(spreadNS.Events.EnterCell, function (e, info) {
+                    if (info.sheet.leaveCell) {
+                        info.sheet.repaint(info.sheet.getCellRect(info.sheet.leaveCell.row, info.sheet.leaveCell.col));
+                    }
+                });
             }
             sheet.getRange(-1, col, -1, 1).cellType(sheet.extendCellType.unit);
         }
@@ -1429,7 +1442,7 @@ const SpreadJsObj = {
          * @returns {ActiveComboCellType}
          */
         getActiveComboCellType: function () {
-            const ActiveComboCellType = function () { };
+            const ActiveComboCellType = function () {};
             ActiveComboCellType.prototype = new spreadNS.CellTypes.ComboBox();
             const proto = ActiveComboCellType.prototype;
             proto.paintValue = function (ctx, value, x, y, w, h, style, options) {