| 
					
				 | 
			
			
				@@ -95,6 +95,20 @@ class TreeService extends Service { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    async getDataByKidAndCount(mid, kid, count) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if ((mid <= 0) || (kid <= 0)) return []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const select = await this.getDataByKid(mid, kid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!select) throw '数据错误'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (count > 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const selects = await this.getNextsData(mid, select[this.setting.pid], select[this.setting.order] - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (selects.length < count) throw '数据错误'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return selects.slice(0, count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return [select]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 获取节点数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param id 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -167,6 +181,7 @@ class TreeService extends Service { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             value: order, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             operate: '>', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.sqlBuilder.orderBy = [['order', 'ASC']]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         const [sql, sqlParam] = this.sqlBuilder.build(this.tableName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         const data = await this.db.query(sql, sqlParam); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -350,6 +365,17 @@ class TreeService extends Service { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 删除相关数据 用于继承 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param mid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param deleteData 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @returns {Promise<void>} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @private 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    async _deleteRelaData(mid, deleteData) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 删除节点 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param {Number} tenderId - 标段id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param {Object} deleteData - 删除节点数据 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -403,9 +429,8 @@ class TreeService extends Service { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 选中节点--全部后节点 order-- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             await this._updateChildrenOrder(mid, select[this.setting.pid], select[this.setting.order] + 1, -1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //await this._updateSelectNextsOrder(select, -1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 删除部位明细 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //await this.ctx.service.pos.deletePosData(this.transaction, tenderId, this._.map(deleteData, 'id')); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            await this._deleteRelaData(mid, deleteData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             await this.transaction.commit(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             this.transaction = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } catch (err) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -424,6 +449,57 @@ class TreeService extends Service { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return { delete: deleteData, update: updateData }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    async deleteNodes(mid, kid, count) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if ((mid <= 0) || (kid <= 0) || (count <= 0)) return []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const selects = await this.getDataByKidAndCount(mid, kid, count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const first = selects[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const parent = await this.getDataByKid(mid, first[this.setting.pid]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const childCount = parent ? this.count(this.getCondition({mid: mid, pid: parent[this.setting.id]})) : -1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let deleteData = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (const s of selects) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            deleteData = deleteData.concat(await this.getDataByFullPath(mid, s[this.setting.fullPath] + '%')); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.transaction = await this.db.beginTransaction(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 删除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (const s of selects) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const operate = await this._deleteNodeData(mid, s); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 选中节点--父节点 只有一个子节点时,应升级is_leaf 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (parent && childCount === count) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const updateParent = {id: parent.id }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                updateParent[this.setting.isLeaf] = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this.transaction.update(this.tableName, updateParent); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 选中节点--全部后节点 order-- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            await this._updateChildrenOrder(mid, first[this.setting.pid], first[this.setting.order] + count, -count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            await this.transaction.commit(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.transaction = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const updateData = await this.getNextsData(mid, first[this.setting.pid], first[this.setting.order] - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (parent && childCount === count) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const updateData1 = await this.getDataByKid(mid, parent[this.setting.id]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                updateData.push(updateData1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return { delete: deleteData, update: updateData }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (this.transaction) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this.transaction.rollback(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                this.transaction = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw err; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    async delete(mid, kid, count) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (count && count > 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return await this.deleteNodes(mid, kid, count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return await this.deleteNode(mid, kid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 上移节点 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -431,21 +507,24 @@ class TreeService extends Service { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param {Number} kid - 选中节点id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return {Array} - 发生改变的数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    async upMoveNode(mid, kid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (!mid || !kid) return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const select = await this.getDataByKid(mid, kid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (!select) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw '上移节点数据错误'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const pre = await this.getDataByParentAndOrder(mid, select[this.setting.pid], select[this.setting.order] - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (!pre) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw '节点不可上移'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    async upMoveNode(mid, kid, count) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!count) count = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!mid || (mid <= 0) || !kid || (kid <= 0)) return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const selects = await this.getDataByKidAndCount(mid, kid, count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (selects.length !== count) throw '上移节点数据错误'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const first = selects[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const pre = await this.getDataByParentAndOrder(mid, first[this.setting.pid], first[this.setting.order] - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!pre) throw '节点不可上移'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const order = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.transaction = await this.db.beginTransaction(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sData = await this.transaction.update(this.tableName, { id: select.id, order: select[this.setting.order] - 1 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const pData = await this.transaction.update(this.tableName, { id: pre.id, order: pre[this.setting.order] + 1 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (const s of selects) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const sData = await this.transaction.update(this.tableName, { id: s.id, order: s[this.setting.order] - 1 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                order.push(s[this.setting.order] - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const pData = await this.transaction.update(this.tableName, { id: pre.id, order: pre[this.setting.order] + count }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            order.push(pre[this.setting.order] + count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             await this.transaction.commit(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             this.transaction = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } catch (err) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -454,7 +533,7 @@ class TreeService extends Service { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             throw err; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const resultData = await this.getDataByParentAndOrder(mid, select[this.setting.pid], [select[this.setting.order], pre[this.setting.order]]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const resultData = await this.getDataByParentAndOrder(mid, first[this.setting.pid], order); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return { update: resultData }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -465,21 +544,28 @@ class TreeService extends Service { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param {Number} kid - 选中节点id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return {Array} - 发生改变的数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    async downMoveNode(mid, kid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (!mid || !kid) return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const select = await this.getDataByKid(mid, kid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (!select) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    async downMoveNode(mid, kid, count) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!count) count = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!mid || (mid <= 0) || !kid || (kid <= 0)) return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const selects = await this.getDataByKidAndCount(mid, kid, count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (selects.length !== count) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             throw '下移节点数据错误'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const next = await this.getDataByParentAndOrder(mid, select[this.setting.pid], select[this.setting.order] + 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const last = selects[count - 1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const next = await this.getDataByParentAndOrder(mid, last[this.setting.pid], last[this.setting.order] + 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (!next) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             throw '节点不可下移'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const order = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.transaction = await this.db.beginTransaction(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sData = await this.transaction.update(this.tableName, { id: select.id, order: select[this.setting.order] + 1 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const pData = await this.transaction.update(this.tableName, { id: next.id, order: next[this.setting.order] - 1 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (const s of selects) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const sData = await this.transaction.update(this.tableName, { id: s.id, order: s[this.setting.order] + 1 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                order.push(s[this.setting.order] + 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const nData = await this.transaction.update(this.tableName, { id: next.id, order: next[this.setting.order] - count }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            order.push(next[this.setting.order] - count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             await this.transaction.commit(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             this.transaction = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } catch (err) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -488,7 +574,7 @@ class TreeService extends Service { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             throw err; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const resultData = await this.getDataByParentAndOrder(mid, select[this.setting.pid], [select[this.setting.order], next[this.setting.order]]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const resultData = await this.getDataByParentAndOrder(mid, last[this.setting.pid], order); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return { update: resultData }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -591,48 +677,52 @@ class TreeService extends Service { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param {Number} selectId - 选中节点id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return {Array} - 发生改变的数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    async upLevelNode(mid, kid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if ((mid <= 0) || (kid <= 0)) return []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    async upLevelNode(mid, kid, count) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!count) count = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const selects = await this.getDataByKidAndCount(mid, kid, count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const select = await this.getDataByKid(mid, kid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (!select) throw '升级节点数据错误'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const parent = await this.getDataByKid(mid, select[this.setting.pid]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (selects.length !== count) throw '升级节点数据错误'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const first = selects[0], last = selects[count - 1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const parent = await this.getDataByKid(mid, first[this.setting.pid]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (!parent) throw '升级节点数据错误'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const newPath = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.transaction = await this.db.beginTransaction(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const newFullPath = select[this.setting.fullPath].replace(select[this.setting.pid] + '-', ''); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 选中节点--父节点 选中节点为firstChild时,修改is_leaf 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (select[this.setting.order] === 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (first[this.setting.order] === 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await this.transaction.update(this.tableName, { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     id: parent.id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     is_leaf: true, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 选中节点--父节点--全部后兄弟节点 order+1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            await this._updateChildrenOrder(mid, parent[this.setting.pid], parent[this.setting.order] + 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //await this._updateSelectNextsOrder(parent); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 选中节点 修改pid, order, full_path, level, is_leaf, 清空计算项 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const updateData = { id: select.id }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            updateData[this.setting.pid] = parent[this.setting.pid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            updateData[this.setting.order] = parent[this.setting.order] + 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            updateData[this.setting.level] = select[this.setting.level] - 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            updateData[this.setting.fullPath] = newFullPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const nexts = await this.getNextsData(mid, parent[this.setting.kid], select[this.setting.order]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (nexts.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                updateData.is_leaf = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                // updateData.unit_price = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                // updateData.quantity = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                // updateData.total_price = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                // updateData.deal_qty = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                // updateData.deal_tp = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            await this._updateChildrenOrder(mid, parent[this.setting.pid], parent[this.setting.order] + 1, count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (const [i, s] of selects.entries()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 选中节点 修改pid, order, full_path, level, is_leaf, 清空计算项 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const updateData = { id: s.id }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                updateData[this.setting.pid] = parent[this.setting.pid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                updateData[this.setting.order] = parent[this.setting.order] + i + 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                updateData[this.setting.level] = s[this.setting.level] - 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                updateData[this.setting.fullPath] = s[this.setting.fullPath].replace(s[this.setting.pid] + '-', ''); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                newPath.push(updateData[this.setting.fullPath]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (s.is_leaf && s.id === last.id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    const nexts = await this.getNextsData(mid, parent[this.setting.kid], last[this.setting.order]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (nexts.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        updateData.is_leaf = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // updateData.unit_price = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // updateData.quantity = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // updateData.total_price = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // updateData.deal_qty = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // updateData.deal_tp = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this.transaction.update(this.tableName, updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 选中节点--全部子节点(含孙) level-1, full_path变更 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this._syncUplevelChildren(s); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            await this.transaction.update(this.tableName, updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 选中节点--全部子节点(含孙) level-1, full_path变更 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            await this._syncUplevelChildren(select); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 选中节点--全部后兄弟节点 收编为子节点 修改pid, order, full_path 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            await this._syncUpLevelNexts(select); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            await this._syncUpLevelNexts(last); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             await this.transaction.commit(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             this.transaction = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } catch (err) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -642,9 +732,12 @@ class TreeService extends Service { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 查询修改的数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const resultData1 = await this.getDataByFullPath(mid, newFullPath + '%'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const resultData2 = await this.getNextsData(mid, parent[this.setting.pid], parent[this.setting.order] - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return { update: resultData1.concat(resultData2) }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let updateData = await this.getNextsData(mid, parent[this.setting.pid], parent[this.setting.order] - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (const path of newPath) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const children = await this.getDataByFullPath(mid, path + '-%'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            updateData = updateData.concat(children); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return { update: updateData }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -685,30 +778,40 @@ class TreeService extends Service { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param {Number} selectId - 选中节点id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return {Array} - 发生改变的数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    async downLevelNode(mid, kid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if ((mid <= 0) || (kid <= 0)) return []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const select = await this.getDataByKid(mid, kid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (!select) throw '降级节点数据错误'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const pre = await this.getDataByParentAndOrder(mid, select[this.setting.pid], select[this.setting.order] - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    async downLevelNode(mid, kid, count) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        console.log(mid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        console.log(kid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        console.log(count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!count) count = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const selects = await this.getDataByKidAndCount(mid, kid, count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!selects) throw '降级节点数据错误'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const first = selects[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const pre = await this.getDataByParentAndOrder(mid, first[this.setting.pid], first[this.setting.order] - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (!pre) throw '节点不可降级'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         const preLastChild = await this.getLastChildData(mid, pre[this.setting.kid]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        console.log(selects); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        console.log(pre); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const newPath = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.transaction = await this.db.beginTransaction(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const orgLastPath = select[this.setting.level] === 1 ? select[this.setting.kid] : '-' + select[this.setting.kid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const newLastPath = select[this.setting.level] === 1 ? pre[this.setting.kid] + '-' + select[this.setting.kid] : '-' + pre[this.setting.kid] + '-' + select[this.setting.kid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const newFullPath = select.full_path.replace(orgLastPath, newLastPath); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 选中节点--全部后节点 order-- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            await this._updateChildrenOrder(mid, select[this.setting.pid], select[this.setting.order] + 1, -1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 选中节点 修改pid, level, order, full_path 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const updateData = { id: select.id }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            updateData[this.setting.pid] = pre[this.setting.kid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            updateData[this.setting.order] = preLastChild ? preLastChild[this.setting.order] + 1 : 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            updateData[this.setting.level] = select[this.setting.level] + 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            updateData[this.setting.fullPath] = newFullPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            await this.transaction.update(this.tableName, updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 选中节点--全部子节点(含孙) level++, full_path 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            await this._syncDownlevelChildren(select, pre); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            await this._updateChildrenOrder(mid, first[this.setting.pid], first[this.setting.order] + 1, -count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (const [i, s] of selects.entries()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 选中节点 修改pid, level, order, full_path 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const updateData = { id: s.id }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                updateData[this.setting.pid] = pre[this.setting.kid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                updateData[this.setting.order] = preLastChild ? preLastChild[this.setting.order] + i + 1 : i + 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                updateData[this.setting.level] = s[this.setting.level] + 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const orgLastPath = s[this.setting.level] === 1 ? s[this.setting.kid] : '-' + s[this.setting.kid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const newLastPath = s[this.setting.level] === 1 ? pre[this.setting.kid] + '-' + s[this.setting.kid] : '-' + pre[this.setting.kid] + '-' + s[this.setting.kid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                updateData[this.setting.fullPath] = s[this.setting.fullPath].replace(orgLastPath, newLastPath); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                newPath.push(updateData[this.setting.fullPath]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this.transaction.update(this.tableName, updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 选中节点--全部子节点(含孙) level++, full_path 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this._syncDownlevelChildren(s, pre); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 选中节点--前兄弟节点 is_leaf应为false, 清空计算相关字段 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const updateData2 = { id: pre.id }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             updateData2[this.setting.isLeaf] = false; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -727,11 +830,13 @@ class TreeService extends Service { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 查询修改的数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let updateData = await this.getNextsData(mid, pre[this.setting.pid], pre[this.setting.order] - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 选中节点及子节点 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const resultData1 = await this.getDataByFullPath(mid, newFullPath + '%'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (const p of newPath) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            updateData = updateData.concat(await this.getDataByFullPath(mid, p + '%')); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 选中节点--原前兄弟节点&全部后兄弟节点 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const resultData2 = await this.getNextsData(mid, pre[this.setting.pid], pre[this.setting.order] - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return { update: resultData1.concat(resultData2) }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return { update: updateData }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -781,6 +886,112 @@ class TreeService extends Service { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return await this.getDataById(datas.id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    async pasteBlockRelaData(relaData) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!this.transaction) throw '更新数据错误'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // for (const id of relaData) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //     await this.ctx.service.pos.copyBillsPosData(id.org, id.new, this.transaction); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    async getPasteBlockResult(select, copyNodes) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const createData = await this.getDataByIds(newIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const updateData = await this.getNextsData(selectData[this.setting.mid], selectData[this.setting.pid], selectData[this.setting.order] + copyNodes.length); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //const posData = await this.ctx.service.pos.getPosData({ lid: newIds }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ledger: { create: createData, update: updateData }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //pos: posData, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 复制粘贴整块 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param {Number} tenderId - 标段Id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param {Number} selectId - 选中几点Id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param {Array} block - 复制节点Id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return {Object} - 提价后的数据(其中新增粘贴数据,只返回第一层) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    async pasteBlock(mid, kid, block) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if ((mid <= 0) || (kid <= 0)) return []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const selectData = await this.getDataByKid(mid, kid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!selectData) throw '数据错误'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const copyNodes = await this.getDataByNodeIds(mid, block); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!copyNodes || copyNodes.length <= 0)  throw '复制数据错误'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (const node of copyNodes) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (node[this.setting.pid] !== copyNodes[0][this.setting.pid]) throw '复制数据错误:仅可操作同层节点'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const newParentPath = selectData[this.setting.fullPath].replace(selectData[this.setting.kid], ''); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const orgParentPath = copyNodes[0][this.setting.fullPath].replace(copyNodes[0][this.setting.kid], ''); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const newIds = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.transaction = await this.db.beginTransaction(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 选中节点的所有后兄弟节点,order+粘贴节点个数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            await this._updateSelectNextsOrder(selectData, copyNodes.length); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (let iNode = 0; iNode < copyNodes.length; iNode++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const node = copyNodes[iNode]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                let datas = await this.getDataByFullPath(mid, node[this.setting.fullPath] + '%'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                datas = this._.sortBy(datas, 'level'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const maxId = await this._getMaxLid(mid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                this._cacheMaxLid(mid, maxId + datas.length); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const billsId = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 计算粘贴数据中需更新部分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (let index = 0; index < datas.length; index++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    const data = datas[index]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    const newId = maxId + index + 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    const idChange = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        org: data.id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (this.setting.uuid) data.id = this.uuid.v4(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    idChange.new = data.id; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    data[this.setting.mid] = mid; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (!data[this.setting.isLeaf]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        for (const children of datas) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            children[this.setting.fullPath] = children[this.setting.fullPath].replace('-' + data[this.setting.kid], '-' + newId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (children[this.setting.pid] === data[this.setting.kid]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                children[this.setting.pid] = newId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        data[this.setting.fullPath] = data[this.setting.fullPath].replace('-' + data[this.setting.kid], '-' + newId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    data[this.setting.kid] = newId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    data[this.setting.fullPath] = data[this.setting.fullPath].replace(orgParentPath, newParentPath); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (data[this.setting.pid] === node[this.setting.pid]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        data[this.setting.pid] = selectData[this.setting.pid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        data[this.setting.order] = selectData[this.setting.order] + iNode + 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    data[this.setting.level] = data[this.setting.level] + selectData[this.setting.level] - copyNodes[0][this.setting.level]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    idChange.isLeaf = data[this.setting.isLeaf]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    billsId.push(idChange); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    newIds.push(data.id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const newData = await this.transaction.insert(this.tableName, datas); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this.pasteBlockRelaData(billsId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 数据库创建新增节点数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            await this.transaction.commit(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.transaction = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            await this.transaction.rollback(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.transaction = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw err; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 查询应返回的结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const createData = await this.getDataByIds(newIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const updateData = await this.getNextsData(selectData[this.setting.mid], selectData[this.setting.pid], selectData[this.setting.order] + copyNodes.length); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //const posData = await this.ctx.service.pos.getPosData({ lid: newIds }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ledger: { create: createData, update: updateData }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //pos: posData, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 module.exports = TreeService; 
			 |