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

fix: 清单库批量多行后,粘贴异常问题

vian 3 месяцев назад
Родитель
Сommit
184eac4cc7

+ 25 - 24
public/web/tree_sheet/tree_sheet_controller.js

@@ -31,7 +31,7 @@ var TREE_SHEET_CONTROLLER = {
                 var sels = me.sheet.getSelections();
                 newNodes.sort(function (a, b) {
                     let rst = 0;
-                    if(a.serialNo() > b.serialNo()){
+                    if (a.serialNo() > b.serialNo()) {
                         rst = 1;
                     }
                     else {
@@ -39,10 +39,10 @@ var TREE_SHEET_CONTROLLER = {
                     }
                     return rst;
                 });
-                for(let newNode of newNodes){
+                for (let newNode of newNodes) {
                     me.sheet.addRows(newNode.serialNo(), 1);
                 }
-                for(let newNode of newNodes){
+                for (let newNode of newNodes) {
                     me.setTreeSelected(newNode);
                     TREE_SHEET_HELPER.refreshTreeNodeData(me.setting, me.sheet, [newNode], false);
                     me.sheet.setSelection(newNode.serialNo(), sels[0].col, 1, 1);
@@ -51,7 +51,7 @@ var TREE_SHEET_CONTROLLER = {
         };
 
         controller.prototype.insert = function () {
-            var newNode = null, that = this,  sels = this.sheet.getSelections();
+            var newNode = null, that = this, sels = this.sheet.getSelections();
             if (this.tree) {
                 if (this.tree.selected) {
                     newNode = this.tree.insert(this.tree.selected.getParentID(), this.tree.selected.getNextSiblingID());
@@ -70,10 +70,10 @@ var TREE_SHEET_CONTROLLER = {
             }
         };
         controller.prototype.m_insert = function (datas) {
-            let nodes = [], that = this,  sels = this.sheet.getSelections();
-            if(this.tree){
+            let nodes = [], that = this, sels = this.sheet.getSelections();
+            if (this.tree) {
                 if (this.tree.selected) {
-                    nodes = this.tree.m_insert(datas,this.tree.selected.getParentID(), this.tree.selected.getNextSiblingID());
+                    nodes = this.tree.m_insert(datas, this.tree.selected.getParentID(), this.tree.selected.getNextSiblingID());
                 } else {
                     nodes = this.tree.m_insert(datas);
                 }
@@ -88,11 +88,12 @@ var TREE_SHEET_CONTROLLER = {
                     //that.sheet.showRow(newNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
                 });
             }
+            return nodes;
         };
 
 
         controller.prototype.insertByID = function (ID) {
-            var newNode = null, that = this,  sels = this.sheet.getSelections();
+            var newNode = null, that = this, sels = this.sheet.getSelections();
             if (this.tree) {
                 if (this.tree.selected) {
                     newNode = this.tree.insertByID(ID, this.tree.selected.getParentID(), this.tree.selected.getNextSiblingID());
@@ -112,7 +113,7 @@ var TREE_SHEET_CONTROLLER = {
             return newNode;
         };
         controller.prototype.insertByIDS = function (ID, ParentID, NexSiblingID) {
-            var newNode = null, that = this,  sels = this.sheet.getSelections();
+            var newNode = null, that = this, sels = this.sheet.getSelections();
             if (this.tree) {
                 if (this.tree.selected) {
                     newNode = this.tree.insertByID(ID, ParentID, NexSiblingID);
@@ -132,7 +133,7 @@ var TREE_SHEET_CONTROLLER = {
             return newNode;
         };
         controller.prototype.insertToChild = function (ID, ParentID, NextSiblingID) {
-            var newNode = null, that = this,  sels = this.sheet.getSelections();
+            var newNode = null, that = this, sels = this.sheet.getSelections();
             if (this.tree) {
                 if (this.tree.selected) {
                     newNode = this.tree.insertByID(ID, ParentID, NextSiblingID);
@@ -164,16 +165,16 @@ var TREE_SHEET_CONTROLLER = {
         };
         controller.prototype.m_delete = function (nodes) {
             var that = this, sels = this.sheet.getSelections();
-            if(nodes.length > 0){
-                if(this.tree.m_delete(nodes)){
+            if (nodes.length > 0) {
+                if (this.tree.m_delete(nodes)) {
                     TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
                         let rowCount = 0;
-                        for(let node of nodes){
-                            rowCount = rowCount+node.posterityCount() + 1;
+                        for (let node of nodes) {
+                            rowCount = rowCount + node.posterityCount() + 1;
                         }
                         that.sheet.deleteRows(sels[0].row, rowCount);
                         that.setTreeSelected(that.tree.items[sels[0].row]);
-                        that.sheet.setSelection(sels[0].row,sels[0].col,1,sels[0].colCount);
+                        that.sheet.setSelection(sels[0].row, sels[0].col, 1, sels[0].colCount);
                     });
                 }
             }
@@ -184,7 +185,7 @@ var TREE_SHEET_CONTROLLER = {
                 if (this.tree.selected.upLevel()) {
                     TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
                         TREE_SHEET_HELPER.refreshNodesVisible([that.tree.selected], that.sheet, true);
-                       // that.sheet.showRow(that.tree.selected.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
+                        // that.sheet.showRow(that.tree.selected.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
                         if (that.event.refreshBaseActn) {
                             that.event.refreshBaseActn(that.tree);
                         }
@@ -235,12 +236,12 @@ var TREE_SHEET_CONTROLLER = {
             var that = this, sels = this.sheet.getSelections();
             if (this.tree.selected) {
                 TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
-                    TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected,that.tree.selected.serialNo(),true);//为了处理移动前子项是隐藏的情况,先把所有的列设置为显示
-                    TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected.preSibling,that.tree.selected.preSibling.serialNo(),true);
+                    TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet, that.tree, that.tree.selected, that.tree.selected.serialNo(), true);//为了处理移动前子项是隐藏的情况,先把所有的列设置为显示
+                    TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet, that.tree, that.tree.selected.preSibling, that.tree.selected.preSibling.serialNo(), true);
                     if (that.tree.selected.upMove()) {
                         TREE_SHEET_HELPER.refreshTreeNodeData(that.setting, that.sheet, [that.tree.selected, that.tree.selected.nextSibling], true);
-                        TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected,that.tree.selected.serialNo());
-                        TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected.nextSibling,that.tree.selected.nextSibling.serialNo());
+                        TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet, that.tree, that.tree.selected, that.tree.selected.serialNo());
+                        TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet, that.tree, that.tree.selected.nextSibling, that.tree.selected.nextSibling.serialNo());
                         that.sheet.setSelection(that.tree.selected.serialNo(), sels[0].col, 1, 1);
                         if (that.event.refreshBaseActn) {
                             that.event.refreshBaseActn(that.tree);
@@ -253,12 +254,12 @@ var TREE_SHEET_CONTROLLER = {
             var that = this, sels = this.sheet.getSelections();
             if (this.tree.selected) {
                 TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
-                    TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected,that.tree.selected.serialNo(),true);//为了处理移动前子项是隐藏的情况,先把所有的列设置为显示
-                    TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected.nextSibling,that.tree.selected.nextSibling.serialNo(),true);
+                    TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet, that.tree, that.tree.selected, that.tree.selected.serialNo(), true);//为了处理移动前子项是隐藏的情况,先把所有的列设置为显示
+                    TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet, that.tree, that.tree.selected.nextSibling, that.tree.selected.nextSibling.serialNo(), true);
                     if (that.tree.selected.downMove()) {
                         TREE_SHEET_HELPER.refreshTreeNodeData(that.setting, that.sheet, [that.tree.selected, that.tree.selected.preSibling], true);
-                        TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected,that.tree.selected.serialNo());
-                        TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected.preSibling,that.tree.selected.preSibling.serialNo());
+                        TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet, that.tree, that.tree.selected, that.tree.selected.serialNo());
+                        TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet, that.tree, that.tree.selected.preSibling, that.tree.selected.preSibling.serialNo());
                         that.sheet.setSelection(that.tree.selected.serialNo(), sels[0].col, 1, 1);
                         if (that.event.refreshBaseActn) {
                             that.event.refreshBaseActn(that.tree);

+ 16 - 12
web/maintain/bills_lib/scripts/db_controller.js

@@ -32,7 +32,8 @@ function getNewBIlls(controller, rowCount, billsLibId) {
     };
     if (i === rowCount - 1) {
       tem.NextSiblingID = NextSiblingID;
-    } else if (i !== 0) {
+    }
+    if (i !== 0) {
       insertBills[i - 1].NextSiblingID = tem.ID;
     }
 
@@ -74,14 +75,17 @@ var dbController = {
           type: "new",
           data: item,
         }));
-        controller.m_insert(treeData);
-        controller.tree.selected.jobs = new Array();
-        controller.tree.selected.items = new Array();
-        controller.sheet.setTag(
-          controller.tree.selected.serialNo(),
-          0,
-          controller.tree.selected.getID()
-        );
+        const newNodes = controller.m_insert(treeData);
+        newNodes.forEach(n => {
+          n.jobs = [];
+          n.items = [];
+          console.log(n.serialNo(), n.getID());
+          controller.sheet.setTag(
+            n.serialNo(),
+            0,
+            n.getID()
+          );
+        });
         sheetBillsDatas = tools.getsheetDatas(
           controller.sheet,
           "bills",
@@ -299,9 +303,9 @@ var dbController = {
       }
       let updateNode = node.preSibling
         ? {
-            ID: node.preSibling.getID(),
-            NextSiblingID: node.getNextSiblingID(),
-          }
+          ID: node.preSibling.getID(),
+          NextSiblingID: node.getNextSiblingID(),
+        }
         : null;
       billsAjax.deleteBills(
         userAccount,