Browse Source

自定义右键输入文本中敲击"enter"键,直接触发相关操作

vian 5 years atrás
parent
commit
2499c295c3

+ 1 - 1
public/web/id_tree.js

@@ -573,7 +573,7 @@ var idTree = {
             }
             return node;
         };
-        Tree.prototype.insertByID = function (newID, parentID, nextSiblingID, resort = true) {
+        Tree.prototype.insertByID = function (newID, parentID, nextSiblingID) {
             var node = null, data = {};
             var parent = parentID == -1 ? null : this.nodes[this.prefix + parentID];
             var nextSibling = nextSiblingID == -1 ? null: this.nodes[this.prefix + nextSiblingID];

+ 11 - 4
public/web/sheet/sheet_common.js

@@ -1297,6 +1297,12 @@ var sheetCommonObj = {
                     input.setSelectionRange(idx, idx);
                 }
             }
+            function handleConfirm() {
+                if (callback) {
+                    callback();
+                }
+                root.$menu.trigger('contextmenu:hide');
+            }
             $(html)
                 .appendTo(this)
                 .on('input', 'input', function () {
@@ -1312,6 +1318,10 @@ var sheetCommonObj = {
                     if (key === 'ArrowUp' || key === 'ArrowDown') {
                         return false;
                     }
+                    if (key === 'Enter') {
+                        handleConfirm();
+                        return false;
+                    }
                     const input = $(this)[0];
                     if (key === 'ArrowLeft') {
                         moveLeft(input, e.shiftKey);
@@ -1323,10 +1333,7 @@ var sheetCommonObj = {
                     if (e.target.tagName === 'INPUT') {
                         return false;
                     }
-                    if (callback) {
-                        callback();
-                    }
-                    root.$menu.trigger('contextmenu:hide');
+                    handleConfirm();
                 });
 
             this.addClass(`context-menu-icon context-menu-icon--fa fa ${icon}`);

+ 3 - 16
web/building_saas/main/js/models/cache_tree.js

@@ -399,28 +399,15 @@ var cacheTree = {
             return iCount;
         };
 
-        Tree.prototype.insert = function (parentID, nextSiblingID, id, resort = true) {
+        Tree.prototype.insert = function (parentID, nextSiblingID, id) {
             var parent = !parentID || parentID === -1 ? null : this.nodes[this.prefix + parentID];
             var nextSibling = !nextSiblingID || nextSiblingID === -1 ? null: this.nodes[this.prefix + nextSiblingID];
 
             var newNode = this.addNode(parent, nextSibling, id);
-            if (resort) {
-                this.sortTreeItems();
-            }
+            this.sortTreeItems();
 
             return newNode;
         };
-        Tree.prototype.multiInsert = function (datas) {
-            debugger;
-            const newNodes = [];
-            for (const data of datas) {
-                const node = this.insert(data.ParentID, data.NextSiblingID, data.ID, true);
-                newNodes.push(node);
-            }
-            this.roots = tools.reSortNodes(this.roots, true);
-            this.sortTreeItems();
-            return newNodes;
-        }
         //  一次性插入多个连续的同层节点
         Tree.prototype.multiInsert = function (datas, preID) {
             const newNodes = [];
@@ -452,7 +439,7 @@ var cacheTree = {
             return newNodes;
         }
         // 插入某一完整片段到某节点的子项中
-        Tree.prototype.insertByDatas = function (datas, preID) {
+        Tree.prototype.insertByDatas = function (datas) {
             let rst = [];
             for(let data of datas){
                 this.nodes[this.prefix + data.ID] = new Node(this, data.ID);